x86, avx: don't use avx instructions with "noxsave" boot param
PATCH 1/1 x86, avx: don't use avx instructions with "noxsave" boot param
Check the kernel has indeed enabled xsave before using AVX instructions.
Fixes the kernel boot panic with "noxsave" boot parameter.
--- arch/x86/include/asm/xor_avx.h | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
arch/x86/include/asm/xor_avx.h +2 -2
@@ -197,12 +197,12 @@ static struct xor_block_template xor_block_avx = {#define AVX_XOR_SPEED \ do { \ - if (cpu_has_avx) \ + if (cpu_has_avx && cpu_has_osxsave) \ xor_speed(&xor_block_avx); \ } while (0)#define AVX_SELECT (FASTEST ) \ - (cpu_has_avx ? &xor_block_avx : FASTEST) + ((cpu_has_avx && cpu_has_osxsave) ? &xor_block_avx : FASTEST)#else
Quoted 5 lines · On Mon, 30 Jul 2012 15:46:15 -0700 Suresh Siddha <[email protected]>…
Check the kernel has indeed enabled xsave before using AVX instructions.
Fixes the kernel boot panic with "noxsave" boot parameter.
Signed-off-by Suresh Siddha <[email protected]>
Looks consistent with other usage - thanks.
Applied.
Should it go in '-stable' kernels too?
NeilBrown
Quoted 24 lines
--- arch/x86/include/asm/xor_avx.h | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)arch/x86/include/asm/xor_avx.h +2
-2@@ -197,12 +197,12 @@ static struct xor_block_template xor_block_avx = {#define AVX_XOR_SPEED \ do { \ - if (cpu_has_avx) \ + if (cpu_has_avx && cpu_has_osxsave) \ xor_speed(&xor_block_avx); \ } while (0)#define AVX_SELECT (FASTEST ) \ - (cpu_has_avx ? &xor_block_avx : FASTEST) + ((cpu_has_avx && cpu_has_osxsave) ? &xor_block_avx : FASTEST)#else
H. Peter Anvin
reviewerI'm wondering if we shouldn't just kill the affected CPUID bits if osxsave is off...
Quoted 44 lines · NeilBrown
Quoted 1 line · On Mon, 30 Jul 2012 15:46:15 -0700 Suresh Siddha <[email protected]>…
Check the kernel has indeed enabled xsave before using AVX
instructions.
Quoted 4 lines
Fixes the kernel boot panic with "noxsave" boot parameter.
Signed-off-by Suresh Siddha <[email protected]>Looks consistent with other usage - thanks.
Applied.Should it go in '-stable' kernels too?
NeilBrown
Review
Quoted 5 lines
--- arch/x86/include/asm/xor_avx.h | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)(quoted diff) +0
-0
b/arch/x86/include/asm/xor_avx.harch/x86/include/asm/xor_avx.h static struct xor_block_template xor_block_avx
Quoted 4 lines
index 2510d35..77987cd 100644
arch/x86/include/asm/xor_avx.h +0
-0@@ -197,12 +197,12 @@ static struct xor_block_template xor_block_avx= {
Quoted 15 lines
arch/x86/include/asm/xor_avx.h +2
-2#define AVX_XOR_SPEED \ do { \ - if (cpu_has_avx) \ + if (cpu_has_avx && cpu_has_osxsave) \ xor_speed(&xor_block_avx); \ } while (0)#define AVX_SELECT (FASTEST ) \ - (cpu_has_avx ? &xor_block_avx : FASTEST) + ((cpu_has_avx && cpu_has_osxsave) ? &xor_block_avx : FASTEST)#else
Signature · 1 line
Sent from my mobile phone. Please excuse brevity and lack of formatting.
Quoted 1 line · H. Peter Anvin
I'm wondering if we shouldn't just kill the affected CPUID bits if osxsave is off...
Yes, I considered clearing AVX bit (and any future xsave feature bits) as part of the parsing "noxsave" parameter in x86_xsave_setup().
But thought checking for osxsave was more explicit and there are not many places using avx code. Also, this follows the SDM guidelines and sets a nice precedent for someone (app's) to follow in future.
I am ok either way!
thanks,
suresh
H. Peter Anvin
reviewerQuoted 12 lines · Suresh Siddha
Quoted 1 line · H. Peter Anvin
I'm wondering if we shouldn't just kill the affected CPUID bits if osxsave is off...
Yes, I considered clearing AVX bit (and any future xsave feature bits) as part of the parsing "noxsave" parameter in
x86_xsave_setup().But thought checking for osxsave was more explicit and there are not many places using avx code. Also, this follows the SDM guidelines and sets a nice precedent for someone (app's) to follow in future.
I am ok either way!
My main reason for thinking that it would be good to clear the bits is that it plays a lot nicer with alternatives and with static_cpu_has().
-hpa
Signature · 2 lines
H. Peter Anvin, Intel Open Source Technology Center I work for Intel. I don't speak on their behalf.
Quoted 2 lines · H. Peter Anvin
My main reason for thinking that it would be good to clear the bits is that it plays a lot nicer with alternatives and with
static_cpu_has().
Fair enough. Neil, can you please drop the previous patch and Peter, please queue this for v3.6. Thanks.
---
From: Suresh Siddha <[email protected]>
Subject: x86, avx: don't use avx instructions with "noxsave" boot param
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.
--- arch/x86/kernel/cpu/common.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
arch/x86/kernel/cpu/common.c +2 -0
@@ -144,6 +144,8 @@ static int __init x86_xsave_setup(char *s) {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);
Quoted 7 lines · On Tue, 31 Jul 2012 10:29:14 -0700 Suresh Siddha <[email protected]>…
Quoted 2 lines · H. Peter Anvin
My main reason for thinking that it would be good to clear the bits is that it plays a lot nicer with alternatives and with
static_cpu_has().Fair enough. Neil, can you please drop the previous patch and Peter, please queue this for v3.6. Thanks.
Dropped. Thanks,
NeilBrown
[tip:x86/urgent] x86, avx: don't use avx instructions with " noxsave" boot param
In reply to Suresh SiddhaCommit-ID: c6fd893da927c6cefb2ece22402765379921a834 Gitweb: http://git.kernel.org/tip/c6fd893da927c6cefb2ece22402765379921a834 Author: Suresh Siddha <[email protected]> AuthorDate: Tue, 31 Jul 2012 10:29:14 -0700 Committer: H. Peter Anvin <[email protected]> CommitDate: Wed, 8 Aug 2012 13:41:42 -0700
x86, avx: don't use avx instructions with "noxsave" boot param
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.
--- arch/x86/kernel/cpu/common.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
arch/x86/kernel/cpu/common.c +2 -0
@@ -144,6 +144,8 @@ static int __init x86_xsave_setup(char *s) {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);