History log of /openbsd-current/sys/arch/sparc64/sparc64/vm_machdep.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.45 29-Mar-2024 miod

Store the physical address of each pcb in struct mdproc, and use this in
order to speed up window spills, rather than doing an inline pmap_extract
(well, pseg_get).

ok claudio@ kettenis@


# 1.44 29-Mar-2024 miod

Be sure to reset p->p_md.md_fpstate to NULL after freeing it in cpu_exit().
There should hopefully be no further faults on this proc causing an fpu
state to be handled, but better play safe than sorry.

ok claudio@ kettenis@


Revision tags: OPENBSD_7_5_BASE
# 1.43 19-Feb-2024 claudio

In cpu_fork() do not copy the register windows stashed in the u_pcb
if the new proc has its own stack. In that case the new thread starts
with a fresh stack and there are no register windows to spill back.

This fixes the pthread issues that kurt@ was struggling with for a long
time. Depending on the scheduler a thread would stomp over another threads
stack which caused strange crashes.

Improved diff provided by miod@
OK miod@ mpi@ kurt@


Revision tags: OPENBSD_7_3_BASE OPENBSD_7_4_BASE
# 1.42 25-Oct-2022 guenther

STACK_OFFSET was to support it varying when compiling some code for
either 32bit or 64bit. With the elimination of 32bit sparc bits
it was just a superfluous indirection of BIAS. Also, CCFSZ is gone.

ok miod@


# 1.41 21-Oct-2022 miod

Remove vestigial bits of 32-bit binaries support; drop the `64' suffix in
struct names when the matching `32' flavour got removed.

Joint work with cheloha@, all bugs mine.


Revision tags: OPENBSD_7_2_BASE
# 1.40 27-May-2022 kettenis

Convert KVA allocation to km_alloc(9).

ok deraadt@, mpi@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE OPENBSD_7_1_BASE
# 1.39 17-Aug-2017 tom

Fix typo in comments: s/return/returns/ in "a function that never return."


# 1.38 25-May-2017 dlg

tweak sparc64 membars as a step toward making them usable in userland.

specifically, dont rely on magic in ctlreg to implement membars. moving
that to atomic.h would add a lot of pollution to the namespace, so
move to passing the membar options to a single __membar macro.

this tweaks everything that was using the ctlreg backend to either use
an appropriate membar_foo(), or to use __membar() in the MD code.

ok kettenis@


# 1.37 30-Apr-2017 mpi

Rename Debugger() into db_enter().

Using a name with the 'db_' prefix makes it invisible from the dynamic
profiler.

ok deraadt@, kettenis@, visa@


Revision tags: OPENBSD_6_1_BASE
# 1.36 12-Feb-2017 guenther

Split up fork1():
- FORK_THREAD handling is a totally separate function, thread_fork(),
that is only used by sys___tfork() and which loses the flags, func,
arg, and newprocp parameters and gains tcb parameter to guarantee
the new thread's TCB is set before the creating thread returns
- fork1() loses its stack and tidptr parameters
Common bits factor out:
- struct proc allocation and initialization moves to thread_new()
- maxthread handling moves to fork_check_maxthread()
- setting the new thread running moves to fork_thread_start()
The MD cpu_fork() function swaps its unused stacksize parameter for
a tcb parameter.

luna88k testing by aoyama@, alpha testing by dlg@
ok mpi@


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.35 06-Nov-2015 guenther

Move the logic for adjusting userspace registers in the child after fork
from cpu_fork() to child_return(), putting all the SYSCALL_G2RFLAG logic
in trap.c

sparc testing by sebastia@ and miod@


# 1.34 08-Sep-2015 deraadt

sizes for free(); ok semarie


Revision tags: OPENBSD_5_8_BASE
# 1.33 05-May-2015 guenther

emul_native is only used for kernel threads which can't dump core, so
delete coredump_trad(), uvm_coredump(), cpu_coredump(), struct md_coredump,
and various #includes that are superfluous.

This leaves compat_linux processes without a coredump callback. If that
ability is desired, someone should update it to use coredump_elf32() and
verify the results...

ok kettenis@


Revision tags: OPENBSD_5_7_BASE
# 1.32 16-Nov-2014 deraadt

Replace a plethora of historical protection options with just
PROT_NONE, PROT_READ, PROT_WRITE, and PROT_EXEC from mman.h.
PROT_MASK is introduced as the one true way of extracting those bits.
Remove UVM_ADV_* wrapper, using the standard names.
ok doug guenther kettenis


# 1.31 24-Oct-2014 kettenis

Bring phys_map to sparc64 and use it in vmapbuf(9) and vunmapbuf(9).


Revision tags: OPENBSD_5_6_BASE
# 1.30 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.29 16-Jan-2013 miod

cpu_coredump() also needs to invoke vn_rdwr() without IO_NODELOCKED; only
affects a.out binaries' core dumps.


Revision tags: OPENBSD_5_2_BASE
# 1.28 21-Jun-2012 guenther

__tfork() needs to set the stack address of the new thread in the kernel,
so that it can't get a signal while still running on the parent thread's
stack. Also, pass in sizeof(struct __tfork) to provide forward compat
when more members are added. This is an ABI change, so switch syscall
numbers and bump lib majors this time.

ok deraadt@ matthew@


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE
# 1.27 13-Jan-2011 kettenis

Spin forever when waiting for completion of an FPU shootdown instead of
panicing if we spin for too long. It is difficult to find an upper bound
for the spin count and there is some evidence the current limit is too low.
We made similar changes to amd64/i386 some time ago.

ok deraadt@


Revision tags: OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.26 30-Sep-2008 miod

Do not perform cache operations in vmapbuf(), pmap is supposed to do them
for us if needed.

ok art@ kettenis@


Revision tags: OPENBSD_4_4_BASE
# 1.25 14-Jul-2008 miod

Use uvm_km_valloc_prefer_wait() instead of uvm_km_valloc_wait() in vmapbuf().

ok art@


# 1.24 15-Mar-2008 kettenis

Make GENERIC.MP work on the e10k. The e10k is a bit funky since UPA only
supports 32 ports, and a machine with up to 64 CPUs obviously needs more.
So the machine has a special ASIC that does port translation, and because
of that we need to distinguish between port ID's and interrupt target ID's.


Revision tags: OPENBSD_4_3_BASE
# 1.23 04-Jan-2008 kettenis

Prevent sign-extension when setting ASI in %tstate.


# 1.22 03-Jan-2008 kettenis

Fix debug code.


# 1.21 06-Nov-2007 kettenis

Close a race where we might save/drop the fpu state of the wrong process in
the ipi handlers.


# 1.20 31-Oct-2007 kettenis

Overhaul fpu context save/restore code, making it more similar to what we do
on i386 and amd64. Don't let IPIs in when saving fpu context by disabling
interrupts.


# 1.19 17-Oct-2007 kettenis

Sanitize debug printf.


# 1.18 16-Oct-2007 kettenis

Make lazy fpu context switching work for MULTIPROCESSOR kernels. Tested by
many.

ok deraadt@


# 1.17 13-Oct-2007 miod

Fix cpu_exit() comments to be more closer to reality.


# 1.16 10-Oct-2007 art

Make context switching much more MI:
- Move the functionality of choosing a process from cpu_switch into
a much simpler function: cpu_switchto. Instead of having the locore
code walk the run queues, let the MI code choose the process we
want to run and only implement the context switching itself in MD
code.
- Let MD context switching run without worrying about spls or locks.
- Instead of having the idle loop implemented with special contexts
in MD code, implement one idle proc for each cpu. make the idle
loop MI with MD hooks.
- Change the proc lists from the old style vax queues to TAILQs.
- Change the sleep queue from vax queues to TAILQs. This makes
wakeup() go from O(n^2) to O(n)

