From: Yang Weijiang <weijiang.yang@intel.com>
To: pbonzini@redhat.com, sean.j.christopherson@intel.com,
jmattson@google.com, linux-kernel@vger.kernel.org,
kvm@vger.kernel.org
Cc: Yang Weijiang <weijiang.yang@intel.com>
Subject: [RFC PATCH 1/3] KVM: x86: Add helpers for {set|clear} bits in supported_xss
Date: Wed, 11 Nov 2020 14:41:49 +0800 [thread overview]
Message-ID: <20201111064151.1090-2-weijiang.yang@intel.com> (raw)
In-Reply-To: <20201111064151.1090-1-weijiang.yang@intel.com>
From: Sean Christopherson <sean.j.christopherson@intel.com>
KVM supported XSS feature bits are designated in supported_xss, bits
could be set/cleared dynamically, add helpers to facilitate the operation.
Also add MSR_IA32_XSS to the list of MSRs reported to userspace if
supported_xss is non-zero, i.e. KVM supports at least one XSS based
feature.
Co-developed-by: Sean Christopherson <sean.j.christopherson@intel.com>
Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
Signed-off-by: Yang Weijiang <weijiang.yang@intel.com>
---
arch/x86/kvm/x86.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 397f599b20e5..528eba526c9c 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -1237,6 +1237,8 @@ static const u32 msrs_to_save_all[] = {
MSR_ARCH_PERFMON_EVENTSEL0 + 12, MSR_ARCH_PERFMON_EVENTSEL0 + 13,
MSR_ARCH_PERFMON_EVENTSEL0 + 14, MSR_ARCH_PERFMON_EVENTSEL0 + 15,
MSR_ARCH_PERFMON_EVENTSEL0 + 16, MSR_ARCH_PERFMON_EVENTSEL0 + 17,
+
+ MSR_IA32_XSS,
};
static u32 msrs_to_save[ARRAY_SIZE(msrs_to_save_all)];
@@ -5728,6 +5730,10 @@ static void kvm_init_msr_list(void)
min(INTEL_PMC_MAX_GENERIC, x86_pmu.num_counters_gp))
continue;
break;
+ case MSR_IA32_XSS:
+ if (!supported_xss)
+ continue;
+ break;
default:
break;
}
@@ -10137,6 +10143,18 @@ void kvm_arch_hardware_disable(void)
drop_user_return_notifiers();
}
+static inline void __maybe_unused kvm_set_xss_bits(u32 low, u32 high)
+{
+ supported_xss |= low;
+ supported_xss |= ((u64)high) << 32;
+}
+
+static inline void __maybe_unused kvm_clear_xss_bits(u32 low, u32 high)
+{
+ supported_xss &= ~low;
+ supported_xss &= ~(((u64)high) << 32);
+}
+
int kvm_arch_hardware_setup(void *opaque)
{
struct kvm_x86_init_ops *ops = opaque;
@@ -10155,6 +10173,8 @@ int kvm_arch_hardware_setup(void *opaque)
if (!kvm_cpu_cap_has(X86_FEATURE_XSAVES))
supported_xss = 0;
+ else
+ supported_xss &= host_xss;
#define __kvm_cpu_cap_has(UNUSED_, f) kvm_cpu_cap_has(f)
cr4_reserved_bits = __cr4_reserved_bits(__kvm_cpu_cap_has, UNUSED_);
--
2.17.2
next prev parent reply other threads:[~2020-11-11 6:32 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-11 6:41 [RFC PATCH 0/3] Get supported_xss ready for XSS dependent Yang Weijiang
2020-11-11 6:41 ` Yang Weijiang [this message]
2020-11-11 6:41 ` [RFC PATCH 2/3] KVM: x86: Refresh CPUID when guest modifies MSR_IA32_XSS Yang Weijiang
2020-11-11 6:41 ` [RFC PATCH 3/3] KVM: x86: Load guest fpu state when accessing MSRs managed by XSAVES Yang Weijiang
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=20201111064151.1090-2-weijiang.yang@intel.com \
--to=weijiang.yang@intel.com \
--cc=jmattson@google.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=sean.j.christopherson@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®