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:57:41 -0000 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by Galois.linutronix.de with esmtps (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1fehWg-000481-EB for speck@linutronix.de; Sun, 15 Jul 2018 15:57:26 +0200 Received: by mail-wr1-x42e.google.com with SMTP id g6-v6so20423499wrp.0 for ; Sun, 15 Jul 2018 06:57:26 -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:20 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Subject: [MODERATED] [PATCH] L1TF KVM ARCH_CAPABILITIES #2 Date: Sun, 15 Jul 2018 15:57:14 +0200 Message-Id: <20180715135716.1874-3-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: Bit 3 of ARCH_CAPABILITIES tells a hypervisor that L1D flush on vmentry is not needed. In that case, KVM can behave as if there is no L1TF bug at all. Signed-off-by: Paolo Bonzini --- arch/x86/include/asm/msr-index.h | 1 + arch/x86/kernel/cpu/bugs.c | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h index 0e7517089b80..f03ec33878c3 100644 --- a/arch/x86/include/asm/msr-index.h +++ b/arch/x86/include/asm/msr-index.h @@ -70,6 +70,7 @@ #define MSR_IA32_ARCH_CAPABILITIES 0x0000010a #define ARCH_CAP_RDCL_NO (1 << 0) /* Not susceptible to Meltdown */ #define ARCH_CAP_IBRS_ALL (1 << 1) /* Enhanced IBRS support */ +#define ARCH_CAP_SKIP_L1DFL_VMENTRY (1 << 3) /* Skip L1DF on VMENTRY */ #define ARCH_CAP_SSB_NO (1 << 4) /* * Not susceptible to Speculative Store Bypass * attack, so no Speculative Store Bypass diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c index 4e06eee987d4..a8bddb8b42ba 100644 --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c @@ -677,6 +677,14 @@ static void __init l1tf_select_mitigation(void) return; } + if (boot_cpu_has(X86_FEATURE_ARCH_CAPABILITIES)) { + u64 msr; + + rdmsrl(MSR_IA32_ARCH_CAPABILITIES, msr); + if (msr & ARCH_CAP_SKIP_L1DFL_VMENTRY) + l1tf_vmx_mitigation = VMENTER_L1D_FLUSH_NOT_VULNERABLE; + } + switch (l1tf_mitigation) { case L1TF_MITIGATION_OFF: case L1TF_MITIGATION_FLUSH_NOWARN: -- 1.8.3.1