Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp522823lql; Mon, 11 Mar 2024 09:21:56 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV10mkli2eUZ03wdCGXaLNQGhVSPd0f2iaLlDCdcHhV+iUjTwt4G/iCqDJkhOL6WBoWIcR7eF31Jx/w2+TNTi4iS8JIl7W9aWr0SGTUDQ== X-Google-Smtp-Source: AGHT+IF7r7C0EHg4kLASGCnWd2SOSSZpNX1ktrX86LNnECDJKreWBCWT3ZsLiGKVK8WLtcK72PJA X-Received: by 2002:a05:6102:1957:b0:472:6df7:e56c with SMTP id jl23-20020a056102195700b004726df7e56cmr4040466vsb.30.1710174116276; Mon, 11 Mar 2024 09:21:56 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710174116; cv=pass; d=google.com; s=arc-20160816; b=tT3G2SqoHIddQGCIA+HiPQN6/pRYhx5H/65z+3hoVKwt0i+0/bI/Z0JUuSCCF7upGz Awdd2g70GrppLRfqqf5KGDJDWkZDfmBem+BJmp3HS+9tYi4D0PlAFD+O8BcDAiKwGH6S Osscz7O22MvWA9uyORb1lcTO87Os0ii1yEdZMkWurIfBIJML8C7aE2Nmzr7erlXwT3HC HY+sGmukMojXuFMbnTNjUvxjJ1smMrY/RMqAzUkfbzQ0LMMXLCdM8MgzF4NeZmIa32QI TG5DjcfYuxL8Cs9Ugs3Bo20kIBJsWmHWooYap+FsJh7ShBCxp0mT/XiB/Eb3O22bVDLQ 0s5Q== 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=ImRzpHgQ7+uutfuh8SJRk0DTE4K/6LtArW0nv9lfM+k=; fh=ySSiDpY7sLv13tnY47xjqYqHuzKiTUMTcpJQWU21k8k=; b=FTR5ywmUe9cUOOfB02qStrlLeb+fPjEKJhkZD41UMWrsXu7DeN3XV8mAkCZKV7dlZS MankOXnYLhyiZAiSaP3uABLiLK8oXdj/gq/tpRNHCj4aQrLTuNuybZPmVshGtNQgaQLa YJny+21IlOjP0nY1aal7zv4h2RJsE5fgbF+ReUSoOaPKP33ucDmsLUGLa8Gog/SPcXRW YwhXTgJ1HdnmBj2SP6bXT8xjafeTpqrhh22mItpDUPEux50SkKWFlk4ZgCi/XCK7R2i1 egmden+6zcoNP1X3GNI+UJ4H/fUPohhGmVAAmANd/DZQlOYlwBlSqpQLsw+SityKSbyK A99w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=DXuzGXTL; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-99212-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-99212-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id f14-20020a0562141d2e00b00690063e030esi5772129qvd.98.2024.03.11.09.21.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 09:21:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-99212-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=DXuzGXTL; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-99212-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-99212-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id D5B741C21ED6 for ; Mon, 11 Mar 2024 16:21:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1A62558213; Mon, 11 Mar 2024 16:17:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DXuzGXTL" Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8C05C56B85; Mon, 11 Mar 2024 16:17:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710173869; cv=none; b=tBOFqAKrWDF1hZ6AMAf1Z82e4RncVdG5s6Rf+EoBzkgPH560g0+SOxkV3JkpqNcQuesW+HnnoT07SEjY6uSozXg3zG0tFT+RfnXhJwl2kze9cySGw1XOV7g/Owr1vAayCzvhCB4PH++IXxONrbcp9sg7YOMcYLiYmSerkkPCqx8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710173869; c=relaxed/simple; bh=ruyWOEutbzTX21I1GbtMMknQjZcW/AmsekAFWxYC848=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=SxrQiH4Hvjj5rAqGuF30njOjwuApsi0iUxiLNEVLQlz45OOe+IDrdXaeaMTl3gRkXSNgwhPqs6+T96239Go+ZiZN3/Rxr6DdGxXfEli4yfYGM0jmS28Mrf0NG8fkvocEa+bMjO4cm8rx6Chwl8OpakUg72rjD8OizCBGAr4aOY0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=DXuzGXTL; arc=none smtp.client-ip=209.85.221.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-33e7ae72312so2690224f8f.1; Mon, 11 Mar 2024 09:17:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710173866; x=1710778666; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ImRzpHgQ7+uutfuh8SJRk0DTE4K/6LtArW0nv9lfM+k=; b=DXuzGXTLwNXREXvwONtgEqoG4t9uQ/1EkX0ek2WbQgwBx9M+lDtkdpBgZ0DOfCxXhD 0JhH55g00qQLe4SR8rvAGwC85lI3vjE8C6+tNyw+NcYr5+lROMgiitqbSanW5wVTtmF7 9D9Tc3TELUqFlOQlRP0XOdGQa8WvHmdFWNOmdtoLJVtLDUoG1Q0isVxgmkEDiHTCOq+5 QZY97HmxuUsSYdzr6COZ6TP4rcZYpwowVzp7YqyJrhyFuTQpvEdF+TZbLMwrMP8yMhG0 EFSL8uqCSoIVVkVnizh0USUO+wZEnLPSLf7ZJWySKNPkVtFlerFwCngilcS4wbBvQ1ch UgFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710173866; x=1710778666; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ImRzpHgQ7+uutfuh8SJRk0DTE4K/6LtArW0nv9lfM+k=; b=hHOs0nBGGYLXhd6KRJY2fEFTA9Gj0Rw/WZ9+rYrEBSErm1luX5WG7mvkvOIHtxNwhD u2HQHBCV3IIDWNMnXi/cwYsoErtjzRSV94TQVsT/M7LoZVNMrGsqlM1XH/2imZZlB0oY w9h+5yyM8myTlgGTHidXInvy1Fy/4JahG4nFZUK1ViNFUq0NnwMCD8x43WQQKxgSGlRP gFLr+DJdgUzo8+SHYuByk06kHBBhkTkBZ97MLmsE5bkEAIgGPVtM0WMJbxXKMl6MSHhV VdnI1mvNvEpouiUh7Rgg90THgg5EAlhdwEQlHdSB80uRsjglmY3+IjHUIM8fxtcfHTrq tYRw== X-Forwarded-Encrypted: i=1; AJvYcCVPkC9tkJlRJ8Qg9b49Ti7Vv4R/HkjvawxOABXI/M0jKCWkdsddqwL1CLuKqzdBX2yijZp/7VkiROj8kj3Dakz7GlvBqQ8uJwKnPT1Ti2+zkhN0RHU61d/Wi0eYeiOqiQR8uNDX3EJSN9OQ4RmJYH5SRDSSZGY1y0aT X-Gm-Message-State: AOJu0YwUTZl8sfV+e3CUtjnyvIXbpeWDsImGOHn9ryOEwBb92e4KVAGQ WH5OV09aeJac+Jui0FxAnc/QiNAO8T5rwFGDvPGE/vr9ZbqiFIvP X-Received: by 2002:a5d:6611:0:b0:33e:5a33:b169 with SMTP id n17-20020a5d6611000000b0033e5a33b169mr4250288wru.28.1710173865721; Mon, 11 Mar 2024 09:17:45 -0700 (PDT) Received: from vasant-suse.suse.cz ([2001:9e8:ab47:8200:c3b9:43af:f8e1:76f9]) by smtp.gmail.com with ESMTPSA id ba14-20020a0560001c0e00b0033e96fe9479sm2823815wrb.89.2024.03.11.09.17.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 09:17:45 -0700 (PDT) From: Vasant Karasulli To: x86@kernel.org Cc: joro@8bytes.org, cfir@google.com, dan.j.williams@intel.com, dave.hansen@linux.intel.com, ebiederm@xmission.com, erdemaktas@google.com, hpa@zytor.com, jgross@suse.com, jslaby@suse.cz, keescook@chromium.org, kexec@lists.infradead.org, kvm@vger.kernel.org, linux-coco@lists.linux.dev, linux-kernel@vger.kernel.org, luto@kernel.org, martin.b.radev@gmail.com, mhiramat@kernel.org, mstunes@vmware.com, nivedita@alum.mit.edu, peterz@infradead.org, rientjes@google.com, seanjc@google.com, stable@vger.kernel.org, thomas.lendacky@amd.com, virtualization@lists.linux-foundation.org, Joerg Roedel , Vasant Karasulli Subject: [PATCH v4 9/9] x86/kexec/64: Support kexec under SEV-ES with AP Jump Table Blob Date: Mon, 11 Mar 2024 17:17:27 +0100 Message-Id: <20240311161727.14916-10-vsntk18@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240311161727.14916-1-vsntk18@gmail.com> References: <20240311161727.14916-1-vsntk18@gmail.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 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 Signed-off-by: Vasant Karasulli --- 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 2dbd2238325a..26027083a2a9 100644 --- a/arch/x86/include/asm/sev.h +++ b/arch/x86/include/asm/sev.h @@ -217,6 +217,7 @@ void snp_accept_memory(phys_addr_t start, phys_addr_t end); u64 snp_get_unsupported_features(u64 status); u64 sev_get_status(void); 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) { } @@ -246,6 +247,7 @@ static inline void snp_accept_memory(phys_addr_t start, phys_addr_t end) { } static inline u64 snp_get_unsupported_features(u64 status) { return 0; } static inline u64 sev_get_status(void) { 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 3671ea1a5045..6013ba6fc16e 100644 --- a/arch/x86/kernel/machine_kexec_64.c +++ b/arch/x86/kernel/machine_kexec_64.c @@ -28,6 +28,7 @@ #include #include #include +#include #ifdef CONFIG_ACPI /* @@ -269,7 +270,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 73477eeb7de2..66e85b82d170 100644 --- a/arch/x86/kernel/sev.c +++ b/arch/x86/kernel/sev.c @@ -1456,6 +1456,21 @@ static void __init sev_es_setup_play_dead(void) static inline void sev_es_setup_play_dead(void) { } #endif +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