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 0B189C00140 for ; Tue, 26 Jul 2022 20:17:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CDA3D8E0002; Tue, 26 Jul 2022 16:17:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C8A488E0001; Tue, 26 Jul 2022 16:17:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B038B8E0002; Tue, 26 Jul 2022 16:17:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 9EDD48E0001 for ; Tue, 26 Jul 2022 16:17:42 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 6E9EBA0A34 for ; Tue, 26 Jul 2022 20:17:42 +0000 (UTC) X-FDA: 79730361564.27.0574CD5 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf09.hostedemail.com (Postfix) with ESMTP id 0B3041400B7 for ; Tue, 26 Jul 2022 20:17:40 +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 dfw.source.kernel.org (Postfix) with ESMTPS id 0577C615C5; Tue, 26 Jul 2022 20:17:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 277ACC433B5; Tue, 26 Jul 2022 20:17:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1658866659; bh=GIbzRLMc9lrNfJDLat0Hlv7hVWiWNwlnlBD/YoWm7qk=; h=In-Reply-To:References:Date:From:To:Cc:Subject:From; b=HUgoqY2e9W43NpWGppKfLxqPT6/YHFWqQPaWTnFvfuupCtEEEighHCoWgZkclwHVw 8AqhJMfX+te8UwJm4gMUuKSx8n+GXYBzLffSEANnsXLwSol0V+QNQXyx/g6t5kzThs onAwtDCafnKiMzQqr23be8U8Wc+OZApDBGF5KWcE5XWncQTJ8seJxWH7Nx4iFwVPIU OA4kZ/A/sDYa3cr9SrTD06uJ5l1tgypf9VGGppBUF7fiwzgnug8UK9Gt4fuZZvNx3j gT1UYbxAndS/v6xebtRaMF0OHeIYE3sb/dG/el95rgE8BHFreVM4ORt5eQoi5i+hbL dwVDq+WOW3mkA== Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailauth.nyi.internal (Postfix) with ESMTP id E625C27C0054; Tue, 26 Jul 2022 16:17:36 -0400 (EDT) Received: from imap48 ([10.202.2.98]) by compute2.internal (MEProxy); Tue, 26 Jul 2022 16:17:36 -0400 X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrvddutddgudegkecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefofgggkfgjfhffhffvvefutgfgsehtqhertderreejnecuhfhrohhmpedf tehnugihucfnuhhtohhmihhrshhkihdfuceolhhuthhosehkvghrnhgvlhdrohhrgheqne cuggftrfgrthhtvghrnhepudevffdvgedvfefhgeejjeelgfdtffeukedugfekuddvtedv udeileeugfejgefgnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilh hfrhhomheprghnugihodhmvghsmhhtphgruhhthhhpvghrshhonhgrlhhithihqdduudei udekheeifedvqddvieefudeiiedtkedqlhhuthhopeepkhgvrhhnvghlrdhorhhgsehlih hnuhigrdhluhhtohdruhhs X-ME-Proxy: Feedback-ID: ieff94742:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id C5B1A31A0062; Tue, 26 Jul 2022 16:17:34 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.7.0-alpha0-757-gc3ad9c75d3-fm-20220722.001-gc3ad9c75 Mime-Version: 1.0 Message-Id: <7cec93c5-3db4-409b-8c1e-bc1f10dd68fc@www.fastmail.com> In-Reply-To: <20220614120231.48165-11-kirill.shutemov@linux.intel.com> References: <20220614120231.48165-1-kirill.shutemov@linux.intel.com> <20220614120231.48165-11-kirill.shutemov@linux.intel.com> Date: Tue, 26 Jul 2022 13:17:13 -0700 From: "Andy Lutomirski" To: "Kirill A. Shutemov" , "Borislav Petkov" , "Sean Christopherson" , "Andrew Morton" , "Joerg Roedel" , "Ard Biesheuvel" Cc: "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-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=HUgoqY2e; spf=pass (imf09.hostedemail.com: domain of luto@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=luto@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1658866661; a=rsa-sha256; cv=none; b=FnEHzdFoyA94U+XuTcDEr9x+U5JrPfb6dJWczCJdsLT+RmR4FJ8ZHQxWoVmG9D1vxEHPyM 6PY3XstMyQ8qVx+axReDONHxMwu/CQEIF0cv5DWZhvoAW6eYs3xggN6Dr98WS1IiLfUulR UQHIoFq2yuJKX/Le6yf7+pd2GMz6zA8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1658866661; 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=rT2BuoKH5/1WmXRkhdBKNIYoMJklBHjYIpuw0im4vUE=; b=ix5E3hFAG4Dzve9kDH2N8Qidi3IHf7BXkJoN+PMxhZ7cri5nPqIKoyCH3i9ixDlziaIbU0 5fitz/4peIKLjhH2e6YNvH2na1YltZSW5ZM5B8tc+i0i3a8wFI8h6NG9Kj0ObnG1f94EcK BT08tcprL2Q14C5AEeYU/1uzxeXmHW8= X-Rspamd-Server: rspam10 X-Rspam-User: Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=HUgoqY2e; spf=pass (imf09.hostedemail.com: domain of luto@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=luto@kernel.org; dmarc=pass (policy=none) header.from=kernel.org X-Stat-Signature: ria5pfmaoxitpsbyq9zkeohr1gdhqxan X-Rspamd-Queue-Id: 0B3041400B7 X-HE-Tag: 1658866660-823098 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, Jun 14, 2022, at 5:02 AM, Kirill A. Shutemov wrote: > load_unaligned_zeropad() can lead to unwanted loads across page bounda= ries. > 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 these > 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 within > the guest. The guest will exit to the VMM where the only recourse is to > terminate the guest. Why is unaccepted memory marked present in the direct map in the first p= lace? Having kernel code assume that every valid address is followed by severa= l bytes of memory that may be read without side effects other than #PF a= lso seems like a mistake, but I probably won=E2=80=99t win that fight. B= ut sticking guard pages in front of definitely-not-logically present pag= es seems silly to me. Let=E2=80=99s just not map it. (What if MMIO memory is mapped next to regular memory? Doing random una= ligned reads that cross into MMIO seems unwise.)