Patchwork [174/262] x86, avx: dont use avx instructions with "noxsave" boot param

login
register
mail settings
Submitter gregkh@linuxfoundation.org
Date Sept. 28, 2012, 6:51 p.m.
Message ID <20120928183018.599659336@linuxfoundation.org>
Download mbox | patch
Permalink /patch/1521191/
State New, archived
Headers show

Comments

gregkh@linuxfoundation.org - Sept. 28, 2012, 6:51 p.m.
From: Greg KH <gregkh@linuxfoundation.org>

3.5-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Suresh Siddha <suresh.b.siddha@intel.com>

commit c6fd893da927c6cefb2ece22402765379921a834 upstream.

Clear AVX, AVX2 features along with clearing XSAVE feature bits,
as part of the parsing "noxsave" parameter.

Fixes the kernel boot panic with "noxsave" boot parameter.

We could have checked cpu_has_osxsave along with cpu_has_avx etc, but Peter
mentioned clearing the feature bits will be better for uses like
static_cpu_has() etc.

Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com>
Link: http://lkml.kernel.org/r/1343755754.2041.2.camel@sbsiddha-desk.sc.intel.com
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/x86/kernel/cpu/common.c |    2 ++
 1 file changed, 2 insertions(+)



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
Ben Hutchings - Oct. 7, 2012, 9:26 p.m.
On Fri, 2012-09-28 at 11:51 -0700, Greg Kroah-Hartman wrote:
> From: Greg KH <gregkh@linuxfoundation.org>
> 
> 3.5-stable review patch.  If anyone has any objections, please let me know.
> 
> ------------------
> 
> From: Suresh Siddha <suresh.b.siddha@intel.com>
> 
> commit c6fd893da927c6cefb2ece22402765379921a834 upstream.
> 
> Clear AVX, AVX2 features along with clearing XSAVE feature bits,
> as part of the parsing "noxsave" parameter.
> 
> Fixes the kernel boot panic with "noxsave" boot parameter.
> 
> We could have checked cpu_has_osxsave along with cpu_has_avx etc, but Peter
> mentioned clearing the feature bits will be better for uses like
> static_cpu_has() etc.

This was marked as needed for 3.5 only - presumably because the kernel
wasn't using AVX before this - but don't we also need to clear these
bits even in earlier versions so userland knows not to use it?

Ben.

> Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com>
> Link: http://lkml.kernel.org/r/1343755754.2041.2.camel@sbsiddha-desk.sc.intel.com
> Signed-off-by: H. Peter Anvin <hpa@zytor.com>
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> 
> ---
>  arch/x86/kernel/cpu/common.c |    2 ++
>  1 file changed, 2 insertions(+)
> 
> --- a/arch/x86/kernel/cpu/common.c
> +++ b/arch/x86/kernel/cpu/common.c
> @@ -144,6 +144,8 @@ static int __init x86_xsave_setup(char *
>  {
>  	setup_clear_cpu_cap(X86_FEATURE_XSAVE);
>  	setup_clear_cpu_cap(X86_FEATURE_XSAVEOPT);
> +	setup_clear_cpu_cap(X86_FEATURE_AVX);
> +	setup_clear_cpu_cap(X86_FEATURE_AVX2);
>  	return 1;
>  }
>  __setup("noxsave", x86_xsave_setup);
H. Peter Anvin - Oct. 7, 2012, 11:55 p.m.
Userland should use a different query mechanism.  On the other hand, it will not hurt either.  On pre-xsave kernels AVX is a non-option.

Ben Hutchings <ben@decadent.org.uk> wrote:

>On Fri, 2012-09-28 at 11:51 -0700, Greg Kroah-Hartman wrote:
>> From: Greg KH <gregkh@linuxfoundation.org>
>> 
>> 3.5-stable review patch.  If anyone has any objections, please let me
>know.
>> 
>> ------------------
>> 
>> From: Suresh Siddha <suresh.b.siddha@intel.com>
>> 
>> commit c6fd893da927c6cefb2ece22402765379921a834 upstream.
>> 
>> Clear AVX, AVX2 features along with clearing XSAVE feature bits,
>> as part of the parsing "noxsave" parameter.
>> 
>> Fixes the kernel boot panic with "noxsave" boot parameter.
>> 
>> We could have checked cpu_has_osxsave along with cpu_has_avx etc, but
>Peter
>> mentioned clearing the feature bits will be better for uses like
>> static_cpu_has() etc.
>
>This was marked as needed for 3.5 only - presumably because the kernel
>wasn't using AVX before this - but don't we also need to clear these
>bits even in earlier versions so userland knows not to use it?
>
>Ben.
>
>> Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com>
>> Link:
>http://lkml.kernel.org/r/1343755754.2041.2.camel@sbsiddha-desk.sc.intel.com
>> Signed-off-by: H. Peter Anvin <hpa@zytor.com>
>> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>> 
>> ---
>>  arch/x86/kernel/cpu/common.c |    2 ++
>>  1 file changed, 2 insertions(+)
>> 
>> --- a/arch/x86/kernel/cpu/common.c
>> +++ b/arch/x86/kernel/cpu/common.c
>> @@ -144,6 +144,8 @@ static int __init x86_xsave_setup(char *
>>  {
>>  	setup_clear_cpu_cap(X86_FEATURE_XSAVE);
>>  	setup_clear_cpu_cap(X86_FEATURE_XSAVEOPT);
>> +	setup_clear_cpu_cap(X86_FEATURE_AVX);
>> +	setup_clear_cpu_cap(X86_FEATURE_AVX2);
>>  	return 1;
>>  }
>>  __setup("noxsave", x86_xsave_setup);
Ben Hutchings - Oct. 8, 2012, 1:15 a.m.
On Mon, 2012-10-08 at 07:55 +0800, H. Peter Anvin wrote:
> Userland should use a different query mechanism.  On the other hand,
> it will not hurt either.  On pre-xsave kernels AVX is a non-option.
[...]

OK, having looked at what the SDM says I agree that there shouldn't be a
problem for userland.

Ben.

Patch

--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -144,6 +144,8 @@  static int __init x86_xsave_setup(char *
 {
 	setup_clear_cpu_cap(X86_FEATURE_XSAVE);
 	setup_clear_cpu_cap(X86_FEATURE_XSAVEOPT);
+	setup_clear_cpu_cap(X86_FEATURE_AVX);
+	setup_clear_cpu_cap(X86_FEATURE_AVX2);
 	return 1;
 }
 __setup("noxsave", x86_xsave_setup);