All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH] x86/xen: init %gs very early to avoid page faults with stack protector
@ 2018-04-14  5:55 Daniel Reichelt
  2018-04-16  5:43 ` Juergen Gross
  0 siblings, 1 reply; 9+ messages in thread
From: Daniel Reichelt @ 2018-04-14  5:55 UTC (permalink / raw)
  To: xen-devel


[-- Attachment #1.1.1: Type: text/plain, Size: 7047 bytes --]

Hi,

the patch v2 solved the issue for me only on amd64, i386 guests keep crashing
with linux 4.15, 4.14 works fine.


XEN host:
- xen 4.8.3
- Debian stretch (tried with linux packages 4.14.0-0.bpo.3-amd64 and
linux-image-4.15.0-0.bpo.2-amd64
- grub-pc package from buster (2.02+dfsg1-4)


XEN guest:
- Debian testing 32bit
- booted via Debian's /usr/lib/grub-xen/grub-i386-xen.bin (buster, see XEN host)
- linux-image-4.14.0-0.bpo.3-686-pae and earlier work fine
--> linux-image-4.15.0-2-686-pae: boot aborts right after pvgrub
launches the kernel, no output to the xen-guest console logfile. Whereas
on the XEN host's serial console I see output similar to [1]:


Try #1:
--------8<-----------------------------------
(XEN) d9v0: unhandled page fault (ec=0000)
(XEN) Pagetable walk from 0000000000000014:
(XEN)  L4[0x000] = 000000028903b027 0000000000001e3b
(XEN)  L3[0x000] = 000000028904d027 0000000000001e4d
(XEN)  L2[0x000] = 000000028904e023 0000000000001e4e
(XEN)  L1[0x000] = 0000000000000000 ffffffffffffffff
(XEN) domain_crash_sync called from entry.S: fault at ffff82d080239a68 entry.o#compat_create_bounce_frame+0xd9/0xf1
(XEN) Domain 9 (vcpu#0) crashed on cpu#8:
(XEN) ----[ Xen-4.8.3  x86_64  debug=n   Not tainted ]----
(XEN) CPU:    8
(XEN) RIP:    e019:[<00000000c1031d39>]
(XEN) RFLAGS: 0000000000000292   EM: 1   CONTEXT: pv guest (d9v0)
(XEN) rax: 00000000c18a84c0   rbx: 00000000c162fce0   rcx: 0000000000000000
(XEN) rdx: 0000000000000000   rsi: 00000000c1815eec   rdi: 00000000c1815f34
(XEN) rbp: 00000000c1815f10   rsp: 00000000c1815ecc   r8:  ffff83207b00fe58
(XEN) r9:  ffff82d080197ea3   r10: 0000000080000008   r11: 0000000000000297
(XEN) r12: ffff83103ff30140   r13: ffff83103ff30148   r14: ffff83207b00ffff
(XEN) r15: 0000000000000000   cr0: 000000008005003b   cr4: 00000000003526e0
(XEN) cr3: 000000207b10c000   cr2: 0000000000000014
(XEN) fsb: 0000000000000000   gsb: 0000000000000000   gss: 0000000000000000
(XEN) ds: e021   es: e021   fs: e021   gs: e021   ss: e021   cs: e019
(XEN) Guest stack trace from esp=c1815ecc:
(XEN)   00000000 c1031d39 0001e019 00010092 c18a84c0 00000000 00000000 00000000
(XEN)   00000000 00000000 00000000 ffffffff c1815f24 c18a84c0 c18a84c0 c1815f30
(XEN)   c1815f34 c1815f50 c10328c7 c1815f3c c1815f38 c1815f40 0000302e 00000000
(XEN)   00000000 00000000 80000008 00000000 00000000 00000000 00000000 c1e38000
(XEN)   c1a08000 c1815ffc c18c44c3 00000000 00000000 00000000 00000000 00000000
(XEN)   00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
(XEN)   00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
(XEN)   00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
(XEN)   00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
(XEN)   00000000 00000000 c1e38000 c1a08000 00000000 00000000 00000000 00000000
(XEN)   00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
(XEN)   00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
(XEN)   00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
(XEN)   00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
(XEN)   00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
(XEN)   00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
(XEN)   00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
(XEN)   00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
(XEN)   00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
(XEN)   00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
-------->8-----------------------------------



Try #2:
--------8<-----------------------------------
(XEN) d15v0: unhandled page fault (ec=0000)
(XEN) Pagetable walk from 0000000000000014:
(XEN)  L4[0x000] = 000000028903b027 0000000000001e3b
(XEN)  L3[0x000] = 000000028904d027 0000000000001e4d
(XEN)  L2[0x000] = 000000028904e023 0000000000001e4e 
(XEN)  L1[0x000] = 0000000000000000 ffffffffffffffff
(XEN) domain_crash_sync called from entry.S: fault at ffff82d080239a68 entry.o#compat_create_bounce_frame+0xd9/0xf1
(XEN) Domain 15 (vcpu#0) crashed on cpu#7:
(XEN) ----[ Xen-4.8.3  x86_64  debug=n   Not tainted ]----
(XEN) CPU:    7
(XEN) RIP:    e019:[<00000000c1031d39>]
(XEN) RFLAGS: 0000000000000292   EM: 1   CONTEXT: pv guest (d15v0)
(XEN) rax: 00000000c18a84c0   rbx: 00000000c162fce0   rcx: 0000000000000000
(XEN) rdx: 0000000000000000   rsi: 00000000c1815eec   rdi: 00000000c1815f34
(XEN) rbp: 00000000c1815f10   rsp: 00000000c1815ecc   r8:  ffff83103ff3fe58
(XEN) r9:  ffff82d080197ea3   r10: 0000000080000008   r11: 0000000000000297
(XEN) r12: ffff83103ff42140   r13: ffff83103ff42148   r14: ffff83103ff3ffff
(XEN) r15: 0000000000000000   cr0: 000000008005003b   cr4: 00000000003526e0
(XEN) cr3: 000000207b103000   cr2: 0000000000000014
(XEN) fsb: 0000000000000000   gsb: 0000000000000000   gss: 0000000000000000
(XEN) ds: e021   es: e021   fs: e021   gs: e021   ss: e021   cs: e019
(XEN) Guest stack trace from esp=c1815ecc:
(XEN)   00000000 c1031d39 0001e019 00010092 c18a84c0 00000000 00000000 00000000
(XEN)   00000000 00000000 00000000 ffffffff c1815f24 c18a84c0 c18a84c0 c1815f30
(XEN)   c1815f34 c1815f50 c10328c7 c1815f3c c1815f38 c1815f40 0000302e 00000000
(XEN)   00000000 00000000 80000008 00000000 00000000 00000000 00000000 c1e38000
(XEN)   c1a08000 c1815ffc c18c44c3 00000000 00000000 00000000 00000000 00000000
(XEN)   00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
(XEN)   00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
(XEN)   00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
(XEN)   00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
(XEN)   00000000 00000000 c1e38000 c1a08000 00000000 00000000 00000000 00000000
(XEN)   00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
(XEN)   00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
(XEN)   00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
(XEN)   00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
(XEN)   00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
(XEN)   00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
(XEN)   00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
(XEN)   00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
(XEN)   00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
(XEN)   00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
-------->8-----------------------------------


Let me know if you need more info.


Thanks!
Daniel
(please CC me since I'm not subscribed to the list)



[1] https://www.mail-archive.com/grub-devel@gnu.org/msg26612.html


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 866 bytes --]

[-- Attachment #2: Type: text/plain, Size: 157 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] x86/xen: init %gs very early to avoid page faults with stack protector
  2018-04-14  5:55 [PATCH] x86/xen: init %gs very early to avoid page faults with stack protector Daniel Reichelt
@ 2018-04-16  5:43 ` Juergen Gross
  2018-04-16 20:15   ` Daniel Reichelt
  0 siblings, 1 reply; 9+ messages in thread
From: Juergen Gross @ 2018-04-16  5:43 UTC (permalink / raw)
  To: Daniel Reichelt, xen-devel

On 14/04/18 07:55, Daniel Reichelt wrote:
> Hi,
> 
> the patch v2 solved the issue for me only on amd64, i386 guests keep crashing
> with linux 4.15, 4.14 works fine.

Upstream commit 36104cb9012a82e73c32a3b709257766b16bcd1d fixed that. It
needs to be added to stable as well.


Juergen

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] x86/xen: init %gs very early to avoid page faults with stack protector
  2018-04-16  5:43 ` Juergen Gross
