Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp7522319rwd; Tue, 6 Jun 2023 12:00:46 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7BOlB5S8LDzilUxRVySG5eV5JzEEWAf833ln8tNzKOnQLzI5PHNJdC944BwgRGSE9F+q+5 X-Received: by 2002:a92:c801:0:b0:33d:60dc:cee9 with SMTP id v1-20020a92c801000000b0033d60dccee9mr4008598iln.6.1686078046412; Tue, 06 Jun 2023 12:00:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686078046; cv=none; d=google.com; s=arc-20160816; b=ymjuF0qG9xftscP1ySBSJ3hzx6UZpww417APK2fEtpt+erJf7BOHMsailbvPBIyVOt qaEJQJn1PyEg5Zhz5FJYHxrr5OM8xxMsE8nI72M/50mk9FPhHeFI0jEmy1D2Jvpyyffj O3DktTrAaotm10cBs7hCdc5bvYl69mfl+ZIbb9jKIk3ND+oTaaODM1iWFmVDZT59fXyz 9oiuKai+Ea0WAKJYY2tdJ61ytQcz/RqLFTbNISPbc0GolwDZ5AiLVQuQAUg/B4GNKTis JnFYJoNj6npwt+TqaP01KMedkTeS51+TlvH6D6+DFLEz2mvwGfKeQZ5Ncy/612hL4+9P 0gEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:feedback-id :dkim-signature:dkim-signature; bh=qNOCEgxMB7pIxtXQBqOz7su+7qTpoyeO5gMs+si+Gg0=; b=FywNNJR1QM3/hoj+jhmFyRFIb7+xEDN64bfA0VmRthcgAmCseopTZo1mmVMrWY8BrK 003gtvHsz7gXoj4IxGM8z3m9Asq1xjB2vgFHnbt2GlG8zR67cTltkZFT00Y4ee1L87Lm Id7kSEDz2EkmzmtbQ+W28id2dt91hdK1FNQ1qEEGcYv+9HaTf0N4nhfZF5h6Y7pQSJKB Xu5LjpGFlSC1AIZpq3McME9nQc/O3jJqJSMKgW1MIJXLpyfxA9yH/8RQMIcKsRkLL6Gt SgxsV73Fanm/zGKzSNfMo7db4X3M7jKsrLo4TkVZVbAPVMxhaYYK/eTTmjbrNfoRVMsA 6oZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@shutemov.name header.s=fm3 header.b=Oe4ZsRW6; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=ZiEpH+rj; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 138-20020a630090000000b0053fa62e7c4csi7435774pga.776.2023.06.06.12.00.33; Tue, 06 Jun 2023 12:00: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=@shutemov.name header.s=fm3 header.b=Oe4ZsRW6; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=ZiEpH+rj; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238856AbjFFShX (ORCPT + 99 others); Tue, 6 Jun 2023 14:37:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237728AbjFFShW (ORCPT ); Tue, 6 Jun 2023 14:37:22 -0400 Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A963E8 for ; Tue, 6 Jun 2023 11:37:21 -0700 (PDT) Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id E6C2F5C01F5; Tue, 6 Jun 2023 14:37:20 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Tue, 06 Jun 2023 14:37:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov.name; h=cc:cc:content-type:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm3; t=1686076640; x= 1686163040; bh=qNOCEgxMB7pIxtXQBqOz7su+7qTpoyeO5gMs+si+Gg0=; b=O e4ZsRW6iVpjbhERzX1UNjYYmJCM3yNzrlbc/Mqm/fgtCVavQ27KOVLZPDHIfPQVt gUmEUMUO+nhr1+gK+vswfOIgkdkJdSuO5SSYroAQU+XxJ/kW5x3+dApmVkpxcVS5 zDMiwy4gna60+aiQ8m/PAhnUbMrIO2nFI+OX72q3xRZIbcTr83FEh6tGIoPxiCOl oagGYKTtQugL2otxicQr4RVZirDHIOpM+Sg2turkDV6eM+30tHvMrUGxJMCbPmvJ AchejnfC7+I/6fosYCA8w5hCDf9RyVm9m81PBZ+IVICmr8ufvvuDiTlA5dKH89TF trqzSiLxkx99iD4vaQ8+g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; t=1686076640; x=1686163040; bh=qNOCEgxMB7pIx tXQBqOz7su+7qTpoyeO5gMs+si+Gg0=; b=ZiEpH+rjON5QD10p6KlAGSQa0CioJ 3jSbFTLUzTrFO/qZwCmFvycmoxKo/OQfOFUdrPiP8QaSCmObUHpd7weWuhqD7Uz5 h3T0dwU9AGX4b4QlryS/lPM+rONHPpuJfThwYD8w2GLomvLOlazG/B2ZJM3rVsxj 9R8+yFdtb2usH6aKksTMneVwGSQD/P/LlwdK/AzcCxFrLBL1pDqBAntU6JzJQysV OvY9bGAwt2T/Qe7MMeiuaenQ+/h7vIXdhTNUiyfIoeUQ7c8UrFSedt9sQSn0WKBB kAtfG0dZjxeL3r8ZdBb+91skOYQW55iSCjvY6aCkVmSxPaWSmpRZW9/5g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrgedtuddguddvlecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpeffhffvvefukfhfgggtuggjsehttddttddttddvnecuhfhrohhmpedfmfhi rhhilhhlucetrdcuufhhuhhtvghmohhvfdcuoehkihhrihhllhesshhhuhhtvghmohhvrd hnrghmvgeqnecuggftrfgrthhtvghrnhephfeigefhtdefhedtfedthefghedutddvueeh tedttdehjeeukeejgeeuiedvkedtnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrg hmpehmrghilhhfrhhomhepkhhirhhilhhlsehshhhuthgvmhhovhdrnhgrmhgv X-ME-Proxy: Feedback-ID: ie3994620:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 6 Jun 2023 14:37:20 -0400 (EDT) Received: by box.shutemov.name (Postfix, from userid 1000) id 98CCA10CFD2; Tue, 6 Jun 2023 21:37:18 +0300 (+03) Date: Tue, 6 Jun 2023 21:37:18 +0300 From: "Kirill A. Shutemov" To: Dave Hansen Cc: "Kirill A. Shutemov" , tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, decui@microsoft.com, rick.p.edgecombe@intel.com, sathyanarayanan.kuppuswamy@linux.intel.com, seanjc@google.com, thomas.lendacky@amd.com, x86@kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCHv3 2/3] x86/tdx: Fix race between set_memory_encrypted() and load_unaligned_zeropad() Message-ID: <20230606183718.i3iqwbk7gdomiq5s@box.shutemov.name> References: <20230606095622.1939-1-kirill.shutemov@linux.intel.com> <20230606095622.1939-3-kirill.shutemov@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 06, 2023 at 11:14:29AM -0700, Dave Hansen wrote: > On 6/6/23 02:56, Kirill A. Shutemov wrote: > > load_unaligned_zeropad() can touch memory that is not owned by the > > caller, but just happened to next after the owned memory. > > This load_unaligned_zeropad() behaviour makes it important when kernel > > asks VMM to convert a GPA from shared to private or back. Kernel must > > never have a page mapped into direct mapping (and aliases) as private > > when the GPA is already converted to shared or when GPA is not yet > > converted to private. > > > > load_unaligned_zeropad() can touch memory that is not owned by the > > caller, but just happens to be next after the owned memory. This > > load_unaligned_zeropad() behavior makes it important when the kernel > > asks VMM to convert a GPA from shared to private or back. The kernel > > must never have a page mapped into direct mapping (and aliases) as > > private when the GPA is already converted to shared or when the GPA is > > not yet converted to private. > > Heh, that must be really important info to have it in the changelog twice! > > I'll fix it up when I apply it. Ouch. Please fix the comment in the code too. -- Kiryl Shutsemau / Kirill A. Shutemov