Page MenuHomeFreeBSD

D60377.diff
No OneTemporary

D60377.diff

diff --git a/sys/amd64/include/_smp.h b/sys/amd64/include/_smp.h
new file mode 100644
--- /dev/null
+++ b/sys/amd64/include/_smp.h
@@ -0,0 +1 @@
+#include <x86/_smp.h>
diff --git a/sys/amd64/include/pcpu.h b/sys/amd64/include/pcpu.h
--- a/sys/amd64/include/pcpu.h
+++ b/sys/amd64/include/pcpu.h
@@ -265,8 +265,6 @@
#define PCPU_PTR(member) __PCPU_PTR(pc_ ## member)
#define PCPU_SET(member, val) __PCPU_SET(pc_ ## member, val)
-#define IS_BSP() (PCPU_GET(cpuid) == 0)
-
#define zpcpu_offset_cpu(cpu) ((uintptr_t)&__pcpu[0] + UMA_PCPU_ALLOC_SIZE * cpu)
#define zpcpu_base_to_offset(base) (void *)((uintptr_t)(base) - (uintptr_t)&__pcpu[0])
#define zpcpu_offset_to_base(base) (void *)((uintptr_t)(base) + (uintptr_t)&__pcpu[0])
diff --git a/sys/arm/include/_smp.h b/sys/arm/include/_smp.h
new file mode 100644
--- /dev/null
+++ b/sys/arm/include/_smp.h
@@ -0,0 +1,16 @@
+/*
+ * Copyright (c) 2026 The FreeBSD Foundation
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * This software was developed by Olivier Certner <olce@FreeBSD.org>
+ * at Kumacom SARL under sponsorship from the FreeBSD Foundation.
+ */
+
+#ifndef _MACHINE__SMP_H_
+#define _MACHINE__SMP_H_
+
+/* Routines in '*machdep.c' ensure the BSP is assigned ID 0. */
+#define BSP_CPUID() (0)
+
+#endif /* !_MACHINE__SMP_H_ */
diff --git a/sys/arm/include/smp.h b/sys/arm/include/smp.h
--- a/sys/arm/include/smp.h
+++ b/sys/arm/include/smp.h
@@ -1,4 +1,3 @@
-
#ifndef _MACHINE_SMP_H_
#define _MACHINE_SMP_H_
diff --git a/sys/arm64/include/_smp.h b/sys/arm64/include/_smp.h
new file mode 100644
--- /dev/null
+++ b/sys/arm64/include/_smp.h
@@ -0,0 +1,16 @@
+/*
+ * Copyright (c) 2026 The FreeBSD Foundation
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * This software was developed by Olivier Certner <olce@FreeBSD.org>
+ * at Kumacom SARL under sponsorship from the FreeBSD Foundation.
+ */
+
+#ifndef _MACHINE__SMP_H_
+#define _MACHINE__SMP_H_
+
+/* Routines in '*machdep.c' ensure the BSP is assigned ID 0. */
+#define BSP_CPUID() (0)
+
+#endif /* !_MACHINE__SMP_H_ */
diff --git a/sys/i386/include/_smp.h b/sys/i386/include/_smp.h
new file mode 100644
--- /dev/null
+++ b/sys/i386/include/_smp.h
@@ -0,0 +1 @@
+#include <x86/_smp.h>
diff --git a/sys/i386/include/pcpu.h b/sys/i386/include/pcpu.h
--- a/sys/i386/include/pcpu.h
+++ b/sys/i386/include/pcpu.h
@@ -190,8 +190,6 @@
#define PCPU_PTR(member) __PCPU_PTR(pc_ ## member)
#define PCPU_SET(member, val) __PCPU_SET(pc_ ## member, val)
-#define IS_BSP() (PCPU_GET(cpuid) == 0)
-
#endif /* _KERNEL */
#endif /* !_MACHINE_PCPU_H_ */
diff --git a/sys/powerpc/include/_smp.h b/sys/powerpc/include/_smp.h
new file mode 100644
--- /dev/null
+++ b/sys/powerpc/include/_smp.h
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2026 The FreeBSD Foundation
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * This software was developed by Olivier Certner <olce@FreeBSD.org>
+ * at Kumacom SARL under sponsorship from the FreeBSD Foundation.
+ */
+
+#ifndef _X86__SMP_H_
+#define _X86__SMP_H_
+
+#include <sys/kassert.h>
+
+extern unsigned int powerpc_bsp_cpuid;
+
+#define BSP_CPUID() ({ \
+ KASSERT(powerpc_bsp_cpuid != -1, \
+ ("BSP_CPUID() called before initialization " \
+ "of 'powerpc_bsp_cpuid'")); \
+ powerpc_bsp_cpuid; \
+})
+
+#endif /* !_X86__SMP_H_ */
diff --git a/sys/powerpc/powerpc/machdep.c b/sys/powerpc/powerpc/machdep.c
--- a/sys/powerpc/powerpc/machdep.c
+++ b/sys/powerpc/powerpc/machdep.c
@@ -105,6 +105,7 @@
#include <vm/vm_object.h>
#include <vm/vm_pager.h>
+#include <machine/_smp.h>
#include <machine/altivec.h>
#ifndef __powerpc64__
#include <machine/bat.h>
@@ -131,6 +132,9 @@
#include <dev/ofw/ofw_subr.h>
int cold = 1;
+
+unsigned int powerpc_bsp_cpuid = -1;
+
#ifdef __powerpc64__
int cacheline_size = 128;
#else
@@ -448,6 +452,7 @@
*/
if (platform_smp_get_bsp(&bsp) != 0)
bsp.cr_cpuid = 0;
+ powerpc_bsp_cpuid = bsp.cr_cpuid;
pc = &__pcpu[bsp.cr_cpuid];
__asm __volatile("mtsprg 0, %0" :: "r"(pc));
pcpu_init(pc, bsp.cr_cpuid, sizeof(struct pcpu));
diff --git a/sys/riscv/include/_smp.h b/sys/riscv/include/_smp.h
new file mode 100644
--- /dev/null
+++ b/sys/riscv/include/_smp.h
@@ -0,0 +1,16 @@
+/*
+ * Copyright (c) 2026 The FreeBSD Foundation
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * This software was developed by Olivier Certner <olce@FreeBSD.org>
+ * at Kumacom SARL under sponsorship from the FreeBSD Foundation.
+ */
+
+#ifndef _MACHINE__SMP_H_
+#define _MACHINE__SMP_H_
+
+/* Routines in '*machdep.c' ensure the BSP is assigned ID 0. */
+#define BSP_CPUID() (0)
+
+#endif /* !_MACHINE__SMP_H_ */
diff --git a/sys/sys/pcpu.h b/sys/sys/pcpu.h
--- a/sys/sys/pcpu.h
+++ b/sys/sys/pcpu.h
@@ -41,10 +41,12 @@
#include <sys/_cpuset.h>
#include <sys/_lock.h>
#include <sys/_mutex.h>
+#include <sys/_rmlock.h>
#include <sys/_sx.h>
#include <sys/queue.h>
-#include <sys/_rmlock.h>
#include <sys/resource.h>
+
+#include <machine/_smp.h>
#include <machine/pcpu.h>
#define DPCPU_SETNAME "set_pcpu"
@@ -218,6 +220,9 @@
#define curcpu PCPU_GET(cpuid)
#define curvidata PCPU_GET(vidata)
+/* Is this the bootstrap processor? */
+#define IS_BSP() (curcpu == BSP_CPUID())
+
#define UMA_PCPU_ALLOC_SIZE PAGE_SIZE
#include <machine/pcpu_aux.h>
diff --git a/sys/x86/include/_smp.h b/sys/x86/include/_smp.h
new file mode 100644
--- /dev/null
+++ b/sys/x86/include/_smp.h
@@ -0,0 +1,16 @@
+/*
+ * Copyright (c) 2026 The FreeBSD Foundation
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * This software was developed by Olivier Certner <olce@FreeBSD.org>
+ * at Kumacom SARL under sponsorship from the FreeBSD Foundation.
+ */
+
+#ifndef _X86__SMP_H_
+#define _X86__SMP_H_
+
+/* assign_cpu_ids() ensures the BSP is assigned ID 0. */
+#define BSP_CPUID() (0)
+
+#endif /* !_X86__SMP_H_ */

File Metadata

Mime Type
text/plain
Expires
Sat, Oct 10, 5:29 PM (6 h, 50 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
40480778
Default Alt Text
D60377.diff (5 KB)

Event Timeline