From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Yang, Wei" Subject: [PATCH 2/3] Add RDWRGSFS support when setting CR4 Date: Tue, 14 Jun 2011 20:10:18 +0800 Message-ID: <1308053419-9953-3-git-send-email-wei.y.yang@intel.com> References: <1308053419-9953-1-git-send-email-wei.y.yang@intel.com> Cc: kvm@vger.kernel.org, "Yang, Wei" To: avi@redhat.com Return-path: Received: from mga11.intel.com ([192.55.52.93]:50741 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753137Ab1FNMMC (ORCPT ); Tue, 14 Jun 2011 08:12:02 -0400 In-Reply-To: <1308053419-9953-1-git-send-email-wei.y.yang@intel.com> Sender: kvm-owner@vger.kernel.org List-ID: This patch adds RDWRGSFS support when setting CR4. Signed-off-by: Yang, Wei --- arch/x86/kvm/x86.c | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index ff4623b..59d25ce 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -588,6 +588,14 @@ static bool guest_cpuid_has_smep(struct kvm_vcpu *vcpu) return best && (best->ebx & bit(X86_FEATURE_SMEP)); } +static bool guest_cpuid_has_fsgsbase(struct kvm_vcpu *vcpu) +{ + struct kvm_cpuid_entry2 *best; + + best = kvm_find_cpuid_entry(vcpu, 7, 0); + return best && (best->ebx & bit(X86_FEATURE_FSGSBASE)); +} + static void update_cpuid(struct kvm_vcpu *vcpu) { struct kvm_cpuid_entry2 *best; @@ -618,6 +626,9 @@ int kvm_set_cr4(struct kvm_vcpu *vcpu, unsigned long cr4) if (!guest_cpuid_has_smep(vcpu) && (cr4 & X86_CR4_SMEP)) return 1; + if (!guest_cpuid_has_fsgsbase(vcpu) && (cr4 & X86_CR4_RDWRGSFS)) + return 1; + if (is_long_mode(vcpu)) { if (!(cr4 & X86_CR4_PAE)) return 1; -- 1.7.1