Skip to content

Commit 96e8fc5

Browse files
jgross1suryasaimadhu
authored andcommitted
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
1 parent 03c765b commit 96e8fc5

File tree

4 files changed

+11
-12
lines changed

4 files changed

+11
-12
lines changed

arch/x86/include/asm/setup.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@ void *extend_brk(size_t size, size_t align);
120120
static char __brk_##name[size]
121121

122122
extern void probe_roms(void);
123+
124+
void clear_bss(void);
125+
123126
#ifdef __i386__
124127

125128
asmlinkage void __init i386_start_kernel(void);

arch/x86/kernel/head64.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ void __init do_early_exception(struct pt_regs *regs, int trapnr)
426426

427427
/* Don't add a printk in there. printk relies on the PDA which is not initialized
428428
yet. */
429-
static void __init clear_bss(void)
429+
void __init clear_bss(void)
430430
{
431431
memset(__bss_start, 0,
432432
(unsigned long) __bss_stop - (unsigned long) __bss_start);

arch/x86/xen/enlighten_pv.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,15 +1183,19 @@ static void __init xen_domu_set_legacy_features(void)
11831183
extern void early_xen_iret_patch(void);
11841184

11851185
/* 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)
11871187
{
11881188
struct physdev_set_iopl set_iopl;
11891189
unsigned long initrd_start = 0;
11901190
int rc;
11911191

1192-
if (!xen_start_info)
1192+
if (!si)
11931193
return;
11941194

1195+
clear_bss();
1196+
1197+
xen_start_info = si;
1198+
11951199
__text_gen_insn(&early_xen_iret_patch,
11961200
JMP32_INSN_OPCODE, &early_xen_iret_patch, &xen_iret,
11971201
JMP32_INSN_SIZE);

arch/x86/xen/xen-head.S

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,6 @@ SYM_CODE_START(startup_xen)
4848
ANNOTATE_NOENDBR
4949
cld
5050

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
6051
mov initial_stack(%rip), %rsp
6152

6253
/* Set up %gs.
@@ -71,6 +62,7 @@ SYM_CODE_START(startup_xen)
7162
cdq
7263
wrmsr
7364

65+
mov %rsi, %rdi
7466
call xen_start_kernel
7567
SYM_CODE_END(startup_xen)
7668
__FINIT

0 commit comments

Comments
 (0)