there will be some MD fallout, but it will be fixed shortly.
There's also a few cleanups to be done after this.

deraadt@, kettenis@ ok


Revision tags: OPENBSD_4_2_BASE
# 1.15 20-Jun-2007 miod

In vunmapbuf(), explicitely remove mappings before invoking uvm_km_free().
Even if the latter would end up removing the mappings by itself, it would
do so using pmap_remove() because phys_map is not intrsafe; but some
platforms use pmap_kenter_pa() in vmapbuf(). By removing the mappings
ourselves, we can ensure the remove function used matches the enter function
which has been used.
Discussed and theoretical ok art@


# 1.14 27-May-2007 miod

pagemove() is no longer used.


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE
# 1.13 29-May-2006 miod

Remove dead extern declarations.


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE
# 1.12 08-Aug-2005 kettenis

Skip (trap) instruction in cpu_fork() instead of proc_trampoline().
Fixes returning from fork(2) in the child with a pending signal.
tested by otto@, krw@, sturm@
ok deraadt@


# 1.11 29-Mar-2005 kettenis

sparc64 StackGhost.
ok deraadt@


Revision tags: OPENBSD_3_6_BASE OPENBSD_3_7_BASE SMP_SYNC_A SMP_SYNC_B
# 1.10 23-May-2004 deraadt

netbsd 1.54; do not count on new process having cleared condition codes;
hunted down by brian poole as relevant for the occassional cron failure
at startup...


Revision tags: OPENBSD_3_3_BASE OPENBSD_3_4_BASE OPENBSD_3_5_BASE UBC_SYNC_A
# 1.9 24-Feb-2003 miod

Oops, forgot to commit that part of the pmap_kenter changes; spotted by art@


Revision tags: OPENBSD_3_2_BASE UBC_SYNC_B
# 1.8 15-Jun-2002 art

Decruftification.

We will never have a.out kernels.
We will never have 32-bit kernels.
We will never have sun4c, sun4 and sun4m support in the sparc64 kernels.
We don't need support old netbsd libc.
The cpu will never be identified as some of the sun4c and sun4m types.
We don't need the gazillion of fields in cpuinfo that the sparc port uses.
Just generally remove dead code.

This is just a first step in making this meess readable.


Revision tags: OPENBSD_3_1_BASE
# 1.7 14-Mar-2002 millert

First round of __P removal in sys


Revision tags: UBC_BASE
# 1.6 04-Dec-2001 art

branches: 1.6.2;
Yet another sync to NetBSD uvm.
Today we add a pmap argument to pmap_update() and allocate map entries for
kernel_map from kmem_map instead of using the static entries. This should
get rid of MAX_KMAPENT panics. Also some uvm_loan problems are fixed.


# 1.5 06-Nov-2001 miod

Replace inclusion of <vm/foo.h> with the correct <uvm/bar.h> when necessary.
(Look ma, I might have broken the tree)


# 1.4 06-Nov-2001 art

Let fork1, uvm_fork, and cpu_fork take a function/argument pair as argument,
instead of doing fork1, cpu_set_kpc. This lets us retire cpu_set_kpc and
avoid a multiprocessor race.

This commit breaks vax because it doesn't look like any other arch, someone
working on vax might want to look at this and try to adapt the code to be
more like the rest of the world.

Idea and uvm parts from NetBSD.


Revision tags: OPENBSD_3_0_BASE
# 1.3 19-Sep-2001 mickey

branches: 1.3.4;
merge vm/vm_kern.h into uvm/uvm_extern.h; art@ ok


# 1.2 20-Aug-2001 jason

$OpenBSD$


# 1.1 19-Aug-2001 jason

Lot of stuff... Some from NetBSD, some from OpenBSD, minor modifications


# 1.43 19-Feb-2024 claudio

In cpu_fork() do not copy the register windows stashed in the u_pcb
if the new proc has its own stack. In that case the new thread starts
with a fresh stack and there are no register windows to spill back.

This fixes the pthread issues that kurt@ was struggling with for a long
time. Depending on the scheduler a thread would stomp over another threads
stack which caused strange crashes.

Improved diff provided by miod@
OK miod@ mpi@ kurt@


Revision tags: OPENBSD_7_3_BASE OPENBSD_7_4_BASE
# 1.42 25-Oct-2022 guenther

STACK_OFFSET was to support it varying when compiling some code for
either 32bit or 64bit. With the elimination of 32bit sparc bits
it was just a superfluous indirection of BIAS. Also, CCFSZ is gone.

ok miod@


# 1.41 21-Oct-2022 miod

Remove vestigial bits of 32-bit binaries support; drop the `64' suffix in
struct names when the matching `32' flavour got removed.

Joint work with cheloha@, all bugs mine.


Revision tags: OPENBSD_7_2_BASE
# 1.40 27-May-2022 kettenis

Convert KVA allocation to km_alloc(9).

ok deraadt@, mpi@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE OPENBSD_7_1_BASE
# 1.39 17-Aug-2017 tom

Fix typo in comments: s/return/returns/ in "a function that never return."


# 1.38 25-May-2017 dlg

tweak sparc64 membars as a step toward making them usable in userland.

specifically, dont rely on magic in ctlreg to implement membars. moving
that to atomic.h would add a lot of pollution to the namespace, so
move to passing the membar options to a single __membar macro.

this tweaks everything that was using the ctlreg backend to either use
an appropriate membar_foo(), or to use __membar() in the MD code.

ok kettenis@


# 1.37 30-Apr-2017 mpi

Rename Debugger() into db_enter().

Using a name with the 'db_' prefix makes it invisible from the dynamic
profiler.

ok deraadt@, kettenis@, visa@


Revision tags: OPENBSD_6_1_BASE
# 1.36 12-Feb-2017 guenther

Split up fork1():
- FORK_THREAD handling is a totally separate function, thread_fork(),
that is only used by sys___tfork() and which loses the flags, func,
arg, and newprocp parameters and gains tcb parameter to guarantee
the new thread's TCB is set before the creating thread returns
- fork1() loses its stack and tidptr parameters
Common bits factor out:
- struct proc allocation and initialization moves to thread_new()
- maxthread handling moves to fork_check_maxthread()
- setting the new thread running moves to fork_thread_start()
The MD cpu_fork() function swaps its unused stacksize parameter for
a tcb parameter.

luna88k testing by aoyama@, alpha testing by dlg@
ok mpi@


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.35 06-Nov-2015 guenther

Move the logic for adjusting userspace registers in the child after fork
from cpu_fork() to child_return(), putting all the SYSCALL_G2RFLAG logic
in trap.c

sparc testing by sebastia@ and miod@


# 1.34 08-Sep-2015 deraadt

sizes for free(); ok semarie


Revision tags: OPENBSD_5_8_BASE
# 1.33 05-May-2015 guenther

emul_native is only used for kernel threads which can't dump core, so
delete coredump_trad(), uvm_coredump(), cpu_coredump(), struct md_coredump,
and various #includes that are superfluous.

This leaves compat_linux processes without a coredump callback. If that
ability is desired, someone should update it to use coredump_elf32() and
verify the results...

ok kettenis@


Revision tags: OPENBSD_5_7_BASE
# 1.32 16-Nov-2014 deraadt

Replace a plethora of historical protection options with just
PROT_NONE, PROT_READ, PROT_WRITE, and PROT_EXEC from mman.h.
PROT_MASK is introduced as the one true way of extracting those bits.
Remove UVM_ADV_* wrapper, using the standard names.
ok doug guenther kettenis


# 1.31 24-Oct-2014 kettenis

Bring phys_map to sparc64 and use it in vmapbuf(9) and vunmapbuf(9).


Revision tags: OPENBSD_5_6_BASE
# 1.30 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.29 16-Jan-2013 miod

