[PATCH 1/3] x86/sev: Move the internal header

Borislav Petkov posted 3 patches 2 weeks, 1 day ago
[PATCH 1/3] x86/sev: Move the internal header
Posted by Borislav Petkov 2 weeks, 1 day ago
From: "Borislav Petkov (AMD)" <bp@alien8.de>

Move the internal header out of the usual include/asm/ include path
because having an "internal" header there doesn't really make it so
- quite the opposite.

So move where it belongs and make it really internal.

No functional changes.

Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
---
 arch/x86/boot/startup/sev-startup.c                          | 3 ++-
 arch/x86/coco/sev/core.c                                     | 3 ++-
 arch/x86/{include/asm/sev-internal.h => coco/sev/internal.h} | 0
 arch/x86/coco/sev/noinstr.c                                  | 3 ++-
 arch/x86/coco/sev/vc-handle.c                                | 3 ++-
 5 files changed, 8 insertions(+), 4 deletions(-)
 rename arch/x86/{include/asm/sev-internal.h => coco/sev/internal.h} (100%)

diff --git a/arch/x86/boot/startup/sev-startup.c b/arch/x86/boot/startup/sev-startup.c
index 09725428d3e6..1115214429fd 100644
--- a/arch/x86/boot/startup/sev-startup.c
+++ b/arch/x86/boot/startup/sev-startup.c
@@ -27,7 +27,6 @@
 #include <asm/cpu_entry_area.h>
 #include <asm/stacktrace.h>
 #include <asm/sev.h>
-#include <asm/sev-internal.h>
 #include <asm/insn-eval.h>
 #include <asm/fpu/xcr.h>
 #include <asm/processor.h>
@@ -41,6 +40,8 @@
 #include <asm/cpuid/api.h>
 #include <asm/cmdline.h>
 
+#include "../coco/sev/internal.h"
+
 /* Include code shared with pre-decompression boot stage */
 #include "sev-shared.c"
 
diff --git a/arch/x86/coco/sev/core.c b/arch/x86/coco/sev/core.c
index 9ae3b11754e6..4e618e596267 100644
--- a/arch/x86/coco/sev/core.c
+++ b/arch/x86/coco/sev/core.c
@@ -31,7 +31,6 @@
 #include <asm/cpu_entry_area.h>
 #include <asm/stacktrace.h>
 #include <asm/sev.h>
-#include <asm/sev-internal.h>
 #include <asm/insn-eval.h>
 #include <asm/fpu/xcr.h>
 #include <asm/processor.h>
@@ -46,6 +45,8 @@
 #include <asm/cmdline.h>
 #include <asm/msr.h>
 
+#include "internal.h"
+
 /* Bitmap of SEV features supported by the hypervisor */
 u64 sev_hv_features __ro_after_init;
 SYM_PIC_ALIAS(sev_hv_features);
diff --git a/arch/x86/include/asm/sev-internal.h b/arch/x86/coco/sev/internal.h
similarity index 100%
rename from arch/x86/include/asm/sev-internal.h
rename to arch/x86/coco/sev/internal.h
diff --git a/arch/x86/coco/sev/noinstr.c b/arch/x86/coco/sev/noinstr.c
index b527eafb6312..9d94aca4a698 100644
--- a/arch/x86/coco/sev/noinstr.c
+++ b/arch/x86/coco/sev/noinstr.c
@@ -16,7 +16,8 @@
 #include <asm/msr.h>
 #include <asm/ptrace.h>
 #include <asm/sev.h>
