From: Ard Biesheuvel <ardb@kernel.org>
Provide PIC aliases for data objects that are shared between the SEV
startup code and the SEV code that executes later. This is needed so
that the confined startup code is permitted to access them.
This requires some of these variables to be moved into a source file
that is not part of the startup code, as the PIC alias is already
implied, and exporting variables in the opposite direction is not
supported.
Move ghcb_version as well, but don't provide a PIC alias as it is not
actually needed.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
arch/x86/boot/compressed/sev.c | 3 ++
arch/x86/boot/startup/sev-shared.c | 19 -----------
arch/x86/boot/startup/sev-startup.c | 9 ------
arch/x86/coco/sev/core.c | 34 ++++++++++++++++++++
4 files changed, 37 insertions(+), 28 deletions(-)
diff --git a/arch/x86/boot/compressed/sev.c b/arch/x86/boot/compressed/sev.c
index d650a314143b..6822eb4b9152 100644
--- a/arch/x86/boot/compressed/sev.c
+++ b/arch/x86/boot/compressed/sev.c
@@ -38,6 +38,9 @@ struct ghcb *boot_ghcb;
#define __BOOT_COMPRESSED
u8 snp_vmpl;
+u16 ghcb_version;
+
+u64 boot_svsm_caa_pa;
/* Include code for early handlers */
#include "../../boot/startup/sev-shared.c"
diff --git a/arch/x86/boot/startup/sev-shared.c b/arch/x86/boot/startup/sev-shared.c
index b86027d9a968..180f54570022 100644
--- a/arch/x86/boot/startup/sev-shared.c
+++ b/arch/x86/boot/startup/sev-shared.c
@@ -19,25 +19,6 @@
#define WARN(condition, format...) (!!(condition))
#endif
-/*
- * SVSM related information:
- * During boot, the page tables are set up as identity mapped and later
- * changed to use kernel virtual addresses. Maintain separate virtual and
- * physical addresses for the CAA to allow SVSM functions to be used during
- * early boot, both with identity mapped virtual addresses and proper kernel
- * virtual addresses.
- */
-u64 boot_svsm_caa_pa __ro_after_init;
-
-/*
- * Since feature negotiation related variables are set early in the boot
- * process they must reside in the .data section so as not to be zeroed
- * out when the .bss section is later cleared.
- *
- * GHCB protocol version negotiated with the hypervisor.
- */
-u16 ghcb_version __ro_after_init;
-
/* Copy of the SNP firmware's CPUID page. */
static struct snp_cpuid_table cpuid_table_copy __ro_after_init;
diff --git a/arch/x86/boot/startup/sev-startup.c b/arch/x86/boot/startup/sev-startup.c
index b0fc63f8dee1..138b26f14ff1 100644
--- a/arch/x86/boot/startup/sev-startup.c
+++ b/arch/x86/boot/startup/sev-startup.c
@@ -41,15 +41,6 @@
#include <asm/cpuid/api.h>
#include <asm/cmdline.h>
-/* Bitmap of SEV features supported by the hypervisor */
-u64 sev_hv_features __ro_after_init;
-
-/* Secrets page physical address from the CC blob */
-u64 sev_secrets_pa __ro_after_init;
-
-/* For early boot SVSM communication */
-struct svsm_ca boot_svsm_ca_page __aligned(PAGE_SIZE);
-
/*
* Nothing shall interrupt this code path while holding the per-CPU
* GHCB. The backup GHCB is only for NMIs interrupting this path.
diff --git a/arch/x86/coco/sev/core.c b/arch/x86/coco/sev/core.c
index 9782ebe30675..b9133c825f90 100644
--- a/arch/x86/coco/sev/core.c
+++ b/arch/x86/coco/sev/core.c
@@ -46,6 +46,29 @@
#include <asm/cmdline.h>
#include <asm/msr.h>
+/* Bitmap of SEV features supported by the hypervisor */
+u64 sev_hv_features __ro_after_init;
+SYM_PIC_ALIAS(sev_hv_features);
+
+/* Secrets page physical address from the CC blob */
+u64 sev_secrets_pa __ro_after_init;
+SYM_PIC_ALIAS(sev_secrets_pa);
+
+/* For early boot SVSM communication */
+struct svsm_ca boot_svsm_ca_page __aligned(PAGE_SIZE);
+SYM_PIC_ALIAS(boot_svsm_ca_page);
+
+/*
+ * SVSM related information:
+ * During boot, the page tables are set up as identity mapped and later
+ * changed to use kernel virtual addresses. Maintain separate virtual and
+ * physical addresses for the CAA to allow SVSM functions to be used during
+ * early boot, both with identity mapped virtual addresses and proper kernel
+ * virtual addresses.
+ */
+u64 boot_svsm_caa_pa __ro_after_init;
+SYM_PIC_ALIAS(boot_svsm_caa_pa);
+
DEFINE_PER_CPU(struct svsm_ca *, svsm_caa);
DEFINE_PER_CPU(u64, svsm_caa_pa);
@@ -119,6 +142,17 @@ DEFINE_PER_CPU(struct sev_es_save_area *, sev_vmsa);
*/
u8 snp_vmpl __ro_after_init;
EXPORT_SYMBOL_GPL(snp_vmpl);
+SYM_PIC_ALIAS(snp_vmpl);
+
+/*
+ * Since feature negotiation related variables are set early in the boot
+ * process they must reside in the .data section so as not to be zeroed
+ * out when the .bss section is later cleared.
+ *
+ * GHCB protocol version negotiated with the hypervisor.
+ */
+u16 ghcb_version __ro_after_init;
+SYM_PIC_ALIAS(ghcb_version);
/* For early boot hypervisor communication in SEV-ES enabled guests */
static struct ghcb boot_ghcb_page __bss_decrypted __aligned(PAGE_SIZE);
--
2.51.0.268.g9569e192d0-goog
On Thu, Aug 28, 2025 at 12:22:15PM +0200, Ard Biesheuvel wrote:
> From: Ard Biesheuvel <ardb@kernel.org>
>
> Provide PIC aliases for data objects that are shared between the SEV
> startup code and the SEV code that executes later. This is needed so
> that the confined startup code is permitted to access them.
>
> This requires some of these variables to be moved into a source file
> that is not part of the startup code, as the PIC alias is already
> implied, and exporting variables in the opposite direction is not
> supported.
>
> Move ghcb_version as well, but don't provide a PIC alias as it is not
> actually needed.
I see
SYM_PIC_ALIAS(ghcb_version);
below.
Stale commit message?
>
> Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
> ---
> arch/x86/boot/compressed/sev.c | 3 ++
> arch/x86/boot/startup/sev-shared.c | 19 -----------
> arch/x86/boot/startup/sev-startup.c | 9 ------
> arch/x86/coco/sev/core.c | 34 ++++++++++++++++++++
> 4 files changed, 37 insertions(+), 28 deletions(-)
>
> diff --git a/arch/x86/boot/compressed/sev.c b/arch/x86/boot/compressed/sev.c
> index d650a314143b..6822eb4b9152 100644
> --- a/arch/x86/boot/compressed/sev.c
> +++ b/arch/x86/boot/compressed/sev.c
> @@ -38,6 +38,9 @@ struct ghcb *boot_ghcb;
> #define __BOOT_COMPRESSED
>
> u8 snp_vmpl;
> +u16 ghcb_version;
> +
> +u64 boot_svsm_caa_pa;
>
> /* Include code for early handlers */
> #include "../../boot/startup/sev-shared.c"
> diff --git a/arch/x86/boot/startup/sev-shared.c b/arch/x86/boot/startup/sev-shared.c
> index b86027d9a968..180f54570022 100644
> --- a/arch/x86/boot/startup/sev-shared.c
> +++ b/arch/x86/boot/startup/sev-shared.c
> @@ -19,25 +19,6 @@
> #define WARN(condition, format...) (!!(condition))
> #endif
>
> -/*
> - * SVSM related information:
> - * During boot, the page tables are set up as identity mapped and later
> - * changed to use kernel virtual addresses. Maintain separate virtual and
> - * physical addresses for the CAA to allow SVSM functions to be used during
> - * early boot, both with identity mapped virtual addresses and proper kernel
> - * virtual addresses.
> - */
> -u64 boot_svsm_caa_pa __ro_after_init;
> -
> -/*
> - * Since feature negotiation related variables are set early in the boot
> - * process they must reside in the .data section so as not to be zeroed
> - * out when the .bss section is later cleared.
> - *
> - * GHCB protocol version negotiated with the hypervisor.
> - */
> -u16 ghcb_version __ro_after_init;
> -
> /* Copy of the SNP firmware's CPUID page. */
> static struct snp_cpuid_table cpuid_table_copy __ro_after_init;
>
> diff --git a/arch/x86/boot/startup/sev-startup.c b/arch/x86/boot/startup/sev-startup.c
> index b0fc63f8dee1..138b26f14ff1 100644
> --- a/arch/x86/boot/startup/sev-startup.c
> +++ b/arch/x86/boot/startup/sev-startup.c
> @@ -41,15 +41,6 @@
> #include <asm/cpuid/api.h>
> #include <asm/cmdline.h>
>
> -/* Bitmap of SEV features supported by the hypervisor */
> -u64 sev_hv_features __ro_after_init;
> -
> -/* Secrets page physical address from the CC blob */
> -u64 sev_secrets_pa __ro_after_init;
> -
> -/* For early boot SVSM communication */
> -struct svsm_ca boot_svsm_ca_page __aligned(PAGE_SIZE);
> -
> /*
> * Nothing shall interrupt this code path while holding the per-CPU
> * GHCB. The backup GHCB is only for NMIs interrupting this path.
> diff --git a/arch/x86/coco/sev/core.c b/arch/x86/coco/sev/core.c
> index 9782ebe30675..b9133c825f90 100644
> --- a/arch/x86/coco/sev/core.c
> +++ b/arch/x86/coco/sev/core.c
> @@ -46,6 +46,29 @@
> #include <asm/cmdline.h>
> #include <asm/msr.h>
>
> +/* Bitmap of SEV features supported by the hypervisor */
> +u64 sev_hv_features __ro_after_init;
> +SYM_PIC_ALIAS(sev_hv_features);
> +
> +/* Secrets page physical address from the CC blob */
> +u64 sev_secrets_pa __ro_after_init;
> +SYM_PIC_ALIAS(sev_secrets_pa);
> +
> +/* For early boot SVSM communication */
> +struct svsm_ca boot_svsm_ca_page __aligned(PAGE_SIZE);
> +SYM_PIC_ALIAS(boot_svsm_ca_page);
> +
> +/*
> + * SVSM related information:
> + * During boot, the page tables are set up as identity mapped and later
> + * changed to use kernel virtual addresses. Maintain separate virtual and
> + * physical addresses for the CAA to allow SVSM functions to be used during
> + * early boot, both with identity mapped virtual addresses and proper kernel
> + * virtual addresses.
> + */
> +u64 boot_svsm_caa_pa __ro_after_init;
> +SYM_PIC_ALIAS(boot_svsm_caa_pa);
> +
> DEFINE_PER_CPU(struct svsm_ca *, svsm_caa);
> DEFINE_PER_CPU(u64, svsm_caa_pa);
>
> @@ -119,6 +142,17 @@ DEFINE_PER_CPU(struct sev_es_save_area *, sev_vmsa);
> */
> u8 snp_vmpl __ro_after_init;
> EXPORT_SYMBOL_GPL(snp_vmpl);
> +SYM_PIC_ALIAS(snp_vmpl);
> +
> +/*
> + * Since feature negotiation related variables are set early in the boot
> + * process they must reside in the .data section so as not to be zeroed
> + * out when the .bss section is later cleared.
> + *
> + * GHCB protocol version negotiated with the hypervisor.
> + */
> +u16 ghcb_version __ro_after_init;
> +SYM_PIC_ALIAS(ghcb_version);
>
> /* For early boot hypervisor communication in SEV-ES enabled guests */
> static struct ghcb boot_ghcb_page __bss_decrypted __aligned(PAGE_SIZE);
> --
> 2.51.0.268.g9569e192d0-goog
>
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
On Tue, 2 Sept 2025 at 14:07, Borislav Petkov <bp@alien8.de> wrote: > > On Thu, Aug 28, 2025 at 12:22:15PM +0200, Ard Biesheuvel wrote: > > From: Ard Biesheuvel <ardb@kernel.org> > > > > Provide PIC aliases for data objects that are shared between the SEV > > startup code and the SEV code that executes later. This is needed so > > that the confined startup code is permitted to access them. > > > > This requires some of these variables to be moved into a source file > > that is not part of the startup code, as the PIC alias is already > > implied, and exporting variables in the opposite direction is not > > supported. > > > > Move ghcb_version as well, but don't provide a PIC alias as it is not > > actually needed. > > I see > > SYM_PIC_ALIAS(ghcb_version); > > below. > > Stale commit message? > Yes, as a result of https://lore.kernel.org/all/20250530165507.GBaDni69NqgOi4mFNn@fat_crate.local/ it was exported but I failed to update the commit log accordingly.
On Tue, Sep 02, 2025 at 02:24:31PM +0200, Ard Biesheuvel wrote:
> it was exported but I failed to update the commit log accordingly.
Ack, zapped commit message sentence locally.
Thx.
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
The following commit has been merged into the x86/sev branch of tip:
Commit-ID: 9723dd0c705eb626bac2cd06b83a2c8514ed697a
Gitweb: https://git.kernel.org/tip/9723dd0c705eb626bac2cd06b83a2c8514ed697a
Author: Ard Biesheuvel <ardb@kernel.org>
AuthorDate: Thu, 28 Aug 2025 12:22:15 +02:00
Committer: Borislav Petkov (AMD) <bp@alien8.de>
CommitterDate: Wed, 03 Sep 2025 17:59:43 +02:00
x86/sev: Provide PIC aliases for SEV related data objects
Provide PIC aliases for data objects that are shared between the SEV startup
code and the SEV code that executes later. This is needed so that the confined
startup code is permitted to access them.
This requires some of these variables to be moved into a source file that is
not part of the startup code, as the PIC alias is already implied, and
exporting variables in the opposite direction is not supported.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://lore.kernel.org/20250828102202.1849035-36-ardb+git@google.com
---
arch/x86/boot/compressed/sev.c | 3 ++-
arch/x86/boot/startup/sev-shared.c | 19 +----------------
arch/x86/boot/startup/sev-startup.c | 9 +-------
arch/x86/coco/sev/core.c | 34 ++++++++++++++++++++++++++++-
4 files changed, 37 insertions(+), 28 deletions(-)
diff --git a/arch/x86/boot/compressed/sev.c b/arch/x86/boot/compressed/sev.c
index 26aa389..a5e002f 100644
--- a/arch/x86/boot/compressed/sev.c
+++ b/arch/x86/boot/compressed/sev.c
@@ -38,6 +38,9 @@ struct ghcb *boot_ghcb;
#define __BOOT_COMPRESSED
u8 snp_vmpl;
+u16 ghcb_version;
+
+u64 boot_svsm_caa_pa;
/* Include code for early handlers */
#include "../../boot/startup/sev-shared.c"
diff --git a/arch/x86/boot/startup/sev-shared.c b/arch/x86/boot/startup/sev-shared.c
index fb86f03..2a28463 100644
--- a/arch/x86/boot/startup/sev-shared.c
+++ b/arch/x86/boot/startup/sev-shared.c
@@ -19,25 +19,6 @@
#define WARN(condition, format...) (!!(condition))
#endif
-/*
- * SVSM related information:
- * During boot, the page tables are set up as identity mapped and later
- * changed to use kernel virtual addresses. Maintain separate virtual and
- * physical addresses for the CAA to allow SVSM functions to be used during
- * early boot, both with identity mapped virtual addresses and proper kernel
- * virtual addresses.
- */
-u64 boot_svsm_caa_pa __ro_after_init;
-
-/*
- * Since feature negotiation related variables are set early in the boot
- * process they must reside in the .data section so as not to be zeroed
- * out when the .bss section is later cleared.
- *
- * GHCB protocol version negotiated with the hypervisor.
- */
-u16 ghcb_version __ro_after_init;
-
/* Copy of the SNP firmware's CPUID page. */
static struct snp_cpuid_table cpuid_table_copy __ro_after_init;
diff --git a/arch/x86/boot/startup/sev-startup.c b/arch/x86/boot/startup/sev-startup.c
index b0fc63f..138b26f 100644
--- a/arch/x86/boot/startup/sev-startup.c
+++ b/arch/x86/boot/startup/sev-startup.c
@@ -41,15 +41,6 @@
#include <asm/cpuid/api.h>
#include <asm/cmdline.h>
-/* Bitmap of SEV features supported by the hypervisor */
-u64 sev_hv_features __ro_after_init;
-
-/* Secrets page physical address from the CC blob */
-u64 sev_secrets_pa __ro_after_init;
-
-/* For early boot SVSM communication */
-struct svsm_ca boot_svsm_ca_page __aligned(PAGE_SIZE);
-
/*
* Nothing shall interrupt this code path while holding the per-CPU
* GHCB. The backup GHCB is only for NMIs interrupting this path.
diff --git a/arch/x86/coco/sev/core.c b/arch/x86/coco/sev/core.c
index 9782ebe..b9133c8 100644
--- a/arch/x86/coco/sev/core.c
+++ b/arch/x86/coco/sev/core.c
@@ -46,6 +46,29 @@
#include <asm/cmdline.h>
#include <asm/msr.h>
+/* Bitmap of SEV features supported by the hypervisor */
+u64 sev_hv_features __ro_after_init;
+SYM_PIC_ALIAS(sev_hv_features);
+
+/* Secrets page physical address from the CC blob */
+u64 sev_secrets_pa __ro_after_init;
+SYM_PIC_ALIAS(sev_secrets_pa);
+
+/* For early boot SVSM communication */
+struct svsm_ca boot_svsm_ca_page __aligned(PAGE_SIZE);
+SYM_PIC_ALIAS(boot_svsm_ca_page);
+
+/*
+ * SVSM related information:
+ * During boot, the page tables are set up as identity mapped and later
+ * changed to use kernel virtual addresses. Maintain separate virtual and
+ * physical addresses for the CAA to allow SVSM functions to be used during
+ * early boot, both with identity mapped virtual addresses and proper kernel
+ * virtual addresses.
+ */
+u64 boot_svsm_caa_pa __ro_after_init;
+SYM_PIC_ALIAS(boot_svsm_caa_pa);
+
DEFINE_PER_CPU(struct svsm_ca *, svsm_caa);
DEFINE_PER_CPU(u64, svsm_caa_pa);
@@ -119,6 +142,17 @@ DEFINE_PER_CPU(struct sev_es_save_area *, sev_vmsa);
*/
u8 snp_vmpl __ro_after_init;
EXPORT_SYMBOL_GPL(snp_vmpl);
+SYM_PIC_ALIAS(snp_vmpl);
+
+/*
+ * Since feature negotiation related variables are set early in the boot
+ * process they must reside in the .data section so as not to be zeroed
+ * out when the .bss section is later cleared.
+ *
+ * GHCB protocol version negotiated with the hypervisor.
+ */
+u16 ghcb_version __ro_after_init;
+SYM_PIC_ALIAS(ghcb_version);
/* For early boot hypervisor communication in SEV-ES enabled guests */
static struct ghcb boot_ghcb_page __bss_decrypted __aligned(PAGE_SIZE);
© 2016 - 2026 Red Hat, Inc.