cpu_coredump() also needs to invoke vn_rdwr() without IO_NODELOCKED; only
affects a.out binaries' core dumps.


Revision tags: OPENBSD_5_2_BASE
# 1.28 21-Jun-2012 guenther

__tfork() needs to set the stack address of the new thread in the kernel,
so that it can't get a signal while still running on the parent thread's
stack. Also, pass in sizeof(struct __tfork) to provide forward compat
when more members are added. This is an ABI change, so switch syscall
numbers and bump lib majors this time.

ok deraadt@ matthew@


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE
# 1.27 13-Jan-2011 kettenis

Spin forever when waiting for completion of an FPU shootdown instead of
panicing if we spin for too long. It is difficult to find an upper bound
for the spin count and there is some evidence the current limit is too low.
We made similar changes to amd64/i386 some time ago.

ok deraadt@


Revision tags: OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.26 30-Sep-2008 miod

Do not perform cache operations in vmapbuf(), pmap is supposed to do them
for us if needed.

ok art@ kettenis@


Revision tags: OPENBSD_4_4_BASE
# 1.25 14-Jul-2008 miod

Use uvm_km_valloc_prefer_wait() instead of uvm_km_valloc_wait() in vmapbuf().

ok art@


# 1.24 15-Mar-2008 kettenis

Make GENERIC.MP work on the e10k. The e10k is a bit funky since UPA only
supports 32 ports, and a machine with up to 64 CPUs obviously needs more.
So the machine has a special ASIC that does port translation, and because
of that we need to distinguish between port ID's and interrupt target ID's.


Revision tags: OPENBSD_4_3_BASE
# 1.23 04-Jan-2008 kettenis

Prevent sign-extension when setting ASI in %tstate.


# 1.22 03-Jan-2008 kettenis

Fix debug code.


# 1.21 06-Nov-2007 kettenis

Close a race where we might save/drop the fpu state of the wrong process in
the ipi handlers.


# 1.20 31-Oct-2007 kettenis

Overhaul fpu context save/restore code, making it more similar to what we do
on i386 and amd64. Don't let IPIs in when saving fpu context by disabling
interrupts.


# 1.19 17-Oct-2007 kettenis

Sanitize debug printf.


# 1.18 16-Oct-2007 kettenis

Make lazy fpu context switching work for MULTIPROCESSOR kernels. Tested by
many.

ok deraadt@


# 1.17 13-Oct-2007 miod

Fix cpu_exit() comments to be more closer to reality.


# 1.16 10-Oct-2007 art

Make context switching much more MI:
- Move the functionality of choosing a process from cpu_switch into
a much simpler function: cpu_switchto. Instead of having the locore
code walk the run queues, let the MI code choose the process we
want to run and only implement the context switching itself in MD
code.
- Let MD context switching run without worrying about spls or locks.
- Instead of having the idle loop implemented with special contexts
in MD code, implement one idle proc for each cpu. make the idle
loop MI with MD hooks.
- Change the proc lists from the old style vax queues to TAILQs.
- Change the sleep queue from vax queues to TAILQs. This makes
wakeup() go from O(n^2) to O(n)

there will be some MD fallout, but it will be fixed shortly.
There's also a few cleanups to be done after this.

deraadt@, kettenis@ ok


Revision tags: OPENBSD_4_2_BASE
# 1.15 20-Jun-2007 miod

In vunmapbuf(), explicitely remove mappings before invoking uvm_km_free().
Even if the latter would end up removing the mappings by itself, it would
do so using pmap_remove() because phys_map is not intrsafe; but some
platforms use pmap_kenter_pa() in vmapbuf(). By removing the mappings
ourselves, we can ensure the remove function used matches the enter function
which has been used.
Discussed and theoretical ok art@


# 1.14 27-May-2007 miod

pagemove() is no longer used.


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE
# 1.13 29-May-2006 miod

Remove dead extern declarations.


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE
# 1.12 08-Aug-2005 kettenis

Skip (trap) instruction in cpu_fork() instead of proc_trampoline().
Fixes returning from fork(2) in the child with a pending signal.
tested by otto@, krw@, sturm@
ok deraadt@


# 1.11 29-Mar-2005 kettenis

sparc64 StackGhost.
ok deraadt@


Revision tags: OPENBSD_3_6_BASE OPENBSD_3_7_BASE SMP_SYNC_A SMP_SYNC_B
# 1.10 23-May-2004 deraadt

netbsd 1.54; do not count on new process having cleared condition codes;
hunted down by brian poole as relevant for the occassional cron failure
at startup...


Revision tags: OPENBSD_3_3_BASE OPENBSD_3_4_BASE OPENBSD_3_5_BASE UBC_SYNC_A
# 1.9 24-Feb-2003 miod

Oops, forgot to commit that part of the pmap_kenter changes; spotted by art@


Revision tags: OPENBSD_3_2_BASE UBC_SYNC_B
# 1.8 15-Jun-2002 art

Decruftification.

We will never have a.out kernels.
We will never have 32-bit kernels.
We will never have sun4c, sun4 and sun4m support in the sparc64 kernels.
We don't need support old netbsd libc.
The cpu will never be identified as some of the sun4c and sun4m types.
We don't need the gazillion of fields in cpuinfo that the sparc port uses.
Just generally remove dead code.

This is just a first step in making this meess readable.


Revision tags: OPENBSD_3_1_BASE
# 1.7 14-Mar-2002 millert

First round of __P removal in sys


Revision tags: UBC_BASE
# 1.6 04-Dec-2001 art

branches: 1.6.2;
Yet another sync to NetBSD uvm.
Today we add a pmap argument to pmap_update() and allocate map entries for
kernel_map from kmem_map instead of using the static entries. This should
get rid of MAX_KMAPENT panics. Also some uvm_loan problems are fixed.


# 1.5 06-Nov-2001 miod

Replace inclusion of <vm/foo.h> with the correct <uvm/bar.h> when necessary.
(Look ma, I might have broken the tree)


# 1.4 06-Nov-2001 art

Let fork1, uvm_fork, and cpu_fork take a function/argument pair as argument,
instead of doing fork1, cpu_set_kpc. This lets us retire cpu_set_kpc and
avoid a multiprocessor race.

This commit breaks vax because it doesn't look like any other arch, someone
working on vax might want to look at this and try to adapt the code to be
more like the rest of the world.

Idea and uvm parts from NetBSD.


Revision tags: OPENBSD_3_0_BASE
# 1.3 19-Sep-2001 mickey

branches: 1.3.4;
merge vm/vm_kern.h into uvm/uvm_extern.h; art@ ok


# 1.2 20-Aug-2001 jason

$OpenBSD$


# 1.1 19-Aug-2001 jason

Lot of stuff... Some from NetBSD, some from OpenBSD, minor modifications


# 1.42 25-Oct-2022 guenther

STACK_OFFSET was to support it varying when compiling some code for
either 32bit or 64bit. With the elimination of 32bit sparc bits
it was just a superfluous indirection of BIAS. Also, CCFSZ is gone.

ok miod@


# 1.41 21-Oct-2022 miod

Remove vestigial bits of 32-bit binaries support; drop the `64' suffix in
struct names when the matching `32' flavour got removed.

Joint work with cheloha@, all bugs mine.


Revision tags: OPENBSD_7_2_BASE
# 1.40 27-May-2022 kettenis

Convert KVA allocation to km_alloc(9).

ok deraadt@, mpi@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE OPENBSD_7_1_BASE
# 1.39 17-Aug-2017 tom

Fix typo in comments: s/return/returns/ in "a function that never return."


# 1.38 25-May-2017 dlg

tweak sparc64 membars as a step toward making them usable in userland.

specifically, dont rely on magic in ctlreg to implement membars. moving
that to atomic.h would add a lot of pollution to the namespace, so
move to passing the membar options to a single __membar macro.

