Skip to content

Commit a9deda6

Browse files
ubizjakIngo Molnar
authored andcommitted
x86/kexec: Merge x86_32 and x86_64 code using macros from <asm/asm.h>
Merge common x86_32 and x86_64 code in crash_setup_regs() using macros from <asm/asm.h>. The compiled object files before and after the patch are unchanged. Signed-off-by: Uros Bizjak <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Cc: David Woodhouse <[email protected]> Cc: Baoquan He <[email protected]> Cc: Vivek Goyal <[email protected]> Cc: Dave Young <[email protected]> Cc: Ard Biesheuvel <[email protected]> Cc: "H. Peter Anvin" <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent bd72baf commit a9deda6

File tree

1 file changed

+25
-33
lines changed

1 file changed

+25
-33
lines changed

arch/x86/include/asm/kexec.h

Lines changed: 25 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <linux/string.h>
1919
#include <linux/kernel.h>
2020

21+
#include <asm/asm.h>
2122
#include <asm/page.h>
2223
#include <asm/ptrace.h>
2324

@@ -71,41 +72,32 @@ static inline void crash_setup_regs(struct pt_regs *newregs,
7172
if (oldregs) {
7273
memcpy(newregs, oldregs, sizeof(*newregs));
7374
} else {
75+
asm volatile("mov %%" _ASM_BX ",%0" : "=m"(newregs->bx));
76+
asm volatile("mov %%" _ASM_CX ",%0" : "=m"(newregs->cx));
77+
asm volatile("mov %%" _ASM_DX ",%0" : "=m"(newregs->dx));
78+
asm volatile("mov %%" _ASM_SI ",%0" : "=m"(newregs->si));
79+
asm volatile("mov %%" _ASM_DI ",%0" : "=m"(newregs->di));
80+
asm volatile("mov %%" _ASM_BP ",%0" : "=m"(newregs->bp));
81+
asm volatile("mov %%" _ASM_AX ",%0" : "=m"(newregs->ax));
82+
asm volatile("mov %%" _ASM_SP ",%0" : "=m"(newregs->sp));
83+
#ifdef CONFIG_X86_64
84+
asm volatile("mov %%r8,%0" : "=m"(newregs->r8));
85+
asm volatile("mov %%r9,%0" : "=m"(newregs->r9));
86+
asm volatile("mov %%r10,%0" : "=m"(newregs->r10));
87+
asm volatile("mov %%r11,%0" : "=m"(newregs->r11));
88+
asm volatile("mov %%r12,%0" : "=m"(newregs->r12));
89+
asm volatile("mov %%r13,%0" : "=m"(newregs->r13));
90+
asm volatile("mov %%r14,%0" : "=m"(newregs->r14));
91+
asm volatile("mov %%r15,%0" : "=m"(newregs->r15));
92+
#endif
93+
asm volatile("mov %%ss,%k0" : "=a"(newregs->ss));
94+
asm volatile("mov %%cs,%k0" : "=a"(newregs->cs));
7495
#ifdef CONFIG_X86_32
75-
asm volatile("movl %%ebx,%0" : "=m"(newregs->bx));
76-
asm volatile("movl %%ecx,%0" : "=m"(newregs->cx));
77-
asm volatile("movl %%edx,%0" : "=m"(newregs->dx));
78-
asm volatile("movl %%esi,%0" : "=m"(newregs->si));
79-
asm volatile("movl %%edi,%0" : "=m"(newregs->di));
80-
asm volatile("movl %%ebp,%0" : "=m"(newregs->bp));
81-
asm volatile("movl %%eax,%0" : "=m"(newregs->ax));
82-
asm volatile("movl %%esp,%0" : "=m"(newregs->sp));
83-
asm volatile("movl %%ss, %%eax;" :"=a"(newregs->ss));
84-
asm volatile("movl %%cs, %%eax;" :"=a"(newregs->cs));
85-
asm volatile("movl %%ds, %%eax;" :"=a"(newregs->ds));
86-
asm volatile("movl %%es, %%eax;" :"=a"(newregs->es));
87-
asm volatile("pushfl; popl %0" :"=m"(newregs->flags));
88-
#else
89-
asm volatile("movq %%rbx,%0" : "=m"(newregs->bx));
90-
asm volatile("movq %%rcx,%0" : "=m"(newregs->cx));
91-
asm volatile("movq %%rdx,%0" : "=m"(newregs->dx));
92-
asm volatile("movq %%rsi,%0" : "=m"(newregs->si));
93-
asm volatile("movq %%rdi,%0" : "=m"(newregs->di));
94-
asm volatile("movq %%rbp,%0" : "=m"(newregs->bp));
95-
asm volatile("movq %%rax,%0" : "=m"(newregs->ax));
96-
asm volatile("movq %%rsp,%0" : "=m"(newregs->sp));
97-
asm volatile("movq %%r8,%0" : "=m"(newregs->r8));
98-
asm volatile("movq %%r9,%0" : "=m"(newregs->r9));
99-
asm volatile("movq %%r10,%0" : "=m"(newregs->r10));
100-
asm volatile("movq %%r11,%0" : "=m"(newregs->r11));
101-
asm volatile("movq %%r12,%0" : "=m"(newregs->r12));
102-
asm volatile("movq %%r13,%0" : "=m"(newregs->r13));
103-
asm volatile("movq %%r14,%0" : "=m"(newregs->r14));
104-
asm volatile("movq %%r15,%0" : "=m"(newregs->r15));
105-
asm volatile("movl %%ss, %%eax;" :"=a"(newregs->ss));
106-
asm volatile("movl %%cs, %%eax;" :"=a"(newregs->cs));
107-
asm volatile("pushfq; popq %0" :"=m"(newregs->flags));
96+
asm volatile("mov %%ds,%k0" : "=a"(newregs->ds));
97+
asm volatile("mov %%es,%k0" : "=a"(newregs->es));
10898
#endif
99+
asm volatile("pushf\n\t"
100+
"pop %0" : "=m"(newregs->flags));
109101
newregs->ip = _THIS_IP_;
110102
}
111103
}

0 commit comments

Comments
 (0)