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=-7.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 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 7E521C433E0 for ; Fri, 12 Feb 2021 23:51:23 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0D5F464E14 for ; Fri, 12 Feb 2021 23:51:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0D5F464E14 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 68D548D00AE; Fri, 12 Feb 2021 18:51:22 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 63E148D0060; Fri, 12 Feb 2021 18:51:22 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5546C8D00AE; Fri, 12 Feb 2021 18:51:22 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0049.hostedemail.com [216.40.44.49]) by kanga.kvack.org (Postfix) with ESMTP id 415DD8D0060 for ; Fri, 12 Feb 2021 18:51:22 -0500 (EST) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 024891841C1CF for ; Fri, 12 Feb 2021 23:51:22 +0000 (UTC) X-FDA: 77811264804.29.D6980FB Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by imf07.hostedemail.com (Postfix) with ESMTP id 646D8A0000FD for ; Fri, 12 Feb 2021 23:51:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1613173880; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yQ/ZdB3C/59Umr73xWbjH6ldpOIkw/gFwuxsArF4DLs=; b=V/5msDC6oGdFV+Sua8ss16h8yZsMNMDLfb+2wX/nMyG5rAdNSQbhSA5Ek9ar5lDZt+00X/ U+qeNiOZp702/W2hJ8arRXswD0opp0cc9L7LJii4eLByOmJB/J3prfLLY0U44Oku13R5CX u6sKcVhRAFhE6K9B17xuJWcv1vQAcI0= Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-598-Avg3yOUxPLS-u0jloQ942g-1; Fri, 12 Feb 2021 18:51:16 -0500 X-MC-Unique: Avg3yOUxPLS-u0jloQ942g-1 Received: by mail-ej1-f70.google.com with SMTP id p1so995548ejo.4 for ; Fri, 12 Feb 2021 15:51:15 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=yQ/ZdB3C/59Umr73xWbjH6ldpOIkw/gFwuxsArF4DLs=; b=ES0NpvxPz31DIawbDVm1yyexjR8s1jgwk6sQvy/FZE0FXa+bxnKwsJvViVYa51sd6c aPu1ejMFQC9Eec53ArG+aq87k6Mg06kXmXxFNwkIoBYYCiglI9sPl9QziLgUofXE7CeV 1mcV1pLbi+qjVJCV/QS2OgTH+ZlZpeX0o97okSD6Ykp7y5rg4Jlon3IuXqOPIIqhb2OK ydeFDV0qphkzTa/YsWrXILkka/Snw7Pf4Noy/T/zwle55X6Bv7m368cDh7vJIk+0PrhE rjOk/QfMkFnKQSKGNB1FtboeNVHFkIB29o5W4PeJBg0538IqfGp/GoOGpXYMSvap9Ozu Wulw== X-Gm-Message-State: AOAM533NmT2IOqe/zg4PZtxmyCtySzgPuhogLOoZKK0q+pLmgfrZ9Yig y7tMql+7ZCmnw3p/jFaBXaB/2CftL0UjKQe548a5rDD6lNZ6Gx6a5/CIMOhe1GLTgRHj0CD/OaK QFV3KlMBtnn/s0Y0vbeHptWOESNXeCzA7lEp2M1E4Lr7/VXL6Tse5A6EK/XrHLhw= X-Received: by 2002:a17:907:2172:: with SMTP id rl18mr5310939ejb.125.1613173874416; Fri, 12 Feb 2021 15:51:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJwtdB1gYqKxc2XFAaL+yXKSEHG5E3PYZ03e5vO/QtZd9llh+FWHqgLuVZZfVbu9XhpsO5cC6A== X-Received: by 2002:a17:907:2172:: with SMTP id rl18mr5310908ejb.125.1613173874201; Fri, 12 Feb 2021 15:51:14 -0800 (PST) Received: from ?IPv6:2001:b07:6468:f312:c8dd:75d4:99ab:290a? ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id g20sm1377814ejz.54.2021.02.12.15.51.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 12 Feb 2021 15:51:13 -0800 (PST) Subject: Re: AMD SEV-SNP/Intel TDX: validation of memory pages To: Peter Zijlstra , Andi Kleen Cc: 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 References: <7515a81a-19e-b063-2081-3f5e79f0f7a8@google.com> <20210212131907.GI5453@suse.de> <20210212145318.GK5453@suse.de> <20210212152813.GA28884@suse.de> <20210212214205.GF365765@tassilo.jf.intel.com> <20210212215852.GL8912@worktop.programming.kicks-ass.net> From: Paolo Bonzini Message-ID: Date: Sat, 13 Feb 2021 00:51:11 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: <20210212215852.GL8912@worktop.programming.kicks-ass.net> Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pbonzini@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 646D8A0000FD X-Stat-Signature: ds648sb83w7bc1ztgywjeagmc156yp8d Received-SPF: none (redhat.com>: No applicable sender policy available) receiver=imf07; identity=mailfrom; envelope-from=""; helo=us-smtp-delivery-124.mimecast.com; client-ip=63.128.21.124 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1613173880-154733 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 12/02/21 22:58, Peter Zijlstra wrote: > But AFAI recursive #VE is entirely possible. The moment #VE reads that > ve_info thing, NMIs can happen, which can trigger another #VE which then > clobbers your stack and we're irrecoverably screwed again. Yes, you need to zero the handler-active word in the info structure, and at that point recursion can happen. A while ago Andy proposed re-enabling #VE from an interrupt, that would have worked at the time since we were concerned with asynchronous page faults but it wouldn't extend to TDX. Unlike NMIs, however, #VE handlers can be written so that they only a single nesting happens. A few months ago, also while discussing #VE for asynchronous page faults, I came up with a scheme that did exactly that and handled recursion by flipping the IST between two stacks (https://lkml.org/lkml/2020/5/15/1239). It should work and it'd be almost entirely C code, but I don't expect you or Thomas to be ecstatic about it... > (also, inhibiting NMI is a seriously dodgy hack, the very last thing x86 > needs is is more ductape on the recursion rules) I can't disagree about that, but then again I don't see many alternatives. Paolo