From: Avi Kivity <avi@redhat.com>
To: Sheng Yang <sheng@linux.intel.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>, kvm@vger.kernel.org
Subject: Re: [PATCH 4/4] KVM: VMX: Add instruction rdtscp support for guest
Date: Wed, 16 Dec 2009 11:47:44 +0200 [thread overview]
Message-ID: <4B28ACC0.8050702@redhat.com> (raw)
In-Reply-To: <1260942485-19156-5-git-send-email-sheng@linux.intel.com>
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
next prev parent reply other threads:[~2009-12-16 9:47 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-16 5:48 [PATCH 0/4] Add support for RDTSCP in VMX Sheng Yang
2009-12-16 5:48 ` [PATCH 1/4] KVM: VMX: Remove redundant variable Sheng Yang
2009-12-16 5:48 ` [PATCH 2/4] KVM: Extended shared_msr_global to per CPU Sheng Yang
2009-12-16 9:21 ` Avi Kivity
2009-12-17 9:32 ` Sheng Yang
2009-12-17 10:32 ` Avi Kivity
2009-12-17 15:01 ` Sheng Yang
2009-12-17 15:06 ` Avi Kivity
2009-12-16 5:48 ` [PATCH 3/4] x86: Add IA32_TSC_AUX MSR Sheng Yang
2009-12-16 8:20 ` [tip:x86/urgent] x86: Add IA32_TSC_AUX MSR and use it tip-bot for Sheng Yang
2009-12-16 5:48 ` [PATCH 4/4] KVM: VMX: Add instruction rdtscp support for guest Sheng Yang
2009-12-16 9:47 ` Avi Kivity [this message]
2009-12-17 9:33 ` Sheng Yang
2009-12-17 10:39 ` Avi Kivity
2009-12-17 14:52 ` Sheng Yang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4B28ACC0.8050702@redhat.com \
--to=avi@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@redhat.com \
--cc=sheng@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.