Skip to contentSkip to conversation

x86/cpuid: Avoid unconditionally clobbering ITSC for guests

PATCH In review Andrew Cooper 3 participants 3 messages May 16, 2016 – May 17, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/cpuid: Avoid unconditionally clobbering ITSC for guests

In general, Invariant TSC is not a feature which can be advertised to guests, because it cannot be guaranteed across migrate. domain_cpuid() goes so far as to deliberately clobber the feature flag under a number of circumstances.

Because ITSC is absent from the static {pv,hvm}_featureset masks, c/s b648feff "xen/x86: Improvements to in-hypervisor cpuid sanity checks" caused ITSC to be unconditionally masked out.

As an interim solution, include the hosts idea of ITSC along with the static {pv,hvm}_featureset when restricting the guests view of features. This causes the hardware domain, and VMs explicitly configured with ITSC and no-migrate to be offered ITSC (subject to hardware availability).

---
CC: Jan Beulich <[email protected]>
CC: Wei Liu <[email protected]>

---
 xen/arch/x86/hvm/hvm.c | 3 ++-
 xen/arch/x86/traps.c   | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)
xen/arch/x86/hvm/hvm.c +2 -1
index 7492030..5040a5c 100644
@@ -3509,7 +3509,8 @@ void hvm_cpuid(unsigned int input, unsigned int *eax, unsigned int *ebx,
         break;
 
     case 0x80000007:
-        *edx &= hvm_featureset[FEATURESET_e7d];
+        *edx &= (hvm_featureset[FEATURESET_e7d] |
+                 (host_featureset[FEATURESET_e7d] & cpufeat_mask(X86_FEATURE_ITSC)));
         break;
 
     case 0x80000008:
xen/arch/x86/traps.c +2 -1
index 0052ab8..1ef8401 100644
@@ -1142,7 +1142,8 @@ void pv_cpuid(struct cpu_user_regs *regs)
         break;
 
     case 0x80000007:
-        d &= pv_featureset[FEATURESET_e7d];
+        d &= (pv_featureset[FEATURESET_e7d] |
+              (host_featureset[FEATURESET_e7d] & cpufeat_mask(X86_FEATURE_ITSC)));
         break;
 
     case 0x80000008:
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 16.05.16 at 18:59, <[email protected]> wrote:

In general, Invariant TSC is not a feature which can be advertised to guests, because it cannot be guaranteed across migrate. domain_cpuid() goes so far as to deliberately clobber the feature flag under a number of circumstances.

Because ITSC is absent from the static {pv,hvm}_featureset masks, c/s b648feff "xen/x86: Improvements to in-hypervisor cpuid sanity checks" caused ITSC to be unconditionally masked out.

Quoted 6 lines

As an interim solution, include the hosts idea of ITSC along with the static {pv,hvm}_featureset when restricting the guests view of features. This causes the hardware domain, and VMs explicitly configured with ITSC and no-migrate to be offered ITSC (subject to hardware availability).

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#2 lore raw
In reply to Andrew Cooper
Quoted 8 lines · Andrew Cooper

In general, Invariant TSC is not a feature which can be advertised to guests, because it cannot be guaranteed across migrate. domain_cpuid() goes so far as to deliberately clobber the feature flag under a number of circumstances.

Because ITSC is absent from the static {pv,hvm}_featureset masks, c/s b648feff "xen/x86: Improvements to in-hypervisor cpuid sanity checks" caused ITSC to be unconditionally masked out.

Quoted 6 lines

As an interim solution, include the hosts idea of ITSC along with the static {pv,hvm}_featureset when restricting the guests view of features. This causes the hardware domain, and VMs explicitly configured with ITSC and no-migrate to be offered ITSC (subject to hardware availability).

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel