@@ -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.)
*
@@ -3,7 +3,9 @@
#include <bitops.h>
#include <stdint.h>
+
#include "apic-defs.h"
+#include "smp.h"
extern u8 id_map[MAX_TEST_CPUS];
@@ -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
@@ -1,5 +1,6 @@
#include "apic-defs.h"
+#include "smp.h"
.global online_cpus
@@ -1,5 +1,6 @@
#include "apic-defs.h"
#include "desc.h"
+#include "smp.h"
ipi_vector = 0x20
@@ -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:
@@ -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
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