Return-Path: Received: from mail.linutronix.de (146.0.238.70:993) by crypto-ml.lab.linutronix.de with IMAP4-SSL for ; 27 Jun 2018 16:08:57 -0000 Received: from mx2.suse.de ([195.135.220.15]) by Galois.linutronix.de with esmtps (TLS1.0:DHE_RSA_CAMELLIA_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1fYD00-0008V9-Fz for speck@linutronix.de; Wed, 27 Jun 2018 18:08:55 +0200 Received: from relay1.suse.de (charybdis-ext-too.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id D2323AB35 for ; Wed, 27 Jun 2018 16:08:46 +0000 (UTC) Date: Wed, 27 Jun 2018 18:08:42 +0200 From: Borislav Petkov Subject: [MODERATED] Re: [PATCH v4 3/8] [PATCH v4 3/8] Linux Patch #3 Message-ID: <20180627160842.GG24227@zn.tnic> References: <20180623135445.641656585@localhost.localdomain> MIME-Version: 1.0 In-Reply-To: <20180623135445.641656585@localhost.localdomain> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable To: speck@linutronix.de List-ID: On Sat, Jun 23, 2018 at 09:54:17AM -0400, speck for konrad.wilk_at_oracle.com= wrote: > x86/KVM: Use L1 cache flush before VMENTER if available. >=20 > 336996-Speculative-Execution-Side-Channel-Mitigations.pdf defines > a new MSR (IA32_FLUSH_CMD aka 0x10B) which has similar write-only > semantics to other MSRs defined in the document. >=20 > The semantics of this MSR is to allow "finer granularity invalidation > of caching structures than existing mechanisms like WBINVD. It will > writeback and invalidate the L1 data cache, including all cachelines > brought in by preceding instructions, without invalidating all caches > (eg. L2 or LLC). Some processors may also invalidate the first level level > instruction cache on a L1D_FLUSH command. The L1 data and > instruction caches may be shared across the logical processors of a core." >=20 > Hence right before we do an VMENTER we need to flush the L1 data cache > to thwart against untrusted guests reading the host memory that > is cached in L1 data cache. >=20 > A copy of this document is available at > https://bugzilla.kernel.org/show_bug.cgi?id=3D199511 >=20 > Signed-off-by: Paolo Bonzini > Signed-off-by: Konrad Rzeszutek Wilk As before, fix From: or fixup when committing. ... > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > index 4d2e4975f91d..f0f25d31e5e2 100644 > --- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -6551,11 +6551,17 @@ static void *__read_mostly empty_zero_pages; > =20 > void kvm_l1d_flush(void) > { > - /* FIXME: could this be boot_cpu_data.x86_cache_size * 2? */ > - int size =3D PAGE_SIZE << L1D_CACHE_ORDER; > + int size; > =20 > ASSERT(boot_cpu_has(X86_BUG_L1TF)); > =20 > + if (static_cpu_has(X86_FEATURE_FLUSH_L1D)) { > + wrmsrl(MSR_IA32_FLUSH_CMD, L1D_FLUSH); alternative_msr_write(... --=20 Regards/Gruss, Boris. SUSE Linux GmbH, GF: Felix Imend=C3=B6rffer, Jane Smithard, Graham Norton, HR= B 21284 (AG N=C3=BCrnberg) --=20