aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Belousov <kib@FreeBSD.org>2021-10-07 21:57:55 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2023-08-23 00:02:21 +0000
commit74ccb8ecf6c115a79f008bc32d4981f1126b63a8 (patch)
treeb22f019433b4f41c1524ee15e96efb5d3f2104fe
parent8882b7852acf2588d87ccb6d4c6bf7694511fc56 (diff)
downloadsrc-74ccb8ecf6c115a79f008bc32d4981f1126b63a8.tar.gz
src-74ccb8ecf6c115a79f008bc32d4981f1126b63a8.zip
Add cpu_sync_core()
Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D32360
-rw-r--r--sys/amd64/amd64/support.S21
-rw-r--r--sys/arm/arm/vm_machdep.c5
-rw-r--r--sys/arm64/arm64/vm_machdep.c11
-rw-r--r--sys/i386/i386/support.S8
-rw-r--r--sys/powerpc/powerpc/vm_machdep.c10
-rw-r--r--sys/riscv/riscv/vm_machdep.c7
-rw-r--r--sys/sys/proc.h1
7 files changed, 63 insertions, 0 deletions
diff --git a/sys/amd64/amd64/support.S b/sys/amd64/amd64/support.S
index ae2793aa7584..6e541b75cdae 100644
--- a/sys/amd64/amd64/support.S
+++ b/sys/amd64/amd64/support.S
@@ -1969,3 +1969,24 @@ ENTRY(mds_handler_silvermont)
popq %rax
retq
END(mds_handler_silvermont)
+
+/*
+ * Do the same as Linux and execute IRET explicitly, despite IPI
+ * return does it as well.
+ */
+ENTRY(cpu_sync_core)
+/*
+ * Can utilize SERIALIZE when instruction is moved from
+ * 'future extensions' to SDM.
+ */
+ movq (%rsp), %rdx
+ movl %ss, %eax
+ pushq %rax
+ pushq %rsp
+ addq $16, (%rsp)
+ pushfq
+ movl %cs, %eax
+ pushq %rax
+ pushq %rdx
+ iretq
+END(cpu_sync_core)
diff --git a/sys/arm/arm/vm_machdep.c b/sys/arm/arm/vm_machdep.c
index ace6b4ce668b..b7c08cd4e97f 100644
--- a/sys/arm/arm/vm_machdep.c
+++ b/sys/arm/arm/vm_machdep.c
@@ -311,3 +311,8 @@ cpu_procctl(struct thread *td __unused, int idtype __unused, id_t id __unused,
return (EINVAL);
}
+
+void
+cpu_sync_core(void)
+{
+}
diff --git a/sys/arm64/arm64/vm_machdep.c b/sys/arm64/arm64/vm_machdep.c
index 06e063d916f1..5e45b45dc320 100644
--- a/sys/arm64/arm64/vm_machdep.c
+++ b/sys/arm64/arm64/vm_machdep.c
@@ -310,3 +310,14 @@ cpu_procctl(struct thread *td __unused, int idtype __unused, id_t id __unused,
return (EINVAL);
}
+
+void
+cpu_sync_core(void)
+{
+ /*
+ * Do nothing. According to ARM ARMv8 D1.11 Exception return
+ * If FEAT_ExS is not implemented, or if FEAT_ExS is
+ * implemented and the SCTLR_ELx.EOS field is set, exception
+ * return from ELx is a context synchronization event.
+ */
+}
diff --git a/sys/i386/i386/support.S b/sys/i386/i386/support.S
index 58c01f37a3fc..982108a0b968 100644
--- a/sys/i386/i386/support.S
+++ b/sys/i386/i386/support.S
@@ -578,3 +578,11 @@ ENTRY(mds_handler_silvermont)
movl %eax, %cr0
3: ret
END(mds_handler_silvermont)
+
+ENTRY(cpu_sync_core)
+ popl %eax
+ pushfl
+ pushl %cs
+ pushl %eax
+ iretl
+END(cpu_sync_core)
diff --git a/sys/powerpc/powerpc/vm_machdep.c b/sys/powerpc/powerpc/vm_machdep.c
index b53da3dd04fa..1a31959b278b 100644
--- a/sys/powerpc/powerpc/vm_machdep.c
+++ b/sys/powerpc/powerpc/vm_machdep.c
@@ -239,3 +239,13 @@ cpu_procctl(struct thread *td __unused, int idtype __unused, id_t id __unused,
return (EINVAL);
}
+
+void
+cpu_sync_core(void)
+{
+ /*
+ * Linux performs "rfi" there. Our rendezvous IPI handler on
+ * the target cpu does "rfi" before and lwsync/sync after the
+ * action, which is stronger than required.
+ */
+}
diff --git a/sys/riscv/riscv/vm_machdep.c b/sys/riscv/riscv/vm_machdep.c
index 3b2553996bb8..58acf5df9e14 100644
--- a/sys/riscv/riscv/vm_machdep.c
+++ b/sys/riscv/riscv/vm_machdep.c
@@ -49,6 +49,7 @@
#include <machine/riscvreg.h>
#include <machine/cpu.h>
+#include <machine/cpufunc.h>
#include <machine/pcb.h>
#include <machine/frame.h>
#include <machine/sbi.h>
@@ -267,3 +268,9 @@ cpu_procctl(struct thread *td __unused, int idtype __unused, id_t id __unused,
return (EINVAL);
}
+
+void
+cpu_sync_core(void)
+{
+ fence_i();
+}
diff --git a/sys/sys/proc.h b/sys/sys/proc.h
index a35446690526..05ab914af409 100644
--- a/sys/sys/proc.h
+++ b/sys/sys/proc.h
@@ -1229,6 +1229,7 @@ void cpu_idle(int);
int cpu_idle_wakeup(int);
extern void (*cpu_idle_hook)(sbintime_t); /* Hook to machdep CPU idler. */
void cpu_switch(struct thread *, struct thread *, struct mtx *);
+void cpu_sync_core(void);
void cpu_throw(struct thread *, struct thread *) __dead2;
bool curproc_sigkilled(void);
void userret(struct thread *, struct trapframe *);