Two Fixes for xsave compoent features
cover Two Fixes for xsave compoent features
Two simple fixes for XSAVE component features, please see each one for details.
Xiaoyao Li (2):
i386/cpu: Clear FEAT_XSAVE_COMP_{LO,HI} when XSAVE is not available i386/cpu: Mask off unsupported XSAVE components
target/i386/cpu.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
Signature · 1 line
2.18.4
PATCH 1/2 i386/cpu: Clear FEAT_XSAVE_COMP_{LO, HI} when XSAVE is not available
Per Intel SDM vol 1, 13.2, if CPUID.1:ECX.XSAVE[bit 26] is 0, the processor provides no further enumeration through CPUID function 0DH.
--- target/i386/cpu.c | 2 ++ 1 file changed, 2 insertions(+)
target/i386/cpu.c +2 -0
@@ -6261,6 +6261,8 @@ static void x86_cpu_enable_xsave_components(X86CPU *cpu)uint64_t mask;if (!(env->features[FEAT_1_ECX ] &CPUID_EXT_XSAVE )) { + env->features[FEAT_XSAVE_COMP_LO ] =0 ; + env->features[FEAT_XSAVE_COMP_HI ] =0 ;return ; }
Signature · 1 line
2.18.4
Re: [PATCH 1/2] i386/cpu: Clear FEAT_XSAVE_COMP_{LO,HI} when XSAVE is not available
Quoted 2 lines · Xiaoyao Li
Per Intel SDM vol 1, 13.2, if CPUID.1:ECX.XSAVE[bit 26] is 0, the processor provides no further enumeration through CPUID function 0DH.
Can you explain what's the bug you are trying to fix? env->features[FEAT_XSAVE_COMP_*] is already initialized as zero.
Quoted 22 lines
Signed-off-by Xiaoyao Li <[email protected]>--- target/i386/cpu.c | 2 ++ 1 file changed, 2 insertions(+)target/i386/cpu.c +2
-0@@ -6261,6 +6261,8 @@ static void x86_cpu_enable_xsave_components(X86CPU *cpu)uint64_t mask;if (!(env->features[FEAT_1_ECX ] &CPUID_EXT_XSAVE )) { + env->features[FEAT_XSAVE_COMP_LO ] =0 ; + env->features[FEAT_XSAVE_COMP_HI ] =0 ;return ; }Signature · 1 line
2.18.4
Signature · 1 line
Eduardo
Re: [PATCH 1/2] i386/cpu: Clear FEAT_XSAVE_COMP_{LO, HI} when XSAVE is not available
Quoted 6 lines · Eduardo Habkost
Quoted 2 lines · Xiaoyao Li
Per Intel SDM vol 1, 13.2, if CPUID.1:ECX.XSAVE[bit 26] is 0, the processor provides no further enumeration through CPUID function 0DH.
Can you explain what's the bug you are trying to fix? env->features[FEAT_XSAVE_COMP_*] is already initialized as zero.
When "-cpu host", it's not zero I think.
Quoted 24 lines
Quoted 23 lines
Signed-off-by Xiaoyao Li <[email protected]>--- target/i386/cpu.c | 2 ++ 1 file changed, 2 insertions(+)target/i386/cpu.c +2
-0@@ -6261,6 +6261,8 @@ static void x86_cpu_enable_xsave_components(X86CPU *cpu)uint64_t mask;if (!(env->features[FEAT_1_ECX ] &CPUID_EXT_XSAVE )) { + env->features[FEAT_XSAVE_COMP_LO ] =0 ; + env->features[FEAT_XSAVE_COMP_HI ] =0 ;return ; }Signature · 1 line
2.18.4
Re: [PATCH 1/2] i386/cpu: Clear FEAT_XSAVE_COMP_{LO, HI} when XSAVE is not available
In reply to Xiaoyao LiQuoted 14 lines · Xiaoyao Li
Per Intel SDM vol 1, 13.2, if CPUID.1:ECX.XSAVE[bit 26] is 0, the processor provides no further enumeration through CPUID function 0DH.
Signed-off-by Xiaoyao Li <[email protected]>--- target/i386/cpu.c | 2 ++ 1 file changed, 2 insertions(+)target/i386/cpu.c +0
-0
target/i386/cpu.c static void x86_cpu_enable_xsave_components(X86CPU *cpu) · line 6268
Quoted 8 lines
target/i386/cpu.c +2
-0@@ -6261,6 +6261,8 @@ static void x86_cpu_enable_xsave_components(X86CPU *cpu)uint64_t mask;if (!(env->features[FEAT_1_ECX ] &CPUID_EXT_XSAVE )) { + env->features[FEAT_XSAVE_COMP_LO ] =0 ; + env->features[FEAT_XSAVE_COMP_HI ] =0 ;return ; }
Queued this patch, noting in the commit message that it affects "-cpu host,-xsave".
Paolo
PATCH 2/2 i386/cpu: Mask off unsupported XSAVE components
In reply to Xiaoyao LiWhen setting up XSAVE components, it needs to mask off those unsupported by KVM.
--- target/i386/cpu.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
target/i386/cpu.c +4 -2
@@ -6274,8 +6274,10 @@ static void x86_cpu_enable_xsave_components(X86CPU *cpu) } } - env->features[FEAT_XSAVE_COMP_LO ] = mask; - env->features[FEAT_XSAVE_COMP_HI ] = mask >>32 ; + env->features[FEAT_XSAVE_COMP_LO ] = mask & +x86_cpu_get_supported_feature_word (FEAT_XSAVE_COMP_LO , cpu->migratable); + env->features[FEAT_XSAVE_COMP_HI ] = (mask >>32 ) & +x86_cpu_get_supported_feature_word (FEAT_XSAVE_COMP_HI , cpu->migratable); }/***** Steps involved on loading and filtering CPUID data
Signature · 1 line
2.18.4
Re: [PATCH 2/2] i386/cpu: Mask off unsupported XSAVE components
Quoted 4 lines · Xiaoyao Li
When setting up XSAVE components, it needs to mask off those unsupported by KVM.
Signed-off-by Xiaoyao Li <[email protected]>
We must never disable CPUID features silently based on host capabilities, otherwise we can't guarantee guest ABI stability when migrating to another host. Filtering of features should involve a call to mark_unavailable_features() (or some equivalent mechanism) so we can report the missing features properly through QMP.
Could you explain what's the bug you are trying to fix? The loop at x86_cpu_filter_features() is already supposed to disable features unsupported by the host.
Quoted 24 lines
--- target/i386/cpu.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)target/i386/cpu.c +4
-2@@ -6274,8 +6274,10 @@ static void x86_cpu_enable_xsave_components(X86CPU *cpu) } } - env->features[FEAT_XSAVE_COMP_LO ] = mask; - env->features[FEAT_XSAVE_COMP_HI ] = mask >>32 ; + env->features[FEAT_XSAVE_COMP_LO ] = mask & +x86_cpu_get_supported_feature_word (FEAT_XSAVE_COMP_LO , cpu->migratable); + env->features[FEAT_XSAVE_COMP_HI ] = (mask >>32 ) & +x86_cpu_get_supported_feature_word (FEAT_XSAVE_COMP_HI , cpu->migratable); }/***** Steps involved on loading and filtering CPUID data Signature · 1 line
2.18.4
Signature · 1 line
Eduardo
Re: [PATCH 2/2] i386/cpu: Mask off unsupported XSAVE components
Quoted 13 lines · Eduardo Habkost
Quoted 4 lines · Xiaoyao Li
When setting up XSAVE components, it needs to mask off those unsupported by KVM.
Signed-off-by Xiaoyao Li <[email protected]>We must never disable CPUID features silently based on host capabilities, otherwise we can't guarantee guest ABI stability when migrating to another host. Filtering of features should involve a call to
mark_unavailable_features()(or some equivalent mechanism) so we can report the missing features properly through QMP.
Quoted 3 lines
Could you explain what's the bug you are trying to fix? The loop at
x86_cpu_filter_features()is already supposed to disable features unsupported by the host.
Sorry, I forgot x86_cpu_filter_features() totally when code inspection.
Quoted 25 lines
Quoted 24 lines
--- target/i386/cpu.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)target/i386/cpu.c +4
-2@@ -6274,8 +6274,10 @@ static void x86_cpu_enable_xsave_components(X86CPU *cpu) } } - env->features[FEAT_XSAVE_COMP_LO ] = mask; - env->features[FEAT_XSAVE_COMP_HI ] = mask >>32 ; + env->features[FEAT_XSAVE_COMP_LO ] = mask & +x86_cpu_get_supported_feature_word (FEAT_XSAVE_COMP_LO , cpu->migratable); + env->features[FEAT_XSAVE_COMP_HI ] = (mask >>32 ) & +x86_cpu_get_supported_feature_word (FEAT_XSAVE_COMP_HI , cpu->migratable); }/***** Steps involved on loading and filtering CPUID data Signature · 1 line
2.18.4