git: fdc1f3450634 - main - x86: change signatures of ipi_{bitmap,swi}_handler() to take pointer
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 07 Mar 2026 03:59:33 UTC
The branch main has been updated by kib:
URL: https://cgit.FreeBSD.org/src/commit/?id=fdc1f34506346fd26db8bfb80ba69d1af844c53a
commit fdc1f34506346fd26db8bfb80ba69d1af844c53a
Author: Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2026-02-27 03:54:06 +0000
Commit: Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2026-03-07 03:58:48 +0000
x86: change signatures of ipi_{bitmap,swi}_handler() to take pointer
to the frame instead of the frame itself. It is some stretch of the
amd64 ABI, and is not easily fullfilled when handlers are called from C
and not asm. In particular, the struct frame is passed by value but is
modified by callees, with the expectation that the caller will see the
modifications.
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D55679
---
sys/amd64/amd64/apic_vector.S | 2 ++
sys/i386/i386/apic_vector.S | 4 ++--
sys/i386/i386/mp_machdep.c | 14 ++++++++++++++
sys/x86/include/x86_smp.h | 4 ++--
sys/x86/x86/mp_x86.c | 10 +++++-----
sys/x86/xen/xen_apic.c | 4 ++--
6 files changed, 27 insertions(+), 11 deletions(-)
diff --git a/sys/amd64/amd64/apic_vector.S b/sys/amd64/amd64/apic_vector.S
index 8691387a5a8e..c753ddbad9be 100644
--- a/sys/amd64/amd64/apic_vector.S
+++ b/sys/amd64/amd64/apic_vector.S
@@ -179,6 +179,7 @@ IDTVEC(spuriousint)
INTR_HANDLER ipi_intr_bitmap_handler
call as_lapic_eoi
KMSAN_ENTER
+ movq %rsp,%rdi
call ipi_bitmap_handler
KMSAN_LEAVE
jmp doreti
@@ -220,6 +221,7 @@ IDTVEC(spuriousint)
INTR_HANDLER ipi_swi
call as_lapic_eoi
KMSAN_ENTER
+ movq %rsp,%rdi
call ipi_swi_handler
KMSAN_LEAVE
jmp doreti
diff --git a/sys/i386/i386/apic_vector.S b/sys/i386/i386/apic_vector.S
index 5d248409718d..0037f1c968fb 100644
--- a/sys/i386/i386/apic_vector.S
+++ b/sys/i386/i386/apic_vector.S
@@ -261,7 +261,7 @@ IDTVEC(ipi_intr_bitmap_handler)
cld
KENTER
call as_lapic_eoi
- movl $ipi_bitmap_handler, %eax
+ movl $ipi_bitmap_handler_i386, %eax
call *%eax
jmp doreti
@@ -306,7 +306,7 @@ IDTVEC(ipi_swi)
cld
KENTER
call as_lapic_eoi
- movl $ipi_swi_handler, %eax
+ movl $ipi_swi_handler_i386, %eax
call *%eax
jmp doreti
diff --git a/sys/i386/i386/mp_machdep.c b/sys/i386/i386/mp_machdep.c
index 18ec0d83fad3..0913a0f70d14 100644
--- a/sys/i386/i386/mp_machdep.c
+++ b/sys/i386/i386/mp_machdep.c
@@ -736,3 +736,17 @@ invlcache_handler(void)
wbinvd();
PCPU_SET(smp_tlb_done, generation);
}
+
+void ipi_bitmap_handler_i386(struct trapframe frame);
+void
+ipi_bitmap_handler_i386(struct trapframe frame)
+{
+ ipi_bitmap_handler(&frame);
+}
+
+void ipi_swi_handler_i386(struct trapframe frame);
+void
+ipi_swi_handler_i386(struct trapframe frame)
+{
+ ipi_swi_handler(&frame);
+}
diff --git a/sys/x86/include/x86_smp.h b/sys/x86/include/x86_smp.h
index 045beb3b0f9a..3fa309df1be1 100644
--- a/sys/x86/include/x86_smp.h
+++ b/sys/x86/include/x86_smp.h
@@ -98,10 +98,10 @@ void init_secondary_tail(void);
void init_secondary(void);
void ipi_startup(int apic_id, int vector);
void ipi_all_but_self(u_int ipi);
-void ipi_bitmap_handler(struct trapframe frame);
+void ipi_bitmap_handler(struct trapframe *frame);
void ipi_cpu(int cpu, u_int ipi);
int ipi_nmi_handler(void);
-void ipi_swi_handler(struct trapframe frame);
+void ipi_swi_handler(struct trapframe *frame);
void ipi_selected(cpuset_t cpus, u_int ipi);
void ipi_self_from_nmi(u_int vector);
void set_interrupt_apic_ids(void);
diff --git a/sys/x86/x86/mp_x86.c b/sys/x86/x86/mp_x86.c
index 0c32657290a0..66ad23ee957c 100644
--- a/sys/x86/x86/mp_x86.c
+++ b/sys/x86/x86/mp_x86.c
@@ -1328,14 +1328,14 @@ ipi_send_cpu(int cpu, u_int ipi)
}
void
-ipi_bitmap_handler(struct trapframe frame)
+ipi_bitmap_handler(struct trapframe *frame)
{
struct trapframe *oldframe;
struct thread *td;
int cpu = PCPU_GET(cpuid);
u_int ipi_bitmap;
- kasan_mark(&frame, sizeof(frame), sizeof(frame), 0);
+ kasan_mark(frame, sizeof(*frame), sizeof(*frame), 0);
td = curthread;
ipi_bitmap = atomic_readandclear_int(&cpuid_to_pcpu[cpu]->
@@ -1353,7 +1353,7 @@ ipi_bitmap_handler(struct trapframe frame)
td->td_intr_nesting_level++;
oldframe = td->td_intr_frame;
- td->td_intr_frame = &frame;
+ td->td_intr_frame = frame;
#if defined(STACK) || defined(DDB)
if (ipi_bitmap & (1 << IPI_TRACE))
stack_capture_intr();
@@ -1729,10 +1729,10 @@ cpuoff_handler(void)
* Handle an IPI_SWI by waking delayed SWI thread.
*/
void
-ipi_swi_handler(struct trapframe frame)
+ipi_swi_handler(struct trapframe *frame)
{
- intr_event_handle(clk_intr_event, &frame);
+ intr_event_handle(clk_intr_event, frame);
}
/*
diff --git a/sys/x86/xen/xen_apic.c b/sys/x86/xen/xen_apic.c
index 43a253cc2860..c8760545c8e9 100644
--- a/sys/x86/xen/xen_apic.c
+++ b/sys/x86/xen/xen_apic.c
@@ -217,7 +217,7 @@ static int
xen_ipi_bitmap_handler(void *arg)
{
- ipi_bitmap_handler(*curthread->td_intr_frame);
+ ipi_bitmap_handler(curthread->td_intr_frame);
return (FILTER_HANDLED);
}
@@ -296,7 +296,7 @@ static int
xen_ipi_swi_handler(void *arg)
{
- ipi_swi_handler(*curthread->td_intr_frame);
+ ipi_swi_handler(curthread->td_intr_frame);
return (FILTER_HANDLED);
}