Return-Path: Received: from mail.linutronix.de (146.0.238.70:993) by crypto-ml.lab.linutronix.de with IMAP4-SSL for ; 15 Jul 2018 13:58:48 -0000 Received: from mail-wm0-x22d.google.com ([2a00:1450:400c:c09::22d]) by Galois.linutronix.de with esmtps (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1fehWh-000482-DM for speck@linutronix.de; Sun, 15 Jul 2018 15:57:27 +0200 Received: by mail-wm0-x22d.google.com with SMTP id z13-v6so13295718wma.5 for ; Sun, 15 Jul 2018 06:57:27 -0700 (PDT) Received: from donizetti.redhat.com (dynamic-adsl-78-12-156-57.clienti.tiscali.it. [78.12.156.57]) by smtp.gmail.com with ESMTPSA id m10-v6sm29902662wrj.35.2018.07.15.06.57.20 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 15 Jul 2018 06:57:21 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Subject: [MODERATED] [PATCH] L1TF KVM ARCH_CAPABILITIES #3 Date: Sun, 15 Jul 2018 15:57:15 +0200 Message-Id: <20180715135716.1874-4-pbonzini@redhat.com> In-Reply-To: <20180715135716.1874-1-pbonzini@redhat.com> References: <20180715135716.1874-1-pbonzini@redhat.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit MIME-Version: 1.0 To: speck@linutronix.de List-ID: This lets userspace read the MSR_IA32_ARCH_CAPABILITIES and check that all requested features are available on the host. Signed-off-by: Paolo Bonzini --- arch/x86/kvm/x86.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 902d535dff8f..79c8ca2c2ad9 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -1098,6 +1098,7 @@ bool kvm_rdpmc(struct kvm_vcpu *vcpu) MSR_F10H_DECFG, MSR_IA32_UCODE_REV, + MSR_IA32_ARCH_CAPABILITIES, }; static unsigned int num_msr_based_features; @@ -1106,7 +1107,8 @@ static int kvm_get_msr_feature(struct kvm_msr_entry *msr) { switch (msr->index) { case MSR_IA32_UCODE_REV: - rdmsrl(msr->index, msr->data); + case MSR_IA32_ARCH_CAPABILITIES: + rdmsrl_safe(msr->index, &msr->data); break; default: if (kvm_x86_ops->get_msr_feature(msr)) -- 1.8.3.1