From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4F69BC433DB for ; Tue, 16 Feb 2021 16:49:06 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id F36A764E0F for ; Tue, 16 Feb 2021 16:49:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F36A764E0F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 6E7B76B0006; Tue, 16 Feb 2021 11:49:05 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6997B6B006C; Tue, 16 Feb 2021 11:49:05 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5AF4C8D0001; Tue, 16 Feb 2021 11:49:05 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0170.hostedemail.com [216.40.44.170]) by kanga.kvack.org (Postfix) with ESMTP id 452EA6B0006 for ; Tue, 16 Feb 2021 11:49:05 -0500 (EST) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 04136824556B for ; Tue, 16 Feb 2021 16:49:05 +0000 (UTC) X-FDA: 77824715850.01.berry47_230846d27645 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin01.hostedemail.com (Postfix) with ESMTP id D679F1005B1D4 for ; Tue, 16 Feb 2021 16:49:04 +0000 (UTC) X-HE-Tag: berry47_230846d27645 X-Filterd-Recvd-Size: 5821 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf29.hostedemail.com (Postfix) with ESMTP for ; Tue, 16 Feb 2021 16:49:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=6G3FLhsX5H34UMfii0yHNXOAnkTMHvnS4BuEPtDQmkc=; b=UjCsGGQVyPXvMLgoHBHsLUzcM8 V1G8UOF1SC1Pb7aUxLmcIgxPiOrLzn9iXCWOX7bO9/953tT2hEFsK3P6PLYyU5p/B1mEK5uxL20Q+ aISZ7fY9vbUlWjNuE8NRJEHL3n+GS84PCiIzA/tfbDBtOurqE41m3b0tCgOWgpftABDxdJ7i4To9q Ud+bu5exDCcXKHm28skNtn5n1XmFG0+jFoccgZq/HtU0zS3uj3Ii7tqM8jhrJByQt0zq8QizQtRSO BoPY/QcQzt4RGnJ0emT7YoQZ2823NAyQ52fJetah483+Tx/tV0eq6tStwqeJer6+oyOMTcQDSZLS/ vRzlOzVA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94 #2 (Red Hat Linux)) id 1lC3Vc-00H4Es-84; Tue, 16 Feb 2021 16:48:01 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id C21E83011E6; Tue, 16 Feb 2021 17:47:30 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 9A0AF2BC72F38; Tue, 16 Feb 2021 17:47:30 +0100 (CET) Date: Tue, 16 Feb 2021 17:47:30 +0100 From: Peter Zijlstra To: Paolo Bonzini Cc: Andi Kleen , Joerg Roedel , David Rientjes , Borislav Petkov , Andy Lutomirski , Sean Christopherson , Andrew Morton , "Kirill A. Shutemov" , Brijesh Singh , Tom Lendacky , Jon Grimm , Thomas Gleixner , Christoph Hellwig , Ingo Molnar , x86@kernel.org, linux-mm@kvack.org Subject: Re: AMD SEV-SNP/Intel TDX: validation of memory pages Message-ID: References: <20210212145318.GK5453@suse.de> <20210212152813.GA28884@suse.de> <20210212161849.GB28884@suse.de> <20210216100045.GE28884@suse.de> <20210216142741.GI365765@tassilo.jf.intel.com> <5ff9690f-331a-8322-3431-212b14f64fcc@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5ff9690f-331a-8322-3431-212b14f64fcc@redhat.com> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tue, Feb 16, 2021 at 04:59:52PM +0100, Paolo Bonzini wrote: > On 16/02/21 15:46, Peter Zijlstra wrote: > > On Tue, Feb 16, 2021 at 06:27:41AM -0800, Andi Kleen wrote: > > > I think the IST solution should at least be explored before > > > dismissing it. It might be simpler than anything else (like > > > using new APIs) > > > > Have you seen the trainwreck bonzini proposed? > > You had been suspiciously silent... :-) > > The very simplest thing is saying no to TDX. > > > > That 'solution' also hard relies on #VE not nesting more than once, so > > lovely things like: #VE -> #DB -> #VE -> #NMI -> #VE, or #VE -> NMI -> > > #VE -> #MC -> #VE or any number of other possible 'fun' combinations > > _must_ not happen. > > ... but no, this is not how it works. It is actually guaranteed that #VE > does not nest more than once, and that's the big difference with NMIs. Note that our NMI entry code is broken vs #MC or any other exception that can land while we're setting up that recursion mess. > Let's look at the first case you listed, this is what would happen: > > > #VE handler starts on stack 1 > First #VE processing... > clear VE-in-progress flag in the info block (allowing reentrancy) > #DB handler starts > nested #VE handler starts on stack 2 NMI can't land here because of the special ductape? The inner #VE never clears VE-in-progress. > outer #VE handler marks stack 1 for reexecution > nested #VE handler ends *** > #DB handler ends So what does the #DB memop that triggered that #VE actually read? What if it was a store? Because clearly it will not have handled the on-demand validation thing. So how can memops proceed? > #VE handler IRETs back to the start of the handler itself > Second #VE processing starts (also on stack 1) > clear VE-in-progress flag in the info block > #NMI handler > nested #VE handler starts on stack 2 > outer #VE handler marks stack 1 for reexecution > nested #VE handler ends *** > #NMI handler ends > #VE handler IRETs back to the start of the handler itself > Third #VE processing starts (also on stack 1) > clear VE-in-progress flag in the info block > #VE handler IRETs back to the caller > > > Two things of note: > > - note that at the points marked *** the nested #VE handler has not allowed > another exception to come. That only happens in the outer handler. > > - the inner handler does nothing but telling the outer handler to rerun. > The way it does it is certainly not pretty, because it has to work at any > instruction boundary, but at its heart it's basically a do{}while loop. So this hard relies on inhibiting NMIs and #MC being busted, right? But I still don't understand what happens to the memops if you don't handle the #VE.