Skip to contentSkip to conversation

x86/kexec: store segment registers directly to memory in crash_setup_regs()

PATCH Superseded Uros Bizjak 1 participant 1 message Mar 25 x86

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/kexec: store segment registers directly to memory in crash_setup_regs()

crash_setup_regs() currently moves segment registers (ss, cs, ds, es) into pt_regs via a general purpose register (%eax). Update the code to avoid the intermediate register and store segment registers directly to their destination fields. This reduces the generated code from:

131: 8c d0 mov %ss,%eax
133: 66 89 84 24 a0 00 00 mov %ax,0xa0(%rsp)
13a: 00
13b: 8c c8 mov %cs,%eax
13d: 66 89 84 24 88 00 00 mov %ax,0x88(%rsp)
144: 00

to:

131: 8c 94 24 a0 00 00 00 mov %ss,0xa0(%rsp)
138: 8c 8c 24 88 00 00 00 mov %cs,0x88(%rsp)

No functional change intended.

Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc Dave Hansen <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
---
 arch/x86/include/asm/kexec.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
arch/x86/include/asm/kexec.h +4 -4
index 5cfb27f26583..ad7ef567452b 100644
@@ -106,11 +106,11 @@ static inline void crash_setup_regs(struct pt_regs *newregs,
 		asm volatile("mov %%r14,%0" : "=m"(newregs->r14));
 		asm volatile("mov %%r15,%0" : "=m"(newregs->r15));
 #endif
-		asm volatile("mov %%ss,%k0" : "=a"(newregs->ss));
-		asm volatile("mov %%cs,%k0" : "=a"(newregs->cs));
+		asm volatile("mov %%ss,%0" : "=m"(newregs->ss));
+		asm volatile("mov %%cs,%0" : "=m"(newregs->cs));
 #ifdef CONFIG_X86_32
-		asm volatile("mov %%ds,%k0" : "=a"(newregs->ds));
-		asm volatile("mov %%es,%k0" : "=a"(newregs->es));
+		asm volatile("mov %%ds,%0" : "=m"(newregs->ds));
+		asm volatile("mov %%es,%0" : "=m"(newregs->es));
 #endif
 		asm volatile("pushf\n\t"
 			     "pop %0" : "=m"(newregs->flags));
Signature · 1 line
2.53.0