this tweaks everything that was using the ctlreg backend to either use
an appropriate membar_foo(), or to use __membar() in the MD code.

ok kettenis@


# 1.37 30-Apr-2017 mpi

Rename Debugger() into db_enter().

Using a name with the 'db_' prefix makes it invisible from the dynamic
profiler.

ok deraadt@, kettenis@, visa@


Revision tags: OPENBSD_6_1_BASE
# 1.36 12-Feb-2017 guenther

Split up fork1():
- FORK_THREAD handling is a totally separate function, thread_fork(),
that is only used by sys___tfork() and which loses the flags, func,
arg, and newprocp parameters and gains tcb parameter to guarantee
the new thread's TCB is set before the creating thread returns
- fork1() loses its stack and tidptr parameters
Common bits factor out:
- struct proc allocation and initialization moves to thread_new()
- maxthread handling moves to fork_check_maxthread()
- setting the new thread running moves to fork_thread_start()
The MD cpu_fork() function swaps its unused stacksize parameter for
a tcb parameter.

luna88k testing by aoyama@, alpha testing by dlg@
ok mpi@


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.35 06-Nov-2015 guenther

Move the logic for adjusting userspace registers in the child after fork
from cpu_fork() to child_return(), putting all the SYSCALL_G2RFLAG logic
in trap.c

sparc testing by sebastia@ and miod@


# 1.34 08-Sep-2015 deraadt

sizes for free(); ok semarie


Revision tags: OPENBSD_5_8_BASE
# 1.33 05-May-2015 guenther

emul_native is only used for kernel threads which can't dump core, so
delete coredump_trad(), uvm_coredump(), cpu_coredump(), struct md_coredump,
and various #includes that are superfluous.

This leaves compat_linux processes without a coredump callback. If that
ability is desired, someone should update it to use coredump_elf32() and
verify the results...

ok kettenis@


Revision tags: OPENBSD_5_7_BASE
# 1.32 16-Nov-2014 deraadt

Replace a plethora of historical protection options with just
PROT_NONE, PROT_READ, PROT_WRITE, and PROT_EXEC from mman.h.
PROT_MASK is introduced as the one true way of extracting those bits.
Remove UVM_ADV_* wrapper, using the standard names.
ok doug guenther kettenis


# 1.31 24-Oct-2014 kettenis

Bring phys_map to sparc64 and use it in vmapbuf(9) and vunmapbuf(9).


Revision tags: OPENBSD_5_6_BASE
# 1.30 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.29 16-Jan-2013 miod

cpu_coredump() also needs to invoke vn_rdwr() without IO_NODELOCKED; only
affects a.out binaries' core dumps.


Revision tags: OPENBSD_5_2_BASE
# 1.28 21-Jun-2012 guenther

__tfork() needs to set the stack address of the new thread in the kernel,
so that it can't get a signal while still running on the parent thread's
stack. Also, pass in sizeof(struct __tfork) to provide forward compat
when more members are added. This is an ABI change, so switch syscall
numbers and bump lib majors this time.

ok deraadt@ matthew@


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE
# 1.27 13-Jan-2011 kettenis

Spin forever when waiting for completion of an FPU shootdown instead of
panicing if we spin for too long. It is difficult to find an upper bound
for the spin count and there is some evidence the current limit is too low.
We made similar changes to amd64/i386 some time ago.

ok deraadt@


Revision tags: OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.26 30-Sep-2008 miod

Do not perform cache operations in vmapbuf(), pmap is supposed to do them
for us if needed.

ok art@ kettenis@


Revision tags: OPENBSD_4_4_BASE
# 1.25 14-Jul-2008 miod

Use uvm_km_valloc_prefer_wait() instead of uvm_km_valloc_wait() in vmapbuf().

ok art@


# 1.24 15-Mar-2008 kettenis

Make GENERIC.MP work on the e10k. The e10k is a bit funky since UPA only
supports 32 ports, and a machine with up to 64 CPUs obviously needs more.
So the machine has a special ASIC that does port translation, and because
of that we need to distinguish between port ID's and interrupt target ID's.


Revision tags: OPENBSD_4_3_BASE
# 1.23 04-Jan-2008 kettenis

Prevent sign-extension when setting ASI in %tstate.


# 1.22 03-Jan-2008 kettenis

Fix debug code.


# 1.21 06-Nov-2007 kettenis

Close a race where we might save/drop the fpu state of the wrong process in
the ipi handlers.


# 1.20 31-Oct-2007 kettenis

Overhaul fpu context save/restore code, making it more similar to what we do
on i386 and amd64. Don't let IPIs in when saving fpu context by disabling
interrupts.


# 1.19 17-Oct-2007 kettenis

Sanitize debug printf.


# 1.18 16-Oct-2007 kettenis

Make lazy fpu context switching work for MULTIPROCESSOR kernels. Tested by
many.

ok deraadt@


# 1.17 13-Oct-2007 miod

Fix cpu_exit() comments to be more closer to reality.


# 1.16 10-Oct-2007 art

Make context switching much more MI:
- Move the functionality of choosing a process from cpu_switch into
a much simpler function: cpu_switchto. Instead of having the locore
code walk the run queues, let the MI code choose the process we
want to run and only implement the context switching itself in MD
code.
- Let MD context switching run without worrying about spls or locks.
- Instead of having the idle loop implemented with special contexts
in MD code, implement one idle proc for each cpu. make the idle
loop MI with MD hooks.
- Change the proc lists from the old style vax queues to TAILQs.
- Change the sleep queue from vax queues to TAILQs. This makes
wakeup() go from O(n^2) to O(n)

there will be some MD fallout, but it will be fixed shortly.
There's also a few cleanups to be done after this.

deraadt@, kettenis@ ok


Revision tags: OPENBSD_4_2_BASE
# 1.15 20-Jun-2007 miod

In vunmapbuf(), explicitely remove mappings before invoking uvm_km_free().
Even if the latter would end up removing the mappings by itself, it would
do so using pmap_remove() because phys_map is not intrsafe; but some
platforms use pmap_kenter_pa() in vmapbuf(). By removing the mappings
ourselves, we can ensure the remove function used matches the enter function
which has been used.
Discussed and theoretical ok art@


# 1.14 27-May-2007 miod

pagemove() is no longer used.


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE
# 1.13 29-May-2006 miod

Remove dead extern declarations.


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE
# 1.12 08-Aug-2005 kettenis

Skip (trap) instruction in cpu_fork() instead of proc_trampoline().
Fixes returning from fork(2) in the child with a pending signal.
tested by otto@, krw@, sturm@
ok deraadt@


# 1.11 29-Mar-2005 kettenis

sparc64 StackGhost.
ok deraadt@


Revision tags: OPENBSD_3_6_BASE OPENBSD_3_7_BASE SMP_SYNC_A SMP_SYNC_B
# 1.10 23-May-2004 deraadt

netbsd 1.54; do not count on new process having cleared condition codes;
hunted down by brian poole as relevant for the occassional cron failure
at startup...


Revision tags: OPENBSD_3_3_BASE OPENBSD_3_4_BASE OPENBSD_3_5_BASE UBC_SYNC_A
# 1.9 24-Feb-2003 miod

Oops, forgot to commit that part of the pmap_kenter changes; spotted by art@


Revision tags: OPENBSD_3_2_BASE UBC_SYNC_B
# 1.8 15-Jun-2002 art

Decruftification.

We will never have a.out kernels.
We will never have 32-bit kernels.
We will never have sun4c, sun4 and sun4m support in the sparc64 kernels.
We don't need support old netbsd libc.
The cpu will never be identified as some of the sun4c and sun4m types.
We don't need the gazillion of fields in cpuinfo that the sparc port uses.
Just generally remove dead code.

