From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) (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 6F0713A8FF for ; Mon, 12 Feb 2024 10:45:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707734709; cv=none; b=QS6pjDNrqkkPlic5+3iSt5dLbYMBzmnJ2JvBFSm9XmuStktAfiu0IUe0jLE803a3QD4Cts6yh1cdRDqdp6kcYytzDuHBVrwO4j1CpCvPg0dN+IAuxAD2ERlceuRzHiVGy14kvaX2INYMyYWNSlSfT+HQq6KiJDuXVKXO4QI0b7k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707734709; c=relaxed/simple; bh=LcZSO2fCT5WaMkS6shCgOhCUo14EJT04WN8x+U0u+KI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KeZrQrTEGFxvlPhQP4gq057jIvngp6dJOFbO0SWBVzkYQJcLIsmhTNdZuTqTsLuU4rgZNewfZ0HfobQfFrnfTT5HjRzXCrjhB3hbEnj/JVy4TYZplrroWLVPPqpjLKpzYhgmcXnrO4AaLFtn3NFJG72NkS7mnJiall4BlBo12cY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.helo=mgamail.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=J3VUunRc; arc=none smtp.client-ip=192.198.163.17 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.helo=mgamail.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="J3VUunRc" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707734706; x=1739270706; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=LcZSO2fCT5WaMkS6shCgOhCUo14EJT04WN8x+U0u+KI=; b=J3VUunRcyQ9nJJ5iRMmPHZ+c3H/gLuhM5+Ov9IS7YQXFDzNfL+TIt4s1 FkZNIUlaUDnNK/s9WTjMRP7inCsxArxMFxJZGIvqC4BhhrSnHE0+7OZYu o/9ow1LI9e0Memvp6yHJX5ptTTAwSJ8o4a9PvLh6/5vXClkKVhZDiidWX UDRWuzHqTcIPPYGn2jJ/Ek7dbO2aC7qr88E8AXfrYtNUcYXhhNQOCQWIy 71RyAMKixhgGLdPFMlOIADT009m5kU2bnoFb/DTtNTvPndpanlQ9eiD+M Eqr61fcoDBXKeopdPCgDQDUWLK60GbrhckyeXY2yvQVVkpvY+zTcI9sIo g==; X-IronPort-AV: E=McAfee;i="6600,9927,10981"; a="1585053" X-IronPort-AV: E=Sophos;i="6.05,263,1701158400"; d="scan'208";a="1585053" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Feb 2024 02:45:04 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10981"; a="935035599" X-IronPort-AV: E=Sophos;i="6.05,262,1701158400"; d="scan'208";a="935035599" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 12 Feb 2024 02:45:00 -0800 Received: by black.fi.intel.com (Postfix, from userid 1000) id 2AEBC535; Mon, 12 Feb 2024 12:44:53 +0200 (EET) From: "Kirill A. Shutemov" To: 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, "Kirill A. Shutemov" Subject: [PATCHv7 05/16] x86/kexec: Keep CR4.MCE set during kexec for TDX guest Date: Mon, 12 Feb 2024 12:44:37 +0200 Message-ID: <20240212104448.2589568-6-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240212104448.2589568-1-kirill.shutemov@linux.intel.com> References: <20240212104448.2589568-1-kirill.shutemov@linux.intel.com> Precedence: bulk X-Mailing-List: linux-coco@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 | 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 -- 2.43.0