Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp6269459pxb; Thu, 27 Jan 2022 09:58:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJwEo6VYRL++VdhG1sM3I4ywOmz+q7sAxLe4p6Nbt4pFT3vZkazx0EAbEhAg4q26vtaGVS/v X-Received: by 2002:a17:906:c156:: with SMTP id dp22mr3795055ejc.240.1643306310708; Thu, 27 Jan 2022 09:58:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643306310; cv=none; d=google.com; s=arc-20160816; b=gHP5XzS145XQMW4AzFaA6tl8hrclPaifcyJ4I/aFytPoSzD4Ieaz240dkbitm8+7NF 6B6pS3ODsg+TxrBO/ezRcKhPbDE71rPZDWgcb8BqXyjKrJcIWevSTb4ry5ECG5YPYdK8 y4rN2oSsdSL0qjIN6yzvjRRrbmmrAbEKq5bilVfQchIAvCzBydxqfF7MvGZ/ZVCpLcOx yEra1SD3ijn68B+DVLO3fcPvnlT3oWtsf47e+tM8LoOXgLZxIDgys3+brcnU+GMgq2Q/ Fb5ucyme3cJ1SHzwoh2b0fwoBzYBLXH3GoSWSFXJOVQvq1apgDc4Kl1NjT6bUlmnrFrL w5kg== 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; bh=LGpntRxPTXesOeMJxhEJ8knkeQbGlf8k5Ttu6eNhaeA=; b=lAbGbx5PVjeBEl9jlSaotLhD0kmwSV6/veUoCHuSr+eflVCExB7eC/zwuNvdgewURM G8CTzdlMRLINq4tQQl3EuyZZEZ+xfBmXGxzk7r7pW2bvqOQK9Y08izp27GdXh50mJgg8 EuzbKj7bkkbZaeGBCvyoUll7d7l0Fq8ZjUEjG2aTt86pTXVeoSPcyCgpcFl5S9ufwIP2 aAzmOG1myBjRLMXwbBIB8AVpznWD5L90TYnJfFq2AQw0VmEUZki4yjVB2UteAGJxQgPV /nWa+LBNfyQxGC4TKHF16EYY1xziRmsV+cOswzQ99nToJLkzMj8WY7/H/JiA02EKJrOA fCMQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qa44si1619214ejc.6.2022.01.27.09.58.05; Thu, 27 Jan 2022 09:58:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239200AbiA0KLs (ORCPT + 99 others); Thu, 27 Jan 2022 05:11:48 -0500 Received: from 8bytes.org ([81.169.241.247]:48002 "EHLO theia.8bytes.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238978AbiA0KL0 (ORCPT ); Thu, 27 Jan 2022 05:11:26 -0500 Received: from cap.home.8bytes.org (p549ad610.dip0.t-ipconnect.de [84.154.214.16]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by theia.8bytes.org (Postfix) with ESMTPSA id C1787DB2; Thu, 27 Jan 2022 11:11:24 +0100 (CET) From: Joerg Roedel To: x86@kernel.org Cc: Joerg Roedel , Joerg Roedel , Eric Biederman , kexec@lists.infradead.org, hpa@zytor.com, Andy Lutomirski , Dave Hansen , Peter Zijlstra , Jiri Slaby , Dan Williams , Tom Lendacky , Juergen Gross , Kees Cook , David Rientjes , Cfir Cohen , Erdem Aktas , Masami Hiramatsu , Mike Stunes , Sean Christopherson , Martin Radev , Arvind Sankar , linux-coco@lists.linux.dev, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org Subject: [PATCH v3 10/10] x86/kexec/64: Support kexec under SEV-ES with AP Jump Table Blob Date: Thu, 27 Jan 2022 11:10:44 +0100 Message-Id: <20220127101044.13803-11-joro@8bytes.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220127101044.13803-1-joro@8bytes.org> References: <20220127101044.13803-1-joro@8bytes.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Joerg Roedel When the AP jump table blob is installed the kernel can hand over the APs from the old to the new kernel. Enable kexec when the AP jump table blob has been installed. Signed-off-by: Joerg Roedel --- arch/x86/include/asm/sev.h | 2 ++ arch/x86/kernel/machine_kexec_64.c | 3 ++- arch/x86/kernel/sev.c | 15 +++++++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/arch/x86/include/asm/sev.h b/arch/x86/include/asm/sev.h index e342dce3e7a1..41e07d037b6e 100644 --- a/arch/x86/include/asm/sev.h +++ b/arch/x86/include/asm/sev.h @@ -91,6 +91,7 @@ extern enum es_result sev_es_ghcb_hv_call(struct ghcb *ghcb, u64 exit_code, u64 exit_info_1, u64 exit_info_2); void sev_es_stop_this_cpu(void); +bool sev_kexec_supported(void); #else static inline void sev_es_ist_enter(struct pt_regs *regs) { } static inline void sev_es_ist_exit(void) { } @@ -98,6 +99,7 @@ static inline int sev_es_setup_ap_jump_table(struct real_mode_header *rmh) { ret static inline void sev_es_nmi_complete(void) { } static inline int sev_es_efi_map_ghcbs(pgd_t *pgd) { return 0; } static inline void sev_es_stop_this_cpu(void) { } +static inline bool sev_kexec_supported(void) { return true; } #endif #endif diff --git a/arch/x86/kernel/machine_kexec_64.c b/arch/x86/kernel/machine_kexec_64.c index 5079a75f8944..c58808fe3fb5 100644 --- a/arch/x86/kernel/machine_kexec_64.c +++ b/arch/x86/kernel/machine_kexec_64.c @@ -27,6 +27,7 @@ #include #include #include +#include #ifdef CONFIG_ACPI /* @@ -271,7 +272,7 @@ static void load_segments(void) static bool machine_kexec_supported(void) { - if (cc_platform_has(CC_ATTR_GUEST_STATE_ENCRYPT)) + if (!sev_kexec_supported()) return false; return true; diff --git a/arch/x86/kernel/sev.c b/arch/x86/kernel/sev.c index 1bced5b49150..17dcbcddd6ab 100644 --- a/arch/x86/kernel/sev.c +++ b/arch/x86/kernel/sev.c @@ -884,6 +884,21 @@ static int __init sev_setup_ap_jump_table(void) } core_initcall(sev_setup_ap_jump_table); +bool sev_kexec_supported(void) +{ + if (!cc_platform_has(CC_ATTR_GUEST_STATE_ENCRYPT)) + return true; + + /* + * KEXEC with SEV-ES and more than one CPU is only supported + * when the AP jump table is installed. + */ + if (num_possible_cpus() > 1) + return sev_ap_jumptable_blob_installed; + else + return true; +} + static void __init alloc_runtime_data(int cpu) { struct sev_es_runtime_data *data; -- 2.34.1