-#include <asm/sev-internal.h>
+
+#include "internal.h"
 
 static __always_inline bool on_vc_stack(struct pt_regs *regs)
 {
diff --git a/arch/x86/coco/sev/vc-handle.c b/arch/x86/coco/sev/vc-handle.c
index f08c7505ed82..43f264afd590 100644
--- a/arch/x86/coco/sev/vc-handle.c
+++ b/arch/x86/coco/sev/vc-handle.c
@@ -23,7 +23,6 @@
 #include <asm/init.h>
 #include <asm/stacktrace.h>
 #include <asm/sev.h>
-#include <asm/sev-internal.h>
 #include <asm/insn-eval.h>
 #include <asm/fpu/xcr.h>
 #include <asm/processor.h>
@@ -35,6 +34,8 @@
 #include <asm/apic.h>
 #include <asm/cpuid/api.h>
 
+#include "internal.h"
+
 static enum es_result vc_slow_virt_to_phys(struct ghcb *ghcb, struct es_em_ctxt *ctxt,
 					   unsigned long vaddr, phys_addr_t *paddr)
 {
-- 
2.51.0
Re: [PATCH 1/3] x86/sev: Move the internal header
Posted by Tom Lendacky 2 weeks, 1 day ago
On 12/4/25 06:48, Borislav Petkov wrote:
> From: "Borislav Petkov (AMD)" <bp@alien8.de>
> 
> Move the internal header out of the usual include/asm/ include path
> because having an "internal" header there doesn't really make it so
> - quite the opposite.
> 
> So move where it belongs and make it really internal.
> 
> No functional changes.
> 
> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
> ---
>  arch/x86/boot/startup/sev-startup.c                          | 3 ++-
>  arch/x86/coco/sev/core.c                                     | 3 ++-
>  arch/x86/{include/asm/sev-internal.h => coco/sev/internal.h} | 0
>  arch/x86/coco/sev/noinstr.c                                  | 3 ++-
>  arch/x86/coco/sev/vc-handle.c                                | 3 ++-
>  5 files changed, 8 insertions(+), 4 deletions(-)
>  rename arch/x86/{include/asm/sev-internal.h => coco/sev/internal.h} (100%)
> 
> diff --git a/arch/x86/boot/startup/sev-startup.c b/arch/x86/boot/startup/sev-startup.c
> index 09725428d3e6..1115214429fd 100644
> --- a/arch/x86/boot/startup/sev-startup.c
> +++ b/arch/x86/boot/startup/sev-startup.c
> @@ -27,7 +27,6 @@
>  #include <asm/cpu_entry_area.h>
>  #include <asm/stacktrace.h>
>  #include <asm/sev.h>
> -#include <asm/sev-internal.h>
>  #include <asm/insn-eval.h>
>  #include <asm/fpu/xcr.h>
>  #include <asm/processor.h>
> @@ -41,6 +40,8 @@
>  #include <asm/cpuid/api.h>
>  #include <asm/cmdline.h>
>  
> +#include "../coco/sev/internal.h"

Shouldn't this be "../../coco/sev/internal.h" ?

What is strange is that it works with either.

Thanks,
Tom

> +
>  /* Include code shared with pre-decompression boot stage */
>  #include "sev-shared.c"
>  
> diff --git a/arch/x86/coco/sev/core.c b/arch/x86/coco/sev/core.c
> index 9ae3b11754e6..4e618e596267 100644
> --- a/arch/x86/coco/sev/core.c
> +++ b/arch/x86/coco/sev/core.c
> @@ -31,7 +31,6 @@
>  #include <asm/cpu_entry_area.h>
>  #include <asm/stacktrace.h>
>  #include <asm/sev.h>
> -#include <asm/sev-internal.h>
>  #include <asm/insn-eval.h>
>  #include <asm/fpu/xcr.h>
>  #include <asm/processor.h>
> @@ -46,6 +45,8 @@
>  #include <asm/cmdline.h>
>  #include <asm/msr.h>
>  
> +#include "internal.h"
> +
>  /* Bitmap of SEV features supported by the hypervisor */
>  u64 sev_hv_features __ro_after_init;
>  SYM_PIC_ALIAS(sev_hv_features);
> diff --git a/arch/x86/include/asm/sev-internal.h b/arch/x86/coco/sev/internal.h
> similarity index 100%
> rename from arch/x86/include/asm/sev-internal.h
> rename to arch/x86/coco/sev/internal.h
> diff --git a/arch/x86/coco/sev/noinstr.c b/arch/x86/coco/sev/noinstr.c
> index b527eafb6312..9d94aca4a698 100644
> --- a/arch/x86/coco/sev/noinstr.c
> +++ b/arch/x86/coco/sev/noinstr.c
> @@ -16,7 +16,8 @@
>  #include <asm/msr.h>
>  #include <asm/ptrace.h>
>  #include <asm/sev.h>
> -#include <asm/sev-internal.h>
> +
> +#include "internal.h"
>  
>  static __always_inline bool on_vc_stack(struct pt_regs *regs)
>  {
> diff --git a/arch/x86/coco/sev/vc-handle.c b/arch/x86/coco/sev/vc-handle.c
> index f08c7505ed82..43f264afd590 100644
> --- a/arch/x86/coco/sev/vc-handle.c
> +++ b/arch/x86/coco/sev/vc-handle.c
> @@ -23,7 +23,6 @@
>  #include <asm/init.h>
>  #include <asm/stacktrace.h>
>  #include <asm/sev.h>
> -#include <asm/sev-internal.h>
>  #include <asm/insn-eval.h>
>  #include <asm/fpu/xcr.h>
>  #include <asm/processor.h>
> @@ -35,6 +34,8 @@
>  #include <asm/apic.h>
>  #include <asm/cpuid/api.h>
>  
> +#include "internal.h"
> +
>  static enum es_result vc_slow_virt_to_phys(struct ghcb *ghcb, struct es_em_ctxt *ctxt,
>  					   unsigned long vaddr, phys_addr_t *paddr)
>  {
Re: [PATCH 1/3] x86/sev: Move the internal header
Posted by Borislav Petkov 2 weeks, 1 day ago
On Thu, Dec 04, 2025 at 08:18:42AM -0600, Tom Lendacky wrote:
> > +#include "../coco/sev/internal.h"
> 
> Shouldn't this be "../../coco/sev/internal.h" ?
> 
> What is strange is that it works with either.

Pure luck :-\

gcc cmdline is:

gcc -Wp,-MMD,arch/x86/boot/startup/.sev-startup.o.d -nostdinc
-I./arch/x86/include...

so the include path becomes:

# 1 "./arch/x86/include/../coco/sev/internal.h" 1

which is

$ readlink -f  arch/x86/include/../coco/sev/internal.h 
/mnt/kernel/kernel/linux/arch/x86/coco/sev/internal.h

And /mnt/kernel is my kernel-sources-containing SSD :-)

In any case, good catch!

I'll do the "../../" so that it is perfectly clear and future
potential include directives changes do not break this.

Thx.

-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette