Return-Path: Received: from mail.linutronix.de (146.0.238.70:993) by crypto-ml.lab.linutronix.de with IMAP4-SSL for ; 25 Jul 2018 14:36:25 -0000 Received: from mail-wm0-x236.google.com ([2a00:1450:400c:c09::236]) by Galois.linutronix.de with esmtps (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1fiKoo-0008J3-Ul for speck@linutronix.de; Wed, 25 Jul 2018 16:31:11 +0200 Received: by mail-wm0-x236.google.com with SMTP id t25-v6so6216978wmi.3 for ; Wed, 25 Jul 2018 07:31:10 -0700 (PDT) Received: from donizetti.redhat.com (nat-pool-mxp-t.redhat.com. [149.6.153.186]) by smtp.gmail.com with ESMTPSA id w8-v6sm13922118wrp.72.2018.07.25.07.31.04 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 25 Jul 2018 07:31:04 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Subject: [MODERATED] [PATCH v2 1/4] L1TF KVM ARCH_CAPABILITIES #1 Date: Wed, 25 Jul 2018 16:30:57 +0200 Message-Id: <20180725143100.16309-2-pbonzini@redhat.com> In-Reply-To: <20180725143100.16309-1-pbonzini@redhat.com> References: <20180725143100.16309-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