Received: by 2002:ab2:4a89:0:b0:1f4:a8b6:6e69 with SMTP id w9csp354309lqj; Wed, 10 Apr 2024 12:25:58 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX7xaxRRmRomsP4Aib2si49YXJTtU8sncgWwiW7nSL2jdIgvSmELQnqZfDMLhaO36ZiHPLB7njeeD4ep3/9qqbds7XnSrUlhY44sSa0jQ== X-Google-Smtp-Source: AGHT+IGgpjLAVcatpNx8uGjETDcq/MJPVbub7ePzpYLsAR5dGyRyGQxKONHQQ+XdTyuJZEsrwSOR X-Received: by 2002:a17:902:e751:b0:1e2:b026:cad5 with SMTP id p17-20020a170902e75100b001e2b026cad5mr4419226plf.0.1712777158461; Wed, 10 Apr 2024 12:25:58 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712777158; cv=pass; d=google.com; s=arc-20160816; b=MvTZyLVxqInYix4xG7XoCi8NIPX9jC3w0Il+iu0E7AQ6/r3DwTM5DLnmnmKIImSRI5 lOvnLritKmDUgpUe3gmdszqRLe1JDulmZJasV7c2xjMUAwAdjm4a9o00iPgwTChCNxPK YRIfKcny6+F5exmcySesk7yAY/Nx+e830rQhHEtu9q/ugYgGPZXMZ8xqte7gO/sbtJiZ ZPD82MGDix99bi5zH0i/WVFx0Sf2yCLr7c6/1Jr3emgRU/RbjUneKDhEehQT60Ywl23k DG1LxedTtWgDTZFKn4ZVhTXlhAx51BSaejNHjAJ4L9Zw3bvYzftGzheZz6JJFN7QgF7+ OZuQ== 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=aLAsJS0W5uDpCWlDkfvDK7er7/ok6ukrPnkBlcem1ps=; fh=6HUti5oHjdHwdSCI/3htoTpv00HatxVt3zgGrRSwyuY=; b=FWt1qd37Bil3kFxtArGhFcjFOovJ2ZZyfH+3Z+Vn11ZA4n3iu6Z9Lttqr6Cv9KmqQ7 f67Qx2it563TvtRyoAANnLn/iIPq2YVtIQ6zDp/uv0oVJ0wXxGWpxIrXyoepgBXNCGxW z4R1n1L7j36Kv7MCAVbJL50hjmypP+wrYh35d+gLE+qo5T9AcLd8OldYCMFH4mAJqtJg gehwwAcOn44wrY/1O4rXjNWdD0VobVNebaiekjxWYWfK/nPY+aO860fUfvNML/HQDBCm TMrIRImQFkjULcoEGiUV8QgMX8vsXlnhgd/FgvgmHplDRBI9i3UfAKNJQiISV5h21LMc 4vIg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=FFpX+ZMO; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-138729-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-138729-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 n18-20020a170902d0d200b001df846506f5si10675031pln.584.2024.04.10.12.25.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 12:25:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-138729-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=FFpX+ZMO; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-138729-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-138729-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 68848B2CDB9 for ; Wed, 10 Apr 2024 14:13:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0927515F40A; Wed, 10 Apr 2024 14:12:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="FFpX+ZMO" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) (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 B0FC715F403 for ; Wed, 10 Apr 2024 14:12:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.12 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712758377; cv=none; b=apg257jOevyPEZJ3et3Y+2ehSpvuCzsU2AARio2jesY0fy92RczTLw1Y+c9t1CyOCsf5mbjAEBVqoQNSAMGOmJLUd2uTqo2AQ3xJjfoi/7ye7sCyIWbmBKPtwNysPPG9dx3NoUPNSkaOu1yCDIRds88X//3F0Nb7j3XeXNxjbnI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712758377; c=relaxed/simple; bh=o5Xl6KLUlyJc9ziXPk/AZSDc/htjvPYVBAcZVf4ZKjM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=nuwWIcK/n8b73lHrcFQyv2kHQa0Qdo5TeCWAFE69oyjdI+Ze6Vg7/NnN/bDkJHv7rxZw5kvlPap+c4r1FQf42G77U5YKr92oylu/nhjZv19+doJL0XZQQl0mfH1zklO+22J3PdOu5YsML8oCYIPTjxDpRS6hMS1kRGmTYRxA8Tw= 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=FFpX+ZMO; arc=none smtp.client-ip=198.175.65.12 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=1712758376; x=1744294376; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=o5Xl6KLUlyJc9ziXPk/AZSDc/htjvPYVBAcZVf4ZKjM=; b=FFpX+ZMOsgWBWXJWUila7Qz3Ye7W/9MyLrmzvWF4NAUywEXNinkRVusg 8adFzSw7WvFNm4SPGthBie8xnIPDuquXEPB8OrqrdV5uzD658t8Srlqtp UfrzXhpSFyGwzOwoTExpGqNFUrpI7qTH6gpqG0obyc+IB+DO9olepPTbr hNa2auIFHSFlskaOisH7yBL7HazjcaHSLGskIojvWxq1e96vnzO+gYbzd gDVqXRMpOk6N4qkKIAegp1hsq0u/jZudm59C13aoFEFMyhNZGwvcl3+TO 0xs75QR0NlAJrQwYsi61fzaLWZ0E5q1jnwom6Xauc7qpC+c3aPu2lNlJf g==; X-CSE-ConnectionGUID: 00gE0pxPS9KoQuotIyoK2Q== X-CSE-MsgGUID: rFyvLNP1Tm2mSKIYy9g+kg== X-IronPort-AV: E=McAfee;i="6600,9927,11039"; a="19548706" X-IronPort-AV: E=Sophos;i="6.07,190,1708416000"; d="scan'208";a="19548706" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Apr 2024 07:12:55 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,11039"; a="937095148" X-IronPort-AV: E=Sophos;i="6.07,190,1708416000"; d="scan'208";a="937095148" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 10 Apr 2024 07:12:50 -0700 Received: by black.fi.intel.com (Postfix, from userid 1000) id 0BBF3161; Wed, 10 Apr 2024 17:12:49 +0300 (EEST) Date: Wed, 10 Apr 2024 17:12:49 +0300 From: "Kirill A. Shutemov" To: Kai Huang Cc: linux-kernel@vger.kernel.org, x86@kernel.org, dave.hansen@intel.com, bp@alien8.de, tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, luto@kernel.org, peterz@infradead.org, rick.p.edgecombe@intel.com, thomas.lendacky@amd.com, ashish.kalra@amd.com, chao.gao@intel.com, bhe@redhat.com, nik.borisov@suse.com, pbonzini@redhat.com, seanjc@google.com Subject: Re: [PATCH v3 1/5] x86/kexec: do unconditional WBINVD for bare-metal in stop_this_cpu() Message-ID: References: <33b985a8f4346f4bcf0944eaf37193a906b11af3.1712493366.git.kai.huang@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: <33b985a8f4346f4bcf0944eaf37193a906b11af3.1712493366.git.kai.huang@intel.com> On Mon, Apr 08, 2024 at 12:44:54AM +1200, Kai Huang wrote: > TL;DR: The commit message is waaay too verbose for no good reason. You don't really need to repeat all the history around this code. > --- > arch/x86/kernel/process.c | 18 ++++++++---------- > 1 file changed, 8 insertions(+), 10 deletions(-) > > diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c > index b8441147eb5e..5ba8a9c1e47a 100644 > --- a/arch/x86/kernel/process.c > +++ b/arch/x86/kernel/process.c > @@ -813,18 +813,16 @@ void __noreturn stop_this_cpu(void *dummy) > mcheck_cpu_clear(c); > > /* > - * Use wbinvd on processors that support SME. This provides support > - * for performing a successful kexec when going from SME inactive > - * to SME active (or vice-versa). The cache must be cleared so that > - * if there are entries with the same physical address, both with and > - * without the encryption bit, they don't race each other when flushed > - * and potentially end up with the wrong entry being committed to > - * memory. > + * The kernel could leave caches in incoherent state on SME/TDX > + * capable platforms. Flush cache to avoid silent memory > + * corruption for these platforms. > * > - * Test the CPUID bit directly because the machine might've cleared > - * X86_FEATURE_SME due to cmdline options. > + * stop_this_cpu() is not a fast path, just do unconditional > + * WBINVD for simplicity. But only do WBINVD for bare-metal > + * as TDX guests and SEV-ES/SEV-SNP guests will get unexpected > + * (and unnecessary) #VE and may unable to handle. s/#VE/exception/ On SEV it is #VC, not #VE. -- Kiryl Shutsemau / Kirill A. Shutemov