Download raw body.
cpu_xcall glue for amd64
On Sun, Jul 13, 2025 at 07:17:00AM -0600, Theo de Raadt wrote:
> David Gwynne <david@gwynne.id.au> wrote:
>
> > we just went through an effort to shrink kernel code to help the install media fit. it seems a bit ungrateful to use those bytes again for something that's generally only going to be used for performance monitoring.
>
> Nope, that's not a good reason at all. Prefer not to trade tons of cpp
> conditionals all over the place, for having more very different kernel
> execution behaviours.
>
> OTOH, it will take some time to get this into all the architectures. Once
> that's done, this should become a baseline feature. Only then can MI code
> call it. Providing it behind an #ifdef means that it should not be called
> from inside an #ifdef.
ok. how about hanging xcall off an archs cpu device until they're all
implemented, and not providing "xcall.h" so we can't have
#if NXCALL > 0?
Index: arch/amd64/amd64/cpu.c
===================================================================
RCS file: /cvs/src/sys/arch/amd64/amd64/cpu.c,v
diff -u -p -r1.196 cpu.c
--- arch/amd64/amd64/cpu.c 5 Jun 2025 09:29:54 -0000 1.196
+++ arch/amd64/amd64/cpu.c 14 Jul 2025 05:07:42 -0000
@@ -637,6 +637,8 @@ cpu_attach(struct device *parent, struct
#endif
#if defined(MULTIPROCESSOR)
+ cpu_xcall_establish(ci);
+
/*
* Allocate UPAGES contiguous pages for the idle PCB and stack.
*/
Index: arch/amd64/amd64/ipifuncs.c
===================================================================
RCS file: /cvs/src/sys/arch/amd64/amd64/ipifuncs.c,v
diff -u -p -r1.39 ipifuncs.c
--- arch/amd64/amd64/ipifuncs.c 7 Jun 2024 16:53:35 -0000 1.39
+++ arch/amd64/amd64/ipifuncs.c 14 Jul 2025 05:07:42 -0000
@@ -108,6 +108,7 @@ void (*ipifunc[X86_NIPI])(struct cpu_inf
NULL,
#endif
x86_64_ipi_wbinvd,
+ cpu_xcall_dispatch,
};
void
Index: arch/amd64/include/cpu.h
===================================================================
RCS file: /cvs/src/sys/arch/amd64/include/cpu.h,v
diff -u -p -r1.180 cpu.h
--- arch/amd64/include/cpu.h 28 Apr 2025 16:18:25 -0000 1.180
+++ arch/amd64/include/cpu.h 14 Jul 2025 05:07:42 -0000
@@ -53,6 +53,7 @@
#include <sys/sched.h>
#include <sys/sensors.h>
#include <sys/srp.h>
+#include <sys/xcall.h>
#include <uvm/uvm_percpu.h>
#ifdef _KERNEL
@@ -215,6 +216,7 @@ struct cpu_info {
#ifdef MULTIPROCESSOR
struct srp_hazard ci_srp_hazards[SRP_HAZARD_NUM];
+ struct xcall_cpu ci_xcall;
#define __HAVE_UVM_PERCPU
struct uvm_pmr_cache ci_uvm; /* [o] page cache */
#endif
Index: arch/amd64/include/intr.h
===================================================================
RCS file: /cvs/src/sys/arch/amd64/include/intr.h,v
diff -u -p -r1.36 intr.h
--- arch/amd64/include/intr.h 11 Jun 2025 09:57:01 -0000 1.36
+++ arch/amd64/include/intr.h 14 Jul 2025 05:07:42 -0000
@@ -222,7 +222,9 @@ void x86_ipi_handler(void);
void x86_setperf_ipi(struct cpu_info *);
extern void (*ipifunc[X86_NIPI])(struct cpu_info *);
-#endif
+
+#define cpu_xcall_ipi(_ci) x86_send_ipi((_ci), X86_IPI_XCALL)
+#endif /* MULTIPROCESSOR */
#endif /* !_LOCORE */
Index: arch/amd64/include/intrdefs.h
===================================================================
RCS file: /cvs/src/sys/arch/amd64/include/intrdefs.h,v
diff -u -p -r1.24 intrdefs.h
--- arch/amd64/include/intrdefs.h 26 May 2024 13:37:31 -0000 1.24
+++ arch/amd64/include/intrdefs.h 14 Jul 2025 05:07:42 -0000
@@ -85,8 +85,9 @@
#define X86_IPI_START_VMM 0x00000100
#define X86_IPI_STOP_VMM 0x00000200
#define X86_IPI_WBINVD 0x00000400
+#define X86_IPI_XCALL 0x00000800
-#define X86_NIPI 12
+#define X86_NIPI 13
#define IREENT_MAGIC 0x18041969
Index: conf/files
===================================================================
RCS file: /cvs/src/sys/conf/files,v
diff -u -p -r1.746 files
--- conf/files 13 Jul 2025 05:45:21 -0000 1.746
+++ conf/files 14 Jul 2025 05:07:42 -0000
@@ -751,7 +751,7 @@ file kern/kern_uuid.c
file kern/kern_watchdog.c !small_kernel
file kern/kern_task.c
file kern/kern_srp.c
-file kern/kern_xcall.c xcall needs-flag
+file kern/kern_xcall.c xcall
file kern/kern_xxx.c
file kern/sched_bsd.c
file kern/subr_autoconf.c
cpu_xcall glue for amd64