History log of /openbsd-current/sys/arch/sh/sh/vm_machdep.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.18 24-Oct-2023 claudio

Normally context switches happen in mi_switch() but there are 3 cases
where a switch happens outside. Cleanup these code paths and make the
machine independent.

- when a process forks (fork, tfork, kthread), the new proc needs to
somehow be scheduled for the first time. This is done by proc_trampoline.
Since proc_trampoline is machine dependent assembler code change
the MP specific proc_trampoline_mp() to proc_trampoline_mi() and make
sure it is now always called.
- cpu_hatch: when booting APs the code needs to jump to the first proc
running on that CPU. This should be the idle thread for that CPU.
- sched_exit: when a proc exits it needs to switch away from itself and
then instruct the reaper to clean up the rest. This is done by switching
to the idle loop.

Since the last two cases require a context switch to the idle proc factor
out the common code to sched_toidle() and use it in those places.

Tested by many on all archs.
OK miod@ mpi@ cheloha@


Revision tags: OPENBSD_7_2_BASE OPENBSD_7_3_BASE OPENBSD_7_4_BASE
# 1.17 27-May-2022 kettenis

Convert KVA allocation to km_alloc(9).

ok deraadt@, mpi@


Revision tags: OPENBSD_7_0_BASE OPENBSD_7_1_BASE
# 1.16 16-May-2021 jsg

b_saveaddr has a type of void * use NULL not 0


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
# 1.15 17-Aug-2017 tom

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


Revision tags: OPENBSD_6_1_BASE
# 1.14 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_8_BASE OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.13 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.12 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


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.11 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_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.10 14-Jul-2008 miod

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

ok art@


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.9 27-May-2007 miod

pagemove() is no longer used.


Revision tags: OPENBSD_4_1_BASE
# 1.8 02-Mar-2007 miod

Move landisk to hardware floating point. At the moment the FPU context is
always saved upon context switches, as FPU registers are heavily used for
long long computations (don't ask). Gcc default to -m4.

Credits to drahn@ otto@ and deraadt@ for feedback and help testing.

Upgrade procedure if you don't want to use the damn snapshots:
- build and install new kernel, reboot off it
- build new gcc, do not install it yet
- make includes
- install new gcc
- build and install lib/csu and lib/libc
- make build


# 1.7 17-Nov-2006 deraadt

sorry miod, but this version locks the machine up rather fast


# 1.6 16-Nov-2006 miod

pagemove() this time without an accidental line removal


# 1.5 16-Nov-2006 deraadt

backout pagemove() diff; does not work


# 1.4 14-Nov-2006 miod

A less awkward pagemove() implementation.


# 1.3 05-Nov-2006 miod

Fix a couple of comments.


# 1.2 03-Nov-2006 mickey

mdproc has to be initialised


# 1.1 06-Oct-2006 miod

branches: 1.1.1;
Initial revision


# 1.17 27-May-2022 kettenis

Convert KVA allocation to km_alloc(9).

ok deraadt@, mpi@


Revision tags: OPENBSD_7_0_BASE OPENBSD_7_1_BASE
# 1.16 16-May-2021 jsg

b_saveaddr has a type of void * use NULL not 0


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
# 1.15 17-Aug-2017 tom

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


Revision tags: OPENBSD_6_1_BASE
# 1.14 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_8_BASE OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.13 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.12 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


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.11 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_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.10 14-Jul-2008 miod

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

ok art@


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.9 27-May-2007 miod

pagemove() is no longer used.


Revision tags: OPENBSD_4_1_BASE
# 1.8 02-Mar-2007 miod

Move landisk to hardware floating point. At the moment the FPU context is
always saved upon context switches, as FPU registers are heavily used for
long long computations (don't ask). Gcc default to -m4.

Credits to drahn@ otto@ and deraadt@ for feedback and help testing.

Upgrade procedure if you don't want to use the damn snapshots:
- build and install new kernel, reboot off it
- build new gcc, do not install it yet
- make includes
- install new gcc
- build and install lib/csu and lib/libc
- make build


# 1.7 17-Nov-2006 deraadt

sorry miod, but this version locks the machine up rather fast


# 1.6 16-Nov-2006 miod

pagemove() this time without an accidental line removal


# 1.5 16-Nov-2006 deraadt

backout pagemove() diff; does not work


# 1.4 14-Nov-2006 miod

A less awkward pagemove() implementation.


# 1.3 05-Nov-2006 miod

Fix a couple of comments.


# 1.2 03-Nov-2006 mickey

mdproc has to be initialised


# 1.1 06-Oct-2006 miod

branches: 1.1.1;
Initial revision


# 1.16 16-May-2021 jsg

b_saveaddr has a type of void * use NULL not 0


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
# 1.15 17-Aug-2017 tom

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


Revision tags: OPENBSD_6_1_BASE
# 1.14 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_8_BASE OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.13 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.12 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


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.11 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_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.10 14-Jul-2008 miod

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

ok art@


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.9 27-May-2007 miod

pagemove() is no longer used.


Revision tags: OPENBSD_4_1_BASE
# 1.8 02-Mar-2007 miod

Move landisk to hardware floating point. At the moment the FPU context is
always saved upon context switches, as FPU registers are heavily used for
long long computations (don't ask). Gcc default to -m4.

Credits to drahn@ otto@ and deraadt@ for feedback and help testing.

Upgrade procedure if you don't want to use the damn snapshots:
- build and install new kernel, reboot off it
- build new gcc, do not install it yet
- make includes
- install new gcc
- build and install lib/csu and lib/libc
- make build


# 1.7 17-Nov-2006 deraadt

sorry miod, but this version locks the machine up rather fast


# 1.6 16-Nov-2006 miod

pagemove() this time without an accidental line removal


# 1.5 16-Nov-2006 deraadt

backout pagemove() diff; does not work


# 1.4 14-Nov-2006 miod

A less awkward pagemove() implementation.


# 1.3 05-Nov-2006 miod

Fix a couple of comments.


# 1.2 03-Nov-2006 mickey

mdproc has to be initialised


# 1.1 06-Oct-2006 miod

branches: 1.1.1;
Initial revision


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

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


Revision tags: OPENBSD_6_1_BASE
# 1.14 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_8_BASE OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.13 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.12 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


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.11 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_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.10 14-Jul-2008 miod

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

ok art@


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.9 27-May-2007 miod

pagemove() is no longer used.


Revision tags: OPENBSD_4_1_BASE
# 1.8 02-Mar-2007 miod

Move landisk to hardware floating point. At the moment the FPU context is
always saved upon context switches, as FPU registers are heavily used for
long long computations (don't ask). Gcc default to -m4.

Credits to drahn@ otto@ and deraadt@ for feedback and help testing.

Upgrade procedure if you don't want to use the damn snapshots:
- build and install new kernel, reboot off it
- build new gcc, do not install it yet
- make includes
- install new gcc
- build and install lib/csu and lib/libc
- make build


# 1.7 17-Nov-2006 deraadt

sorry miod, but this version locks the machine up rather fast


# 1.6 16-Nov-2006 miod

pagemove() this time without an accidental line removal


# 1.5 16-Nov-2006 deraadt

backout pagemove() diff; does not work


# 1.4 14-Nov-2006 miod

A less awkward pagemove() implementation.


# 1.3 05-Nov-2006 miod

Fix a couple of comments.


# 1.2 03-Nov-2006 mickey

mdproc has to be initialised


# 1.1 06-Oct-2006 miod

branches: 1.1.1;
Initial revision