Skip to content

Commit

Permalink
x86: allow "=rm" in native_save_fl()
Browse files Browse the repository at this point in the history
This is a partial revert of f1f029c.

"=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 f1f029c was
apparently using a broken x86 simulator.

[ Impact: performance ]

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Cc: Gabe Black <spamforgabe@umich.edu>
  • Loading branch information
H. Peter Anvin committed Aug 25, 2009
1 parent e8a2eb4 commit ab94fcf
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions arch/x86/include/asm/irqflags.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@ static inline unsigned long native_save_fl(void)
unsigned long flags;

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

Expand Down

0 comments on commit ab94fcf

Please sign in to comment.