Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp3081055rdb; Mon, 4 Dec 2023 16:46:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IHIVUXnqOWqMBIi9R/aRf0C65FROcWfqYT+vvQAETMYWt3d9El0YL8PPWJuvqJpbDwFjKLp X-Received: by 2002:a17:902:e743:b0:1d0:6b95:9c0e with SMTP id p3-20020a170902e74300b001d06b959c0emr2779208plf.57.1701737211072; Mon, 04 Dec 2023 16:46:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701737211; cv=none; d=google.com; s=arc-20160816; b=ZnNXAj3l0mzCN5tjKCVfoSllYb56HwnUiqfjpRWF9yfg53gk2aAFY3n9Cl19u9QVwF 2KSAPOJZRvjlgYhUwobObwOemyiZo12Jq4/yOHpM7c3fanCUulaKYgDXcnUaJPkTgC3O znlz697U2nkarHU2pB/3YvD5nZrBZJ+X9l26Tzzjn0CiAdZzDh3zC7uOgjjQCO+0fpMJ LsZSvyIQmmLohQarry5bPs1jSA/3q+xD+3RAvn+d8PiF9tfL/zqiDKTM/WsH0KBeIwO9 VyVE6HVMqSIt+OL4JDugZL4Avxjf3jKla0QvjbOF0sPwIWG3CR4ZT4PafR9oBp7nQIHr Wb8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=kzdVNUOIUQb5nbNceDWwNKCkDI+wYcQTHHY/dNwObBM=; fh=OvJRnOqsMTm9XoNmEwebcqh9Ud7yh1CTeKAP84ols98=; b=s7zypAu+cRDjQTVbfXzxeLKS8llmZZNirczZytxxIHTzqHUmhZm0oF1G3xoAhsxZPV mspAU1c9h2Z19NXxfVzCvMUfJ0fVvxAX5xIiLEHgbLli+FY3usLVUmjdo6iF1+9UXyNP Awi3f8X7og0yMqiYRUGJH65uC90Xm3whu/6NeGCeOFWev/CaBAJJLs4lMBIxIN8rV3ic H2rPgAtDHY0vGCNOyTL2jtWb7OjJ9pLBoDxNLYYeHVp6Ioxra47uDCryyQp/aXekzfDe RplTsMwLvzMIChWgOn1V8mX40QyYMMGK86QXpi18LBL2jl+PM8zNzKVBUYHtsCULM1YY h32Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Qb2rTBYq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id iz13-20020a170902ef8d00b001d03e572976si4524225plb.591.2023.12.04.16.46.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 16:46:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Qb2rTBYq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (Postfix) with ESMTP id 89C94802EF2E; Mon, 4 Dec 2023 16:46:37 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234895AbjLEAqC (ORCPT + 99 others); Mon, 4 Dec 2023 19:46:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343632AbjLEAp2 (ORCPT ); Mon, 4 Dec 2023 19:45:28 -0500 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD0D2A4 for ; Mon, 4 Dec 2023 16:45:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1701737134; x=1733273134; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wYs3fU4C0jZd+PnKZxc0e8e/KDE7b/5Kd3uwb7sJ62o=; b=Qb2rTBYqT1YCgBPpUKZffe+VXslh7ruFlAP0N7wHYiza4djqc0gwNBa7 5rJV836ZOyxlgYWcqULyqj+61zpDSKDk4E8K2xWEHP1OyOZTH83Luu+iu g5V2vJRDPyS7w3jqkCBmjVPwlI4Zp/xwyohmzWAfpZ+meYfqP6piTJrKc 7LKMt+3wZJGpqNvAOY/58/qshBeVEuLwCl+6UwhICz6zFN2cy/a/IKAvx pYHaQoDcy3grocjYsfFN+J0DKVSxAvgdfNiA0t84rQm9u2A+DRHsi4Udu v39zl6ZQ+Oq3Kskx+jaPI56/g3dCFp/nSOlTLnwxZ1v6MLe+AADFtvBiW Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10914"; a="392688656" X-IronPort-AV: E=Sophos;i="6.04,251,1695711600"; d="scan'208";a="392688656" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Dec 2023 16:45:34 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10914"; a="888704402" X-IronPort-AV: E=Sophos;i="6.04,251,1695711600"; d="scan'208";a="888704402" Received: from abijaz-mobl2.ger.corp.intel.com (HELO box.shutemov.name) ([10.252.61.240]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Dec 2023 16:45:29 -0800 Received: by box.shutemov.name (Postfix, from userid 1000) id 67CE110A446; Tue, 5 Dec 2023 03:45:20 +0300 (+03) 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: [PATCHv4 06/14] x86/kexec: Keep CR4.MCE set during kexec for TDX guest Date: Tue, 5 Dec 2023 03:45:02 +0300 Message-ID: <20231205004510.27164-7-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231205004510.27164-1-kirill.shutemov@linux.intel.com> References: <20231205004510.27164-1-kirill.shutemov@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 pete.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 (pete.vger.email [0.0.0.0]); Mon, 04 Dec 2023 16:46:37 -0800 (PST) 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 -- 2.41.0