x86: allow "=rm" in native_save_fl()

This is a partial revert of f1f029c7bf.

"=rm" is allowed in this context, because "pop" is explicitly defined
to adjust the stack pointer *before* it evaluates its effective
address, if it has one.  Thus, we do end up writing to the correct
address even if we use an on-stack memory argument.

The original reporter for f1f029c7bf was
apparently using a broken x86 simulator.

[ Impact: performance ]

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Cc: Gabe Black <spamforgabe@umich.edu>
This commit is contained in:
H. Peter Anvin
2009-08-25 16:47:16 -07:00
parent e8a2eb47e6
commit ab94fcf528

View File

@@ -13,14 +13,13 @@ static inline unsigned long native_save_fl(void)
unsigned long flags; unsigned long flags;
/* /*
* Note: this needs to be "=r" not "=rm", because we have the * "=rm" is safe here, because "pop" adjusts the stack before
* stack offset from what gcc expects at the time the "pop" is * it evaluates its effective address -- this is part of the
* executed, and so a memory reference with respect to the stack * documented behavior of the "pop" instruction.
* would end up using the wrong address.
*/ */
asm volatile("# __raw_save_flags\n\t" asm volatile("# __raw_save_flags\n\t"
"pushf ; pop %0" "pushf ; pop %0"
: "=r" (flags) : "=rm" (flags)
: /* no input */ : /* no input */
: "memory"); : "memory");