@ 2018-04-16 20:15   ` Daniel Reichelt
  0 siblings, 0 replies; 9+ messages in thread
From: Daniel Reichelt @ 2018-04-16 20:15 UTC (permalink / raw)
  To: Juergen Gross, xen-devel


[-- Attachment #1.1.1: Type: text/plain, Size: 150 bytes --]

> Upstream commit 36104cb9012a82e73c32a3b709257766b16bcd1d fixed that. It
> needs to be added to stable as well.

Thanks for the ptr!

Daniel


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 866 bytes --]

[-- Attachment #2: Type: text/plain, Size: 157 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] x86/xen: init %gs very early to avoid page faults with stack protector
  2018-02-01 12:22 ` Andrew Cooper
  2018-02-01 12:24   ` Juergen Gross
@ 2018-02-01 12:24   ` Juergen Gross
  1 sibling, 0 replies; 9+ messages in thread
From: Juergen Gross @ 2018-02-01 12:24 UTC (permalink / raw)
  To: Andrew Cooper, linux-kernel, xen-devel; +Cc: boris.ostrovsky, stable

On 01/02/18 13:22, Andrew Cooper wrote:
> On 01/02/18 12:16, Juergen Gross wrote:
>> When running as Xen pv guest %gs is initialized some time after
>> C code is started. Depending on stack protector usage this might be
>> too late, resulting in page faults.
>>
>> So setup %gs and MSR_GS_BASE in assembly code already.
>>
>> Cc: stable@vger.kernel.org
>> Signed-off-by: Juergen Gross <jgross@suse.com>
>> ---
>>  arch/x86/xen/xen-head.S | 14 ++++++++++++++
>>  1 file changed, 14 insertions(+)
>>
>> diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S
>> index 497cc55a0c16..b47d87076efb 100644
>> --- a/arch/x86/xen/xen-head.S
>> +++ b/arch/x86/xen/xen-head.S
>> @@ -9,7 +9,9 @@
>>  
>>  #include <asm/boot.h>
>>  #include <asm/asm.h>
>> +#include <asm/msr.h>
>>  #include <asm/page_types.h>
>> +#include <asm/percpu.h>
>>  #include <asm/unwind_hints.h>
>>  
>>  #include <xen/interface/elfnote.h>
>> @@ -35,6 +37,18 @@ ENTRY(startup_xen)
>>  	mov %_ASM_SI, xen_start_info
>>  	mov $init_thread_union+THREAD_SIZE, %_ASM_SP
>>  
>> +	/* Set up %gs.
>> +	 *
>> +	 * The base of %gs always points to the bottom of the irqstack
>> +	 * union.  If the stack protector canary is enabled, it is
>> +	 * located at %gs:40.  Note that, on SMP, the boot cpu uses
>> +	 * init data section till per cpu areas are set up.
>> +	 */
>> +	movl	$MSR_GS_BASE,%ecx
>> +	movq	$INIT_PER_CPU_VAR(irq_stack_union),%rax
>> +	cdq
>> +	wrmsr
> 
> You surely want a #ifdef __x86_64__ ?  This path is common to the 32bit
> entry as well?

