Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

x86/xen: Use clear_bss() for Xen PV guests

Instead of clearing the bss area in assembly code, use the clear_bss()
function.

This requires to pass the start_info address as parameter to
xen_start_kernel() in order to avoid the xen_start_info being zeroed
again.

Signed-off-by: Juergen Gross <jgross@suse.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Link: https://lore.kernel.org/r/20220630071441.28576-2-jgross@suse.com

authored by

Juergen Gross and committed by
Borislav Petkov
96e8fc58 03c765b0

+11 -12
+3
arch/x86/include/asm/setup.h
··· 120 120 static char __brk_##name[size] 121 121 122 122 extern void probe_roms(void); 123 + 124 + void clear_bss(void); 125 + 123 126 #ifdef __i386__ 124 127 125 128 asmlinkage void __init i386_start_kernel(void);
+1 -1
arch/x86/kernel/head64.c
··· 426 426 427 427 /* Don't add a printk in there. printk relies on the PDA which is not initialized 428 428 yet. */ 429 - static void __init clear_bss(void) 429 + void __init clear_bss(void) 430 430 { 431 431 memset(__bss_start, 0, 432 432 (unsigned long) __bss_stop - (unsigned long) __bss_start);
+6 -2
arch/x86/xen/enlighten_pv.c
··· 1183 1183 extern void early_xen_iret_patch(void); 1184 1184 1185 1185 /* First C function to be called on Xen boot */ 1186 - asmlinkage __visible void __init xen_start_kernel(void) 1186 + asmlinkage __visible void __init xen_start_kernel(struct start_info *si) 1187 1187 { 1188 1188 struct physdev_set_iopl set_iopl; 1189 1189 unsigned long initrd_start = 0; 1190 1190 int rc; 1191 1191 1192 - if (!xen_start_info) 1192 + if (!si) 1193 1193 return; 1194 + 1195 + clear_bss(); 1196 + 1197 + xen_start_info = si; 1194 1198 1195 1199 __text_gen_insn(&early_xen_iret_patch, 1196 1200 JMP32_INSN_OPCODE, &early_xen_iret_patch, &xen_iret,
+1 -9
arch/x86/xen/xen-head.S
··· 48 48 ANNOTATE_NOENDBR 49 49 cld 50 50 51 - /* Clear .bss */ 52 - xor %eax,%eax 53 - mov $__bss_start, %rdi 54 - mov $__bss_stop, %rcx 55 - sub %rdi, %rcx 56 - shr $3, %rcx 57 - rep stosq 58 - 59 - mov %rsi, xen_start_info 60 51 mov initial_stack(%rip), %rsp 61 52 62 53 /* Set up %gs. ··· 62 71 cdq 63 72 wrmsr 64 73 74 + mov %rsi, %rdi 65 75 call xen_start_kernel 66 76 SYM_CODE_END(startup_xen) 67 77 __FINIT