Add cpu_sync_core()

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D32360
This commit is contained in:
Konstantin Belousov 2021-10-08 00:57:55 +03:00
parent 8882b7852a
commit 74ccb8ecf6
7 changed files with 63 additions and 0 deletions

View file

@ -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)

View file

@ -311,3 +311,8 @@ cpu_procctl(struct thread *td __unused, int idtype __unused, id_t id __unused,
return (EINVAL);
}
void
cpu_sync_core(void)
{
}

View file

@ -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.
*/
}

View file

@ -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)

View file

@ -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.
*/
}

View file

@ -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();
}

View file

@ -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 *);