Oh, indeed! Thanks for noticing.

V2 coming soon...


Juergen

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] x86/xen: init %gs very early to avoid page faults with stack protector
  2018-02-01 12:22 ` Andrew Cooper
@ 2018-02-01 12:24   ` Juergen Gross
  2018-02-01 12:24   ` Juergen Gross
  1 sibling, 0 replies; 9+ messages in thread
From: Juergen Gross @ 2018-02-01 12:24 UTC (permalink / raw)
  To: Andrew Cooper, linux-kernel, xen-devel; +Cc: boris.ostrovsky, stable

On 01/02/18 13:22, Andrew Cooper wrote:
> On 01/02/18 12:16, Juergen Gross wrote:
>> When running as Xen pv guest %gs is initialized some time after
>> C code is started. Depending on stack protector usage this might be
>> too late, resulting in page faults.
>>
>> So setup %gs and MSR_GS_BASE in assembly code already.
>>
>> Cc: stable@vger.kernel.org
>> Signed-off-by: Juergen Gross <jgross@suse.com>
>> ---
>>  arch/x86/xen/xen-head.S | 14 ++++++++++++++
>>  1 file changed, 14 insertions(+)
>>
>> diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S
>> index 497cc55a0c16..b47d87076efb 100644
>> --- a/arch/x86/xen/xen-head.S
>> +++ b/arch/x86/xen/xen-head.S
>> @@ -9,7 +9,9 @@
>>  
>>  #include <asm/boot.h>
>>  #include <asm/asm.h>
>> +#include <asm/msr.h>
>>  #include <asm/page_types.h>
>> +#include <asm/percpu.h>
>>  #include <asm/unwind_hints.h>
>>  
>>  #include <xen/interface/elfnote.h>
>> @@ -35,6 +37,18 @@ ENTRY(startup_xen)
>>  	mov %_ASM_SI, xen_start_info
>>  	mov $init_thread_union+THREAD_SIZE, %_ASM_SP
>>  
>> +	/* Set up %gs.
>> +	 *
>> +	 * The base of %gs always points to the bottom of the irqstack
>> +	 * union.  If the stack protector canary is enabled, it is
>> +	 * located at %gs:40.  Note that, on SMP, the boot cpu uses
>> +	 * init data section till per cpu areas are set up.
>> +	 */
>> +	movl	$MSR_GS_BASE,%ecx
>> +	movq	$INIT_PER_CPU_VAR(irq_stack_union),%rax
>> +	cdq
>> +	wrmsr
> 
> You surely want a #ifdef __x86_64__ ?  This path is common to the 32bit
> entry as well?

Oh, indeed! Thanks for noticing.

V2 coming soon...


Juergen


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] x86/xen: init %gs very early to avoid page faults with stack protector
  2018-02-01 12:16 Juergen Gross
  2018-02-01 12:22 ` Andrew Cooper
