Received: by 2002:a05:7412:8d09:b0:fa:4c10:6cad with SMTP id bj9csp363749rdb; Tue, 16 Jan 2024 02:46:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IFln3Uxm+50vNnaKO2YXdYPcpr645izb8nhUwXSHFW7Lhy4rJTcH2obvP14OsiGxnMObnfu X-Received: by 2002:a05:6402:2024:b0:558:5725:ff40 with SMTP id ay4-20020a056402202400b005585725ff40mr3331073edb.21.1705401973614; Tue, 16 Jan 2024 02:46:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705401973; cv=none; d=google.com; s=arc-20160816; b=ZT/yq/gjjFwLJ9NoslloS3p+owRkVLT9ReehqYsSdY2nnq0+MEDzhxnFb1NoIftZgW jWLyy3DzgMhDyyyrSbLiyefSjS7RCdXppmFegCH6P/VYwpmHM1/65Q3PZQX0BgS0gdGe PvNyssFsF4H8PP2qVjwTJrPlCV2ec47MJ1P9K6ZPbLgtqKuwTDN3EPzWH64qIolEn/7K MQj8/K3JMHy0JesVehS0R5mEI0c7HQMcrLPm9c5SkkB6qZQl2y9GKC/QLL29PTEqIK/E vI+Yak/qrK5jTb2pCldBoCR7lpVgwN4CQDpyk0r8oPjEx9L2Z0WdDAJ/d/brMT2wvVnZ Q0nA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Omug/jXzyGgMvzthU7sYm1jKLcuek7zoXlfEIRGMYiI=; fh=dcRslSjZTlGgDHJ9/mCy7T4peJ7te6GzM1eJdKDJ8HQ=; b=fSLWkJCGDGl/nD+6flEtAM+X1G+rDGCkB3ZYWyUQHyn7oXEdKKNyaxHkz+0mLaBHml Asvo8f4DTpdl8sm+6ZASTiDJ/a87Av+3bZtiE7UonmlnwIzuds8SnI+hD5GwI82u1O5i OwtohoXSM39ivbwkyj1RhQkzu3nRZm/BP5R0q61X3iEEfV2kM2B/ZeyYrVke1cbXKFUz v6rVDUfvBlG9Np4dBSrPmxVt2ZYNl35KDyqvk/7nLAvnKDlPwMMOlqiYi7pct0w+pXRy WCF/ewQz6kAZCKDRKQxrF/qQqz7qrXi6vgYUugYqSsuvKbICkKsgdpFAKYFQiKklnQrF D97g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=i67mAgAz; spf=pass (google.com: domain of linux-kernel+bounces-27265-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-27265-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id s11-20020a508dcb000000b00557d3a8a69bsi4958378edh.553.2024.01.16.02.46.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jan 2024 02:46:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-27265-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=i67mAgAz; spf=pass (google.com: domain of linux-kernel+bounces-27265-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-27265-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 5FB121F224F4 for ; Tue, 16 Jan 2024 10:46:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EC0E918C1B; Tue, 16 Jan 2024 10:45:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="i67mAgAz" Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.115]) (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 AE8DD18C16 for ; Tue, 16 Jan 2024 10:45:56 +0000 (UTC) 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=1705401956; x=1736937956; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=U149l/P2gQncQeTKVFG2mholC+8inxIjrWVzckSmZk0=; b=i67mAgAznK8e2Gn+v9ebF/vQyY85UzOE+4us0/5X52CYHqur8Qf0VgSX iPqUqYdzQGPdBnJQtss99GhVvwL6DVnVauRWhp4ZQLPqW4honnzJx2Zmy pdPn7YUiZa/Po4pySteSJYJFMjqwZbRa5sPweaeDgNqEqW+v0Hxdx5jnv A1/ECTuzBxLgI6SjPyx2vfEFwfceZqNXeF7S2b2rUZHu+ZoZQwHRhrVx/ MzpfnVyhHhukG/fIifV+OLeA6eXZNnj196DfX7xAgyHzXiQDn4EZjgFou OFOArZCvUO7JAgeRumAFYUPeswnsltLlpCBiRDehK7V6suOD2umlLwe1L Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10954"; a="399493504" X-IronPort-AV: E=Sophos;i="6.04,198,1695711600"; d="scan'208";a="399493504" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jan 2024 02:45:55 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10954"; a="787403940" X-IronPort-AV: E=Sophos;i="6.04,198,1695711600"; d="scan'208";a="787403940" Received: from uschumac-mobl2.ger.corp.intel.com (HELO box.shutemov.name) ([10.251.213.254]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jan 2024 02:45:51 -0800 Received: by box.shutemov.name (Postfix, from userid 1000) id 7226210A17B; Tue, 16 Jan 2024 13:45:48 +0300 (+03) Date: Tue, 16 Jan 2024 13:45:48 +0300 From: "Kirill A. Shutemov" To: Nikolay Borisov 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" , Baoquan He , kexec@lists.infradead.org, linux-coco@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCHv5 10/16] x86/tdx: Convert shared memory back to private on kexec Message-ID: <20240116104548.4jmku5pq34p4lqn6@box.shutemov.name> References: <20231222235209.32143-1-kirill.shutemov@linux.intel.com> <20231222235209.32143-11-kirill.shutemov@linux.intel.com> <89e8722b-661b-4319-8018-06705b366c62@suse.com> <20240116072822.pvzseyqry56eqa4j@box.shutemov.name> 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=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Tue, Jan 16, 2024 at 10:01:47AM +0200, Nikolay Borisov wrote: > > > On 16.01.24 г. 9:28 ч., Kirill A. Shutemov wrote: > > > > > > > @@ -41,6 +44,9 @@ > > > > static atomic_long_t nr_shared; > > > > +static atomic_t conversions_in_progress; > > > > +static bool conversion_allowed = true; > > > > > > Given the usage model of this variable, shouldn't it be simply accessed via > > > READ/WRITE_ONCE macros? > > > > What do you see it changing? > > > Serving as documentation that you are accessing a shared variable without an > explicit lock (unless I'm missing something). conversion_allowed can be read > by multiple threads, no ? And it's written by a single thread? I don't think READ_ONCE()/WRITE_ONCE() have documentation sense you imply. I would argue adding them will add more confusion as they serve no purpose in this context: issuing multiple loads/stores for the variable have no impact on outcome. > > kexec on AMD will not work without them, I think. But noops makes sense > > anyway. Will fix. > > I'm not disputing whether those are needed for AMD or not, that way I see it > you make those callbacks mandatory in the case of CC_ATTR_GUEST_MEM_ENCRYPT > being present, yet only implement them for TDX. So in the case of AMD they > will be NULL and so AMD with kexec enabled (albeit erroneously) will crash, > no ? As I said, I will fix it. -- Kiryl Shutsemau / Kirill A. Shutemov