Skip to contentSkip to conversation

i8k: Avoid lahf in 64-bit code

PATCH New Jean Delvare 1 participant 1 message May 16, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 i8k: Avoid lahf in 64-bit code

From: Luca Tettamanti <[email protected]>

i8k uses lahf to read the flag register in 64-bit code; early x86-64 CPUs, however, lack this instruction and we get an invalid opcode exception at runtime.
Use pushf to load the flag register into the stack instead.

---
If nobody picks this fix quickly, I'll send it to Linus myself. I haven't heard from Massimo for weeks if not months :(

 drivers/char/i8k.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/char/i8k.c +2 -2
index d72433f..ee01716 100644
@@ -139,8 +139,8 @@ static int i8k_smm(struct smm_regs *regs)
 		"movl %%edi,20(%%rax)\n\t"
 		"popq %%rdx\n\t"
 		"movl %%edx,0(%%rax)\n\t"
-		"lahf\n\t"
-		"shrl $8,%%eax\n\t"
+		"pushfq\n\t"
+		"popq %%rax\n\t"
 		"andl $1,%%eax\n"
 		:"=a"(rc)
 		:    "a"(regs)
Signature · 1 line
Jean Delvare