[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMzpN2hgk4P+RHTO2oysEZJvJHJgiyGQ6JdfimaQ5yG+Gr2Q6g@mail.gmail.com>
Date: Wed, 24 Feb 2016 11:05:50 -0500
From: Brian Gerst <brgerst@...il.com>
To: Boris Ostrovsky <boris.ostrovsky@...cle.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@...cle.com>,
David Vrabel <david.vrabel@...rix.com>,
xen-devel@...ts.xenproject.org,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
mcgrof@...nel.org, stable <stable@...r.kernel.org>
Subject: Re: [PATCH v2] xen/x86: Zero out .bss for PV guests
On Wed, Feb 24, 2016 at 10:19 AM, Boris Ostrovsky
<boris.ostrovsky@...cle.com> wrote:
> Baremetal kernels clear .bss early in the boot but Xen PV guests don't
> execute that code. They have been able to run without problems because
> Xen domain builder happens to give out zeroed pages. However, since this
> is not really guaranteed, .bss should be explicitly cleared.
>
> (Since we introduce macros for specifying 32- and 64-bit registers we
> can get rid of ifdefs in startup_xen())
>
> Signed-off-by: Boris Ostrovsky <boris.ostrovsky@...cle.com>
> Cc: stable@...r.kernel.org
> ---
> arch/x86/xen/xen-head.S | 29 ++++++++++++++++++++++-------
> 1 file changed, 22 insertions(+), 7 deletions(-)
>
> diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S
> index b65f59a..2af87d1 100644
> --- a/arch/x86/xen/xen-head.S
> +++ b/arch/x86/xen/xen-head.S
> @@ -35,16 +35,31 @@
> #define PVH_FEATURES (0)
> #endif
>
> - __INIT
> -ENTRY(startup_xen)
> - cld
> #ifdef CONFIG_X86_32
> - mov %esi,xen_start_info
> - mov $init_thread_union+THREAD_SIZE,%esp
> +#define REG(register) %e##register
> +#define WSIZE_SHIFT 2
> +#define STOS stosl
> #else
> - mov %rsi,xen_start_info
> - mov $init_thread_union+THREAD_SIZE,%rsp
> +#define REG(register) %r##register
> +#define WSIZE_SHIFT 3
> +#define STOS stosq
> #endif
> +
> + __INIT
> +ENTRY(startup_xen)
> + cld
> +
> + /* Clear .bss */
> + xor REG(ax),REG(ax)
> + mov $__bss_start,REG(di)
> + mov $__bss_stop,REG(cx)
> + sub REG(di),REG(cx)
> + shr $WSIZE_SHIFT,REG(cx)
> + rep STOS
> +
> + mov REG(si),xen_start_info
> + mov $init_thread_union+THREAD_SIZE,REG(sp)
> +
> jmp xen_start_kernel
>
> __FINIT
Use the macros in <asm/asm.h> instead of defining your own. Also,
xorl %eax,%eax is good for 64-bit too, since the upper bits are
cleared.
--
Brian Gerst
Powered by blists - more mailing lists