x86/cpuid: do not expand max leaves on restore
PATCH 1/1 x86/cpuid: do not expand max leaves on restore
When restoring limit the maximum leaves to the ones supported by Xen 4.13 in order to not expand the maximum leaf a guests sees. Note this is unlikely to cause real issues.
Guests restored from Xen versions 4.13 or greater will contain CPUID data on the stream that will override the values set by xc_cpuid_apply_policy.
--- tools/libs/guest/xg_cpuid_x86.c | 5 +++++ 1 file changed, 5 insertions(+)
tools/libs/guest/xg_cpuid_x86.c +5 -0
@@ -510,6 +510,11 @@ int xc_cpuid_apply_policy(xc_interface *xch, uint32_t domid, bool restore, { p->feat.mpx =test_bit (X86_FEATURE_MPX , host_featureset); } + +/* Clamp maximum leaves to the supported ones on 4.13. */ + p->basic.max_leaf =min (p->basic.max_leaf,0xdu ); + p->feat.max_subleaf =min (p->feat.max_subleaf,1u ); + p->extd.max_leaf =min (p->extd.max_leaf,0x1cu ); }if ( featureset )
Signature · 1 line
2.30.1
Quoted 3 lines · Roger Pau Monne
When restoring limit the maximum leaves to the ones supported by Xen 4.13 in order to not expand the maximum leaf a guests sees. Note this is unlikely to cause real issues.
Why 4.13 (and not 4.12) here when ...
Quoted 3 lines
Guests restored from Xen versions 4.13 or greater will contain CPUID data on the stream that will override the values set by
xc_cpuid_apply_policy.
... 4.13 already communicates the values?
tools/libs/guest/xg_cpuid_x86.c int xc_cpuid_apply_policy(xc_interface *xch, uint32_t domid, bool restore, · line 514
Quoted 8 lines
tools/libs/guest/xg_cpuid_x86.c +2
-0@@ -510,6 +510,11 @@ int xc_cpuid_apply_policy(xc_interface *xch, uint32_t domid, bool restore, { p->feat.mpx =test_bit (X86_FEATURE_MPX , host_featureset); } + +/* Clamp maximum leaves to the supported ones on 4.13. */
Same aspect here then. (While not being a native speaker, it would still seem to me that flipping "supported" and "ones" would read slightly more clearly.)
tools/libs/guest/xg_cpuid_x86.c int xc_cpuid_apply_policy(xc_interface *xch, uint32_t domid, bool restore, · line 518
Quoted 4 lines
tools/libs/guest/xg_cpuid_x86.c +3
-0+ p->basic.max_leaf =min (p->basic.max_leaf,0xdu ); + p->feat.max_subleaf =min (p->feat.max_subleaf,1u ); + p->extd.max_leaf =min (p->extd.max_leaf,0x1cu ); }
With this I think the comment ahead of the enclosing if() wants either amending or moving immediately inside the if()'s body.
Jan
Quoted 5 lines · Jan Beulich
Quoted 3 lines · Roger Pau Monne
When restoring limit the maximum leaves to the ones supported by Xen 4.13 in order to not expand the maximum leaf a guests sees. Note this is unlikely to cause real issues.
Quoted 7 lines
Why 4.13 (and not 4.12) here when ...
Quoted 3 lines
Guests restored from Xen versions 4.13 or greater will contain CPUID data on the stream that will override the values set by
xc_cpuid_apply_policy.... 4.13 already communicates the values?
Urg, yes, my bad. This should have been limited to the max leaves supported by 4.12, not 4.13.
Let me send a new version also incorporating the feedback from below.
Thanks, Roger.