Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp61190lqz; Fri, 29 Mar 2024 08:33:01 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWydJxq8vMLcU6LXH1QrJuXkXPr5+IS/2uWFQNbagth3F5TPvecNRlbXwZ2vuhpX1As+RSHMQfvFKQgIHqphmhnjC7ML9imLrg+zL8o8A== X-Google-Smtp-Source: AGHT+IEoCWCu9WEprRYKD/foRdOzDFZOPACALPUplbBwyk5S6NA5FqSNnhFGUmBys1bAeLfVeSF1 X-Received: by 2002:a05:6402:3596:b0:56c:2ad8:6fb2 with SMTP id y22-20020a056402359600b0056c2ad86fb2mr2462008edc.33.1711726381267; Fri, 29 Mar 2024 08:33:01 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711726381; cv=pass; d=google.com; s=arc-20160816; b=Wb8jt0EufTkIO9+sTI6e9oQlPHR/hgNZkishtM0JlSAnN/0yrHwMWwovn4HmU1LkUM ImCUiEpB0cZnIDc/KBodCGywsdIErOht3wbB6ecq4JNz/DsBnH2gY3Lp7sChdf2kkjR/ tPTsaOniSGduIIX9FBgz1JVHpEu4H7GWXddhCdu9P8qFdz7GiVAU7EjGpeuytmEPCg45 366r4QKIMv9AEEpYE+O+7vuCuUBG0CwiynTh5WToOfico0j3mTzmKtXQ38waB9/s8aRR neYnAGgI9UPCaOjpQjl6ls07w1SBAwByXcTpMQJkr1e7uAlslwCyNJNRs5j5460V4TKo z3PQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=WEbCqCRr0HZbRreECKqfI/M0qu/9j6K/Uo8nLOQ8f0o=; fh=cHoPloON7bjP722I6WmJv8Zbx+3xWEPssMYpLtoAQ8s=; b=pltWma/sqWUmUKLlg1IKUTU7bfFXFem7UAILAV7uL8NBlTVA7SLufZmdAdjHxsx06z A8wfxmo5JOF/iSgLL7b20B8lIKArvweumlX3DRNHyCkotGVD8+5dq8PUCivA/M+YWRvQ YTHE8ltmyJ99VEOSfCJrLAS7s+ZFkM+Ea11ejUeMwmbjwB/AAp5y+PMENH6bOZUjn5N6 VpnGi/HTRGrzq4cEt55gLbzhrVInFAEAqVO8KbkMo+t47flhQhcelcgRi38nEzoSSc9u CYLz7gBR6tJo9ZZrZoO2jqgWP9Q4329dsGjJUnQ2Vjgwer6t+HgTTQOwp8TojZogWx6X peuQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ZJKtspY0; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-125123-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-125123-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 x22-20020a50d616000000b005673b8a79c9si2008856edi.394.2024.03.29.08.33.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 08:33:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-125123-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=ZJKtspY0; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-125123-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-125123-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 9D30D1F2CB9D for ; Fri, 29 Mar 2024 15:25:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EDEE385C43; Fri, 29 Mar 2024 15:21:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="ZJKtspY0" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) (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 96E602562E for ; Fri, 29 Mar 2024 15:21:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.11 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711725703; cv=none; b=oyA6Il1qbPsFv7uCrk4/Pr6TnyL2kl2+0j2wLweMqkYCCW3VZNoig5F1V78Hxl0k96TZg3COlN3UeHz7M05QcAkRAg2RXlAOsofLZxaBzH0v+xlf82TV5FH6UgnoSlUqO3cv3k6XndZ8HWZAfcX+9d5YdsM9F7f3LUgY0NUO9Ic= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711725703; c=relaxed/simple; bh=xIhz1fc0gd8bUoWk1Yba/XGwSpCgbpumuPmPXecDCog=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=vAl3DJidDHkQB+U4yKFlg60kafpCihyOBtOgFrZVtYEaLnuwKqYGXaccWJ9QIRRkG5QDP2ZQFtgEGqeDP/cW81xUJJUkJKBWPjCrh+/nudnqENBDfDKUyrMDyqA4s3CwJanx8EtzugUUOuRVFFAQNZfGdsaSaeATJE9eJkZ5UhY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=ZJKtspY0; arc=none smtp.client-ip=198.175.65.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1711725702; x=1743261702; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=xIhz1fc0gd8bUoWk1Yba/XGwSpCgbpumuPmPXecDCog=; b=ZJKtspY0jsFuTnIcc6aqcoRMvX4hnpNMkAHa5QnXVSPxFrU2xUe//mUN hPzYbvxgu2NUyV4XP5JArSs4yuSM0ERKdwcEyprikmgz0swbmV9wz4mS+ XIjqWkYXyC9zekGb4Vd1YEgKQRg20DtwbovEfwHUBn+v2GEC2+APKRcdi G5M7AzgQr0tZoa6ty6lgxXeE5mDCm/JM8m/n8aMFIJs/yU74dOpgJcjjr AJJj7vsVCKNbSuyQhu0ytbdvf1eYFV4Yc7C+W3lCCwTsdvtcWVFwus49l LzBsCvWV9PHcLziiOrO2G4JjCJv157ckdYjL9RIwcycHttjXxZiQoWhm9 Q==; X-CSE-ConnectionGUID: zXcaCzcLQSaw+aqEoGUcUg== X-CSE-MsgGUID: a84RurfVTjOLC2+EqkxsTg== X-IronPort-AV: E=McAfee;i="6600,9927,11028"; a="17472611" X-IronPort-AV: E=Sophos;i="6.07,165,1708416000"; d="scan'208";a="17472611" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Mar 2024 08:21:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,165,1708416000"; d="scan'208";a="17636665" Received: from xiaoyaol-hp-g830.ccr.corp.intel.com (HELO [10.124.224.7]) ([10.124.224.7]) by orviesa008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Mar 2024 08:21:36 -0700 Message-ID: Date: Fri, 29 Mar 2024 23:21:32 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCHv9 05/17] x86/kexec: Keep CR4.MCE set during kexec for TDX guest To: "Kirill A. Shutemov" , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org Cc: "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 References: <20240325103911.2651793-1-kirill.shutemov@linux.intel.com> <20240325103911.2651793-6-kirill.shutemov@linux.intel.com> Content-Language: en-US From: Xiaoyao Li In-Reply-To: <20240325103911.2651793-6-kirill.shutemov@linux.intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 3/25/2024 6:38 PM, Kirill A. Shutemov wrote: > TDX guests are not allowed to clear CR4.MCE. Attempt to clear it leads > to #VE. Will we consider making it more safe and compatible for future to guard against X86_FEATURE_MCE as well? If in the future, MCE becomes configurable for TD guest, then CR4.MCE might not be fixed1. > 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 > Reviewed-by: Thomas Gleixner > --- > arch/x86/kernel/relocate_kernel_64.S | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocate_kernel_64.S > index 56cab1bb25f5..e144bcf60cbe 100644 > --- a/arch/x86/kernel/relocate_kernel_64.S > +++ b/arch/x86/kernel/relocate_kernel_64.S > @@ -5,6 +5,8 @@ > */ > > #include > +#include > +#include > #include > #include > #include > @@ -145,12 +147,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