Received: by 2002:a05:6500:1b41:b0:1fb:d597:ff75 with SMTP id cz1csp298432lqb; Tue, 4 Jun 2024 11:38:22 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXql6HZFtAOg0BohpQ5Ta3bAzEZePjvdLU1w1BY+dsfcaDBEfY5G4FfUgMiJzsB3ZYCGDI55G1AcZ+H4djojXRF+TEejz913bLPFXY9Ng== X-Google-Smtp-Source: AGHT+IEz7HEgKKKJbVeMH7alkb8zTOyXsfFWWc8DD82e6us/ktrvCCVLchYMNZnOZmdjBxEmcgB/ X-Received: by 2002:a17:90a:e213:b0:2bd:d2f9:fa1e with SMTP id 98e67ed59e1d1-2c27db63babmr290146a91.43.1717526302295; Tue, 04 Jun 2024 11:38:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717526302; cv=pass; d=google.com; s=arc-20160816; b=P+L3PtXKcPb66yxawAuYEdrNL+gQXl50qayw2x4QvmJssu5Tt+SOjOKYFxypvpyyN6 5PUjomvcaDeLv3rfXb9AKwm1aUq+N0HEzmQ5G134hj/I//YDs4YK7h9+G/EMvBcmBBYI 9d4Dl+tnRNGP+nn3dCYMU0NtknxOFyDVfoatf0MoOlCSaQKV2hVr7lrgaPAYGWhqiM0A XZIbKCKN990NUhLeQTdxvOaXwRcK9Nf4DE5xhZ/NNIVv7aBwmFPFC2sQumM2ZOjXVoHQ nBQyYIvUADNKWyq+vGbFrkNNgwIB4OQC5XSouxCeQ6tHT8/tJKimUqQVlTkwpylzE+tB voEA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=oVFxQxNv8AFGn7i/vpDL3RY17Sot2BUGSC7yyfnhqMY=; fh=AHHu7Z77xB0aen79byMIYIKak8BFX4rsFVZKYt3smw8=; b=lpW5wgBUoa9jMi7ZKqhEUlYTFs5HoWJdRQjDhKpKfs72F8PzpyzAf0CfmpSbgRW2Av qz/H8tmLQzK+USQqwJZW4dncdMq66PagOpnl4NeATmJjZmxJ9gy7S/7BZNEBRVGM5Eq/ mL5JbJL7XXRG/EqIdk1TMig8jeDjTCETgRgNdUx+V5PaG/rvUrwmnKNxOXu1P7wsLvnP P5/NJ8WaWEGKjmy8mjrDG6jhY3xdq0TPbSFkUGksKSnpE3nUT9Z6Q9aK1sbfcLHkOBuG xbdAKN6/slbonMo1AeqrSA9TLuGJFowPMhsOy2VvSgg2nOfanGxTKPfTRLPCstA/z2jF mLuA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=E9RPLouu; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-201060-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-201060-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2c1c27a9d1esi502973a91.34.2024.06.04.11.38.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 11:38:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-201060-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=E9RPLouu; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-201060-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-201060-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id F3139B245DA for ; Tue, 4 Jun 2024 16:24:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 120EC1487DF; Tue, 4 Jun 2024 16:24:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="E9RPLouu" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D5F0613D526; Tue, 4 Jun 2024 16:24:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717518284; cv=none; b=oRCmf+v0krzy9PbXVqW0zXoLynxHQf+hM4XQX2trW4r6kHZQtrEB9F4JG7O8w5as21z/r9dQzivGGdG5aGEGbbgijHqz+ED8b0hyzDRl0SSBb4GzzQWPchavMOtSC+htWcpIJNYC2FHFvzeBKnM05u8hdKWxLiz9mLm62DhOECs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717518284; c=relaxed/simple; bh=pvWvcrNQgufN9CzRFzzo7ISHTN099yhCI9EO4AnyfJE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=GgXENEMWXAsZ3mIGZP+eY5h3Sac6hTJf30IgTBOFsHd6Pns/JOqvDUSU/L0Gi53a27FB7OQ+ZXhH1VqZS9Kws38zJ49a3MLdZf3dSrNRfVRN75jr87Wo6HW0d2n+j5bzMiA4YypqyFujzU14+pqf6zvW3UrlvHG2viN0uteFuXg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=E9RPLouu; arc=none smtp.client-ip=192.198.163.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717518283; x=1749054283; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=pvWvcrNQgufN9CzRFzzo7ISHTN099yhCI9EO4AnyfJE=; b=E9RPLouuoQ01gCfFcWIVyvTv26hRngmW+hPVI/ttl9onKU7DtSnF0J/w V5K1wsByzqj0WG1hQIHfUHRWfJ00V5tM2G6MVj+PEKJiK/fXesLBgYHMG pAZy45J6i19uGkuLxsCMOkpiYC7NcTqn8t+bXpCsieuCPuFg/jQEep22o TOGr191rby9xVHpvV1dje3NiJbETfv6XiK9OrnpN3tKGFsqAoIHw4PkCn 0hbNvYmSJ1voNHlTfEGjQ+IULpcGHKkeLqtHqfKPYb5bcIb4TL/Rw8QG3 mNTIqrjgPY54FHJjCnd0s9DU0DmHX7vuhtgWrFKoKBUneWOkm9aJtPEqw g==; X-CSE-ConnectionGUID: 9E+3CUy6QFKubGE5ZxhvMA== X-CSE-MsgGUID: y+9UAki3Sky9226jhuy+pw== X-IronPort-AV: E=McAfee;i="6600,9927,11093"; a="13829922" X-IronPort-AV: E=Sophos;i="6.08,214,1712646000"; d="scan'208";a="13829922" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Jun 2024 09:24:42 -0700 X-CSE-ConnectionGUID: qUBTJsF0Q7eFyomBX4zctA== X-CSE-MsgGUID: n0UalEy1Qt+6LV6QKuU3Pw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,214,1712646000"; d="scan'208";a="37293248" Received: from black.fi.intel.com ([10.237.72.28]) by fmviesa006.fm.intel.com with ESMTP; 04 Jun 2024 09:24:36 -0700 Received: by black.fi.intel.com (Postfix, from userid 1000) id 34FF52DC; Tue, 04 Jun 2024 19:24:35 +0300 (EEST) Date: Tue, 4 Jun 2024 19:24:35 +0300 From: "Kirill A. Shutemov" To: Dave Hansen Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "Rafael J. Wysocki" , Peter Zijlstra , Adrian Hunter , Kuppuswamy Sathyanarayanan , Elena Reshetova , Jun Nakajima , Rick Edgecombe , Tom Lendacky , "Kalra, Ashish" , Sean Christopherson , "Huang, Kai" , Ard Biesheuvel , Baoquan He , "H. Peter Anvin" , "K. Y. Srinivasan" , Haiyang Zhang , kexec@lists.infradead.org, linux-hyperv@vger.kernel.org, linux-acpi@vger.kernel.org, linux-coco@lists.linux.dev, linux-kernel@vger.kernel.org, Tao Liu Subject: Re: [PATCHv11 09/19] x86/tdx: Account shared memory Message-ID: <5sjy5qfztnipehq3j3hn4jsufrd642n272sjjcpowvgze5qm22@jjfmw6u4rvgl> References: <20240528095522.509667-1-kirill.shutemov@linux.intel.com> <20240528095522.509667-10-kirill.shutemov@linux.intel.com> <6fd2c15b-5bd9-4e7e-8da0-4ca2c89b38f9@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6fd2c15b-5bd9-4e7e-8da0-4ca2c89b38f9@intel.com> On Tue, Jun 04, 2024 at 09:08:25AM -0700, Dave Hansen wrote: > On 5/28/24 02:55, Kirill A. Shutemov wrote: > > Keep track of the number of shared pages. This will allow for > > cross-checking against the shared information in the direct mapping > > and reporting if the shared bit is lost. > > It's probably also worth mentioning that conversions are slow and > relatively rare and even though a global atomic isn't really scalable, > it also isn't worth doing anything fancier. Okay, will do. > > diff --git a/arch/x86/coco/tdx/tdx.c b/arch/x86/coco/tdx/tdx.c > > index 26fa47db5782..979891e97d83 100644 > > --- a/arch/x86/coco/tdx/tdx.c > > +++ b/arch/x86/coco/tdx/tdx.c > > @@ -38,6 +38,8 @@ > > > > #define TDREPORT_SUBTYPE_0 0 > > > > +static atomic_long_t nr_shared; > > Doesn't this technically need to be: > > static atomic_long_t nr_shared = ATOMIC_LONG_INIT(0); > > ? I thought we had some architectures where the 0 logical value wasn't > actually all 0's. Hm. I am not aware of such requirement. I see plenty uninitilized atomic_long_t in generic code. For instance, invalid_kread_bytes. And I doubt TDX will ever be built for non-x86 :P -- Kiryl Shutsemau / Kirill A. Shutemov