linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org
Cc: David Woodhouse <dwmw@amazon.co.uk>,
	KarimAllah Ahmed <karahmed@amazon.de>
Subject: [PATCH] KVM: VMX: expose the host's ARCH_CAPABILITIES MSR to userspace
Date: Sat, 24 Feb 2018 01:52:26 +0100	[thread overview]
Message-ID: <1519433546-33879-1-git-send-email-pbonzini@redhat.com> (raw)

Use the new MSR feature framework to expose the ARCH_CAPABILITIES MSR to
userspace.  This way, userspace can access the capabilities even if it
does not have the permissions to read MSRs.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 arch/x86/kvm/vmx.c | 12 +++++++++++-
 arch/x86/kvm/x86.c |  1 +
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 130fca0ea1bf..99689061e11e 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -3228,7 +3228,17 @@ static inline bool vmx_feature_control_msr_valid(struct kvm_vcpu *vcpu,
 
 static int vmx_get_msr_feature(struct kvm_msr_entry *msr)
 {
-	return 1;
+	switch (msr->index) {
+	case MSR_IA32_ARCH_CAPABILITIES:
+		if (!boot_cpu_has(X86_FEATURE_ARCH_CAPABILITIES))
+			return 1;
+		rdmsrl(msr->index, msr->data);
+		break;
+	default:
+		return 1;
+	}
+
+	return 0;
 }
 
 /*
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 54b4ed55945b..e9a8cc9e3b2b 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -1054,6 +1054,7 @@ bool kvm_rdpmc(struct kvm_vcpu *vcpu)
  * can be used by a hypervisor to validate requested CPU features.
  */
 static u32 msr_based_features[] = {
+	MSR_IA32_ARCH_CAPABILITIES,
 	MSR_F10H_DECFG,
 };
 
-- 
1.8.3.1

             reply	other threads:[~2018-02-24  0:52 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-24  0:52 Paolo Bonzini [this message]
2018-02-26 22:13 ` [PATCH] KVM: VMX: expose the host's ARCH_CAPABILITIES MSR to userspace Konrad Rzeszutek Wilk
2018-02-26 22:23   ` Konrad Rzeszutek Wilk
2018-03-01 21:39   ` Radim Krčmář
2018-03-02  9:36     ` Paolo Bonzini
2018-03-02 21:42       ` Radim Krčmář
2018-03-07 11:53         ` Paolo Bonzini
2018-03-07 14:56           ` Radim Krčmář
2018-03-07 15:10             ` Paolo Bonzini
2018-03-07 15:39               ` Radim Krčmář

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=1519433546-33879-1-git-send-email-pbonzini@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=dwmw@amazon.co.uk \
    --cc=karahmed@amazon.de \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).