This is just a first step in making this meess readable.


Revision tags: OPENBSD_3_1_BASE
# 1.7 14-Mar-2002 millert

First round of __P removal in sys


Revision tags: UBC_BASE
# 1.6 04-Dec-2001 art

branches: 1.6.2;
Yet another sync to NetBSD uvm.
Today we add a pmap argument to pmap_update() and allocate map entries for
kernel_map from kmem_map instead of using the static entries. This should
get rid of MAX_KMAPENT panics. Also some uvm_loan problems are fixed.


# 1.5 06-Nov-2001 miod

Replace inclusion of <vm/foo.h> with the correct <uvm/bar.h> when necessary.
(Look ma, I might have broken the tree)


# 1.4 06-Nov-2001 art

Let fork1, uvm_fork, and cpu_fork take a function/argument pair as argument,
instead of doing fork1, cpu_set_kpc. This lets us retire cpu_set_kpc and
avoid a multiprocessor race.

This commit breaks vax because it doesn't look like any other arch, someone
working on vax might want to look at this and try to adapt the code to be
more like the rest of the world.

Idea and uvm parts from NetBSD.


Revision tags: OPENBSD_3_0_BASE
# 1.3 19-Sep-2001 mickey

branches: 1.3.4;
merge vm/vm_kern.h into uvm/uvm_extern.h; art@ ok


# 1.2 20-Aug-2001 jason

$OpenBSD$


# 1.1 19-Aug-2001 jason

Lot of stuff... Some from NetBSD, some from OpenBSD, minor modifications


# 1.41 21-Oct-2022 miod

Remove vestigial bits of 32-bit binaries support; drop the `64' suffix in
struct names when the matching `32' flavour got removed.

Joint work with cheloha@, all bugs mine.


Revision tags: OPENBSD_7_2_BASE
# 1.40 27-May-2022 kettenis

Convert KVA allocation to km_alloc(9).

ok deraadt@, mpi@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE OPENBSD_7_1_BASE
# 1.39 17-Aug-2017 tom

Fix typo in comments: s/return/returns/ in "a function that never return."


# 1.38 25-May-2017 dlg

tweak sparc64 membars as a step toward making them usable in userland.

specifically, dont rely on magic in ctlreg to implement membars. moving
that to atomic.h would add a lot of pollution to the namespace, so
move to passing the membar options to a single __membar macro.

this tweaks everything that was using the ctlreg backend to either use
an appropriate membar_foo(), or to use __membar() in the MD code.

ok kettenis@


# 1.37 30-Apr-2017 mpi

Rename Debugger() into db_enter().

Using a name with the 'db_' prefix makes it invisible from the dynamic
profiler.

ok deraadt@, kettenis@, visa@


Revision tags: OPENBSD_6_1_BASE
# 1.36 12-Feb-2017 guenther

Split up fork1():
- FORK_THREAD handling is a totally separate function, thread_fork(),
that is only used by sys___tfork() and which loses the flags, func,
arg, and newprocp parameters and gains tcb parameter to guarantee
the new thread's TCB is set before the creating thread returns
- fork1() loses its stack and tidptr parameters
Common bits factor out:
- struct proc allocation and initialization moves to thread_new()
- maxthread handling moves to fork_check_maxthread()
- setting the new thread running moves to fork_thread_start()
The MD cpu_fork() function swaps its unused stacksize parameter for
a tcb parameter.

luna88k testing by aoyama@, alpha testing by dlg@
ok mpi@


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.35 06-Nov-2015 guenther

Move the logic for adjusting userspace registers in the child after fork
from cpu_fork() to child_return(), putting all the SYSCALL_G2RFLAG logic
in trap.c

sparc testing by sebastia@ and miod@


# 1.34 08-Sep-2015 deraadt

sizes for free(); ok semarie


Revision tags: OPENBSD_5_8_BASE
# 1.33 05-May-2015 guenther

emul_native is only used for kernel threads which can't dump core, so
delete coredump_trad(), uvm_coredump(), cpu_coredump(), struct md_coredump,
and various #includes that are superfluous.

This leaves compat_linux processes without a coredump callback. If that
ability is desired, someone should update it to use coredump_elf32() and
verify the results...

ok kettenis@


Revision tags: OPENBSD_5_7_BASE
# 1.32 16-Nov-2014 deraadt

Replace a plethora of historical protection options with just
PROT_NONE, PROT_READ, PROT_WRITE, and PROT_EXEC from mman.h.
PROT_MASK is introduced as the one true way of extracting those bits.
Remove UVM_ADV_* wrapper, using the standard names.
ok doug guenther kettenis


# 1.31 24-Oct-2014 kettenis

Bring phys_map to sparc64 and use it in vmapbuf(9) and vunmapbuf(9).


Revision tags: OPENBSD_5_6_BASE
# 1.30 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.29 16-Jan-2013 miod

cpu_coredump() also needs to invoke vn_rdwr() without IO_NODELOCKED; only
affects a.out binaries' core dumps.


Revision tags: OPENBSD_5_2_BASE
# 1.28 21-Jun-2012 guenther

__tfork() needs to set the stack address of the new thread in the kernel,
so that it can't get a signal while still running on the parent thread's
stack. Also, pass in sizeof(struct __tfork) to provide forward compat
when more members are added. This is an ABI change, so switch syscall
numbers and bump lib majors this time.

ok deraadt@ matthew@


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE
# 1.27 13-Jan-2011 kettenis

Spin forever when waiting for completion of an FPU shootdown instead of
panicing if we spin for too long. It is difficult to find an upper bound
for the spin count and there is some evidence the current limit is too low.
We made similar changes to amd64/i386 some time ago.

ok deraadt@


Revision tags: OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.26 30-Sep-2008 miod

Do not perform cache operations in vmapbuf(), pmap is supposed to do them
for us if needed.

ok art@ kettenis@


Revision tags: OPENBSD_4_4_BASE
# 1.25 14-Jul-2008 miod

Use uvm_km_valloc_prefer_wait() instead of uvm_km_valloc_wait() in vmapbuf().

ok art@


# 1.24 15-Mar-2008 kettenis

Make GENERIC.MP work on the e10k. The e10k is a bit funky since UPA only
supports 32 ports, and a machine with up to 64 CPUs obviously needs more.
So the machine has a special ASIC that does port translation, and because
of that we need to distinguish between port ID's and interrupt target ID's.


Revision tags: OPENBSD_4_3_BASE
# 1.23 04-Jan-2008 kettenis

Prevent sign-extension when setting ASI in %tstate.


# 1.22 03-Jan-2008 kettenis

Fix debug code.


# 1.21 06-Nov-2007 kettenis

Close a race where we might save/drop the fpu state of the wrong process in
the ipi handlers.


# 1.20 31-Oct-2007 kettenis

Overhaul fpu context save/restore code, making it more similar to what we do
on i386 and amd64. Don't let IPIs in when saving fpu context by disabling
interrupts.


# 1.19 17-Oct-2007 kettenis

Sanitize debug printf.


# 1.18 16-Oct-2007 kettenis

Make lazy fpu context switching work for MULTIPROCESSOR kernels. Tested by
many.

ok deraadt@


# 1.17 13-Oct-2007 miod

Fix cpu_exit() comments to be more closer to reality.


# 1.16 10-Oct-2007 art

Make context switching much more MI:
- Move the functionality of choosing a process from cpu_switch into
a much simpler function: cpu_switchto. Instead of having the locore
code walk the run queues, let the MI code choose the process we
want to run and only implement the context switching itself in MD
code.
- Let MD context switching run without worrying about spls or locks.
- Instead of having the idle loop implemented with special contexts
in MD code, implement one idle proc for each cpu. make the idle
loop MI with MD hooks.
- Change the proc lists from the old style vax queues to TAILQs.
- Change the sleep queue from vax queues to TAILQs. This makes
wakeup() go from O(n^2) to O(n)

