From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.72 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796399334; b=CmQZwI9w8feDRM+4oy7fNeWEzb2I4lx/IQ69CGY2AC7UMT21cQyLH/n+rZaq14rtbzRv QYS+YEcaBhLVwCqdD9V8e9uO93wsJRcf87egqpui3GGJ/nl0JgrojQx3BIL0Z9Ijlr4I0 0Hh/QlV+2ssMckftaMEAgSSWMPcdgWP6m9Gc4RAnhfwjMPDLKF88p8NToAM63w4NOQ4L8 Pb9sylZYZNpB2rIYo+O3dwY7oYkj4eNCHimG8bhBIdtEGONe6NgXi9szyrSWn6gNDlU62 cSRYk5uzFG+TBZeD9zHJRW4ScXT1jfFbodvumBg5/uknNudwQ6QOEih0KmM5F7MVVIA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796399334; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Received:Date:In-Reply-To:Mime-Version: References:X-Developer-Key:X-Developer-Signature:X-Mailer:Message-ID: Subject:From:To:Cc:Content-Type; bh=SJLv1Vlvp4/QzxwyVytvTnU8oKgp0GK4Ks9OxYbcCsU=; b=3fPm5zSs7PQ7et4fVp4zG9PubGWh+XW2ecC22PwRvVaAEb4LlTgmljcJxHS873K2DDZ2 RotPo5Av4y1253p9uEvDfMxNHNi6VdEsV3uJUBF1oS5ANCmROswlarDttFYsN+Jaf1bdi 9fX3MtWB1k+IWLPNKi+fS84dP+eklXyjKKh6PWTD2t/tM4YKvDw+KQC3GXStQN4kXprHI snGYbO/VLjFWp2BsLRANvmFN4FFZ7zWBkx7u+HXd4anvY76dhGGGUktygrvcHCBNbzh13 2NdRtviMRnfuaZzE6Ov8c6+M28MeMJcB0o95WfOWqiZevvxb7DD9JTmU+gnhbprMkQg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=flex--ardb.bounces.google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=pgKXQKfl; arc=none smtp.remote-ip=209.85.128.72 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B065B606A322 for ; Fri, 4 Dec 2026 15:48:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B065B606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--ardb.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=pgKXQKfl Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-4bb64c99bb8so9759915e9.1 for ; Fri, 04 Dec 2026 07:48:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796399332; x=1797004132; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=SJLv1Vlvp4/QzxwyVytvTnU8oKgp0GK4Ks9OxYbcCsU=; b=pgKXQKflDLfX5mN6nbKaAQrrIUB4dNNMmQyI1ccCTWBMdqpmTXUxB0bYT2APHDgcy6 yiIT9zbJQtyNTuekmatQbsiWACUkVehjJDvBM4iHfKq1S7BkH4O5QGF2izrBS9UT+hQH awlC7a2KnxkNE2XRVKvV6WisUwR+D9RuxHZbeDgfQw/JV7p9laiPPCid4AJasoQlL6Hg tixIRIPVoCMJOvuCM9pZcjMRKTpysaJupL1ziBAh9kR/SLoyxRdnEnPSSrVCRcLQt6Uf WNFMeFUg4oV2QDo5rBQhXqt/i8/oHdbX4Mw1rvdZ194CACX6TJr0CEITLklrWJ4WyxoT Xcpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796399332; x=1797004132; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=SJLv1Vlvp4/QzxwyVytvTnU8oKgp0GK4Ks9OxYbcCsU=; b=ovYprkJen/XgoQF3ijnJhA9lY8SSw+jm9+k7yrBjS0pkMGbBPSwhEh4pxy3tR1Z9uc 3w9HY0QAQttwPv5o1Ony+yj5mijk0SWL0LpZbqDDtEFzZy4STSLkQUGVCUi+RZEGG3D1 NuASSwBWlLX6S2lm5UZjJH8m+YG4zW0D+69sDX67t2FDLXOiZhii8kZ5nKIOShHKroMn WKVsMs7yIHIO8Psl8xvbTqhSyY67RB6LYpL8To5ZJnQmbt5nR59BttNXXUu5GJbZOrq4 ksgegxJ8sAQy4mcbs/ooopn7FDv4/QVpEob9VhZ9BbPVUm2SJYaUk4Efu7MJi2mgOWAv cB3w== X-Gm-Message-State: APuU4Z+P9hsmjskU1MVB8h3+JVhWpGFpgOq25cjSBGad26pzM0sC7EZT aiyzTj6Qdw92HSpuDljRAdPdLLeGee/vJpYFzJCS5rhaDMSA18sGg6a2+WWsDrB9v9ObvqNM/5k NtAIGUaK8Wtcw9noCPI7A9MkPTxoI5lw0vS2KbDaSnfmKR+NUOAqWXHyGC4nJVdL8ydjuLW3lj0 klIl4c7XatxFJ5UZvJBkzrM5p/lYRT/g== X-Received: from wrrs5.prod.google.com ([2002:a5d:4245:0:b0:48e:3465:b63e]) (user=ardb job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:348f:b0:4a3:5aea:21e5 with SMTP id 5b1f17b1804b1-4bbeb84ccc3mr41883665e9.9.1796399331536; Fri, 04 Dec 2026 07:48:51 -0800 (PST) Date: Fri, 4 Dec 2026 16:48:44 +0100 In-Reply-To: <20261204154842.414894-5-ardb+git@google.com> X-Mailing-List: linux-efi@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 References: <20261204154842.414894-5-ardb+git@google.com> X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 X-Developer-Signature: v=1; a=openpgp-sha256; l=2655; i=ardb@kernel.org; h=from:subject; bh=NlAZ836F/kUtNwJConHsHDQ52VYksGg4gWDQKu2eZu0=; b=owGbwMvMwCVmkMcZplerG8N4Wi2JIVvowZ1Pp7Ospyz5sX6y0MS4LXNbz00+qZB1/NrU+fWHj 2vkubeZdJSyMIhxMciKKbIIzP77bufpiVK1zrNkYeawMoEMYeDiFICJqCswMvwPrX+i12nasFNI elbyEaFpv1rD1+RW9swybKnVmMl0vICR4Z1kyZVPf3/OXzn5qlLPZTuTOTrvHV9Nurt375N/6Qx zYvkA X-Mailer: git-send-email 2.56.1.915.g69d5ec7298-goog Message-ID: <20261204154842.414894-6-ardb+git@google.com> Subject: [PATCH v2 1/3] x86/efistub: Obtain SEV CC blob address from the stub From: Ard Biesheuvel To: linux-efi@vger.kernel.org Cc: Ard Biesheuvel , Borislav Petkov , Tom Lendacky , Ashish Kalra Content-Type: text/plain; charset="UTF-8" From: Ard Biesheuvel The x86 EFI stub no longer boots the core kernel via the traditional decompressor but jumps straight to it, avoiding all the page fault handling and other complexity that is entirely unnecessary when booting via EFI, which guarantees that all system memory is mapped 1:1. The SEV startup code in the core kernel expects the address of the CC blob configuration table in boot_params, so store it there when booting from EFI with SEV-SNP enabled. This removes the need to call sev_enable() from the EFI stub. Clear the field unconditionally first, so that uninitialized values passed by buggy boot loaders are not propagated, as the decompressor does in sev_enable(). (See commit 4b1c74240757 ("x86/boot: Don't propagate uninitialized boot_params->cc_blob_address")) Signed-off-by: Ard Biesheuvel --- drivers/firmware/efi/libstub/x86-stub.c | 28 ++++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/drivers/firmware/efi/libstub/x86-stub.c b/drivers/firmware/efi/libstub/x86-stub.c index 253dd3ba8fab..1cceab57a738 100644 --- a/drivers/firmware/efi/libstub/x86-stub.c +++ b/drivers/firmware/efi/libstub/x86-stub.c @@ -786,17 +786,35 @@ static efi_status_t exit_boot(struct boot_params *boot_params, void *handle) return EFI_SUCCESS; } -static bool have_unsupported_snp_features(void) +static bool check_snp_features(struct boot_params *bp) { + u64 status = sev_get_status(); u64 unsupported; - unsupported = snp_get_unsupported_features(sev_get_status()); + /* + * bp->cc_blob_address should only be set by the EFI stub or the + * decompressor. Initialize it to 0 to ensure that uninitialized values + * from buggy bootloaders aren't propagated. + */ + bp->cc_blob_address = 0; + + unsupported = snp_get_unsupported_features(status); if (unsupported) { efi_err("Unsupported SEV-SNP features detected: 0x%llx\n", unsupported); - return true; + return false; } - return false; + + if (status & MSR_AMD64_SEV_SNP_ENABLED) { + void *tbl = get_efi_config_table(EFI_CC_BLOB_GUID); + + if (!tbl) { + efi_err("SEV-SNP is enabled but CC blob not found\n"); + return false; + } + bp->cc_blob_address = (u32)(unsigned long)tbl; + } + return true; } static void efi_get_seed(void *seed, int size) @@ -937,7 +955,7 @@ void __noreturn efi_stub_entry(efi_handle_t handle, hdr = &boot_params->hdr; - if (have_unsupported_snp_features()) + if (!check_snp_features(boot_params)) efi_exit(handle, EFI_UNSUPPORTED); if (IS_ENABLED(CONFIG_EFI_DXE_MEM_ATTRIBUTES)) { -- 2.56.1.915.g69d5ec7298-goog