x86: Move SMP #defines from apic-defs.h to smp.h
Sean Christopherson
reviewerPATCH 1/1 x86: Move SMP #defines from apic-defs.h to smp.h
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.
---
This applies on top of two combined series:
https://lore.kernel.org/all/[email protected]
https://lore.kernel.org/all/[email protected]
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(-)
lib/x86/apic-defs.h +0 -8
@@ -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.) *
lib/x86/apic.h +2 -0
@@ -3,7 +3,9 @@#include <bitops.h> #include <stdint.h> +#include "apic-defs.h" +#include "smp.h" extern u8 id_map[MAX_TEST_CPUS ];
lib/x86/smp.h +15 -3
@@ -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
x86/cstart.S +1 -0
@@ -1,5 +1,6 @@ #include "apic-defs.h" +#include "smp.h" .global online_cpus
x86/cstart64.S +1 -0
@@ -1,5 +1,6 @@ #include "apic-defs.h" #include "desc.h" +#include "smp.h" ipi_vector = 0x20
x86/efi/efistart64.S +1 -2
@@ -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:
x86/trampolines.S +1 -0
@@ -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
base-commit: 42bbd80783ab0985dbd195358aa89de8a69cb0ab
Signature · 1 line
2.48.1.601.g30ceb7b040-goog
Quoted 8 lines · Sean Christopherson
Now that the
__ASSEMBLY__versus__ASSEMBLER_mess is sorted out, move the SMP related #defines fromapic-defs.htosmp.h, and drop the comment that explains the hackery.Opportunistically make
REALMODE_GDT_LOWMEMvisible to assembly code as well, and drop efistart64.S's local copy.[...]
Applied to kvm-x86 next (and now pulled by Paolo), thanks!
[1/1] x86: Move SMP #defines from apic-defs.h to smp.h
https://github.com/kvm-x86/kvm-unit-tests/commit/d467e659b2b1