there will be some MD fallout, but it will be fixed shortly.
There's also a few cleanups to be done after this.

deraadt@, kettenis@ ok


Revision tags: OPENBSD_4_2_BASE
# 1.15 20-Jun-2007 miod

In vunmapbuf(), explicitely remove mappings before invoking uvm_km_free().
Even if the latter would end up removing the mappings by itself, it would
do so using pmap_remove() because phys_map is not intrsafe; but some
platforms use pmap_kenter_pa() in vmapbuf(). By removing the mappings
ourselves, we can ensure the remove function used matches the enter function
which has been used.
Discussed and theoretical ok art@


# 1.14 27-May-2007 miod

pagemove() is no longer used.


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE
# 1.13 29-May-2006 miod

Remove dead extern declarations.


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE
# 1.12 08-Aug-2005 kettenis

Skip (trap) instruction in cpu_fork() instead of proc_trampoline().
Fixes returning from fork(2) in the child with a pending signal.
tested by otto@, krw@, sturm@
ok deraadt@


# 1.11 29-Mar-2005 kettenis

sparc64 StackGhost.
ok deraadt@


Revision tags: OPENBSD_3_6_BASE OPENBSD_3_7_BASE SMP_SYNC_A SMP_SYNC_B
# 1.10 23-May-2004 deraadt

netbsd 1.54; do not count on new process having cleared condition codes;
hunted down by brian poole as relevant for the occassional cron failure
at startup...


Revision tags: OPENBSD_3_3_BASE OPENBSD_3_4_BASE OPENBSD_3_5_BASE UBC_SYNC_A
# 1.9 24-Feb-2003 miod

Oops, forgot to commit that part of the pmap_kenter changes; spotted by art@


Revision tags: OPENBSD_3_2_BASE UBC_SYNC_B
# 1.8 15-Jun-2002 art

Decruftification.

We will never have a.out kernels.
We will never have 32-bit kernels.
We will never have sun4c, sun4 and sun4m support in the sparc64 kernels.
We don't need support old netbsd libc.
The cpu will never be identified as some of the sun4c and sun4m types.
We don't need the gazillion of fields in cpuinfo that the sparc port uses.
Just generally remove dead code.

This is just a first step in making this meess readable.


Revision tags: OPENBSD_3_1_BASE
# 1.7 14-Mar-2002 millert

First round of __P removal in sys


Revision tags: UBC_BASE
# 1.6 04-Dec-2001 art

branches: 1.6.2;
Yet another sync to NetBSD uvm.
Today we add a pmap argument to pmap_update() and allocate map entries for
kernel_map from kmem_map instead of using the static entries. This should
get rid of MAX_KMAPENT panics. Also some uvm_loan problems are fixed.


# 1.5 06-Nov-2001 miod

Replace inclusion of <vm/foo.h> with the correct <uvm/bar.h> when necessary.
(Look ma, I might have broken the tree)


# 1.4 06-Nov-2001 art

Let fork1, uvm_fork, and cpu_fork take a function/argument pair as argument,
instead of doing fork1, cpu_set_kpc. This lets us retire cpu_set_kpc and
avoid a multiprocessor race.

This commit breaks vax because it doesn't look like any other arch, someone
working on vax might want to look at this and try to adapt the code to be
more like the rest of the world.

Idea and uvm parts from NetBSD.


Revision tags: OPENBSD_3_0_BASE
# 1.3 19-Sep-2001 mickey

branches: 1.3.4;
merge vm/vm_kern.h into uvm/uvm_extern.h; art@ ok


# 1.2 20-Aug-2001 jason

$OpenBSD$


# 1.1 19-Aug-2001 jason

Lot of stuff... Some from NetBSD, some from OpenBSD, minor modifications


# 1.40 27-May-2022 kettenis

Convert KVA allocation to km_alloc(9).

ok deraadt@, mpi@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE OPENBSD_7_1_BASE
# 1.39 17-Aug-2017 tom

Fix typo in comments: s/return/returns/ in "a function that never return."


# 1.38 25-May-2017 dlg

tweak sparc64 membars as a step toward making them usable in userland.

specifically, dont rely on magic in ctlreg to implement membars. moving
that to atomic.h would add a lot of pollution to the namespace, so
move to passing the membar options to a single __membar macro.

this tweaks everything that was using the ctlreg backend to either use
an appropriate membar_foo(), or to use __membar() in the MD code.

ok kettenis@


# 1.37 30-Apr-2017 mpi

Rename Debugger() into db_enter().

Using a name with the 'db_' prefix makes it invisible from the dynamic
profiler.

ok deraadt@, kettenis@, visa@


Revision tags: OPENBSD_6_1_BASE
# 1.36 12-Feb-2017 guenther

Split up fork1():
- FORK_THREAD handling is a totally separate function, thread_fork(),
that is only used by sys___tfork() and which loses the flags, func,
arg, and newprocp parameters and gains tcb parameter to guarantee
the new thread's TCB is set before the creating thread returns
- fork1() loses its stack and tidptr parameters
Common bits factor out:
- struct proc allocation and initialization moves to thread_new()
- maxthread handling moves to fork_check_maxthread()
- setting the new thread running moves to fork_thread_start()
The MD cpu_fork() function swaps its unused stacksize parameter for
a tcb parameter.

luna88k testing by aoyama@, alpha testing by dlg@
ok mpi@


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.35 06-Nov-2015 guenther

Move the logic for adjusting userspace registers in the child after fork
from cpu_fork() to child_return(), putting all the SYSCALL_G2RFLAG logic
in trap.c

sparc testing by sebastia@ and miod@


# 1.34 08-Sep-2015 deraadt

sizes for free(); ok semarie


Revision tags: OPENBSD_5_8_BASE
# 1.33 05-May-2015 guenther

emul_native is only used for kernel threads which can't dump core, so
delete coredump_trad(), uvm_coredump(), cpu_coredump(), struct md_coredump,
and various #includes that are superfluous.

This leaves compat_linux processes without a coredump callback. If that
ability is desired, someone should update it to use coredump_elf32() and
verify the results...

ok kettenis@


Revision tags: OPENBSD_5_7_BASE
# 1.32 16-Nov-2014 deraadt

Replace a plethora of historical protection options with just
PROT_NONE, PROT_READ, PROT_WRITE, and PROT_EXEC from mman.h.
PROT_MASK is introduced as the one true way of extracting those bits.
Remove UVM_ADV_* wrapper, using the standard names.
ok doug guenther kettenis


# 1.31 24-Oct-2014 kettenis

Bring phys_map to sparc64 and use it in vmapbuf(9) and vunmapbuf(9).


Revision tags: OPENBSD_5_6_BASE
# 1.30 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.29 16-Jan-2013 miod

cpu_coredump() also needs to invoke vn_rdwr() without IO_NODELOCKED; only
affects a.out binaries' core dumps.


Revision tags: OPENBSD_5_2_BASE
# 1.28 21-Jun-2012 guenther

__tfork() needs to set the stack address of the new thread in the kernel,
so that it can't get a signal while still running on the parent thread's
stack. Also, pass in sizeof(struct __tfork) to provide forward compat
when more members are added. This is an ABI change, so switch syscall
numbers and bump lib majors this time.

ok deraadt@ matthew@


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE
# 1.27 13-Jan-2011 kettenis

Spin forever when waiting for completion of an FPU shootdown instead of
panicing if we spin for too long. It is difficult to find an upper bound
for the spin count and there is some evidence the current limit is too low.
We made similar changes to amd64/i386 some time ago.

ok deraadt@


Revision tags: OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.26 30-Sep-2008 miod

