mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] x86/xen: init %gs very early to avoid page faults with stack protector
@ 2018-02-01 12:40 Juergen Gross
  2018-02-01 20:17 ` [Xen-devel] " Boris Ostrovsky
  0 siblings, 1 reply; 5+ messages in thread
From: Juergen Gross @ 2018-02-01 12:40 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 | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S
index 497cc55a0c16..96f26e026783 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,20 @@ ENTRY(startup_xen)
 	mov %_ASM_SI, xen_start_info
 	mov $init_thread_union+THREAD_SIZE, %_ASM_SP
 
+#ifdef CONFIG_X86_64
+	/* 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
+#endif
+
 	jmp xen_start_kernel
 END(startup_xen)
 	__FINIT
-- 
2.13.6

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

* Re: [Xen-devel] [PATCH v2] x86/xen: init %gs very early to avoid page faults with stack protector
  2018-02-01 12:40 [PATCH v2] x86/xen: init %gs very early to avoid page faults with stack protector Juergen Gross
@ 2018-02-01 20:17 ` Boris Ostrovsky
  2018-02-02  0:36   ` Chris Patterson
  0 siblings, 1 reply; 5+ messages in thread
From: Boris Ostrovsky @ 2018-02-01 20:17 UTC (permalink / raw)
  To: Juergen Gross, linux-kernel, xen-devel; +Cc: stable

On 02/01/2018 07:40 AM, 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>

Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>

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

* Re: [Xen-devel] [PATCH v2] x86/xen: init %gs very early to avoid page faults with stack protector
  2018-02-01 20:17 ` [Xen-devel] " Boris Ostrovsky
@ 2018-02-02  0:36   ` Chris Patterson
  2018-02-02  5:56     ` Juergen Gross
  0 siblings, 1 reply; 5+ messages in thread
From: Chris Patterson @ 2018-02-02  0:36 UTC (permalink / raw)
  To: Boris Ostrovsky; +Cc: Juergen Gross, linux-kernel, xen-devel, stable

Works great, tested it and it fixes booting Linux v4.15 kernel for me :)

Cheers!

On Thu, Feb 1, 2018 at 3:17 PM, Boris Ostrovsky
<boris.ostrovsky@oracle.com> wrote:
> On 02/01/2018 07:40 AM, 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>
>
> Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
>
>
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xenproject.org
> https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: [Xen-devel] [PATCH v2] x86/xen: init %gs very early to avoid page faults with stack protector
  2018-02-02  0:36   ` Chris Patterson
@ 2018-02-02  5:56     ` Juergen Gross
  2018-02-02 18:34       ` Chris Patterson
  0 siblings, 1 reply; 5+ messages in thread
From: Juergen Gross @ 2018-02-02  5:56 UTC (permalink / raw)
  To: Chris Patterson, Boris Ostrovsky; +Cc: linux-kernel, xen-devel, stable

On 02/02/18 01:36, Chris Patterson wrote:
> Works great, tested it and it fixes booting Linux v4.15 kernel for me :)

Can I add your "Tested-by:" to the patch when committing it?


Juergen

> 
> Cheers!
> 
> On Thu, Feb 1, 2018 at 3:17 PM, Boris Ostrovsky
> <boris.ostrovsky@oracle.com> wrote:
>> On 02/01/2018 07:40 AM, 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>
>>
>> Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
>>
>>
>>
>> _______________________________________________
>> Xen-devel mailing list
>> Xen-devel@lists.xenproject.org
>> https://lists.xenproject.org/mailman/listinfo/xen-devel
> 

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

* Re: [Xen-devel] [PATCH v2] x86/xen: init %gs very early to avoid page faults with stack protector
  2018-02-02  5:56     ` Juergen Gross
@ 2018-02-02 18:34       ` Chris Patterson
  0 siblings, 0 replies; 5+ messages in thread
From: Chris Patterson @ 2018-02-02 18:34 UTC (permalink / raw)
  To: Juergen Gross; +Cc: Boris Ostrovsky, linux-kernel, xen-devel, stable

On Fri, Feb 2, 2018 at 12:56 AM, Juergen Gross <jgross@suse.com> wrote:
> On 02/02/18 01:36, Chris Patterson wrote:
>> Works great, tested it and it fixes booting Linux v4.15 kernel for me :)
>
> Can I add your "Tested-by:" to the patch when committing it?
>
>

Sure thing, have a great day.

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

end of thread, other threads:[~2018-02-02 18:34 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-01 12:40 [PATCH v2] x86/xen: init %gs very early to avoid page faults with stack protector Juergen Gross
2018-02-01 20:17 ` [Xen-devel] " Boris Ostrovsky
2018-02-02  0:36   ` Chris Patterson
2018-02-02  5:56     ` Juergen Gross
2018-02-02 18:34       ` Chris Patterson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®