Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp843403rwb; Sat, 13 Aug 2022 09:57:14 -0700 (PDT) X-Google-Smtp-Source: AA6agR6y/dX5nWqalI1BAuxw7M3GIgoU//yBOv5RibGz09WIQaiEE1M+1Z0Mw7Xh1sDVMUjblGyz X-Received: by 2002:a63:4b1b:0:b0:41c:863:8ccf with SMTP id y27-20020a634b1b000000b0041c08638ccfmr7114585pga.509.1660409834289; Sat, 13 Aug 2022 09:57:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660409834; cv=none; d=google.com; s=arc-20160816; b=v856aMhP3qDdi6egSSPI9lfyoEoQzgYbrrNx10722B/eaJWLiGCqun/IUdbDL0zWIH apwH1mim6+khuXk9t9JFbFKqDcA/fBszTudif5QviuHxNqwr+yQxLlFp2vMgR6I1ncGN bSSGS91K700nGI+SoMvRb2aWumr9e3Gh48ooGcFHjqrZunDIA+dNep90BN3nTSJcLXXZ JJ/1C+GvzIR6EVy+wrT44fXMlQ4ID+qEeZiCGcfLoo7uCX5tcFHTxkBxpqcis3E16biu B38v0wR3Yuoq/6Rg9hxwcetnxDRyE9aYr3jnMTlok1eSPLQ5y7r0MqcQLNR97yKZEmY1 /Mjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:subject:cc:to:from :date:references:in-reply-to:message-id:mime-version:user-agent :feedback-id:dkim-signature; bh=BBGqWRsgfGwmmvoCG1QPIjuzB4DU/hpnHUCHZCh/SzM=; b=lzCM/a25vun9mAZqdJ5CyBSDQbqZ0w6vEmNv+Fxcfa4oESa6qH2cIVO5EIj89WV1tR 2EFNdq+1JDKCjZFUmOeAC+JrNHHh5SzSjmpugIkmlRifMcF4lRszngmWU80d0mfSs/ES Sxar9rC5JLrlqZGF8sBAKSpOipL5L2hhFbVom0LYxJtrSp54Ev75nKoIFRSL+IZmPOe3 qP12aAPDqFb0Cy53sxmMSPmKR/nVsjjeFfB+kh5ro69kcMmue942237PbqrM00W5CH12 LsfmKjq2IDVr04Yv9WXc4IH0+rD96289e2wM49yxo/83e1IGrdlokHaVukyMtlCYleJk U1ig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=W9kybO58; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r24-20020a6560d8000000b0041cfc9ef388si5985712pgv.159.2022.08.13.09.57.03; Sat, 13 Aug 2022 09:57:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=W9kybO58; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239981AbiHMQF3 (ORCPT + 99 others); Sat, 13 Aug 2022 12:05:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239715AbiHMQF1 (ORCPT ); Sat, 13 Aug 2022 12:05:27 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9EDEBBE36 for ; Sat, 13 Aug 2022 09:05:25 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 4394EB80916 for ; Sat, 13 Aug 2022 16:05:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EBFF3C433C1; Sat, 13 Aug 2022 16:05:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1660406722; bh=3g9RQwus4TjJnSLEmDO7GO8w4lhwGY5MWBNfeGUrI14=; h=In-Reply-To:References:Date:From:To:Cc:Subject:From; b=W9kybO589bVAfO/ZnsMgs4mwe1pNcnCvm8SPmje6pKRcHyn8kr5CjFZ19P19Hxj/l Av6jZqd7bjaifI17Er5C2xGOVOOkya7Y5MCbNBppA94EnuoZwIkV31tkPlDTvhzfXv Tpp8UJqdJhSlVNI9hrbRhvOAodDZyndpwcRTD1/6SIyPSAm214WeC60MqYvmtHzmyc yZvM4fGo/OTDpaz6FJiAyLF5+LbA+ShCCQsCqg/H80JitRxer84fR4vLstIvE/yJS1 mxpWKi3o2l+H6R78vVkvl8frP9DauNd7hgZg0NsISKQyTu4qB+2JtfxXAOUetSfeOS RBvODzM/650Gg== Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailauth.nyi.internal (Postfix) with ESMTP id CB83A27C005A; Sat, 13 Aug 2022 12:05:20 -0400 (EDT) Received: from imap48 ([10.202.2.98]) by compute2.internal (MEProxy); Sat, 13 Aug 2022 12:05:20 -0400 X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrvdegkedgleelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvfevufgtgfesthhqredtreerjeenucfhrhhomhepfdet nhguhicunfhuthhomhhirhhskhhifdcuoehluhhtoheskhgvrhhnvghlrdhorhhgqeenuc ggtffrrghtthgvrhhnpeduveffvdegvdefhfegjeejlefgtdffueekudfgkeduvdetvddu ieeluefgjeeggfenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfh hrohhmpegrnhguhidomhgvshhmthhprghuthhhphgvrhhsohhnrghlihhthidqudduiedu keehieefvddqvdeifeduieeitdekqdhluhhtoheppehkvghrnhgvlhdrohhrgheslhhinh hugidrlhhuthhordhush X-ME-Proxy: Feedback-ID: ieff94742:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 1B36831A0063; Sat, 13 Aug 2022 12:05:20 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.7.0-alpha0-841-g7899e99a45-fm-20220811.002-g7899e99a Mime-Version: 1.0 Message-Id: In-Reply-To: <073c5a97-272c-c5a0-19f2-c3f14f916c72@intel.com> References: <20220614120231.48165-1-kirill.shutemov@linux.intel.com> <20220614120231.48165-11-kirill.shutemov@linux.intel.com> <80cc204b-a24f-684f-ec66-1361b69cae39@intel.com> <073c5a97-272c-c5a0-19f2-c3f14f916c72@intel.com> Date: Sat, 13 Aug 2022 09:04:58 -0700 From: "Andy Lutomirski" To: "Dave Hansen" , "Borislav Petkov" , "Kirill A. Shutemov" Cc: "Sean Christopherson" , "Andrew Morton" , "Joerg Roedel" , "Ard Biesheuvel" , "Andi Kleen" , "Sathyanarayanan Kuppuswamy" , "David Rientjes" , "Vlastimil Babka" , "Tom Lendacky" , "Thomas Gleixner" , "Peter Zijlstra (Intel)" , "Paolo Bonzini" , "Ingo Molnar" , "Varad Gautam" , "Dario Faggioli" , "Mike Rapoport" , "David Hildenbrand" , "Marcelo Henrique Cerri" , tim.gardner@canonical.com, khalid.elmously@canonical.com, philip.cox@canonical.com, "the arch/x86 maintainers" , linux-mm@kvack.org, linux-coco@lists.linux.dev, linux-efi@vger.kernel.org, "Linux Kernel Mailing List" Subject: Re: [PATCHv7 10/14] x86/mm: Avoid load_unaligned_zeropad() stepping into unaccepted memory Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 3, 2022, at 7:02 AM, Dave Hansen wrote: > On 8/2/22 16:46, Dave Hansen wrote: >> To sum it all up, I'm not happy with the complexity of the page >> acceptance code either but I'm not sure that it's bad tradeoff compar= ed >> to greater #VE complexity or fragility. >>=20 >> Does anyone think we should go back and really reconsider this? > > One other thing I remembered as I re-read my write up on this. > > In the "new" mode, guests never get #VE's for unaccepted memory. They > just exit to the host and can never be reentered. They must be killed. > > In the "old" mode, I _believe_ that the guest always gets a #VE for > non-EPT-present memory. The #VE is basically the same no matter if the > page is unaccepted or if the host goes out and makes a > previously-accepted page non-present. > > One really nasty implication of this "old" mode is that the host can > remove *accepted* pages that are used in the syscall gap. That means > that the #VE handler would need to be of the paranoid variety which > opens up all kinds of other fun. > > * "Old" - #VE's can happen in the syscall gap > * "New" - #VE's happen at better-defined times. Unexpected ones are > fatal. > > There's a third option which I proposed but doesn't yet exist. The TDX > module _could_ separate the behavior of unaccepted memory #VE's and > host-induced #VEs. This way, we could use load_unaligned_zeropad() wi= th > impunity and handle it in the #VE handler. At the same time, the host > would not be allowed to remove accepted memory and cause problems in t= he > syscall gap. Kinda the best of both worlds. > > But, I'm not sure how valuable that would be now that we have the > (admittedly squirrelly) code to avoid load_unaligned_zeropad() #VE's. How would that be implemented? It would need to track which GPAs *were*= accepted across a host-induced unmap/remap cycle. This would involve pr= eventing the host from ever completely removing a secure EPT table witho= ut the guest=E2=80=99s help, right? Admittedly this would IMO be better behavior. Is it practical to impleme= nt?