Do not perform cache operations in vmapbuf(), pmap is supposed to do them
for us if needed.

ok art@ kettenis@


Revision tags: OPENBSD_4_4_BASE
# 1.25 14-Jul-2008 miod

Use uvm_km_valloc_prefer_wait() instead of uvm_km_valloc_wait() in vmapbuf().

ok art@


# 1.24 15-Mar-2008 kettenis

Make GENERIC.MP work on the e10k. The e10k is a bit funky since UPA only
supports 32 ports, and a machine with up to 64 CPUs obviously needs more.
So the machine has a special ASIC that does port translation, and because
of that we need to distinguish between port ID's and interrupt target ID's.


Revision tags: OPENBSD_4_3_BASE
# 1.23 04-Jan-2008 kettenis

Prevent sign-extension when setting ASI in %tstate.


# 1.22 03-Jan-2008 kettenis

Fix debug code.


# 1.21 06-Nov-2007 kettenis

Close a race where we might save/drop the fpu state of the wrong process in
the ipi handlers.


# 1.20 31-Oct-2007 kettenis

Overhaul fpu context save/restore code, making it more similar to what we do
on i386 and amd64. Don't let IPIs in when saving fpu context by disabling
interrupts.


# 1.19 17-Oct-2007 kettenis

Sanitize debug printf.


# 1.18 16-Oct-2007 kettenis

Make lazy fpu context switching work for MULTIPROCESSOR kernels. Tested by
many.

ok deraadt@


# 1.17 13-Oct-2007 miod

Fix cpu_exit() comments to be more closer to reality.


# 1.16 10-Oct-2007 art

Make context switching much more MI:
- Move the functionality of choosing a process from cpu_switch into
a much simpler function: cpu_switchto. Instead of having the locore
code walk the run queues, let the MI code choose the process we
want to run and only implement the context switching itself in MD
code.
- Let MD context switching run without worrying about spls or locks.
- Instead of having the idle loop implemented with special contexts
in MD code, implement one idle proc for each cpu. make the idle
loop MI with MD hooks.
- Change the proc lists from the old style vax queues to TAILQs.
- Change the sleep queue from vax queues to TAILQs. This makes
wakeup() go from O(n^2) to O(n)

there will be some MD fallout, but it will be fixed shortly.
There's also a few cleanups to be done after this.

deraadt@, kettenis@ ok


Revision tags: OPENBSD_4_2_BASE
# 1.15 20-Jun-2007 miod

In vunmapbuf(), explicitely remove mappings before invoking uvm_km_free().
Even if the latter would end up removing the mappings by itself, it would
do so using pmap_remove() because phys_map is not intrsafe; but some
platforms use pmap_kenter_pa() in vmapbuf(). By removing the mappings
ourselves, we can ensure the remove function used matches the enter function
which has been used.
Discussed and theoretical ok art@


# 1.14 27-May-2007 miod

pagemove() is no longer used.


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE
# 1.13 29-May-2006 miod

Remove dead extern declarations.


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE
# 1.12 08-Aug-2005 kettenis

Skip (trap) instruction in cpu_fork() instead of proc_trampoline().
Fixes returning from fork(2) in the child with a pending signal.
tested by otto@, krw@, sturm@
ok deraadt@


# 1.11 29-Mar-2005 kettenis

sparc64 StackGhost.
ok deraadt@


Revision tags: OPENBSD_3_6_BASE OPENBSD_3_7_BASE SMP_SYNC_A SMP_SYNC_B
# 1.10 23-May-2004 deraadt

netbsd 1.54; do not count on new process having cleared condition codes;
hunted down by brian poole as relevant for the occassional cron failure
at startup...


Revision tags: OPENBSD_3_3_BASE OPENBSD_3_4_BASE OPENBSD_3_5_BASE UBC_SYNC_A
# 1.9 24-Feb-2003 miod

Oops, forgot to commit that part of the pmap_kenter changes; spotted by art@


Revision tags: OPENBSD_3_2_BASE UBC_SYNC_B
# 1.8 15-Jun-2002 art

Decruftification.

We will never have a.out kernels.
We will never have 32-bit kernels.
We will never have sun4c, sun4 and sun4m support in the sparc64 kernels.
We don't need support old netbsd libc.
The cpu will never be identified as some of the sun4c and sun4m types.
We don't need the gazillion of fields in cpuinfo that the sparc port uses.
Just generally remove dead code.

This is just a first step in making this meess readable.


Revision tags: OPENBSD_3_1_BASE
# 1.7 14-Mar-2002 millert

First round of __P removal in sys


Revision tags: UBC_BASE
# 1.6 04-Dec-2001 art

branches: 1.6.2;
Yet another sync to NetBSD uvm.
Today we add a pmap argument to pmap_update() and allocate map entries for
kernel_map from kmem_map instead of using the static entries. This should
get rid of MAX_KMAPENT panics. Also some uvm_loan problems are fixed.


# 1.5 06-Nov-2001 miod

Replace inclusion of <vm/foo.h> with the correct <uvm/bar.h> when necessary.
(Look ma, I might have broken the tree)


# 1.4 06-Nov-2001 art

Let fork1, uvm_fork, and cpu_fork take a function/argument pair as argument,
instead of doing fork1, cpu_set_kpc. This lets us retire cpu_set_kpc and
avoid a multiprocessor race.

This commit breaks vax because it doesn't look like any other arch, someone
working on vax might want to look at this and try to adapt the code to be
more like the rest of the world.

Idea and uvm parts from NetBSD.


Revision tags: OPENBSD_3_0_BASE
# 1.3 19-Sep-2001 mickey

branches: 1.3.4;
merge vm/vm_kern.h into uvm/uvm_extern.h; art@ ok


# 1.2 20-Aug-2001 jason

$OpenBSD$


# 1.1 19-Aug-2001 jason

Lot of stuff... Some from NetBSD, some from OpenBSD, minor modifications


Revision tags: OPENBSD_6_2_BASE
# 1.39 17-Aug-2017 tom

Fix typo in comments: s/return/returns/ in "a function that never return."


# 1.38 25-May-2017 dlg

tweak sparc64 membars as a step toward making them usable in userland.

specifically, dont rely on magic in ctlreg to implement membars. moving
that to atomic.h would add a lot of pollution to the namespace, so
move to passing the membar options to a single __membar macro.

this tweaks everything that was using the ctlreg backend to either use
an appropriate membar_foo(), or to use __membar() in the MD code.

ok kettenis@


# 1.37 30-Apr-2017 mpi

Rename Debugger() into db_enter().

Using a name with the 'db_' prefix makes it invisible from the dynamic
profiler.

ok deraadt@, kettenis@, visa@


Revision tags: OPENBSD_6_1_BASE
# 1.36 12-Feb-2017 guenther

Split up fork1():
- FORK_THREAD handling is a totally separate function, thread_fork(),
that is only used by sys___tfork() and which loses the flags, func,
arg, and newprocp parameters and gains tcb parameter to guarantee
the new thread's TCB is set before the creating thread returns
- fork1() loses its stack and tidptr parameters
Common bits factor out:
- struct proc allocation and initialization moves to thread_new()
- maxthread handling moves to fork_check_maxthread()
- setting the new thread running moves to fork_thread_start()
The MD cpu_fork() function swaps its unused stacksize parameter for
a tcb parameter.

luna88k testing by aoyama@, alpha testing by dlg@
ok mpi@


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.35 06-Nov-2015 guenther

Move the logic for adjusting userspace registers in the child after fork
from cpu_fork() to child_return(), putting all the SYSCALL_G2RFLAG logic
in trap.c

sparc testing by sebastia@ and miod@


# 1.34 08-Sep-2015 deraadt

sizes for free(); ok semarie


Revision tags: OPENBSD_5_8_BASE
# 1.33 05-May-2015 guenther

