Re: [PATCH 4/4] KVM: VMX: Add instruction rdtscp support for guest

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 12/16/2009 07:48 AM, Sheng Yang wrote:
Before enabling, execution of "rdtscp" in guest would result in #UD.


diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index 4f865e8..3a84acf 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -532,6 +532,7 @@ struct kvm_x86_ops {
  	int (*get_tdp_level)(void);
  	u64 (*get_mt_mask)(struct kvm_vcpu *vcpu, gfn_t gfn, bool is_mmio);
  	bool (*gb_page_enable)(void);
+	bool (*rdtscp_enable)(void);

Naming - a better name is rdtsp_supported(). rdtscp_enable sounds like you change it from disabled to enabled.

@@ -913,6 +924,9 @@ static void setup_msrs(struct vcpu_vmx *vmx)
  		index = __find_msr_index(vmx, MSR_CSTAR);
  		if (index>= 0)
  			move_msr_up(vmx, index, save_nmsrs++);
+		index = __find_msr_index(vmx, MSR_TSC_AUX);
+		if (index>= 0)
+			move_msr_up(vmx, index, save_nmsrs++);

Only if rdtscp is enabled in the guest's cpuid, so we don't play with this unnecessarily. If it isn't, we should trap rdtscp and inject #UD. If it is, support the msr and don't trap.

  		/*
  		 * MSR_K6_STAR is only needed on long mode guests, and only
  		 * if efer.sce is enabled.
@@ -1002,6 +1016,10 @@ static int vmx_get_msr(struct kvm_vcpu *vcpu, u32 msr_index, u64 *pdata)
  	case MSR_IA32_SYSENTER_ESP:
  		data = vmcs_readl(GUEST_SYSENTER_ESP);
  		break;
+	case MSR_TSC_AUX:
+		if (!vmx_rdtscp_enable())
+			return 1;

Again, check the guest rdtscp bit, not (just) the host's.


--
error compiling committee.c: too many arguments to function

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux