[coreboot] [PATCH] cld before call

Carl-Daniel Hailfinger c-d.hailfinger.devel.2006 at gmx.net
Wed Jul 29 12:51:16 CEST 2009

Hi Segher,

a small gcc related question for x86/x86_64 if I may.

On 29.07.2009 05:24, ron minnich wrote:
> On Tue, Jul 28, 2009 at 5:44 PM, Robert Millan<rmh at aybabtu.com> wrote:
>> Isn't C code allowed to set it back?
> my understanding of all this is:
> 1. if you want it set a certain way, you have to set it
> 2. don't ever assume it has any particular value.

There is an excellent LWN.net article about this:

"GCC relies on the ABI mandate that the direction flag is cleared before
entry to a function"

That means if you call the payload via a pointer, gcc will make sure the
direction flag is cleared (either by clearing it directly before the
call or by never changing it after the start of the program).

AFAIK calling a function via inline asm is not something gcc can see, so
this special case might be an exception. Then again, it's pretty
unlikely that gcc sets the direction flag for some operations and defers
clearing to the last possible moment.



More information about the coreboot mailing list