Skip to content

Commit d467e65

Browse files
committed
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. Link: https://lore.kernel.org/r/20250221233832.2251456-1-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent c8a8a35 commit d467e65

File tree

7 files changed

+21
-13
lines changed

7 files changed

+21
-13
lines changed

lib/x86/apic-defs.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
11
#ifndef _X86_APIC_DEFS_H_
22
#define _X86_APIC_DEFS_H_
33

4-
/*
5-
* Abuse this header file to hold the number of max-cpus and the size of the
6-
* per-CPU stack/data area, making them available both in C and ASM. One page
7-
* for per-CPU, and two pages for the stack (plus some buffer in-between).
8-
*/
9-
#define MAX_TEST_CPUS (255)
10-
#define PER_CPU_SIZE (3 * 4096)
11-
124
/*
135
* Constants for various Intel APICs. (local APIC, IOAPIC, etc.)
146
*

lib/x86/apic.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33

44
#include <bitops.h>
55
#include <stdint.h>
6+
67
#include "apic-defs.h"
8+
#include "smp.h"
79

810
extern u8 id_map[MAX_TEST_CPUS];
911

lib/x86/smp.h

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,25 @@
11
#ifndef _X86_SMP_H_
22
#define _X86_SMP_H_
33

4+
#define MAX_TEST_CPUS (255)
5+
6+
/*
7+
* Allocate 12KiB of data for per-CPU usage. One page for per-CPU data, and
8+
* two pages for the stack (plus some buffer in-between).
9+
*/
10+
#define PER_CPU_SIZE (3 * 4096)
11+
12+
/* Address where to store the address of realmode GDT descriptor. */
13+
#define REALMODE_GDT_LOWMEM (PAGE_SIZE - 2)
14+
15+
#ifndef __ASSEMBLER__
16+
417
#include <stddef.h>
518
#include <asm/spinlock.h>
619
#include "libcflat.h"
720
#include "atomic.h"
821
#include "apic-defs.h"
922

10-
/* Address where to store the address of realmode GDT descriptor. */
11-
#define REALMODE_GDT_LOWMEM (PAGE_SIZE - 2)
12-
1323
/* Offsets into the per-cpu page. */
1424
struct percpu_data {
1525
uint32_t smp_id;
@@ -90,4 +100,6 @@ void ap_online(void);
90100
extern atomic_t cpu_online_count;
91101
extern unsigned char online_cpus[(MAX_TEST_CPUS + 7) / 8];
92102

103+
#endif /* __ASSEMBLER__ */
104+
93105
#endif

x86/cstart.S

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

22
#include "apic-defs.h"
3+
#include "smp.h"
34

45
.global online_cpus
56

x86/cstart64.S

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "apic-defs.h"
22
#include "desc.h"
3+
#include "smp.h"
34

45
ipi_vector = 0x20
56

x86/efi/efistart64.S

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include "apic-defs.h"
44
#include "asm-generic/page.h"
55
#include "crt0-efi-x86_64.S"
6-
6+
#include "smp.h"
77

88
/* Reserve stack in .data */
99
.data
@@ -36,7 +36,6 @@ ptl4:
3636
.text
3737

3838
.code16
39-
REALMODE_GDT_LOWMEM = PAGE_SIZE - 2
4039

4140
.globl rm_trampoline
4241
rm_trampoline:

x86/trampolines.S

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* transition from 32-bit to 64-bit code (x86-64 only)
44
*/
55
#include "apic-defs.h"
6+
#include "smp.h"
67

78
per_cpu_size = PER_CPU_SIZE
89

0 commit comments

Comments
 (0)