Received: by 2002:ac0:e34a:0:0:0:0:0 with SMTP id g10csp940829imn; Tue, 26 Jul 2022 13:41:46 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sjshOofjPfaKaJ46iLpB41Q/bsuLgY0ncoknE4edbPgZ7PXKzd3Lm4CzLsPJr37RIgcEmY X-Received: by 2002:a05:6402:4148:b0:43b:7f36:e25f with SMTP id x8-20020a056402414800b0043b7f36e25fmr19577432eda.407.1658868106480; Tue, 26 Jul 2022 13:41:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658868106; cv=none; d=google.com; s=arc-20160816; b=ON0pRunqTX1GFIjawbLqjinVYb17pROIWJeJ/hHxzlWRrvHogwPlPa2425d4eZLEr+ L+JxXAT8zQSlQpgkFlBEfi1SVwX65i62s7LCEQOmRmwbx/+xcrE51IsDD4qj/M60ZGcC KXjUOeA43fbFVlZwE7T3x3bl4AahV+mFPcYdeRn/18imxxwqEkZ46aBgztCORFS5U35+ uDDn0MBqy0yXei1OYu/olXEEkM3vxyUMUk8s+Clo0LUzUUNZ1BQPct9quyCkxvS+jRKE UOLDrExSD+gLVeX3GyiQbPi5wO31Lup35aWZ1GKw5rqSVI0BJB8S/6q5TfT+RL4Zgu/L 2PIw== 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=rT2BuoKH5/1WmXRkhdBKNIYoMJklBHjYIpuw0im4vUE=; b=t29QL8QdXol+s011/CStNhsXHmqgl33zIwvnrgTe1bV8XOw/CFa52d34S5WxZWu3Mc 3ihIaL6WGXK/L/MHojXmKXhEPNXEy0AXyiQxEZMRd726GPRQGXTw6y7pJwXLajCRYshd bIhmXfjiJ5JmxICAeE0/1PjOSqVsaT3+9mXjKkcJmpkqCqdfoCsLeTZrsiHYxN4S9i2i Bf9PlYRDSCRJoh3YKbVylMt50F7KFITZb/usqt2r5ycavUyzZZ4L4P6bQ/ARgq8pmnVV jYnjVBExehX9rKP7RV5fnf+VTHw62lto3LLTVYtU/CFeIKokQIFzV1WbO4twxAWHNQqt gOig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=HUgoqY2e; 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 i10-20020a0564020f0a00b0043bcd699d21si11512953eda.141.2022.07.26.13.41.22; Tue, 26 Jul 2022 13:41:46 -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=HUgoqY2e; 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 S239902AbiGZUS1 (ORCPT + 99 others); Tue, 26 Jul 2022 16:18:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54196 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239935AbiGZUSM (ORCPT ); Tue, 26 Jul 2022 16:18:12 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81D2F371B6; Tue, 26 Jul 2022 13:17:40 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 114566160D; 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 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 autolearn=ham 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 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.)