Received: by 2002:a05:7412:798b:b0:fc:a2b0:25d7 with SMTP id fb11csp340948rdb; Thu, 22 Feb 2024 05:37:51 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW25My/BcgbhXWJdFK0xCApO9maG7siCAfni33jdhJEUCkB2n/TnL4bVqf2/Llk/tzcxSWyT7yk0DwIK6HpRcucgJCG9hIzwE4tRftXsg== X-Google-Smtp-Source: AGHT+IEpyeReVeuSHgSBwHPAAGWHO8tc9+XWLqHoVpHMxC/tqcXGV+ftwZ1oFFZ4J+DIRLWvR0/F X-Received: by 2002:a05:6871:330a:b0:21e:bbdc:cc80 with SMTP id nf10-20020a056871330a00b0021ebbdccc80mr12850934oac.8.1708609071267; Thu, 22 Feb 2024 05:37:51 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708609071; cv=pass; d=google.com; s=arc-20160816; b=PNZ/O/QQZxMizRVvk/0gdBiiyzjqz2Rnn5cuv+P42snHMxuhaZWFvlBdBPdyc7t6Ix ZeGl0uVOmEHlnkiqbx4v956dqTqH8v1TRBuCdiN3W7KY94AOS/zThg5bca5ZoFAGu+hH nDHRoevCvZf14wSvQn/zTV11eJfOw/XpeFRwHKRhUlBSQciDuDfuWT6bdCihp4FLtd/g KcGGJHqo3jhtC8Wn0j2+mzSb+BJbBCUEJphMyYv18TSX51CLW7uZntORr0XmY4J18rWY utpjl9EkMnB3vfGtRbcgsdAxRTa+Elxcu0+AFydO6Y/f9HHvgFe8gqyQ6+vO7bvo4WL/ nYgQ== 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=ved52rzk3EHPuYtlYLhJpYn45Jbay3K7DeTNkg7E93U=; fh=dyGOl66qCYh/kCYfPoO+Q579n9et0msprQVw+qJ9aKU=; b=T1mXC4XOHE9m/+LmWPkjTzrVIwUoXD2nA9KzwH/M7W/sfgYo8kRLJkJIDweXUVsg31 8ZEryIObqecAYWBsq6UdpLYYfn7nWEDd4lLBFfAgTAXbG+b2iQ5hrww8/6jIiuz8NeYl ZU+6TiFmDN3aDPZK2PcSO0XSzSo+AxekvwXLPbnl562XA0mlpz97ba5O/A09DCJpCZVa CwzvhErG8+fPhrK4QaMprC9+GDblZSR1lVCNhCGORJAhAq/4JNMIMdov/S8t31Dta0f/ 7bKL4tpDmHoNcwYUs0QVhlNMJvp0+APK++liBHRyvkY2Tf+b6Huuv+6rzRJxnY2d8GaD bHxg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=SPWqyZAh; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-76356-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76356-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. [147.75.48.161]) by mx.google.com with ESMTPS id i69-20020a638748000000b005cf1ddb15a1si10285189pge.93.2024.02.22.05.37.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 05:37:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76356-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=SPWqyZAh; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-76356-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76356-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 39405B230BC for ; Thu, 22 Feb 2024 10:50:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 441B53FB27; Thu, 22 Feb 2024 10:50:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="SPWqyZAh" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) (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 38C9D39859; Thu, 22 Feb 2024 10:50:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.10 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708599023; cv=none; b=qqOEHbJJvI6r7NB2reOxcz7nU3FV9myo23keZ9PfBQG0D5DT+PF5rsGUewlVJA4/iZwFDNXziikfwsHA+k+mHoxFKc34CySQIzfXwVFaBRux1RvJuyVdgowdyczd+Tgx5VSaLYskxBpsHa4EmZUWpIUxPnc0rAH89GZNuDEUHnU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708599023; c=relaxed/simple; bh=MlCX4WJP2SCKY4u/hH+Za0aayaGTr+j+qDw+YgB04Vc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=d/yItcpCZ9Fl6v0fatmnccqmCMnp4OPRvT0Y7JMzjFk7y76t0dPq1yI32r8pVEu5ZdIci8fE24tTvU5Rtv5p4T/bqpVQzAJiUtRWdWwghDbS2JlECnxi+JQpISi3n5BwoJiWgMpM1YOjE3rV69N4qTKWCrEEGSDrQoCo6dtGyR0= 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=SPWqyZAh; arc=none smtp.client-ip=192.198.163.10 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=1708599021; x=1740135021; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=MlCX4WJP2SCKY4u/hH+Za0aayaGTr+j+qDw+YgB04Vc=; b=SPWqyZAh5fwmniuFaxYiRDyTcApicoq1q44bFHOA4a79LOD5ttYIbkeC DR94rmCclp/ruRL8d7Il1DoXHRvFJw2sgwnza3vOy87iY2FwUoC77jPtU 5wTRsQRkyrv76EdefRk6Y5ZVSUQm5GdAaPRfDec7KQnV6ZB9R+03+Cb0R oTb+1lds/2RSzm/mQrXXOG0iJuaKYgfexWvLWwZIkB+s7jYE/9b5VZkam 8HCgLgAjleTC5n3KMgb85YVZqPmV5V45vePxmp1RXIBaMvrKbh+XWCVQc qPHyIYVklgxN8g0QyFzhXrQz3eW0v8R5tCMTv/F1cwk+p2aFwNhLPKCcK g==; X-IronPort-AV: E=McAfee;i="6600,9927,10991"; a="14232498" X-IronPort-AV: E=Sophos;i="6.06,177,1705392000"; d="scan'208";a="14232498" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Feb 2024 02:50:20 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10991"; a="936832910" X-IronPort-AV: E=Sophos;i="6.06,177,1705392000"; d="scan'208";a="936832910" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 22 Feb 2024 02:50:13 -0800 Received: by black.fi.intel.com (Postfix, from userid 1000) id EB8B42AB; Thu, 22 Feb 2024 12:50:11 +0200 (EET) Date: Thu, 22 Feb 2024 12:50:11 +0200 From: "Kirill A. Shutemov" To: Tom Lendacky Cc: Ashish Kalra , tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, luto@kernel.org, x86@kernel.org, ardb@kernel.org, hpa@zytor.com, linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, rafael@kernel.org, peterz@infradead.org, adrian.hunter@intel.com, sathyanarayanan.kuppuswamy@linux.intel.com, elena.reshetova@intel.com, jun.nakajima@intel.com, rick.p.edgecombe@intel.com, seanjc@google.com, kai.huang@intel.com, bhe@redhat.com, kexec@lists.infradead.org, linux-coco@lists.linux.dev, anisinha@redhat.com, michael.roth@amd.com, bdas@redhat.com, vkuznets@redhat.com, dionnaglaze@google.com, jroedel@suse.de, ashwin.kamat@broadcom.com Subject: Re: [PATCH 2/2] x86/snp: Convert shared memory back to private on kexec Message-ID: References: <20240212104448.2589568-1-kirill.shutemov@linux.intel.com> <97a7d69f-03e1-4ecc-a0ce-10bfe148509c@amd.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: <97a7d69f-03e1-4ecc-a0ce-10bfe148509c@amd.com> On Wed, Feb 21, 2024 at 02:35:13PM -0600, Tom Lendacky wrote: > > @@ -906,6 +917,206 @@ void snp_accept_memory(phys_addr_t start, phys_addr_t end) > > set_pages_state(vaddr, npages, SNP_PAGE_STATE_PRIVATE); > > } > > +static inline bool pte_decrypted(pte_t pte) > > +{ > > + return cc_mkdec(pte_val(pte)) == pte_val(pte); > > +} > > + > > This is duplicated in TDX code, arch/x86/coco/tdx/tdx.c, looks like > something that can go in a header file, maybe mem_encrypt.h. > I think is a better fit. > > +void snp_kexec_stop_conversion(bool crash) > > +{ > > + /* Stop new private<->shared conversions */ > > + conversion_allowed = false; > > + crash_requested = crash; > > + > > + /* > > + * Make sure conversion_allowed is cleared before checking > > + * conversions_in_progress. > > + */ > > + barrier(); > > This should be smp_wmb(). > Why? -- Kiryl Shutsemau / Kirill A. Shutemov