From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.16]) (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 0718B153512 for ; Tue, 27 Feb 2024 21:25:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.16 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709069110; cv=none; b=o4/47V2W/eewiwZUkXAUZ1h22gJ0wz8qDxLHMYwj2MWFgnAjoErMPW8uG+Z7YyVIudLwgeGyXCFJBXkhJFxrwoZufRHK8BWmR8JHjMdvqbPCdiZSzzeQ0pai1WLfEcgXYmcc0cVDlBLudIkkrDWs9yqWxfXMLBZL3yGQUefW6BI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709069110; c=relaxed/simple; bh=7jFuowaz0Vw+N4idIIhc+R9JJKXqB88Qml6sO/pIcmM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=d5rpcYxl9aRZMaG757nbXKg4eHaZb00jrW0PtoXWXqnNLXCTGp4rBdxZmx+2il0RJHIRK+p7QBJsYftys0Ta5CHN5FzifUVtMEt+8gx/qZqFWS9l84y0puQ4g6shR61U02RL2T4Ekd8lRu0WWpR0hB4HXzL33hNB12oivUaFC7I= 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=gHdR11zm; arc=none smtp.client-ip=198.175.65.16 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="gHdR11zm" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709069109; x=1740605109; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=7jFuowaz0Vw+N4idIIhc+R9JJKXqB88Qml6sO/pIcmM=; b=gHdR11zmEGfhHJrf9TGegn2mkl+le7HDbuxXRnMZgjwousdRAuGIg8p/ qAcJJSfrCg5qyrhllBgwI3T0bG1mMmXgAtTge9blvYzbh488NrU230c7y Az7yVf3Fto3aUOhOdH0rd6jSHYJa5dfly5cE+UOjumD7/TPTuYeE5dEHI rDiDSa/e/8w3CDVR5wrTCMIJ1708UtnaOZ7GmvW1L3Si2oyaEMZi86mqa xGgRcAW3lYr2lx0/c//DeguyZJAm9DvShBLB05QacvBXFBbSLFyy999KR 9VatQejelLb9Z5MwInSPZSn6yC2iF9nus+CL/PkiJEN1KtQXHJTOuLvIw Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10996"; a="3566979" X-IronPort-AV: E=Sophos;i="6.06,188,1705392000"; d="scan'208";a="3566979" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Feb 2024 13:25:09 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10996"; a="937032906" X-IronPort-AV: E=Sophos;i="6.06,188,1705392000"; d="scan'208";a="937032906" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 27 Feb 2024 13:25:02 -0800 Received: by black.fi.intel.com (Postfix, from userid 1000) id 1E0E85F5; Tue, 27 Feb 2024 23:24:56 +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: [PATCHv8 05/17] x86/kexec: Keep CR4.MCE set during kexec for TDX guest Date: Tue, 27 Feb 2024 23:24:40 +0200 Message-ID: <20240227212452.3228893-6-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240227212452.3228893-1-kirill.shutemov@linux.intel.com> References: <20240227212452.3228893-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 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 -- 2.43.0