Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp6485663rwd; Mon, 19 Jun 2023 07:59:45 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ78L2gIO1NNJ73cdVQjo2vAxVjTeyIqhToiQ2w9c6bciTBiQh+J+qztbjo8xJgYYbA8/56d X-Received: by 2002:a17:90a:1981:b0:260:a8da:536c with SMTP id 1-20020a17090a198100b00260a8da536cmr2389800pji.23.1687186785119; Mon, 19 Jun 2023 07:59:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687186785; cv=none; d=google.com; s=arc-20160816; b=JKQJvv4/4N/73xqLVVwFkn+wDuSCN0VvQnqlWsXvM2DQMbaYgLwlZbI1/fIoSJY/jh CmYrKxxg0AcPPShpAbSEP6e8rolPT5jjOSPuP7MdGEX+lC/oswgQw94u5lCAXCoG7tRe Yf6AeDLvoswWyxKXzm0pziYsRDyovxYgqyadUjZBYuxZefcTB0rnnSisK4fVxQHVXAp5 fkn1lx8stkkjWl+ZgWAc7gBsFYKGL61yeeNvtjlF+ArtKO8DJfWnJ7RmUQN9aAJD3rFr TAiFOcqpM8V27IL3VDNu0x6ArwcxePU7XAd5z2BH0SXdBIqVj84VDtBKdIeBHO0nAS9+ luuQ== 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=5ITKgYtGrO55ABk0qQJ9+6oRwecJvx9b6EDmGSaWKhQ=; b=ou8/V4ZK4FjH0G1GjlfRxYs8UuK48zpypzuiiin5yDkgtcedIn0eh7RFrXHQFE2bth hYTQUGGCiJGHSJcObL+a8QjCMVixjm6BO75u563bmIn1BDRV2DVIaEI/cHaROtqUDGIG dB/jE1Vi5rVzs/iWsDLCwcYNNFArt8ttOlm/OUXmaleR4gMI+xeZGATdt4CtL7W/e9Zo T24l+zmf7P4BDyLNRBNh7ti2j5I/JIeiSjpTiHfSEwdrIX8yNZbBoFPzFc/jvJ5ozW4K bVCJ4xt6W9O/3Hux3/wgpj+x4qKRTB/A4xFj2I52nWluC4uWS4/dP39OixF1d4nWyAKN n1JQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=CPw3ldJP; 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 x3-20020a17090a9dc300b0025352448b95si7430143pjv.172.2023.06.19.07.59.20; Mon, 19 Jun 2023 07:59:45 -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=CPw3ldJP; 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 S230307AbjFSOb0 (ORCPT + 99 others); Mon, 19 Jun 2023 10:31:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229674AbjFSObZ (ORCPT ); Mon, 19 Jun 2023 10:31:25 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53041E64; Mon, 19 Jun 2023 07:31:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1687185084; x=1718721084; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=SyHqZgKn1J7+dVTcmF56m4tqTwlz6VxhZtSS7tFcl4Q=; b=CPw3ldJP1GucdAnsD/brr3mDne8ALYD8xIs5Dj4KNK7hexxkhnzFhPUk tlGlHPj19jxj+RQQsoXX1ghYEOy2cBdGnK4Tj7HzaqR1Azf7bE7I4aFMy UkH75W8k3cIRhfnJZzTTNyYxvZRLbelw9zm/N9n2rPb0XU1gG6xTZWwNg otz8DDxsVfoKhUK+Xb6GRMH6UQRa+Db3jgLtAkg0wDnzB5xMMcSKc7M3o MNn2IXerwx2o6imRaD0ktqn6dbOIh/G6E1h1fAOj0n0GjCxmPztG1/cPR S763qh85MLIo2/G7q4U8zgLpuLmdRaBmDe+5daWRhz2LtprXc/O4vr0g5 w==; X-IronPort-AV: E=McAfee;i="6600,9927,10746"; a="388720366" X-IronPort-AV: E=Sophos;i="6.00,254,1681196400"; d="scan'208";a="388720366" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jun 2023 07:31:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10746"; a="803621243" X-IronPort-AV: E=Sophos;i="6.00,254,1681196400"; d="scan'208";a="803621243" Received: from alaird-mobl2.amr.corp.intel.com (HELO [10.212.177.39]) ([10.212.177.39]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jun 2023 07:31:22 -0700 Message-ID: Date: Mon, 19 Jun 2023 07:31:21 -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: [PATCH v11 18/20] x86: Handle TDX erratum to reset TDX private memory during kexec() and reboot Content-Language: en-US To: "Huang, Kai" , "kirill.shutemov@linux.intel.com" Cc: "kvm@vger.kernel.org" , "Luck, Tony" , "david@redhat.com" , "bagasdotme@gmail.com" , "ak@linux.intel.com" , "Wysocki, Rafael J" , "linux-kernel@vger.kernel.org" , "Chatre, Reinette" , "Christopherson,, Sean" , "pbonzini@redhat.com" , "tglx@linutronix.de" , "linux-mm@kvack.org" , "Yamahata, Isaku" , "peterz@infradead.org" , "Shahar, Sagi" , "imammedo@redhat.com" , "Gao, Chao" , "Brown, Len" , "sathyanarayanan.kuppuswamy@linux.intel.com" , "Huang, Ying" , "Williams, Dan J" References: <5aa7506d4fedbf625e3fe8ceeb88af3be1ce97ea.1685887183.git.kai.huang@intel.com> <20230609132301.uvvp27yr5kpenl6f@box.shutemov.name> <58f34b4b81b6d6b37d3386dec0f073e6eb7a97ff.camel@intel.com> <20230612075830.jbrdd6ysz4qq7wdf@box.shutemov.name> <4c7effc3abe71aa1cbee41f3bd46b97aed40be26.camel@intel.com> <48d5a29a-878c-665d-6ac2-6f0563bf6f3c@intel.com> <5782c8c2bb3e76a802e4a81c553a21edbaee7c47.camel@intel.com> From: Dave Hansen In-Reply-To: <5782c8c2bb3e76a802e4a81c553a21edbaee7c47.camel@intel.com> 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,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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 6/19/23 04:43, Huang, Kai wrote: > On Mon, 2023-06-12 at 06:47 -0700, Dave Hansen wrote: >> On 6/12/23 03:27, Huang, Kai wrote: >>> So I think a __mb() after setting tdmr->pamt_4k_base should be good enough, as >>> it guarantees when setting to any pamt_*_size happens, the valid pamt_4k_base >>> will be seen by other cpus. >>> >>> Does it make sense? >> Just use a normal old atomic_t or set_bit()/test_bit(). They have >> built-in memory barriers are are less likely to get botched. > Hi Dave, > > Using atomic_set() requires changing tdmr->pamt_4k_base to atomic_t, which is a > little bit silly or overkill IMHO. Looking at the code, it seems > arch_atomic_set() simply uses __WRITE_ONCE(): How about _adding_ a variable that protects tdmr->pamt_4k_base? Wouldn't that be more straightforward than mucking around with existing types?