diff mbox series

[kvm-unit-tests] x86: Move SMP #defines from apic-defs.h to smp.h

Message ID 20250221233832.2251456-1-seanjc@google.com (mailing list archive)
State New
Headers show
Series [kvm-unit-tests] x86: Move SMP #defines from apic-defs.h to smp.h | expand

Commit Message

Sean Christopherson Feb. 21, 2025, 11:38 p.m. UTC
Now that the __ASSEMBLY__ versus __ASSEMBLER_ mess is sorted out, move
the SMP related #defines from apic-defs.h to smp.h, and drop the comment
that explains the hackery.

Opportunistically make REALMODE_GDT_LOWMEM visible to assembly code as
well, and drop efistart64.S's local copy.

Signed-off-by: Sean Christopherson <seanjc@google.com>
---

This applies on top of two combined series:
  
  https://lore.kernel.org/all/20250221225406.2228938-1-seanjc@google.com
  https://lore.kernel.org/all/20250215012032.1206409-1-seanjc@google.com

 lib/x86/apic-defs.h  |  8 --------
 lib/x86/apic.h       |  2 ++
 lib/x86/smp.h        | 18 +++++++++++++++---
 x86/cstart.S         |  1 +
 x86/cstart64.S       |  1 +
 x86/efi/efistart64.S |  3 +--
 x86/trampolines.S    |  1 +
 7 files changed, 21 insertions(+), 13 deletions(-)


base-commit: 42bbd80783ab0985dbd195358aa89de8a69cb0ab
diff mbox series

Patch

diff --git a/lib/x86/apic-defs.h b/lib/x86/apic-defs.h
index 5a1dff3a..fd82b815 100644
--- a/lib/x86/apic-defs.h
+++ b/lib/x86/apic-defs.h
@@ -1,14 +1,6 @@ 
 #ifndef _X86_APIC_DEFS_H_
 #define _X86_APIC_DEFS_H_
 
-/*
- * Abuse this header file to hold the number of max-cpus and the size of the
- * per-CPU stack/data area, making them available both in C and ASM.  One page
- * for per-CPU, and two pages for the stack (plus some buffer in-between).
- */
-#define MAX_TEST_CPUS (255)
-#define PER_CPU_SIZE  (3 * 4096)
-
 /*
  * Constants for various Intel APICs. (local APIC, IOAPIC, etc.)
  *
diff --git a/lib/x86/apic.h b/lib/x86/apic.h
index 8df889b2..23c771ed 100644
--- a/lib/x86/apic.h
+++ b/lib/x86/apic.h
@@ -3,7 +3,9 @@ 
 
 #include <bitops.h>
 #include <stdint.h>
+
 #include "apic-defs.h"
+#include "smp.h"
 
 extern u8 id_map[MAX_TEST_CPUS];
 
diff --git a/lib/x86/smp.h b/lib/x86/smp.h
index 08a440b3..bbe90daa 100644
--- a/lib/x86/smp.h
+++ b/lib/x86/smp.h
@@ -1,15 +1,25 @@ 
 #ifndef _X86_SMP_H_
 #define _X86_SMP_H_
 
+#define MAX_TEST_CPUS (255)
+
+/*
+ * Allocate 12KiB of data for per-CPU usage.  One page for per-CPU data, and
+ * two pages for the stack (plus some buffer in-between).
+ */
+#define PER_CPU_SIZE  (3 * 4096)
+
+/* Address where to store the address of realmode GDT descriptor. */
+#define REALMODE_GDT_LOWMEM (PAGE_SIZE - 2)
+
+#ifndef __ASSEMBLER__
+
 #include <stddef.h>
 #include <asm/spinlock.h>
 #include "libcflat.h"
 #include "atomic.h"
 #include "apic-defs.h"
 
-/* Address where to store the address of realmode GDT descriptor. */
-#define REALMODE_GDT_LOWMEM (PAGE_SIZE - 2)
-
 /* Offsets into the per-cpu page. */
 struct percpu_data {
 	uint32_t  smp_id;
@@ -90,4 +100,6 @@  void ap_online(void);
 extern atomic_t cpu_online_count;
 extern unsigned char online_cpus[(MAX_TEST_CPUS + 7) / 8];
 
+#endif /* __ASSEMBLER__ */
+
 #endif
diff --git a/x86/cstart.S b/x86/cstart.S
index 2e396e52..96e79a47 100644
--- a/x86/cstart.S
+++ b/x86/cstart.S
@@ -1,5 +1,6 @@ 
 
 #include "apic-defs.h"
+#include "smp.h"
 
 .global online_cpus
 
diff --git a/x86/cstart64.S b/x86/cstart64.S
index 018bac98..f3c398a5 100644
--- a/x86/cstart64.S
+++ b/x86/cstart64.S
@@ -1,5 +1,6 @@ 
 #include "apic-defs.h"
 #include "desc.h"
+#include "smp.h"
 
 ipi_vector = 0x20
 
diff --git a/x86/efi/efistart64.S b/x86/efi/efistart64.S
index 3fc16016..6025dc2f 100644
--- a/x86/efi/efistart64.S
+++ b/x86/efi/efistart64.S
@@ -3,7 +3,7 @@ 
 #include "apic-defs.h"
 #include "asm-generic/page.h"
 #include "crt0-efi-x86_64.S"
-
+#include "smp.h"
 
 /* Reserve stack in .data */
 .data
@@ -36,7 +36,6 @@  ptl4:
 .text
 
 .code16
-REALMODE_GDT_LOWMEM = PAGE_SIZE - 2
 
 .globl rm_trampoline
 rm_trampoline:
diff --git a/x86/trampolines.S b/x86/trampolines.S
index 02d9f321..c3f2bd29 100644
--- a/x86/trampolines.S
+++ b/x86/trampolines.S
@@ -3,6 +3,7 @@ 
  * transition from 32-bit to 64-bit code (x86-64 only)
  */
 #include "apic-defs.h"
+#include "smp.h"
 
 per_cpu_size = PER_CPU_SIZE