Return-Path: Received: from mail.linutronix.de (146.0.238.70:993) by crypto-ml.lab.linutronix.de with IMAP4-SSL for ; 05 Jul 2018 19:22:51 -0000 Received: from mx3-rdu2.redhat.com ([66.187.233.73] helo=mx1.redhat.com) by Galois.linutronix.de with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1fb9q5-0002JQ-JY for speck@linutronix.de; Thu, 05 Jul 2018 21:22:50 +0200 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3031C401EF2A for ; Thu, 5 Jul 2018 19:22:43 +0000 (UTC) Received: from washington.bos.jonmasters.org (ovpn-124-173.rdu2.redhat.com [10.10.124.173]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AF5C02156889 for ; Thu, 5 Jul 2018 19:22:42 +0000 (UTC) Subject: [MODERATED] Re: KVM L1TF options References: <47ec967f-ae94-cb68-65ce-64d4aaf14609@suse.de> From: Jon Masters Message-ID: Date: Thu, 5 Jul 2018 15:22:41 -0400 MIME-Version: 1.0 In-Reply-To: <47ec967f-ae94-cb68-65ce-64d4aaf14609@suse.de> Content-Type: multipart/mixed; boundary="CG2oPOCqFEwmDa4B1B0KrRupC7fI7TJRm"; protected-headers="v1" To: speck@linutronix.de List-ID: This is an OpenPGP/MIME encrypted message (RFC 4880 and 3156) --CG2oPOCqFEwmDa4B1B0KrRupC7fI7TJRm Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable On 07/02/2018 05:41 PM, speck for Alexander Graf wrote: > 4) EPT with PT sanitization > We could map additional guest read only RAM in an unused window of the > 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 original > CR3 entry, point to our sanitized clone instead. Otherwise create one. > Then we can slowly propagate that clone similar to shadow page tables, > but we would never have to do the GPA->HVA->GPA dance. Instead, all we > need to do is check whether a PTE has the P bit set or not. If it does,= > copy it. If it doesn't, just set the whole clone PTE to 0. I think this would be safe. It took a few minutes thinking about it, but what you're saying is that the guest *never* has control over its page tables. It's like shadow page tables but leveraging the hardware assist from EPT. So if anyone else also wondered, it's not just CR3, it's actually every page is "shadowed" in this approach. So a guest can't just toggle it's !P bit (even without doing an invalidation, force TLB eviction, wait for walker to see the change) and attack the host. It would be perfectly safe. Slower than EPT, maybe faster than shadow. > The most annoying part about this approach is that we would need to > implement A and D bits by hand, because a) the HW walker can not write > to the clone PTE because it's mapped read-only and b) we should > propagate the bits immediately into the real PTE anyway. You could do this periodically though as some kind of background task, just as long as you didn't then race with the guest also scanning. This is what will kill performance, and differ between Linux and Windows. > What I'm not quite sure of yet are page invalidations. Is there > something we can trap on for those? Otherwise we'd have to set all page= > table pages to read-only in the EPT and that would end up very expensiv= e. >=20 > So what do people think about the idea? Does it sound doable? Depends on the cost of emulating A/D bits and the above question. Jon. --=20 Computer Architect | Sent from my Fedora powered laptop --CG2oPOCqFEwmDa4B1B0KrRupC7fI7TJRm--