Return-Path: Received: from mail.linutronix.de (146.0.238.70:993) by crypto-ml.lab.linutronix.de with IMAP4-SSL for ; 03 Jul 2018 12:50:57 -0000 Received: from mx2.suse.de ([195.135.220.15] helo=mx1.suse.de) by Galois.linutronix.de with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1faKlj-0001AC-8U for speck@linutronix.de; Tue, 03 Jul 2018 14:50:56 +0200 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id CB691AFF7 for ; Tue, 3 Jul 2018 12:50:47 +0000 (UTC) Subject: [MODERATED] Re: ***UNCHECKED*** Re: KVM L1TF options References: <47ec967f-ae94-cb68-65ce-64d4aaf14609@suse.de> <410bdf58-c1c8-1513-3adc-f7b1890fa0ed@redhat.com> From: Alexander Graf Message-ID: <07c9f04e-abd6-070a-2a54-e379b983b097@suse.de> Date: Tue, 3 Jul 2018 14:50:46 +0200 MIME-Version: 1.0 In-Reply-To: <410bdf58-c1c8-1513-3adc-f7b1890fa0ed@redhat.com> Content-Type: multipart/mixed; boundary="nJM33KsHzr7SnhEj1V9gDZKri2RaCbK36"; protected-headers="v1" To: speck@linutronix.de List-ID: This is an OpenPGP/MIME encrypted message (RFC 4880 and 3156) --nJM33KsHzr7SnhEj1V9gDZKri2RaCbK36 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable On 03.07.18 10:36, speck for Paolo Bonzini wrote: > On 03/07/2018 00:02, speck for Anthony Liguori wrote: >>> We could map additional guest read only RAM in an unused window of th= e >>> guest physical address space as a page table cache. Then trap CR3 >>> writes. On CR3 writes, check if we have a counter-page to the origina= l >>> CR3 entry, point to our sanitized clone instead. Otherwise create one= =2E >>> So what do people think about the idea? Does it sound doable? >> >> You need to write protect all levels of the page table so you really d= o >> need to do full blown shadow paging, no? >> >> I'm not able to get my head around what gets simplified with this >> approach. >=20 > I think it's possible indeed to do the WP lazily, because you get > vmexits for both CR3 load and INVLPG which are the only events that > invalidate the TLB. >=20 > However, we can forgo the lazy write protection, and probably get bette= r > by paravirtualizing all the things. Let the guest know about the > private, read-only-mapped copy of the CR3; then use the "CR3 targets" > feature so that the guest can write the last recent values without > vmexits. The increased cost of shadow paging with KPTI is really comin= g > from the CR3 exits, while write protection and A/D emulation have prett= y > good performance (early EPT didn't have A/D bits, so it's optimized a l= ot). So I think it's worth a shot. Given that this would also mean we don't need to flush the L1 cache anymore, doing shadowed EPT may at the end of the day give us the best performance balance. I won't be able to get to it soonish though, so I'd be happy to see someone beat me to it :) Alex --nJM33KsHzr7SnhEj1V9gDZKri2RaCbK36--