All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/xen: Delay get_cpu_cap until stack canary is established
@ 2018-03-19 16:58 Jason Andryuk
  2018-03-19 22:22 ` Boris Ostrovsky
                   ` (3 more replies)
  0 siblings, 4 replies; 13+ messages in thread
From: Jason Andryuk @ 2018-03-19 16:58 UTC (permalink / raw)
  To: Boris Ostrovsky, Juergen Gross
  Cc: Jason Andryuk, Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86,
	xen-devel, linux-kernel

Commit 2cc42bac1c79 ("x86-64/Xen: eliminate W+X mappings") introduced a
call to get_cpu_cap, which is fstack-protected.  This is works on x86-64
as commit 4f277295e54c ("x86/xen: init %gs very early to avoid page
faults with stack protector") ensures the stack protector is configured,
but it it did not cover x86-32.

Delay calling get_cpu_cap until after xen_setup_gdt has initialized the
stack canary.  Without this, a 32bit PV machine crashes early
in boot.
(XEN) Domain 0 (vcpu#0) crashed on cpu#0:
(XEN) ----[ Xen-4.6.6-xc  x86_64  debug=n  Tainted:    C ]----
(XEN) CPU:    0
(XEN) RIP:    e019:[<00000000c10362f8>]

And the PV kernel IP corresponds to init_scattered_cpuid_features
   0xc10362f8 <+24>:    mov    %gs:0x14,%eax

Fixes 2cc42bac1c79 ("x86-64/Xen: eliminate W+X mappings")

Signed-off-by: Jason Andryuk <jandryuk@gmail.com>
---
 arch/x86/xen/enlighten_pv.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/x86/xen/enlighten_pv.c b/arch/x86/xen/enlighten_pv.c
index 3c2c2530737e..c36d23aa6c35 100644
--- a/arch/x86/xen/enlighten_pv.c
+++ b/arch/x86/xen/enlighten_pv.c
@@ -1259,10 +1259,6 @@ asmlinkage __visible void __init xen_start_kernel(void)
 	 */
 	__userpte_alloc_gfp &= ~__GFP_HIGHMEM;
 
-	/* Work out if we support NX */
-	get_cpu_cap(&boot_cpu_data);
-	x86_configure_nx();
-
 	/* Get mfn list */
 	xen_build_dynamic_phys_to_machine();
 
@@ -1272,6 +1268,10 @@ asmlinkage __visible void __init xen_start_kernel(void)
 	 */
 	xen_setup_gdt(0);
 
+	/* Work out if we support NX */
+	get_cpu_cap(&boot_cpu_data);
+	x86_configure_nx();
+
 	xen_init_irq_ops();
 
 	/* Let's presume PV guests always boot on vCPU with id 0. */
-- 
2.14.3

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

* Re: [PATCH] x86/xen: Delay get_cpu_cap until stack canary is established
  2018-03-19 16:58 [PATCH] x86/xen: Delay get_cpu_cap until stack canary is established Jason Andryuk
  2018-03-19 22:22 ` Boris Ostrovsky
@ 2018-03-19 22:22 ` Boris Ostrovsky
  2018-03-20  6:28   ` Juergen Gross
  2018-03-20  6:28   ` Juergen Gross
  2018-03-21 21:14 ` Boris Ostrovsky
  2018-03-21 21:14 ` Boris Ostrovsky
  3 siblings, 2 replies; 13+ messages in thread
From: Boris Ostrovsky @ 2018-03-19 22:22 UTC (permalink / raw)
  To: Jason Andryuk, Juergen Gross
  Cc: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86, xen-devel,
	linux-kernel

On 03/19/2018 12:58 PM, Jason Andryuk wrote:
> Commit 2cc42bac1c79 ("x86-64/Xen: eliminate W+X mappings") introduced a
> call to get_cpu_cap, which is fstack-protected.  This is works on x86-64

s/This is works/This works/

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

Do we still need 4f277295e54?

-boris

> as commit 4f277295e54c ("x86/xen: init %gs very early to avoid page
> faults with stack protector") ensures the stack protector is configured,
> but it it did not cover x86-32.
>
> Delay calling get_cpu_cap until after xen_setup_gdt has initialized the
> stack canary.  Without this, a 32bit PV machine crashes early
> in boot.
> (XEN) Domain 0 (vcpu#0) crashed on cpu#0:
> (XEN) ----[ Xen-4.6.6-xc  x86_64  debug=n  Tainted:    C ]----
> (XEN) CPU:    0
> (XEN) RIP:    e019:[<00000000c10362f8>]
>
> And the PV kernel IP corresponds to init_scattered_cpuid_features
>    0xc10362f8 <+24>:    mov    %gs:0x14,%eax
>
> Fixes 2cc42bac1c79 ("x86-64/Xen: eliminate W+X mappings")
>
> Signed-off-by: Jason Andryuk <jandryuk@gmail.com>
> ---
>  arch/x86/xen/enlighten_pv.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/arch/x86/xen/enlighten_pv.c b/arch/x86/xen/enlighten_pv.c
> index 3c2c2530737e..c36d23aa6c35 100644
> --- a/arch/x86/xen/enlighten_pv.c
> +++ b/arch/x86/xen/enlighten_pv.c
> @@ -1259,10 +1259,6 @@ asmlinkage __visible void __init xen_start_kernel(void)
>  	 */
>  	__userpte_alloc_gfp &= ~__GFP_HIGHMEM;
>  
> -	/* Work out if we support NX */
> -	get_cpu_cap(&boot_cpu_data);
> -	x86_configure_nx();
> -
>  	/* Get mfn list */
>  	xen_build_dynamic_phys_to_machine();
>  
> @@ -1272,6 +1268,10 @@ asmlinkage __visible void __init xen_start_kernel(void)
>  	 */
>  	xen_setup_gdt(0);
>  
> +	/* Work out if we support NX */
> +	get_cpu_cap(&boot_cpu_data);
> +	x86_configure_nx();
> +
>  	xen_init_irq_ops();
>  
>  	/* Let's presume PV guests always boot on vCPU with id 0. */

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

* Re: [PATCH] x86/xen: Delay get_cpu_cap until stack canary is established
  2018-03-19 16:58 [PATCH] x86/xen: Delay get_cpu_cap until stack canary is established Jason Andryuk
@ 2018-03-19 22:22 ` Boris Ostrovsky
  2018-03-19 22:22 ` Boris Ostrovsky
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 13+ messages in thread
From: Boris Ostrovsky @ 2018-03-19 22:22 UTC (permalink / raw)
  To: Jason Andryuk, Juergen Gross
  Cc: x86, linux-kernel, Ingo Molnar, H. Peter Anvin, xen-devel,
	Thomas Gleixner

On 03/19/2018 12:58 PM, Jason Andryuk wrote:
> Commit 2cc42bac1c79 ("x86-64/Xen: eliminate W+X mappings") introduced a
> call to get_cpu_cap, which is fstack-protected.  This is works on x86-64

s/This is works/This works/

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

Do we still need 4f277295e54?

-boris

> as commit 4f277295e54c ("x86/xen: init %gs very early to avoid page
> faults with stack protector") ensures the stack protector is configured,
> but it it did not cover x86-32.
>
> Delay calling get_cpu_cap until after xen_setup_gdt has initialized the
> stack canary.  Without this, a 32bit PV machine crashes early
> in boot.
> (XEN) Domain 0 (vcpu#0) crashed on cpu#0:
> (XEN) ----[ Xen-4.6.6-xc  x86_64  debug=n  Tainted:    C ]----
> (XEN) CPU:    0
> (XEN) RIP:    e019:[<00000000c10362f8>]
>
> And the PV kernel IP corresponds to init_scattered_cpuid_features
>    0xc10362f8 <+24>:    mov    %gs:0x14,%eax
>
> Fixes 2cc42bac1c79 ("x86-64/Xen: eliminate W+X mappings")
>
> Signed-off-by: Jason Andryuk <jandryuk@gmail.com>
> ---
>  arch/x86/xen/enlighten_pv.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/arch/x86/xen/enlighten_pv.c b/arch/x86/xen/enlighten_pv.c
> index 3c2c2530737e..c36d23aa6c35 100644
> --- a/arch/x86/xen/enlighten_pv.c
> +++ b/arch/x86/xen/enlighten_pv.c
> @@ -1259,10 +1259,6 @@ asmlinkage __visible void __init xen_start_kernel(void)
>  	 */
>  	__userpte_alloc_gfp &= ~__GFP_HIGHMEM;
>  
> -	/* Work out if we support NX */
> -	get_cpu_cap(&boot_cpu_data);
> -	x86_configure_nx();
> -
>  	/* Get mfn list */
>  	xen_build_dynamic_phys_to_machine();
>  
> @@ -1272,6 +1268,10 @@ asmlinkage __visible void __init xen_start_kernel(void)
>  	 */
>  	xen_setup_gdt(0);
>  
> +	/* Work out if we support NX */
> +	get_cpu_cap(&boot_cpu_data);
> +	x86_configure_nx();
> +
>  	xen_init_irq_ops();
>  
>  	/* Let's presume PV guests always boot on vCPU with id 0. */


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

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

* Re: [PATCH] x86/xen: Delay get_cpu_cap until stack canary is established
  2018-03-19 22:22 ` Boris Ostrovsky
@ 2018-03-20  6:28   ` Juergen Gross
  2018-03-20  6:28   ` Juergen Gross
  1 sibling, 0 replies; 13+ messages in thread
From: Juergen Gross @ 2018-03-20  6:28 UTC (permalink / raw)
  To: Boris Ostrovsky, Jason Andryuk
  Cc: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86, xen-devel,
	linux-kernel

On 19/03/18 23:22, Boris Ostrovsky wrote:
> On 03/19/2018 12:58 PM, Jason Andryuk wrote:
>> Commit 2cc42bac1c79 ("x86-64/Xen: eliminate W+X mappings") introduced a
>> call to get_cpu_cap, which is fstack-protected.  This is works on x86-64
> 
> s/This is works/This works/
> 
> Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
> 
> Do we still need 4f277295e54?

I'd rather keep it in order to avoid nasty problems in case something
changes. After all we are trying to do an initialization in C code
which should be done in assembly before entering the C part. Doing this
properly for 32-bit pv-kernels would be rather difficult, but this is no
reason to drop the correct solution for the 64-bit case.


Juergen

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

* Re: [PATCH] x86/xen: Delay get_cpu_cap until stack canary is established
  2018-03-19 22:22 ` Boris Ostrovsky
  2018-03-20  6:28   ` Juergen Gross
@ 2018-03-20  6:28   ` Juergen Gross
  1 sibling, 0 replies; 13+ messages in thread
From: Juergen Gross @ 2018-03-20  6:28 UTC (permalink / raw)
  To: Boris Ostrovsky, Jason Andryuk
  Cc: x86, linux-kernel, Ingo Molnar, H. Peter Anvin, xen-devel,
	Thomas Gleixner

On 19/03/18 23:22, Boris Ostrovsky wrote:
> On 03/19/2018 12:58 PM, Jason Andryuk wrote:
>> Commit 2cc42bac1c79 ("x86-64/Xen: eliminate W+X mappings") introduced a
>> call to get_cpu_cap, which is fstack-protected.  This is works on x86-64
> 
> s/This is works/This works/
> 
> Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
> 
> Do we still need 4f277295e54?

I'd rather keep it in order to avoid nasty problems in case something
changes. After all we are trying to do an initialization in C code
which should be done in assembly before entering the C part. Doing this
properly for 32-bit pv-kernels would be rather difficult, but this is no
reason to drop the correct solution for the 64-bit case.


Juergen

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

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

* Re: [PATCH] x86/xen: Delay get_cpu_cap until stack canary is established
  2018-03-19 16:58 [PATCH] x86/xen: Delay get_cpu_cap until stack canary is established Jason Andryuk
  2018-03-19 22:22 ` Boris Ostrovsky
  2018-03-19 22:22 ` Boris Ostrovsky
@ 2018-03-21 21:14 ` Boris Ostrovsky
  2018-03-31 17:38   ` Jason Andryuk
  2018-03-21 21:14 ` Boris Ostrovsky
  3 siblings, 1 reply; 13+ messages in thread
From: Boris Ostrovsky @ 2018-03-21 21:14 UTC (permalink / raw)
  To: Jason Andryuk, Juergen Gross
  Cc: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86, xen-devel,
	linux-kernel

On 03/19/2018 12:58 PM, Jason Andryuk wrote:
> Commit 2cc42bac1c79 ("x86-64/Xen: eliminate W+X mappings") introduced a
> call to get_cpu_cap, which is fstack-protected.  This is works on x86-64
> as commit 4f277295e54c ("x86/xen: init %gs very early to avoid page
> faults with stack protector") ensures the stack protector is configured,
> but it it did not cover x86-32.
>
> Delay calling get_cpu_cap until after xen_setup_gdt has initialized the
> stack canary.  Without this, a 32bit PV machine crashes early
> in boot.
> (XEN) Domain 0 (vcpu#0) crashed on cpu#0:
> (XEN) ----[ Xen-4.6.6-xc  x86_64  debug=n  Tainted:    C ]----
> (XEN) CPU:    0
> (XEN) RIP:    e019:[<00000000c10362f8>]
>
> And the PV kernel IP corresponds to init_scattered_cpuid_features
>    0xc10362f8 <+24>:    mov    %gs:0x14,%eax
>
> Fixes 2cc42bac1c79 ("x86-64/Xen: eliminate W+X mappings")
>
> Signed-off-by: Jason Andryuk <jandryuk@gmail.com>
>


Applied to for-linus-4.17

-boris

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

* Re: [PATCH] x86/xen: Delay get_cpu_cap until stack canary is established
  2018-03-19 16:58 [PATCH] x86/xen: Delay get_cpu_cap until stack canary is established Jason Andryuk
                   ` (2 preceding siblings ...)
  2018-03-21 21:14 ` Boris Ostrovsky
@ 2018-03-21 21:14 ` Boris Ostrovsky
  3 siblings, 0 replies; 13+ messages in thread
From: Boris Ostrovsky @ 2018-03-21 21:14 UTC (permalink / raw)
  To: Jason Andryuk, Juergen Gross
  Cc: x86, linux-kernel, Ingo Molnar, H. Peter Anvin, xen-devel,
	Thomas Gleixner

On 03/19/2018 12:58 PM, Jason Andryuk wrote:
> Commit 2cc42bac1c79 ("x86-64/Xen: eliminate W+X mappings") introduced a
> call to get_cpu_cap, which is fstack-protected.  This is works on x86-64
> as commit 4f277295e54c ("x86/xen: init %gs very early to avoid page
> faults with stack protector") ensures the stack protector is configured,
> but it it did not cover x86-32.
>
> Delay calling get_cpu_cap until after xen_setup_gdt has initialized the
> stack canary.  Without this, a 32bit PV machine crashes early
> in boot.
> (XEN) Domain 0 (vcpu#0) crashed on cpu#0:
> (XEN) ----[ Xen-4.6.6-xc  x86_64  debug=n  Tainted:    C ]----
> (XEN) CPU:    0
> (XEN) RIP:    e019:[<00000000c10362f8>]
>
> And the PV kernel IP corresponds to init_scattered_cpuid_features
>    0xc10362f8 <+24>:    mov    %gs:0x14,%eax
>
> Fixes 2cc42bac1c79 ("x86-64/Xen: eliminate W+X mappings")
>
> Signed-off-by: Jason Andryuk <jandryuk@gmail.com>
>


Applied to for-linus-4.17

-boris

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

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

* Re: [PATCH] x86/xen: Delay get_cpu_cap until stack canary is established
  2018-03-21 21:14 ` Boris Ostrovsky
@ 2018-03-31 17:38   ` Jason Andryuk
  2018-03-31 18:10     ` Boris Ostrovsky
  2018-03-31 18:10     ` Boris Ostrovsky
  0 siblings, 2 replies; 13+ messages in thread
From: Jason Andryuk @ 2018-03-31 17:38 UTC (permalink / raw)
  To: Boris Ostrovsky
  Cc: Juergen Gross, x86, linux-kernel, Ingo Molnar, H. Peter Anvin,
	xen-devel, Thomas Gleixner


[-- Attachment #1.1: Type: text/plain, Size: 1216 bytes --]

On Wed, Mar 21, 2018, 5:12 PM Boris Ostrovsky <boris.ostrovsky@oracle.com>
wrote:

> On 03/19/2018 12:58 PM, Jason Andryuk wrote:
> > Commit 2cc42bac1c79 ("x86-64/Xen: eliminate W+X mappings") introduced a
> > call to get_cpu_cap, which is fstack-protected.  This is works on x86-64
> > as commit 4f277295e54c ("x86/xen: init %gs very early to avoid page
> > faults with stack protector") ensures the stack protector is configured,
> > but it it did not cover x86-32.
> >
> > Delay calling get_cpu_cap until after xen_setup_gdt has initialized the
> > stack canary.  Without this, a 32bit PV machine crashes early
> > in boot.
> > (XEN) Domain 0 (vcpu#0) crashed on cpu#0:
> > (XEN) ----[ Xen-4.6.6-xc  x86_64  debug=n  Tainted:    C ]----
> > (XEN) CPU:    0
> > (XEN) RIP:    e019:[<00000000c10362f8>]
> >
> > And the PV kernel IP corresponds to init_scattered_cpuid_features
> >    0xc10362f8 <+24>:    mov    %gs:0x14,%eax
> >
> > Fixes 2cc42bac1c79 ("x86-64/Xen: eliminate W+X mappings")
> >
> > Signed-off-by: Jason Andryuk <jandryuk@gmail.com>
> >
>
>
> Applied to for-linus-4.17
>

Thanks. If it's not too late, can this be cc: stable? If not, I'll submit
the request after it is in Linus's tree.

-Jason

>

[-- Attachment #1.2: Type: text/html, Size: 2019 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] 13+ messages in thread

* Re: [PATCH] x86/xen: Delay get_cpu_cap until stack canary is established
  2018-03-31 17:38   ` Jason Andryuk
@ 2018-03-31 18:10     ` Boris Ostrovsky
  2018-03-31 18:29       ` Jason Andryuk
  2018-03-31 18:29       ` Jason Andryuk
  2018-03-31 18:10     ` Boris Ostrovsky
  1 sibling, 2 replies; 13+ messages in thread
From: Boris Ostrovsky @ 2018-03-31 18:10 UTC (permalink / raw)
  To: Jason Andryuk
  Cc: Juergen Gross, Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86,
	xen-devel, linux-kernel, stable



On 03/31/2018 01:38 PM, Jason Andryuk wrote:
> On Wed, Mar 21, 2018, 5:12 PM Boris Ostrovsky 
> <boris.ostrovsky@oracle.com <mailto:boris.ostrovsky@oracle.com>> wrote:
> 
>     On 03/19/2018 12:58 PM, Jason Andryuk wrote:
>      > Commit 2cc42bac1c79 ("x86-64/Xen: eliminate W+X mappings")
>     introduced a
>      > call to get_cpu_cap, which is fstack-protected.  This is works on
>     x86-64
>      > as commit 4f277295e54c ("x86/xen: init %gs very early to avoid page
>      > faults with stack protector") ensures the stack protector is
>     configured,
>      > but it it did not cover x86-32.
>      >
>      > Delay calling get_cpu_cap until after xen_setup_gdt has
>     initialized the
>      > stack canary.  Without this, a 32bit PV machine crashes early
>      > in boot.
>      > (XEN) Domain 0 (vcpu#0) crashed on cpu#0:
>      > (XEN) ----[ Xen-4.6.6-xc  x86_64  debug=n  Tainted:    C ]----
>      > (XEN) CPU:    0
>      > (XEN) RIP:    e019:[<00000000c10362f8>]
>      >
>      > And the PV kernel IP corresponds to init_scattered_cpuid_features
>      >    0xc10362f8 <+24>:    mov    %gs:0x14,%eax
>      >
>      > Fixes 2cc42bac1c79 ("x86-64/Xen: eliminate W+X mappings")
>      >
>      > Signed-off-by: Jason Andryuk <jandryuk@gmail.com
>     <mailto:jandryuk@gmail.com>>
>      >
> 
> 
>     Applied to for-linus-4.17
> 
> 
> Thanks. If it's not too late, can this be cc: stable? 


We can always try ;-)

This is 4.15 and 4.16 only, I believe.

-boris



> If not, I'll 
> submit the request after it is in Linus's tree.
> 
> -Jason
> 

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

* Re: [PATCH] x86/xen: Delay get_cpu_cap until stack canary is established
  2018-03-31 17:38   ` Jason Andryuk
  2018-03-31 18:10     ` Boris Ostrovsky
@ 2018-03-31 18:10     ` Boris Ostrovsky
  1 sibling, 0 replies; 13+ messages in thread
From: Boris Ostrovsky @ 2018-03-31 18:10 UTC (permalink / raw)
  To: Jason Andryuk
  Cc: Juergen Gross, x86, linux-kernel, stable, Ingo Molnar,
	H. Peter Anvin, xen-devel, Thomas Gleixner



On 03/31/2018 01:38 PM, Jason Andryuk wrote:
> On Wed, Mar 21, 2018, 5:12 PM Boris Ostrovsky 
> <boris.ostrovsky@oracle.com <mailto:boris.ostrovsky@oracle.com>> wrote:
> 
>     On 03/19/2018 12:58 PM, Jason Andryuk wrote:
>      > Commit 2cc42bac1c79 ("x86-64/Xen: eliminate W+X mappings")
>     introduced a
>      > call to get_cpu_cap, which is fstack-protected.  This is works on
>     x86-64
>      > as commit 4f277295e54c ("x86/xen: init %gs very early to avoid page
>      > faults with stack protector") ensures the stack protector is
>     configured,
>      > but it it did not cover x86-32.
>      >
>      > Delay calling get_cpu_cap until after xen_setup_gdt has
>     initialized the
>      > stack canary.  Without this, a 32bit PV machine crashes early
>      > in boot.
>      > (XEN) Domain 0 (vcpu#0) crashed on cpu#0:
>      > (XEN) ----[ Xen-4.6.6-xc  x86_64  debug=n  Tainted:    C ]----
>      > (XEN) CPU:    0
>      > (XEN) RIP:    e019:[<00000000c10362f8>]
>      >
>      > And the PV kernel IP corresponds to init_scattered_cpuid_features
>      >    0xc10362f8 <+24>:    mov    %gs:0x14,%eax
>      >
>      > Fixes 2cc42bac1c79 ("x86-64/Xen: eliminate W+X mappings")
>      >
>      > Signed-off-by: Jason Andryuk <jandryuk@gmail.com
>     <mailto:jandryuk@gmail.com>>
>      >
> 
> 
>     Applied to for-linus-4.17
> 
> 
> Thanks. If it's not too late, can this be cc: stable? 


We can always try ;-)

This is 4.15 and 4.16 only, I believe.

-boris



> If not, I'll 
> submit the request after it is in Linus's tree.
> 
> -Jason
> 

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

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

* Re: [PATCH] x86/xen: Delay get_cpu_cap until stack canary is established
  2018-03-31 18:10     ` Boris Ostrovsky
@ 2018-03-31 18:29       ` Jason Andryuk
  2018-03-31 18:29       ` Jason Andryuk
  1 sibling, 0 replies; 13+ messages in thread
From: Jason Andryuk @ 2018-03-31 18:29 UTC (permalink / raw)
  To: Boris Ostrovsky
  Cc: Juergen Gross, Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86,
	xen-devel, open list, stable

On Sat, Mar 31, 2018 at 2:10 PM, Boris Ostrovsky
<boris.ostrovsky@oracle.com> wrote:
> On 03/31/2018 01:38 PM, Jason Andryuk wrote:
>> On Wed, Mar 21, 2018, 5:12 PM Boris Ostrovsky <boris.ostrovsky@oracle.com
>> <mailto:boris.ostrovsky@oracle.com>> wrote:
>>
>>     On 03/19/2018 12:58 PM, Jason Andryuk wrote:
>>      > Commit 2cc42bac1c79 ("x86-64/Xen: eliminate W+X mappings")
>>     introduced a
>>      > call to get_cpu_cap, which is fstack-protected.  This is works on
>>     x86-64
>>      > as commit 4f277295e54c ("x86/xen: init %gs very early to avoid page
>>      > faults with stack protector") ensures the stack protector is
>>     configured,
>>      > but it it did not cover x86-32.
>>      >
>>      > Delay calling get_cpu_cap until after xen_setup_gdt has
>>     initialized the
>>      > stack canary.  Without this, a 32bit PV machine crashes early
>>      > in boot.
>>      > (XEN) Domain 0 (vcpu#0) crashed on cpu#0:
>>      > (XEN) ----[ Xen-4.6.6-xc  x86_64  debug=n  Tainted:    C ]----
>>      > (XEN) CPU:    0
>>      > (XEN) RIP:    e019:[<00000000c10362f8>]
>>      >
>>      > And the PV kernel IP corresponds to init_scattered_cpuid_features
>>      >    0xc10362f8 <+24>:    mov    %gs:0x14,%eax
>>      >
>>      > Fixes 2cc42bac1c79 ("x86-64/Xen: eliminate W+X mappings")
>>      >
>>      > Signed-off-by: Jason Andryuk <jandryuk@gmail.com
>>     <mailto:jandryuk@gmail.com>>
>>      >
>>
>>
>>     Applied to for-linus-4.17
>>
>>
>> Thanks. If it's not too late, can this be cc: stable?
>
> We can always try ;-)
>
> This is 4.15 and 4.16 only, I believe.

I'm using this patch on 4.14, so there as well.

-Jason

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

* Re: [PATCH] x86/xen: Delay get_cpu_cap until stack canary is established
  2018-03-31 18:10     ` Boris Ostrovsky
  2018-03-31 18:29       ` Jason Andryuk
@ 2018-03-31 18:29       ` Jason Andryuk
  1 sibling, 0 replies; 13+ messages in thread
From: Jason Andryuk @ 2018-03-31 18:29 UTC (permalink / raw)
  To: Boris Ostrovsky
  Cc: Juergen Gross, x86, open list, stable, Ingo Molnar,
	H. Peter Anvin, xen-devel, Thomas Gleixner

On Sat, Mar 31, 2018 at 2:10 PM, Boris Ostrovsky
<boris.ostrovsky@oracle.com> wrote:
> On 03/31/2018 01:38 PM, Jason Andryuk wrote:
>> On Wed, Mar 21, 2018, 5:12 PM Boris Ostrovsky <boris.ostrovsky@oracle.com
>> <mailto:boris.ostrovsky@oracle.com>> wrote:
>>
>>     On 03/19/2018 12:58 PM, Jason Andryuk wrote:
>>      > Commit 2cc42bac1c79 ("x86-64/Xen: eliminate W+X mappings")
>>     introduced a
>>      > call to get_cpu_cap, which is fstack-protected.  This is works on
>>     x86-64
>>      > as commit 4f277295e54c ("x86/xen: init %gs very early to avoid page
>>      > faults with stack protector") ensures the stack protector is
>>     configured,
>>      > but it it did not cover x86-32.
>>      >
>>      > Delay calling get_cpu_cap until after xen_setup_gdt has
>>     initialized the
>>      > stack canary.  Without this, a 32bit PV machine crashes early
>>      > in boot.
>>      > (XEN) Domain 0 (vcpu#0) crashed on cpu#0:
>>      > (XEN) ----[ Xen-4.6.6-xc  x86_64  debug=n  Tainted:    C ]----
>>      > (XEN) CPU:    0
>>      > (XEN) RIP:    e019:[<00000000c10362f8>]
>>      >
>>      > And the PV kernel IP corresponds to init_scattered_cpuid_features
>>      >    0xc10362f8 <+24>:    mov    %gs:0x14,%eax
>>      >
>>      > Fixes 2cc42bac1c79 ("x86-64/Xen: eliminate W+X mappings")
>>      >
>>      > Signed-off-by: Jason Andryuk <jandryuk@gmail.com
>>     <mailto:jandryuk@gmail.com>>
>>      >
>>
>>
>>     Applied to for-linus-4.17
>>
>>
>> Thanks. If it's not too late, can this be cc: stable?
>
> We can always try ;-)
>
> This is 4.15 and 4.16 only, I believe.

I'm using this patch on 4.14, so there as well.

-Jason

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

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

* [PATCH] x86/xen: Delay get_cpu_cap until stack canary is established
@ 2018-03-19 16:58 Jason Andryuk
  0 siblings, 0 replies; 13+ messages in thread
From: Jason Andryuk @ 2018-03-19 16:58 UTC (permalink / raw)
  To: Boris Ostrovsky, Juergen Gross
  Cc: Jason Andryuk, x86, linux-kernel, Ingo Molnar, H. Peter Anvin,
	xen-devel, Thomas Gleixner

Commit 2cc42bac1c79 ("x86-64/Xen: eliminate W+X mappings") introduced a
call to get_cpu_cap, which is fstack-protected.  This is works on x86-64
as commit 4f277295e54c ("x86/xen: init %gs very early to avoid page
faults with stack protector") ensures the stack protector is configured,
but it it did not cover x86-32.

Delay calling get_cpu_cap until after xen_setup_gdt has initialized the
stack canary.  Without this, a 32bit PV machine crashes early
in boot.
(XEN) Domain 0 (vcpu#0) crashed on cpu#0:
(XEN) ----[ Xen-4.6.6-xc  x86_64  debug=n  Tainted:    C ]----
(XEN) CPU:    0
(XEN) RIP:    e019:[<00000000c10362f8>]

And the PV kernel IP corresponds to init_scattered_cpuid_features
   0xc10362f8 <+24>:    mov    %gs:0x14,%eax

Fixes 2cc42bac1c79 ("x86-64/Xen: eliminate W+X mappings")

Signed-off-by: Jason Andryuk <jandryuk@gmail.com>
---
 arch/x86/xen/enlighten_pv.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/x86/xen/enlighten_pv.c b/arch/x86/xen/enlighten_pv.c
index 3c2c2530737e..c36d23aa6c35 100644
--- a/arch/x86/xen/enlighten_pv.c
+++ b/arch/x86/xen/enlighten_pv.c
@@ -1259,10 +1259,6 @@ asmlinkage __visible void __init xen_start_kernel(void)
 	 */
 	__userpte_alloc_gfp &= ~__GFP_HIGHMEM;
 
-	/* Work out if we support NX */
-	get_cpu_cap(&boot_cpu_data);
-	x86_configure_nx();
-
 	/* Get mfn list */
 	xen_build_dynamic_phys_to_machine();
 
@@ -1272,6 +1268,10 @@ asmlinkage __visible void __init xen_start_kernel(void)
 	 */
 	xen_setup_gdt(0);
 
+	/* Work out if we support NX */
+	get_cpu_cap(&boot_cpu_data);
+	x86_configure_nx();
+
 	xen_init_irq_ops();
 
 	/* Let's presume PV guests always boot on vCPU with id 0. */
-- 
2.14.3


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

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

end of thread, other threads:[~2018-03-31 18:29 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-19 16:58 [PATCH] x86/xen: Delay get_cpu_cap until stack canary is established Jason Andryuk
2018-03-19 22:22 ` Boris Ostrovsky
2018-03-19 22:22 ` Boris Ostrovsky
2018-03-20  6:28   ` Juergen Gross
2018-03-20  6:28   ` Juergen Gross
2018-03-21 21:14 ` Boris Ostrovsky
2018-03-31 17:38   ` Jason Andryuk
2018-03-31 18:10     ` Boris Ostrovsky
2018-03-31 18:29       ` Jason Andryuk
2018-03-31 18:29       ` Jason Andryuk
2018-03-31 18:10     ` Boris Ostrovsky
2018-03-21 21:14 ` Boris Ostrovsky
  -- strict thread matches above, loose matches on Subject: below --
2018-03-19 16:58 Jason Andryuk

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.