Return-Path: Received: from mail.linutronix.de (146.0.238.70:993) by crypto-ml.lab.linutronix.de with IMAP4-SSL for ; 05 Aug 2018 14:18:10 -0000 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by Galois.linutronix.de with esmtps (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1fmJhM-000214-QJ for speck@linutronix.de; Sun, 05 Aug 2018 16:07:57 +0200 Received: by mail-wr1-x434.google.com with SMTP id u12-v6so9852820wrr.4 for ; Sun, 05 Aug 2018 07:07:56 -0700 (PDT) Received: from donizetti.redhat.com ([151.20.245.53]) by smtp.gmail.com with ESMTPSA id w9-v6sm6700112wrr.77.2018.08.05.07.07.49 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 05 Aug 2018 07:07:50 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Subject: [MODERATED] [PATCH v3 1/4] L1TF KVM ARCH_CAPABILITIES #1 Date: Sun, 5 Aug 2018 16:07:44 +0200 Message-Id: <20180805140747.22303-2-pbonzini@redhat.com> In-Reply-To: <20180805140747.22303-1-pbonzini@redhat.com> References: <20180805140747.22303-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 Message-Id: <1529928277-22739-1-git-send-email-pbonzini@redhat.com> 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 @@ static u32 msr_based_features[] = { 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)) -- 2.17.1