Skip to content

Commit

Permalink
x86/xen: Use clear_bss() for Xen PV guests
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jgross1 authored and Borislav Petkov committed Jul 1, 2022
1 parent 03c765b commit 96e8fc5
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
3 changes: 3 additions & 0 deletions arch/x86/include/asm/setup.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ void *extend_brk(size_t size, size_t align);
static char __brk_##name[size]

extern void probe_roms(void);

void clear_bss(void);

#ifdef __i386__

asmlinkage void __init i386_start_kernel(void);
Expand Down
2 changes: 1 addition & 1 deletion arch/x86/kernel/head64.c
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ void __init do_early_exception(struct pt_regs *regs, int trapnr)

/* Don't add a printk in there. printk relies on the PDA which is not initialized
yet. */
static void __init clear_bss(void)
void __init clear_bss(void)
{
memset(__bss_start, 0,
(unsigned long) __bss_stop - (unsigned long) __bss_start);
Expand Down
8 changes: 6 additions & 2 deletions arch/x86/xen/enlighten_pv.c
Original file line number Diff line number Diff line change
Expand Up @@ -1183,15 +1183,19 @@ static void __init xen_domu_set_legacy_features(void)
extern void early_xen_iret_patch(void);

/* First C function to be called on Xen boot */
asmlinkage __visible void __init xen_start_kernel(void)
asmlinkage __visible void __init xen_start_kernel(struct start_info *si)
{
struct physdev_set_iopl set_iopl;
unsigned long initrd_start = 0;
int rc;

if (!xen_start_info)
if (!si)
return;

clear_bss();

xen_start_info = si;

__text_gen_insn(&early_xen_iret_patch,
JMP32_INSN_OPCODE, &early_xen_iret_patch, &xen_iret,
JMP32_INSN_SIZE);
Expand Down
10 changes: 1 addition & 9 deletions arch/x86/xen/xen-head.S
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,6 @@ SYM_CODE_START(startup_xen)
ANNOTATE_NOENDBR
cld

/* Clear .bss */
xor %eax,%eax
mov $__bss_start, %rdi
mov $__bss_stop, %rcx
sub %rdi, %rcx
shr $3, %rcx
rep stosq

mov %rsi, xen_start_info
mov initial_stack(%rip), %rsp

/* Set up %gs.
Expand All @@ -71,6 +62,7 @@ SYM_CODE_START(startup_xen)
cdq
wrmsr

mov %rsi, %rdi
call xen_start_kernel
SYM_CODE_END(startup_xen)
__FINIT
Expand Down

0 comments on commit 96e8fc5

Please sign in to comment.