Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp2092331rbb; Tue, 27 Feb 2024 10:17:44 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXtWLC910CV85AUZ1tbNoJj0g9Its7jJ+5e3QqoHOcIah07zFxWEHL7Obgn6xrbe+D0zdVKiHLToPtjub1N4gabd4X40YP5Ohh642/HAg== X-Google-Smtp-Source: AGHT+IFQKMjU3L5IntTOkisitDYRQcgGhQIvvNEua4AP/V0J3+//VXFn23OglvOjkrEePOmW3/Xv X-Received: by 2002:a05:6e02:1521:b0:365:1a2f:8271 with SMTP id i1-20020a056e02152100b003651a2f8271mr16262443ilu.3.1709057864140; Tue, 27 Feb 2024 10:17:44 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709057864; cv=pass; d=google.com; s=arc-20160816; b=exr+yA4UHIpUdBrXlwNjhHRSDaQX7MPIpbYMJpkdo1xjWbsLOdxLp5rngcQiDdkg0z ePxcCGJkyAlRJa1ElUQsk+HhSlM9aSmTVjQxIzQg6agJ5ZZILnniz9iI32MfWdKFmm1z UANmNMeSPcmCVqrDuSuLIRQhc4DTOMSJCO0OJf/ICNgcHGs0o+PF6lFvkA4BnbmqDesm F2DeaSI8INMHCaxWDO+aP7UmgUynVrjLbKQlj+24Ea2gSx8dd6646hjzcHdMkCWICgRw YBDeIN70VqgI19iOG/wqcNZ7Wm3O5acQdAUcezIdagonrNmhQY/Itu6ZxAZcmRz9i+6s j+KQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=5nY5/kk8s6fYr//Cj2FkdJCG5YE9u6hL2PBs6U9nryU=; fh=OvJRnOqsMTm9XoNmEwebcqh9Ud7yh1CTeKAP84ols98=; b=Wa+lBkL8+4sebuwdZQtAerTm0RJZlftboG+RGBplqXQd7NGjeo2PowBevg6DU/OBeb Ia9RV3nAwjGwkdROYOOLuAR4QU4wXIlc1hFtFeKiXmxgHUcy/JjPiBDu5LCyIAgW95zQ srjOtMrMJrx1V2RFhcqMMfAB1LPheak4BBOKuMs2cfSYxFphhDpWL0btDx9wB27tiHI9 mDhHBVfDtQD1pOPUCGQ5fyitx8BqdfhRnCXzvTD/lEDbKiXWchEO8vWjncqmqGR4Fhbg qIXNpF5uN0iEa/2pwTJrDN2HDVXPl5MTiJK/S6cfy6ZTsyIqTY0ngCrPzzR2DykixYFS OGlQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=DWzC+Ykj; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-83813-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-83813-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id c4-20020aa78c04000000b006e48a63f4ebsi5795528pfd.259.2024.02.27.10.17.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 10:17:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-83813-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=DWzC+Ykj; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-83813-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-83813-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 2AEA6289977 for ; Tue, 27 Feb 2024 18:17:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0D48914AD02; Tue, 27 Feb 2024 18:17:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="DWzC+Ykj" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.8]) (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 2BD97149019 for ; Tue, 27 Feb 2024 18:16:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.8 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709057821; cv=none; b=DtW1xHS810Lih68blssaGuienhlNrfDgcnYSuzNw1njIjAmHgi/IvWk0FKN2jZ4lmJCGfx88zjaZ8zlmMZUcq2aUSeQDA2GMLknvdAJmyJ85BVXnRW+SD6sfGX4F1YLjGakE6MqfI5pl+k4YzoLOSYpe6oeXDaEWpjsrKGHmEgo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709057821; c=relaxed/simple; bh=LcZSO2fCT5WaMkS6shCgOhCUo14EJT04WN8x+U0u+KI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=J0hTb4D1nrdnjgLl1LPEb/Sf6eXp61TkcSjTxhL93WunbJ1iW+rToAc8Pvq0qUTMXqqEzt5QPZu6CCvIEENxV1WfsDPlldOTJLWK+8AZD3fEr1/a0CN7PhIDUC5gamDwCMaODJjF4Mz46JYJyNx7Ohw+vVnP0OpjS7osD4RLZSE= 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=DWzC+Ykj; arc=none smtp.client-ip=192.198.163.8 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709057819; x=1740593819; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=LcZSO2fCT5WaMkS6shCgOhCUo14EJT04WN8x+U0u+KI=; b=DWzC+Ykja44apzKIOzANZucSoRvPq0hGEgOLhi3HZ8EH8rAw7APbleNY WA5Td4TPsZ7NewP+rCa8s4hPsClPk1BOVK76nepvFYJvLtTP5xZ+1+Q9m AlIyQL+3HJAWoQJHShmDoryAYC7NuPIsHIo/UvorrfQNXTbMxnxsaeyus s5IBYcdaTDYg0WTjHISURIQOrzaAhXAeQ6XZNRTdhv+u+qieLK6APBYrw RWA609DKFgTSlRalPGxsKFWO449QVihZCrbFBd0gLbIgo5EAEpDmn80a2 YpRbsO+2fFQgTpTaABEfobHTiyZOJ8YxXCKTUCYPtzm56LFwYAdfzOL7O g==; X-IronPort-AV: E=McAfee;i="6600,9927,10996"; a="20966093" X-IronPort-AV: E=Sophos;i="6.06,188,1705392000"; d="scan'208";a="20966093" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Feb 2024 10:16:30 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10996"; a="937032725" X-IronPort-AV: E=Sophos;i="6.06,188,1705392000"; d="scan'208";a="937032725" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 27 Feb 2024 10:16:26 -0800 Received: by black.fi.intel.com (Postfix, from userid 1000) id 7AAD94C5; Tue, 27 Feb 2024 20:16:19 +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/16] x86/kexec: Keep CR4.MCE set during kexec for TDX guest Date: Tue, 27 Feb 2024 20:16:05 +0200 Message-ID: <20240227181616.3032032-6-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240227181616.3032032-1-kirill.shutemov@linux.intel.com> References: <20240227181616.3032032-1-kirill.shutemov@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org 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