@ 2018-02-01 12:22 ` Andrew Cooper
  2018-02-01 12:24   ` Juergen Gross
  2018-02-01 12:24   ` Juergen Gross
  1 sibling, 2 replies; 9+ messages in thread
From: Andrew Cooper @ 2018-02-01 12:22 UTC (permalink / raw)
  To: Juergen Gross, linux-kernel, xen-devel; +Cc: boris.ostrovsky, stable

On 01/02/18 12:16, Juergen Gross wrote:
> When running as Xen pv guest %gs is initialized some time after
> C code is started. Depending on stack protector usage this might be
> too late, resulting in page faults.
>
> So setup %gs and MSR_GS_BASE in assembly code already.
>
> Cc: stable@vger.kernel.org
> Signed-off-by: Juergen Gross <jgross@suse.com>
> ---
>  arch/x86/xen/xen-head.S | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
>
> diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S
> index 497cc55a0c16..b47d87076efb 100644
> --- a/arch/x86/xen/xen-head.S
> +++ b/arch/x86/xen/xen-head.S
> @@ -9,7 +9,9 @@
>  
>  #include <asm/boot.h>
>  #include <asm/asm.h>
> +#include <asm/msr.h>
>  #include <asm/page_types.h>
> +#include <asm/percpu.h>
>  #include <asm/unwind_hints.h>
>  
>  #include <xen/interface/elfnote.h>
> @@ -35,6 +37,18 @@ ENTRY(startup_xen)
>  	mov %_ASM_SI, xen_start_info
>  	mov $init_thread_union+THREAD_SIZE, %_ASM_SP
>  
> +	/* Set up %gs.
> +	 *
> +	 * The base of %gs always points to the bottom of the irqstack
> +	 * union.  If the stack protector canary is enabled, it is
> +	 * located at %gs:40.  Note that, on SMP, the boot cpu uses
> +	 * init data section till per cpu areas are set up.
> +	 */
> +	movl	$MSR_GS_BASE,%ecx
> +	movq	$INIT_PER_CPU_VAR(irq_stack_union),%rax
> +	cdq
> +	wrmsr

You surely want a #ifdef __x86_64__ ?  This path is common to the 32bit
entry as well?

~Andrew

> +
>  	jmp xen_start_kernel
>  END(startup_xen)
>  	__FINIT

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] x86/xen: init %gs very early to avoid page faults with stack protector
  2018-02-01 12:16 Juergen Gross
@ 2018-02-01 12:22 ` Andrew Cooper
  2018-02-01 12:22 ` Andrew Cooper
  1 sibling, 0 replies; 9+ messages in thread
From: Andrew Cooper @ 2018-02-01 12:22 UTC (permalink / raw)
  To: Juergen Gross, linux-kernel, xen-devel; +Cc: boris.ostrovsky, stable

On 01/02/18 12:16, Juergen Gross wrote:
> When running as Xen pv guest %gs is initialized some time after
> C code is started. Depending on stack protector usage this might be
> too late, resulting in page faults.
>
> So setup %gs and MSR_GS_BASE in assembly code already.
>
> Cc: stable@vger.kernel.org
> Signed-off-by: Juergen Gross <jgross@suse.com>
> ---
>  arch/x86/xen/xen-head.S | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
>
> diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S
> index 497cc55a0c16..b47d87076efb 100644
> --- a/arch/x86/xen/xen-head.S
> +++ b/arch/x86/xen/xen-head.S
> @@ -9,7 +9,9 @@
>  
>  #include <asm/boot.h>
>  #include <asm/asm.h>
> +#include <asm/msr.h>
>  #include <asm/page_types.h>
> +#include <asm/percpu.h>
>  #include <asm/unwind_hints.h>
>  
>  #include <xen/interface/elfnote.h>
> @@ -35,6 +37,18 @@ ENTRY(startup_xen)
>  	mov %_ASM_SI, xen_start_info
>  	mov $init_thread_union+THREAD_SIZE, %_ASM_SP
>  
> +	/* Set up %gs.
> +	 *
> +	 * The base of %gs always points to the bottom of the irqstack
> +	 * union.  If the stack protector canary is enabled, it is
> +	 * located at %gs:40.  Note that, on SMP, the boot cpu uses
> +	 * init data section till per cpu areas are set up.
> +	 */
> +	movl	$MSR_GS_BASE,%ecx
> +	movq	$INIT_PER_CPU_VAR(irq_stack_union),%rax
> +	cdq
> +	wrmsr

You surely want a #ifdef __x86_64__ ?  This path is common to the 32bit
entry as well?

~Andrew

> +
>  	jmp xen_start_kernel
>  END(startup_xen)
>  	__FINIT


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH] x86/xen: init %gs very early to avoid page faults with stack protector
@ 2018-02-01 12:16 Juergen Gross
  2018-02-01 12:22 ` Andrew Cooper
  2018-02-01 12:22 ` Andrew Cooper
  0 siblings, 2 replies; 9+ messages in thread
From: Juergen Gross @ 2018-02-01 12:16 UTC (permalink / raw)
  To: linux-kernel, xen-devel; +Cc: boris.ostrovsky, Juergen Gross, stable

When running as Xen pv guest %gs is initialized some time after
C code is started. Depending on stack protector usage this might be
too late, resulting in page faults.

So setup %gs and MSR_GS_BASE in assembly code already.

Cc: stable@vger.kernel.org
Signed-off-by: Juergen Gross <jgross@suse.com>
---
 arch/x86/xen/xen-head.S | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S
index 497cc55a0c16..b47d87076efb 100644
--- a/arch/x86/xen/xen-head.S
+++ b/arch/x86/xen/xen-head.S
@@ -9,7 +9,9 @@
 
 #include <asm/boot.h>
 #include <asm/asm.h>
+#include <asm/msr.h>
 #include <asm/page_types.h>
+#include <asm/percpu.h>
 #include <asm/unwind_hints.h>
 
 #include <xen/interface/elfnote.h>
@@ -35,6 +37,18 @@ ENTRY(startup_xen)
 	mov %_ASM_SI, xen_start_info
 	mov $init_thread_union+THREAD_SIZE, %_ASM_SP
 
+	/* Set up %gs.
+	 *
+	 * The base of %gs always points to the bottom of the irqstack
+	 * union.  If the stack protector canary is enabled, it is
+	 * located at %gs:40.  Note that, on SMP, the boot cpu uses
+	 * init data section till per cpu areas are set up.
+	 */
+	movl	$MSR_GS_BASE,%ecx
+	movq	$INIT_PER_CPU_VAR(irq_stack_union),%rax
+	cdq
+	wrmsr
+
 	jmp xen_start_kernel
 END(startup_xen)
 	__FINIT
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH] x86/xen: init %gs very early to avoid page faults with stack protector
@ 2018-02-01 12:16 Juergen Gross
  0 siblings, 0 replies; 9+ messages in thread
From: Juergen Gross @ 2018-02-01 12:16 UTC (permalink / raw)
  To: linux-kernel, xen-devel; +Cc: Juergen Gross, boris.ostrovsky, stable

When running as Xen pv guest %gs is initialized some time after
C code is started. Depending on stack protector usage this might be
too late, resulting in page faults.

So setup %gs and MSR_GS_BASE in assembly code already.

Cc: stable@vger.kernel.org
Signed-off-by: Juergen Gross <jgross@suse.com>
---
 arch/x86/xen/xen-head.S | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S
index 497cc55a0c16..b47d87076efb 100644
--- a/arch/x86/xen/xen-head.S
+++ b/arch/x86/xen/xen-head.S
@@ -9,7 +9,9 @@
 
 #include <asm/boot.h>
 #include <asm/asm.h>
+#include <asm/msr.h>
 #include <asm/page_types.h>
+#include <asm/percpu.h>
 #include <asm/unwind_hints.h>
 
 #include <xen/interface/elfnote.h>
@@ -35,6 +37,18 @@ ENTRY(startup_xen)
 	mov %_ASM_SI, xen_start_info
 	mov $init_thread_union+THREAD_SIZE, %_ASM_SP
 
+	/* Set up %gs.
+	 *
+	 * The base of %gs always points to the bottom of the irqstack
+	 * union.  If the stack protector canary is enabled, it is
+	 * located at %gs:40.  Note that, on SMP, the boot cpu uses
+	 * init data section till per cpu areas are set up.
+	 */
+	movl	$MSR_GS_BASE,%ecx
+	movq	$INIT_PER_CPU_VAR(irq_stack_union),%rax
+	cdq
+	wrmsr
+
 	jmp xen_start_kernel
 END(startup_xen)
 	__FINIT
-- 
2.13.6


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2018-04-16 20:15 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-14  5:55 [PATCH] x86/xen: init %gs very early to avoid page faults with stack protector Daniel Reichelt
2018-04-16  5:43 ` Juergen Gross
2018-04-16 20:15   ` Daniel Reichelt
  -- strict thread matches above, loose matches on Subject: below --
2018-02-01 12:16 Juergen Gross
2018-02-01 12:16 Juergen Gross
2018-02-01 12:22 ` Andrew Cooper
2018-02-01 12:22 ` Andrew Cooper
2018-02-01 12:24   ` Juergen Gross
2018-02-01 12:24   ` Juergen Gross

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.