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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id ABF1AC19F2D for ; Sat, 13 Aug 2022 16:03:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 93E6B8E0001; Sat, 13 Aug 2022 12:03:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8ED316B0075; Sat, 13 Aug 2022 12:03:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 78E128E0001; Sat, 13 Aug 2022 12:03:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 67E546B0073 for ; Sat, 13 Aug 2022 12:03:43 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 2CD47140C68 for ; Sat, 13 Aug 2022 16:03:43 +0000 (UTC) X-FDA: 79795039926.27.874E433 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf10.hostedemail.com (Postfix) with ESMTP id 5D4EDC01A0 for ; Sat, 13 Aug 2022 16:03:42 +0000 (UTC) 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 sin.source.kernel.org (Postfix) with ESMTPS id 849CBCE0943; Sat, 13 Aug 2022 16:03:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9F0E7C433B5; Sat, 13 Aug 2022 16:03:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1660406617; bh=8AKntuXc65i1saqB877W3R6RYDsPiOzfHdOG82gubqU=; h=In-Reply-To:References:Date:From:To:Cc:Subject:From; b=PhTckigvrk6wORM1yefMuhw4OzzCT5g0MqPXfKBkB8Ikh82SWyxGormHL2RVr4qaa 5RaurmRXRFFSNRxF4WZl0vecbOzuu815Ii4L3Bvj5VRZN4Padu85IFiJaSZXzV/uTj bkAC3PraOdUJ3Rn3lWl+DmWbtt/fAEPmj9x3xH7d31AtXJtDZVyoZ4C0UWM/ti7blF TQ+CDO8qaPlwRFWZqW7TEIkNT01056UTuWfVNyCayV1STzUhrHZQLNS71p3Bjx7s8E 9q/siV67O39uPnKXtapHZ4pyNVn6akegu/zvDkxPnOshvvzsDsIMA0bws64+k+llO5 jijaAWyfZbLmw== Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailauth.nyi.internal (Postfix) with ESMTP id 6EC2127C0054; Sat, 13 Aug 2022 12:03:35 -0400 (EDT) Received: from imap48 ([10.202.2.98]) by compute2.internal (MEProxy); Sat, 13 Aug 2022 12:03:35 -0400 X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrvdegkedgleekucetufdoteggodetrfdotf 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 BB8CF31A0062; Sat, 13 Aug 2022 12:03:33 -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: <453fb432-ac13-4819-8395-95561bca948b@www.fastmail.com> In-Reply-To: <20220809113827.fchtnyzy44z5fuis@box.shutemov.name> References: <20220614120231.48165-1-kirill.shutemov@linux.intel.com> <20220614120231.48165-11-kirill.shutemov@linux.intel.com> <7cec93c5-3db4-409b-8c1e-bc1f10dd68fc@www.fastmail.com> <20220809113827.fchtnyzy44z5fuis@box.shutemov.name> Date: Sat, 13 Aug 2022 09:03:13 -0700 From: "Andy Lutomirski" To: "Kirill A. Shutemov" Cc: "Borislav Petkov" , "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" , "Dave Hansen" , "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 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1660406622; a=rsa-sha256; cv=none; b=WUYxqZYQ7yfchUbajULldijVebmFSvYvPEWsHULEN/lQdNGg7zQljC7KCvnCOYWgp7LGMR nm2v2EchB1FQS1UZOAKISPDUya3EIeVjn3CdBaCLohA4IeQW3MOL0A3pPGEU9km1jY1bZy gJfKlMfdZhrKey/R79TqdO5pKqCsROc= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=PhTckigv; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf10.hostedemail.com: domain of luto@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=luto@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1660406622; h=from:from:sender: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:dkim-signature; bh=QkjISwrhI0K6AqWr0s0984uyVFFnPkGFa50oEfAuhdM=; b=AIexK+BwDCtVjWFiO9Ft24HrRKKgrixo7sSL3WPr2WLR+px/jawa0CyA1uBsgIRdihjoTi DbFeiNMjilbIknILekDTobW2FRpgDFiiShir8c75jFsClUZgcA7evogDExbZ8inFqAJxkG p8kix6qQzvlP1yBU8LiPO0FYhktj2cQ= X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 5D4EDC01A0 Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=PhTckigv; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf10.hostedemail.com: domain of luto@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=luto@kernel.org X-Stat-Signature: hzrxux3n76mipuxj7sce9api7e5jxzz7 X-Rspam-User: X-HE-Tag: 1660406622-31671 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, Aug 9, 2022, at 4:38 AM, Kirill A. Shutemov wrote: > On Tue, Jul 26, 2022 at 01:17:13PM -0700, Andy Lutomirski wrote: >>=20 >>=20 >> On Tue, Jun 14, 2022, at 5:02 AM, Kirill A. Shutemov wrote: >> > load_unaligned_zeropad() can lead to unwanted loads across page bou= ndaries. >> > The unwanted loads are typically harmless. But, they might be made = to >> > totally unrelated or even unmapped memory. load_unaligned_zeropad() >> > relies on exception fixup (#PF, #GP and now #VE) to recover from th= ese >> > unwanted loads. >> > >> > But, this approach does not work for unaccepted memory. For TDX, a = load >> > from unaccepted memory will not lead to a recoverable exception wit= hin >> > the guest. The guest will exit to the VMM where the only recourse i= s to >> > terminate the guest. >>=20 >> Why is unaccepted memory marked present in the direct map in the firs= t place? >>=20 >> Having kernel code assume that every valid address is followed by >> several bytes of memory that may be read without side effects other t= han >> #PF also seems like a mistake, but I probably won=E2=80=99t win that = fight. But >> sticking guard pages in front of definitely-not-logically present pag= es >> seems silly to me. Let=E2=80=99s just not map it. > > It would mean no 1G pages in direct mapping for TDX as we accept 2M a > time. > >> (What if MMIO memory is mapped next to regular memory? Doing random >> unaligned reads that cross into MMIO seems unwise.) > > MMIO is shared, not unaccpted private. We already handle the situation. > See 1e7769653b06 ("x86/tdx: Handle load_unaligned_zeropad() page-cross= to > a shared page"). > I don=E2=80=99t mean in a confidential guest =E2=80=94 I mean generally.= This whole model of =E2=80=9Coverrun the buffer =E2=80=94 no big deal=E2= =80=9D is just fragile. > --=20 > Kiryl Shutsemau / Kirill A. Shutemov