Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp971746rdb; Wed, 6 Dec 2023 05:27:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IFbi4EepOWRf56CNANziBIxGqb48Pfg6lclWx7zQ6A7yNB5ewDBnfNk+pAu7XJZ1kCb0hws X-Received: by 2002:a17:902:d509:b0:1d0:c418:1758 with SMTP id b9-20020a170902d50900b001d0c4181758mr998221plg.66.1701869228176; Wed, 06 Dec 2023 05:27:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701869228; cv=none; d=google.com; s=arc-20160816; b=NR8SWJZU4c/xnGnjmF9PAxB3xK/CBfSIyjBCspWuIMpCl8jnHHvvioLOiwmNAxmtQL BwUW8JK9IqfDH1Y4tFmPG5yOB01behVUnjVL7g6Pw+EucJ86VOnMlZsF4qnSQaHIQtRR HTYsz6NW9Kmvu8Ortya641IixEYgeiHPmUaZWtAG2QvrBBSGmIh7fS6rfDVDP3dFwyAk xuykaJEY5ii2AUAhqMNqNIiZM3Ln+ftaLiq0x9t7wM/X3qe6CUW9Wwxkst9HlEt3KE7f U/p5ubUjGsz9gtLowQr4G67Gj+BKrlkyBR1nV59KKTX5oVLlTLXI7pO8vMxCAapWHyZp DRkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=gp9Dujco/fgV+W5bMTtSFvTJlOV5Bmqms8S3RJkMwpU=; fh=f4SnCP18GcvdWICWlZ/o9/0mE+7famEFm5zezDEmU9w=; b=E7RGO2d/p5aM7YwOhAgdKMmV1spRaI1o0n7Ihit3jYoHztuAjGdCdvv1gVWYQns7bV IvSN2+Ljhb2HHTCrD5cIAh8Ppv3h4wKAcToURk2kzAL0oSDNfFZN+Apd2PBoRrmi+9yf I7dCMQzdcZhJNghleEXQgkPQgye3XTeWH5MKQsX7xnPnreD6JxMZNcPJby2pe9IRCOeZ MserOiAjV/kL1ApRhEbQtLr8UKcVmGt6u1FEEKI80szCW/afTOME92agbPwhSJ968iQy rCTuMn4IEidfdPqIWgsCvopWw/dver1/gQQydJ8sPNokB2FqyGmYnSW9QfKbDLA5Tdls srdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="dOP/xAK9"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id o9-20020a1709026b0900b001d054a8f128si9316336plk.451.2023.12.06.05.27.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 05:27:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="dOP/xAK9"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id C3B568031AE4; Wed, 6 Dec 2023 05:27:05 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378478AbjLFN0h (ORCPT + 99 others); Wed, 6 Dec 2023 08:26:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378571AbjLFN0d (ORCPT ); Wed, 6 Dec 2023 08:26:33 -0500 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 97707D66 for ; Wed, 6 Dec 2023 05:26:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1701869196; x=1733405196; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=wvRatAZPIQq3Q3PGd/WkGxxbZ5rxDQhioWQiZbIj1vg=; b=dOP/xAK9HYJSWyFK82Q+RtkzXUoK2C6FjDr0SGyRx24a5+iXHu80D+zh 2JJCCOxHbJo330wJTVUX1r5oqfKJnjJo1AUeUI6PotsEOr3RxY7zoBppJ DFke4lMLVG8W4m22PIxT55C9WnvEKsFzCTjYXM4UM/EDuHnYFHDTb4gyN UhREpWloAFS8ONQsCuKawwSZ/dv8kUp5T6PD3vnFM+jmNuwvnQhFnIh1K 3KnoQJrlHqjxev//CJt7qBlLVJ8R+5onFqoD1/vtoelt528W0JoOQPoQE N3DCLo7SeXCRapHmjmi1G12jQIkBuLTPGEi0jYRuRICYA2HUNVlnVR1vc Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10916"; a="930857" X-IronPort-AV: E=Sophos;i="6.04,255,1695711600"; d="scan'208";a="930857" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Dec 2023 05:26:36 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10916"; a="721084730" X-IronPort-AV: E=Sophos;i="6.04,255,1695711600"; d="scan'208";a="721084730" Received: from eborisov-mobl2.ger.corp.intel.com (HELO box.shutemov.name) ([10.252.46.36]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Dec 2023 05:26:30 -0800 Received: by box.shutemov.name (Postfix, from userid 1000) id 0618B10A3F5; Wed, 6 Dec 2023 16:26:28 +0300 (+03) Date: Wed, 6 Dec 2023 16:26:27 +0300 From: "kirill.shutemov@linux.intel.com" To: "Huang, Kai" Cc: "tglx@linutronix.de" , "mingo@redhat.com" , "x86@kernel.org" , "bp@alien8.de" , "dave.hansen@linux.intel.com" , "Edgecombe, Rick P" , "Reshetova, Elena" , "Nakajima, Jun" , "rafael@kernel.org" , "peterz@infradead.org" , "linux-kernel@vger.kernel.org" , "sathyanarayanan.kuppuswamy@linux.intel.com" , "Hunter, Adrian" , "thomas.lendacky@amd.com" , "ashish.kalra@amd.com" , "kexec@lists.infradead.org" , "seanjc@google.com" , "bhe@redhat.com" , "linux-coco@lists.linux.dev" Subject: Re: [PATCHv4 06/14] x86/kexec: Keep CR4.MCE set during kexec for TDX guest Message-ID: <20231206132627.5dx4sbgkypgnq6yn@box.shutemov.name> References: <20231205004510.27164-1-kirill.shutemov@linux.intel.com> <20231205004510.27164-7-kirill.shutemov@linux.intel.com> <861f583e2550959616e19565235f0debbe27149b.camel@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <861f583e2550959616e19565235f0debbe27149b.camel@intel.com> X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Wed, 06 Dec 2023 05:27:05 -0800 (PST) On Tue, Dec 05, 2023 at 11:58:45PM +0000, Huang, Kai wrote: > On Tue, 2023-12-05 at 03:45 +0300, Kirill A. Shutemov wrote: > > TDX guests are not allowed to clear CR4.MCE. Attempt to clear it leads > > to #VE. > > > > Use alternatives to keep the flag during kexec for TDX guests. > > > > The change doesn't affect non-TDX-guest environments. > > > > Signed-off-by: Kirill A. Shutemov > > Reviewed-by: Kai Huang > > --- > > arch/x86/kernel/relocate_kernel_64.S | 3 +++ > > 1 file changed, 3 insertions(+) > > > > diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocate_kernel_64.S > > index 56cab1bb25f5..cd6a53667c6b 100644 > > --- a/arch/x86/kernel/relocate_kernel_64.S > > +++ b/arch/x86/kernel/relocate_kernel_64.S > > @@ -145,12 +145,15 @@ SYM_CODE_START_LOCAL_NOALIGN(identity_mapped) > > * Set cr4 to a known state: > > * - physical address extension enabled > > * - 5-level paging, if it was enabled before > > + * - Machine check exception on TDX guest. Clearing MCE is not allowed > > + * in TDX guests. > > */ > > movl $X86_CR4_PAE, %eax > > testq $X86_CR4_LA57, %r13 > > jz 1f > > orl $X86_CR4_LA57, %eax > > 1: > > + ALTERNATIVE "", __stringify(orl $X86_CR4_MCE, %eax), X86_FEATURE_TDX_GUEST > > movq %rax, %cr4 > > > > jmp 1f > > Nit: > > It seems isn't included in relocate_kernel_64.S. Maybe it's > better to do it explicitly. > > Maybe even better to explicitly include too, but I see > already does that. Okay, I will add both. -- Kiryl Shutsemau / Kirill A. Shutemov