Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp30837016rwd; Thu, 6 Jul 2023 11:23:37 -0700 (PDT) X-Google-Smtp-Source: APBJJlFTqAbrXMP0qvZIknXweWtM2OEyfvE5CWDelNrRtJJLY7Tiqmucvi2s5hLeHOD+oTYm8pMA X-Received: by 2002:a05:6a00:2e09:b0:67b:f249:35e2 with SMTP id fc9-20020a056a002e0900b0067bf24935e2mr3040007pfb.21.1688667817662; Thu, 06 Jul 2023 11:23:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688667817; cv=none; d=google.com; s=arc-20160816; b=hCWf467/SyyKBjnAIrMbM0TBQ8CMZFQ448D6jpiMEm21UMt50AlfbEbC+0p5KMx9uu WYFo2FVnnJzjDOE9G1w4lZlC4MaJkY7+VCDXWkRQYKZOxGb0yoJCBmlBTRCswRk80RYK AObbcMtp2IWw7g/96bl2TLU7vNsvLTcuj+MF+0fIeWoNBOujpK8NXqHMO4EiXgPSXO08 k8seBEhLt1MLuTruD7gsn5RsquBh0pypF49RVYX38Jgm1j0DiTA5VCRS3EU2sEsCfpC/ EWmNHmkkVa2MHE8Xtz4Wujjn2wS9g8YzY42zT7Xo2GXNA2yEtwhR1gCm3rRPb9djmZ3A OTkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=oEswOXXnJkYW8yUvxdJZLwJeKmy0vowjpd8JZo6BOMM=; fh=6KofXUFwhTxL1VWUdkFCD3KwFzoPIXVzJp1F7NiT81I=; b=FXKtT4ZbBvpbv/uIIO/VNyf+7lxvbTqmMfE2BxD8iakEvgTPFyfa2QfNew21Cz+kzR w50lD6pfWQcgCB9A5iItCVEGJnUnoYSaLhoBv3FcW1bRIpAShB4OElUPoYI4bvSs7YmO uPB/y815L1vIFowFuMAAZoNSvJu7QHDfvJfG1+u1gpW/J79eWR7Wwmh281FpQ3Fbmm2Y 9K+RGoeOr1XLcKfQ6vqkS5HwIlJdpayGiXa+9uMVmCAy+oR29JGYMjuX7T5CsD+wLEu5 LqJRCvOkWkhf3Ux5tz3rpiTDwj64zwEIBNx3bTqFV0lAa+y8Kmhk6APbI3P2785pr8gt 7Pvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=fHMD+EiY; 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=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u24-20020a656718000000b00557523b8fa1si1939896pgf.880.2023.07.06.11.23.21; Thu, 06 Jul 2023 11:23:37 -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=@intel.com header.s=Intel header.b=fHMD+EiY; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232282AbjGFRph (ORCPT + 99 others); Thu, 6 Jul 2023 13:45:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231616AbjGFRpf (ORCPT ); Thu, 6 Jul 2023 13:45:35 -0400 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83B781FDE for ; Thu, 6 Jul 2023 10:45:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1688665528; x=1720201528; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=NRDnbLMW0cXY6ygtX7nwHk3/rr1hm1CMmJHpi3gISkU=; b=fHMD+EiYJcU0b2O43+6AtVS4oBx5+0v3sEnHnaKzZvErLCqyE+VRXc99 fgSk3q5DAejCfq5/PMBukmQ5dO4a3TmYm0DXxNEWMEHIfg7DSizCEBhYx FX+G0XiJXRNCNfZqZJNp3NS7o189J4n6ICGTRvZFd0YfdfWrtI/aCVZ4H /mLujn2SpgUR6bat0+tcLt/5rrUhCsxoDF9APO4E/2xZiwaLazy47Rsc7 LDb6qkq36W1Dy7wseepavphha2Xr3SGznTPneYsC/L+GU116sXuJ0nDZ5 M42t45iVqC1HYkYVqFAzSM5B2oA1p7UpBZnSPzZQfZRhKRjAQgpJiEh4z w==; X-IronPort-AV: E=McAfee;i="6600,9927,10763"; a="362544157" X-IronPort-AV: E=Sophos;i="6.01,185,1684825200"; d="scan'208";a="362544157" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jul 2023 10:45:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10763"; a="789631863" X-IronPort-AV: E=Sophos;i="6.01,185,1684825200"; d="scan'208";a="789631863" Received: from adityan1-mobl1.amr.corp.intel.com (HELO [10.212.197.9]) ([10.212.197.9]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jul 2023 10:45:26 -0700 Message-ID: Date: Thu, 6 Jul 2023 10:45:25 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [PATCHv3 0/3] x86/tdx: Fix one more load_unaligned_zeropad() issue Content-Language: en-US To: "Michael Kelley (LINUX)" , "Kirill A. Shutemov" , "tglx@linutronix.de" , "mingo@redhat.com" , "bp@alien8.de" Cc: Dexuan Cui , "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" References: <20230606095622.1939-1-kirill.shutemov@linux.intel.com> From: Dave Hansen In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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 7/6/23 09:48, Michael Kelley (LINUX) wrote: > When a page is transitioning, the caller can and should ensure > that it is not being accessed during the transition. But we have > the load_unaligned_zeropad() wildcard. So do the following for > the transition sequence in __set_memory_enc_pgtable(): > > 1. Remove aliasing mappings > 2. Remove the PRESENT bit from the PTEs of all transitioning pages > 3. Flush the TLB globally > 4. Flush the data cache if needed > 5. Set/clear the encryption attribute as appropriate > 6. Notify the hypervisor of the page status change > 7. Add back the PRESENT bit > > With this approach, load_unaligned_zeropad() just takes the > normal page-fault-based fixup path if it touches a page that is > transitioning. Yes, this does seem much simpler. It funnels everything through the page fault handler and also doesn't require because careful about the ordering of the private<=>shared conversions.