Return-Path: Received: from smtp.eu.citrix.com ([185.25.65.24]) by Galois.linutronix.de with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1fNoWY-0003dd-D3 for speck@linutronix.de; Wed, 30 May 2018 01:59:30 +0200 Subject: [MODERATED] Re: [PATCH 2/2] L1TF KVM 2 References: <20180529194214.2600-1-pbonzini@redhat.com> <20180529194322.8B56F610F8@crypto-ml.lab.linutronix.de> From: Andrew Cooper Message-ID: <5f5ee0f8-ac8f-fdee-900c-7a2fed532053@citrix.com> Date: Wed, 30 May 2018 00:59:23 +0100 MIME-Version: 1.0 In-Reply-To: <20180529194322.8B56F610F8@crypto-ml.lab.linutronix.de> Content-Type: multipart/mixed; boundary="6QjVLfbY0Fn1R9APWjOzN1837XNH98mbY"; protected-headers="v1" To: speck@linutronix.de List-ID: --6QjVLfbY0Fn1R9APWjOzN1837XNH98mbY Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Content-Language: en-GB On 29/05/2018 20:42, speck for Paolo Bonzini wrote: > From: Paolo Bonzini > Subject: [PATCH 2/2] kvm: x86: mitigation for L1 cache terminal fault v= ulnerabilities > > Intel's new microcode adds a new feature bit in CPUID[7,0].EDX[28]. > If it is active, the displacement flush is unnecessary. Tested on > a Coffee Lake machine. > > Signed-off-by: Paolo Bonzini > --- > arch/x86/include/asm/cpufeatures.h | 1 + > arch/x86/include/asm/msr-index.h | 3 +++ > arch/x86/kvm/x86.c | 4 ++++ > 3 files changed, 8 insertions(+) > > diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/= cpufeatures.h > index 578793e97431..aebf89c4175d 100644 > --- a/arch/x86/include/asm/cpufeatures.h > +++ b/arch/x86/include/asm/cpufeatures.h > @@ -333,6 +333,7 @@ > #define X86_FEATURE_PCONFIG (18*32+18) /* Intel PCONFIG */ > #define X86_FEATURE_SPEC_CTRL (18*32+26) /* "" Speculation Control (I= BRS + IBPB) */ > #define X86_FEATURE_INTEL_STIBP (18*32+27) /* "" Single Thread Indire= ct Branch Predictors */ > +#define X86_FEATURE_FLUSH_L1D (18*32+28) /* IA32_FLUSH_L1D MSR */ > #define X86_FEATURE_ARCH_CAPABILITIES (18*32+29) /* IA32_ARCH_CAPABILI= TIES MSR (Intel) */ > =20 > /* > diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/ms= r-index.h > index 53d5b1b9255e..f43bd9f23053 100644 > --- a/arch/x86/include/asm/msr-index.h > +++ b/arch/x86/include/asm/msr-index.h > @@ -65,6 +65,9 @@ > =20 > #define MSR_MTRRcap 0x000000fe > =20 > +#define MSR_IA32_FLUSH_L1D 0x10b > +#define MSR_IA32_FLUSH_L1D_VALUE 0x00000001 > + > #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 */ > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > index ada9e55fc871..43738283aa2a 100644 > --- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -6518,6 +6518,10 @@ static int pvclock_gtod_notify(struct notifier_b= lock *nb, unsigned long unused, > =20 > void kvm_l1d_flush(void) > { > + if (static_cpu_has(X86_FEATURE_FLUSH_L1D)) { > + wrmsrl(MSR_IA32_FLUSH_L1D, MSR_IA32_FLUSH_L1D_VALUE); > + return; > + } What is this supposed to achieve?=C2=A0 Sure, most of the cache content h= as disappeared, but some of the most interesting parts are still left available to the guest. In Xen, I've come to the conclusion that the only viable option here is for a guest load-only MSR entry.=C2=A0 Without this, the GPRs at the most= recent vmentry are still available in the cache (as there is no way for the hypervisor to rationally zero them), which results in a guest kenrel =3D> guest user leak if a vmentry occurs late in the guest kernels return-to-userspace path. A guest kernel which is implementing the PTE mitigation is immune to this attack, but the hypervisor does not know a priori whether this is the case or not. ~Andrew --6QjVLfbY0Fn1R9APWjOzN1837XNH98mbY--