diff --git a/sys/amd64/vmm/intel/vmx.h b/sys/amd64/vmm/intel/vmx.h --- a/sys/amd64/vmm/intel/vmx.h +++ b/sys/amd64/vmm/intel/vmx.h @@ -140,6 +140,7 @@ uint64_t eptp; struct vm *vm; long eptgen[MAXCPU]; /* cached pmap->pm_eptgen */ + bool have_msr_tsc_aux; }; #define VMX_GUEST_VMEXIT 0 @@ -159,15 +160,8 @@ static inline bool vmx_have_msr_tsc_aux(struct vmx *vmx) { - int rdpid_rdtscp_bits = ((1 << VM_CAP_RDPID) | (1 << VM_CAP_RDTSCP)); - /* - * Since the values of these bits are uniform across all vCPUs - * (see discussion in vmx_modinit() and initialization of these bits - * in vmx_init()), just always use vCPU-zero's capability set and - * remove the need to require a vcpuid argument. - */ - return ((vmx->vcpus[0].cap.set & rdpid_rdtscp_bits) != 0); + return (vmx->have_msr_tsc_aux); } #endif diff --git a/sys/amd64/vmm/intel/vmx.c b/sys/amd64/vmm/intel/vmx.c --- a/sys/amd64/vmm/intel/vmx.c +++ b/sys/amd64/vmm/intel/vmx.c @@ -1105,6 +1105,8 @@ KASSERT(error == 0, ("vm_map_mmio(apicbase) error %d", error)); } + vmx->have_msr_tsc_aux = (cap_rdpid != 0 || cap_rdtscp != 0); + for (i = 0; i < maxcpus; i++) { vcpu = &vmx->vcpus[i];