Received: by 2002:a05:7412:518d:b0:e2:908c:2ebd with SMTP id fn13csp395975rdb; Thu, 5 Oct 2023 08:58:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFdaA3I9HCfc4hUOOnhJKR8hneYQ3DeRDJJR46qoILPt8ilbMwCnX0z+btTaxLlTWgReEDF X-Received: by 2002:a05:6a21:6d98:b0:138:92ef:78f9 with SMTP id wl24-20020a056a216d9800b0013892ef78f9mr6696733pzb.6.1696521512642; Thu, 05 Oct 2023 08:58:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696521512; cv=none; d=google.com; s=arc-20160816; b=JhZtrWfk7+vugQ52FOTtDCEUTI1Z0V2Gbqg8fGqQj7h/0OapYtTWkXT01JYx4mhJm5 ZTsmkYfiyduU7q68zCHuTh1fD2WgFKHLgbKg297rnWJGWoxH0Ou8g5/1nc/2nBX4aCAb 7mb8Ef72JmvDh5UwtLCv9efKVKdtZBJ8K1vHsrCyx81M73rLM1VyubcPMHJibg5pO+hB rqkGshc7e0qUrZ59AVZ+B1XPIOPW4o9mv2eCkf+MoMkwhcMXFDCsQNMj7KYfVo35ZAzr lIVb3SjZwWum3En4X+b/dZkhGtGCQnILTp8G+xHforBpTGnUzrpCJ/6pyZbLtQj+AF+d D3rw== 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=o5Y8doXVdKJk+1QaGPkIclZvAKJT41o2Q1akVoEM1r0=; fh=F1gpqSS/HYttK+doOKuW4yrAifo5qykyq1MCI9SIQmQ=; b=aPzYmmLEulU8KIjnpZFX/4dIeFhL28LltFi7ZP17aWibL9xA/ay0ydKXiPlXUy4MtP kgVfNRuJV9bjq0ZishGQYiS8HF+S5eR3U+MvIuLKkab/RtPde9ebH1hu0E2Wh4pThKqa fe4z9PlgN++HyEbSr/6Cp7NEGjr0h+KkNx1sYMq6IZq+gGkKKof9dBT1URBe1kqQt0mt ulMpSA7ZDBzV6Fv8WwXTGqqBx7bauKmYY5WgyLLiPUs3gj5Ih0qBc77tGfX2hIvcCKP/ ckvtqhoMwBprfuucZToIll8vy/PTmvKgvKa7K2Ol9IS4IDu0uUSW2luS5130187WJITh IKGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ILf+ujyD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id n11-20020a170902d2cb00b001b8904eadb8si1805567plc.460.2023.10.05.08.58.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 08:58:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ILf+ujyD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (Postfix) with ESMTP id 8666782E752F; Thu, 5 Oct 2023 08:58:30 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237874AbjJEP55 (ORCPT + 99 others); Thu, 5 Oct 2023 11:57:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233396AbjJEP4n (ORCPT ); Thu, 5 Oct 2023 11:56:43 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A2B66620 for ; Thu, 5 Oct 2023 07:04:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1696514684; x=1728050684; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2WU7kKiOy1VKJ5VS01o46StvhoI+3fSkV4NdlGG5HN8=; b=ILf+ujyDGQFTZ/JWQGF/IuxJRj9c2B3cRVH/yThZTCIvai3jd0BnON98 WpvuwH33ehUeNYnLpnOlTaXJ6+zbtnNWtW7O50Hvh4dn01uZMvOO90DUb NhuPkD2bBa6KM1dUGCsou8fxDlEYAFhiryQz0Fbs03R9xUYRdRFobOTGj Kcck4+YunlRspwl5ysV93KBaq0rbXcFNjihdAtwlK4ukOK5k7yAYYNi7H WEVYCnxeh5ByDK3YidMcfO/tWgN3OzHiAnuw9nTUAnZibhd4Kla+RhemE 9p5mGKHBtFpVCeZ5FcA7hEhUi9MPqE2cKMIb5v5dVkYAd094UNqN0vd2f g==; X-IronPort-AV: E=McAfee;i="6600,9927,10854"; a="380767178" X-IronPort-AV: E=Sophos;i="6.03,203,1694761200"; d="scan'208";a="380767178" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Oct 2023 06:14:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10854"; a="728449267" X-IronPort-AV: E=Sophos;i="6.03,203,1694761200"; d="scan'208";a="728449267" Received: from skwasnia-mobl.ger.corp.intel.com (HELO box.shutemov.name) ([10.251.222.71]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Oct 2023 06:14:23 -0700 Received: by box.shutemov.name (Postfix, from userid 1000) id 3D69E10A14E; Thu, 5 Oct 2023 16:14:14 +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 , kexec@lists.infradead.org, linux-coco@lists.linux.dev, linux-kernel@vger.kernel.org, "Kirill A. Shutemov" Subject: [PATCH 05/13] x86/kexec: Keep CR4.MCE set during kexec for TDX guest Date: Thu, 5 Oct 2023 16:13:54 +0300 Message-ID: <20231005131402.14611-6-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231005131402.14611-1-kirill.shutemov@linux.intel.com> References: <20231005131402.14611-1-kirill.shutemov@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Thu, 05 Oct 2023 08:58:30 -0700 (PDT) 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 environments. Signed-off-by: Kirill A. Shutemov --- 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..bea89814b48e 100644 --- a/arch/x86/kernel/relocate_kernel_64.S +++ b/arch/x86/kernel/relocate_kernel_64.S @@ -145,11 +145,16 @@ 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 "jmp 1f", "", X86_FEATURE_TDX_GUEST + orl $X86_CR4_MCE, %eax 1: movq %rax, %cr4 -- 2.41.0