emul_native is only used for kernel threads which can't dump core, so
delete coredump_trad(), uvm_coredump(), cpu_coredump(), struct md_coredump,
and various #includes that are superfluous.

This leaves compat_linux processes without a coredump callback. If that
ability is desired, someone should update it to use coredump_elf32() and
verify the results...

ok kettenis@


Revision tags: OPENBSD_5_7_BASE
# 1.32 16-Nov-2014 deraadt

Replace a plethora of historical protection options with just
PROT_NONE, PROT_READ, PROT_WRITE, and PROT_EXEC from mman.h.
PROT_MASK is introduced as the one true way of extracting those bits.
Remove UVM_ADV_* wrapper, using the standard names.
ok doug guenther kettenis


# 1.31 24-Oct-2014 kettenis

Bring phys_map to sparc64 and use it in vmapbuf(9) and vunmapbuf(9).


Revision tags: OPENBSD_5_6_BASE
# 1.30 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.29 16-Jan-2013 miod

cpu_coredump() also needs to invoke vn_rdwr() without IO_NODELOCKED; only
affects a.out binaries' core dumps.


Revision tags: OPENBSD_5_2_BASE
# 1.28 21-Jun-2012 guenther

__tfork() needs to set the stack address of the new thread in the kernel,
so that it can't get a signal while still running on the parent thread's
stack. Also, pass in sizeof(struct __tfork) to provide forward compat
when more members are added. This is an ABI change, so switch syscall
numbers and bump lib majors this time.

ok deraadt@ matthew@


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE
# 1.27 13-Jan-2011 kettenis

Spin forever when waiting for completion of an FPU shootdown instead of
panicing if we spin for too long. It is difficult to find an upper bound
for the spin count and there is some evidence the current limit is too low.
We made similar changes to amd64/i386 some time ago.

ok deraadt@


Revision tags: OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.26 30-Sep-2008 miod

Do not perform cache operations in vmapbuf(), pmap is supposed to do them
for us if needed.

ok art@ kettenis@


Revision tags: OPENBSD_4_4_BASE
# 1.25 14-Jul-2008 miod

Use uvm_km_valloc_prefer_wait() instead of uvm_km_valloc_wait() in vmapbuf().

ok art@


# 1.24 15-Mar-2008 kettenis

Make GENERIC.MP work on the e10k. The e10k is a bit funky since UPA only
supports 32 ports, and a machine with up to 64 CPUs obviously needs more.
So the machine has a special ASIC that does port translation, and because
of that we need to distinguish between port ID's and interrupt target ID's.


Revision tags: OPENBSD_4_3_BASE
# 1.23 04-Jan-2008 kettenis

Prevent sign-extension when setting ASI in %tstate.


# 1.22 03-Jan-2008 kettenis

Fix debug code.


# 1.21 06-Nov-2007 kettenis

Close a race where we might save/drop the fpu state of the wrong process in
the ipi handlers.


# 1.20 31-Oct-2007 kettenis

Overhaul fpu context save/restore code, making it more similar to what we do
on i386 and amd64. Don't let IPIs in when saving fpu context by disabling
interrupts.


# 1.19 17-Oct-2007 kettenis

Sanitize debug printf.


# 1.18 16-Oct-2007 kettenis

Make lazy fpu context switching work for MULTIPROCESSOR kernels. Tested by
many.

ok deraadt@


# 1.17 13-Oct-2007 miod

Fix cpu_exit() comments to be more closer to reality.


# 1.16 10-Oct-2007 art

Make context switching much more MI:
- Move the functionality of choosing a process from cpu_switch into
a much simpler function: cpu_switchto. Instead of having the locore
code walk the run queues, let the MI code choose the process we
want to run and only implement the context switching itself in MD
code.
- Let MD context switching run without worrying about spls or locks.
- Instead of having the idle loop implemented with special contexts
in MD code, implement one idle proc for each cpu. make the idle
loop MI with MD hooks.
- Change the proc lists from the old style vax queues to TAILQs.
- Change the sleep queue from vax queues to TAILQs. This makes
wakeup() go from O(n^2) to O(n)

there will be some MD fallout, but it will be fixed shortly.
There's also a few cleanups to be done after this.

deraadt@, kettenis@ ok


Revision tags: OPENBSD_4_2_BASE
# 1.15 20-Jun-2007 miod

In vunmapbuf(), explicitely remove mappings before invoking uvm_km_free().
Even if the latter would end up removing the mappings by itself, it would
do so using pmap_remove() because phys_map is not intrsafe; but some
platforms use pmap_kenter_pa() in vmapbuf(). By removing the mappings
ourselves, we can ensure the remove function used matches the enter function
which has been used.
Discussed and theoretical ok art@


# 1.14 27-May-2007 miod

pagemove() is no longer used.


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE
# 1.13 29-May-2006 miod

Remove dead extern declarations.


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE
# 1.12 08-Aug-2005 kettenis

Skip (trap) instruction in cpu_fork() instead of proc_trampoline().
Fixes returning from fork(2) in the child with a pending signal.
tested by otto@, krw@, sturm@
ok deraadt@


# 1.11 29-Mar-2005 kettenis

sparc64 StackGhost.
ok deraadt@


Revision tags: OPENBSD_3_6_BASE OPENBSD_3_7_BASE SMP_SYNC_A SMP_SYNC_B
# 1.10 23-May-2004 deraadt

netbsd 1.54; do not count on new process having cleared condition codes;
hunted down by brian poole as relevant for the occassional cron failure
at startup...


Revision tags: OPENBSD_3_3_BASE OPENBSD_3_4_BASE OPENBSD_3_5_BASE UBC_SYNC_A
# 1.9 24-Feb-2003 miod

Oops, forgot to commit that part of the pmap_kenter changes; spotted by art@


Revision tags: OPENBSD_3_2_BASE UBC_SYNC_B
# 1.8 15-Jun-2002 art

Decruftification.

We will never have a.out kernels.
We will never have 32-bit kernels.
We will never have sun4c, sun4 and sun4m support in the sparc64 kernels.
We don't need support old netbsd libc.
The cpu will never be identified as some of the sun4c and sun4m types.
We don't need the gazillion of fields in cpuinfo that the sparc port uses.
Just generally remove dead code.

This is just a first step in making this meess readable.


Revision tags: OPENBSD_3_1_BASE
# 1.7 14-Mar-2002 millert

First round of __P removal in sys


Revision tags: UBC_BASE
# 1.6 04-Dec-2001 art

branches: 1.6.2;
Yet another sync to NetBSD uvm.
Today we add a pmap argument to pmap_update() and allocate map entries for
kernel_map from kmem_map instead of using the static entries. This should
get rid of MAX_KMAPENT panics. Also some uvm_loan problems are fixed.


# 1.5 06-Nov-2001 miod

Replace inclusion of <vm/foo.h> with the correct <uvm/bar.h> when necessary.
(Look ma, I might have broken the tree)


# 1.4 06-Nov-2001 art

Let fork1, uvm_fork, and cpu_fork take a function/argument pair as argument,
instead of doing fork1, cpu_set_kpc. This lets us retire cpu_set_kpc and
avoid a multiprocessor race.

This commit breaks vax because it doesn't look like any other arch, someone
working on vax might want to look at this and try to adapt the code to be
more like the rest of the world.

Idea and uvm parts from NetBSD.


Revision tags: OPENBSD_3_0_BASE
# 1.3 19-Sep-2001 mickey

branches: 1.3.4;
merge vm/vm_kern.h into uvm/uvm_extern.h; art@ ok


# 1.2 20-Aug-2001 jason

$OpenBSD$


# 1.1 19-Aug-2001 jason

Lot of stuff... Some from NetBSD, some from OpenBSD, minor modifications