Home | History | Annotate | Download | only in sh3
History log of /src/sys/arch/sh3/sh3/sh3_machdep.c
RevisionDateAuthorComments
 1.114  16-Mar-2025  riastradh Clear trapframe on exec.

Do this for all architectures, even if the trapframe is fully
initialized -- makes it easier to audit and be confident it's
correct, and most likely (with the exception of sh3 which has an
intermediate call to ufetch_int in the middle) the compiler can
eliminate redundant stores in these routines.

PR kern/59084: exec/spawn leaks register content
 1.113  20-Dec-2023  thorpej Remove unnecessary <sys/malloc.h>.
 1.112  23-Feb-2022  andvar fix various typos in comments, mainly immediatly/immediately/,
as well shared and recently fixed typos in OpenBSD code by Jonathan Grey.
 1.111  01-Nov-2021  thorpej Use "stack_t" instead of "struct sigaltstack", as the former is the
newer standardized name. NFC.
 1.110  11-Jun-2020  ad uvm_availmem(): give it a boolean argument to specify whether a recent
cached value will do, or if the very latest total must be fetched. It can
be called thousands of times a second and fetching the totals impacts not
only the calling LWP but other CPUs doing unrelated activity in the VM
system.
 1.109  31-Dec-2019  ad Rename uvm_free() -> uvm_availmem().
 1.108  21-Dec-2019  ad uvmexp.free -> uvm_free()
 1.107  06-Apr-2019  thorpej Overhaul the API used to fetch and store individual memory cells in
userspace. The old fetch(9) and store(9) APIs (fubyte(), fuword(),
subyte(), suword(), etc.) are retired and replaced with new ufetch(9)
and ustore(9) APIs that can return proper error codes, etc. and are
implemented consistently across all platforms. The interrupt-safe
variants are no longer supported (and several of the existing attempts
at fuswintr(), etc. were buggy and not actually interrupt-safe).

Also augmement the ucas(9) API, making it consistently available on
all plaforms, supporting uniprocessor and multiprocessor systems, even
those that do not have CAS or LL/SC primitives.

Welcome to NetBSD 8.99.37.
 1.106  27-Nov-2018  maxv Fix widespread leak in the sendsig_siginfo() functions. sigframe_siginfo
has padding, so zero it out properly. While here I'm also zeroing out some
other things in several ports, for safety. Same problem in netbsd32, so
fix that too.

I can't compile-test on each architecture, but there should be no
breakage (tm).

Overall this fixes at least 14 info leaks. Prompted by the discovery by
KLEAK of a leak in amd64's sendsig_siginfo.
 1.105  22-Dec-2016  cherry branches: 1.105.8; 1.105.14; 1.105.16;
switch all ports to use uvm_init.c:uvm_md_init()

uvm_setpagesize() is now subsumed within this funciton.
 1.104  02-Nov-2016  pgoyette * Split sys/kern/sys_process.c into three parts:
1 - ptrace(2) syscall for native emulation
2 - common ptrace(2) syscall code (shared with compat_netbsd32)
3 - support routines that are shared with PROCFS and/or KTRACE

* Add module glue for #1 and #2. Both modules will be built-in to the
kernel if "options PTRACE" is included in the config file (this is
the default, defined in sys/conf/std).

* Mark the ptrace(2) syscall as modular in syscalls.master (generated
files will be committed shortly).

* Conditionalize all remaining portions of PTRACE code on a new kernel
option PTRACE_HOOKS.

XXX Instead of PROCFS depending on 'options PTRACE', we should probably
just add a procfs attribute to the sys/kern/sys_process.c file's
entry in files.kern, and add PROCFS to the "#if defineds" for
process_domem(). It's really confusing to have two different ways
of requiring this file.
 1.103  22-Nov-2015  tsutsui branches: 1.103.2;
Remove \n from set_cpumodel(), and explicitly print \n during boot instead.

Fixes dmesg on NetBSD/dreamcast 7.0 (and probably NetBSD/hpcsh 7.0):
---
NetBSD 7.0 (GENERIC.201509250726Z)
SEGA Dreamcasttotal memory = 16384 KB
avail memory = 13668 KB
---
which was mangled when cpu_getmode() and cpu_setmodel() were introduced:
http://mail-index.netbsd.org/source-changes/2014/03/24/msg053273.html

Should be pulled up to netbsd-7 and netbsd-7-0.
 1.102  24-Mar-2014  christos branches: 1.102.4; 1.102.6; 1.102.8;
use cpu_{g,s}etmodel
 1.101  21-Sep-2012  ryo branches: 1.101.2;
adapt for _UC_TLSBASE.

Approved by manu@ and msaitoh@
 1.100  08-Jul-2012  dsl branches: 1.100.2;
The MDP_USEDFPU (amd64 and sh3) and MDP_SSTEP (sh3) are lwp flags not
process ones, rename to MDL_xxx.
 1.99  21-May-2012  martin Calling _lwp_create() with a bogus ucontext could trigger a kernel
assertion failure (and thus a crash in DIAGNOSTIC kernels). Independently
discovered by YAMAMOTO Takashi and Joel Sing.

To avoid this, introduce a cpu_mcontext_validate() function and move all
sanity checks from cpu_setmcontext() there. Also untangle the netbsd32
compat mess slightly and add a cpu_mcontext32_validate() cousin there.

Add an exhaustive atf test case, based partly on code from Joel Sing.

Should finally fix the remaining open part of PR kern/43903.
 1.98  19-Feb-2012  rmind Remove COMPAT_SA / KERN_SA. Welcome to 6.99.3!
Approved by core@.
 1.97  12-Feb-2012  matt branches: 1.97.2;
Change old-style function defintions to C89 prototypes.

Approved by releng.
 1.96  25-Jul-2011  dyoung branches: 1.96.2; 1.96.6;
Move some macros back to sh3/include/bus_funcs.h from
sh3/sh3/sh3_machdep.c, where I moved them by mistake.

Pull the bus_space(9) routines into a new module,
sh3/sh3/sh3_bus_space.c, that is built only on !landisk.

Fixes the mmeye and landisk builds. Should fix other sh3 ports.
 1.95  25-Jul-2011  dyoung Move the sh_memio_*() declarations back to sh3/include/bus_funcs.h.
Should fix the mmeye build.
 1.94  25-Jul-2011  dyoung #include <sys/bus.h>. Should fix most of the SH3 ports.
 1.93  20-Jul-2011  dyoung Remove redundant, static inline bus_space(9) declarations
from sh3/bus_funcs.h and move the non-inline definitions to
sh3/sh3_machdep.c.
 1.92  04-Mar-2011  joerg Refactor ps_strings access. Based on PK_32, write either the normal
version or the 32bit compat layout in execve1. Introduce a new function
copyin_psstrings for reading it back from userland and converting it to
the native layout. Refactor procfs to share most of the code with the
kern.proc_args sysctl handler.

This material is based upon work partially supported by
The NetBSD Foundation under a contract with Joerg Sonnenberger.
 1.91  24-Feb-2011  joerg Allow storing and receiving the LWP private pointer via ucontext_t
on all platforms except VAX and IA64. Add fast access via register for
AMD64, i386 and SH3 ports. Use this fast access in libpthread to replace
the stack based pthread_self(). Implement skeleton support for Alpha,
HPPA, PowerPC, SPARC and SPARC64, but leave it disabled.

Ports that support this feature provide __HAVE____LWP_GETPRIVATE_FAST in
machine/types.h and a corresponding __lwp_getprivate_fast in
machine/mcontext.h.

This material is based upon work partially supported by
The NetBSD Foundation under a contract with Joerg Sonnenberger.
 1.90  28-Jan-2011  uwe Implement PT_STEP.
 1.89  26-Jan-2011  uwe Clear MDP_SSTEP in setregs().
 1.88  14-Jan-2011  rmind branches: 1.88.2; 1.88.4;
Retire struct user, remove sys/user.h inclusions. Note sys/user.h header
as obsolete. Remove USER_TO_UAREA/UAREA_TO_USER macros.

Various #include fixes and review by matt@.
 1.87  06-Nov-2010  uebayasi Machine dependent code is considered as part of UVM. Include
internal API header.
 1.86  08-Feb-2010  joerg branches: 1.86.2;
Remove separate mb_map. The nmbclusters is computed at boot time based
on the amount of physical memory and limited by NMBCLUSTERS if present.
Architectures without direct mapping also limit it based on the kmem_map
size, which is used as backing store. On i386 and ARM, the maximum KVA
used for mbuf clusters is limited to 64MB by default.

The old default limits and limits based on GATEWAY have been removed.
key_registered_sb_max is hard-wired to a value derived from 2048
clusters.
 1.85  10-Dec-2009  matt branches: 1.85.2;
Change u_long to vaddr_t/vsize_t in exec code where appropriate (mostly
involves setregs and vmcmds). Should result in no code differences.
 1.84  27-Nov-2009  rmind - Use uvm_lwp_setuarea() instead of directly setting address to lwp_t::l_addr.
- Replace most remaining uses of l_addr with uvm_lwp_getuarea() or lwp_getpcb().
- Amend assembly in ports where it accesses PCB via struct user.
- Rename L_ADDR to L_PCB in few places. Reduce sys/user.h inclusions.
 1.83  26-Nov-2009  matt Kill proc0paddr. Use lwp0.l_addr instead.
 1.82  21-Nov-2009  rmind Use lwp_getpcb() on mips, powerpc and sh3, clean from struct user usage.
 1.81  11-Aug-2009  matt Remove all declarations of physmem from sys/arch. Add an include of
<sys/systm.h> to the one file that did not already contain it.
This now means that physmem can be changed by updating systm.h and uvm_page.c
(excluding fixing printfs)
 1.80  18-Mar-2009  cegger Ansify function definitions w/o arguments. Generated with sed.
 1.79  14-Mar-2009  dsl ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.
 1.78  22-Nov-2008  uwe branches: 1.78.4;
Move COMPAT_16 signal stuff to the new compat_16_machdep.c file, so
that it can be built as part of a module.
 1.77  19-Nov-2008  ad Make the emulations, exec formats, coredump, NFS, and the NFS server
into modules. By and large this commit:

- shuffles header files and ifdefs
- splits code out where necessary to be modular
- adds module glue for each of the components
- adds/replaces hooks for things that can be installed at runtime
 1.76  15-Oct-2008  wrstuden branches: 1.76.2;
Merge wrstuden-revivesa into HEAD.
 1.75  02-Jul-2008  ad branches: 1.75.2;
Replce exec_map with a pool. Proposed on tech-kern@, reviewed by chs@.
 1.74  01-Jun-2008  uwe branches: 1.74.2;
Recycle unused _REG_EXPEVT slot in mcontext for _REG_GBR.

As the size of mcontext is not changed, we avoid the hassle of
versioning all the calls that use it.

_REG_EXPEVT was never used by any code in the tree. Reporting EXPEVT
makes sense only for signals and in that case we pass it to userland
in ksi_trap already which is official MI way to get this (MD) information.

Old binaries running on new kernels will now have their GBR set from
new mcontext, but that's ok too, as GBR was not properly supported by
old kernels (not saved in trapframe), so old binaries couldn't have
possibly used it anyway.
 1.73  01-Jun-2008  uwe Add GBR register to trapframe.
 1.72  28-Apr-2008  martin branches: 1.72.2;
Remove clause 3 and 4 from TNF licenses
 1.71  24-Apr-2008  ad branches: 1.71.2;
Merge proc::p_mutex and proc::p_smutex into a single adaptive mutex, since
we no longer need to guard against access from hardware interrupt handlers.

Additionally, if cloning a process with CLONE_SIGHAND, arrange to have the
child process share the parent's lock so that signal state may be kept in
sync. Partially addresses PR kern/37437.
 1.70  22-Mar-2008  uwe branches: 1.70.2;
Revert interrupt stack changes. There are some issues and, at least
in the current form, they complicate implementation of fast software
interrupts. I'd rather get fast softints in now and may be revisit
interrupt stack later.
 1.69  15-Feb-2008  uwe branches: 1.69.6;
G/c vestiges of curpute hack that was obsoleted by the fast TLB miss handler.
 1.68  20-Dec-2007  dsl Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
 1.67  14-Dec-2007  uwe Use dedicated interrupt stack. Tested on hpcsh and landisk. This has
been sitting in my tree for quite a while. While here s/top/bottom/
in a few places related to stacks to confirm to conventional
terminology.
 1.66  17-Oct-2007  garbled branches: 1.66.2; 1.66.4; 1.66.8;
Merge the ppcoea-renovation branch to HEAD.

This branch was a major cleanup and rototill of many of the various OEA
cpu based PPC ports that focused on sharing as much code as possible
between the various ports to eliminate near-identical copies of files in
every tree. Additionally there is a new PIC system that unifies the
interface to interrupt code for all different OEA ppc arches. The work
for this branch was done by a variety of people, too long to list here.

TODO:
bebox still needs work to complete the transition to -renovation.
ofppc still needs a bunch of work, which I will be looking at.
ev64260 still needs to be renovated
amigappc was not attempted.

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.65  14-Oct-2007  uwe For KSTACK_DEBUG fill lwp0 switchframe with 0xb4 too to match
what we do to other lwps in sh3_setup_uarea in vm_machdep.c.
 1.64  20-Aug-2007  uwe branches: 1.64.2; 1.64.4;
Fix couple of whitespace glitches.
 1.63  08-Jul-2007  pooka branches: 1.63.4; 1.63.8;
Initialize the link context in a signal frame to the receiving lwp's
link context instead of NULL. Otherwise, if we got a signal while the
lwp had a link context set, the link context would be set to NULL upon
return from signal delivery.

christos@tech-kern: "I think you are right."
 1.62  04-Mar-2007  christos branches: 1.62.2; 1.62.4; 1.62.10;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.61  22-Feb-2007  thorpej TRUE -> true, FALSE -> false
 1.60  09-Feb-2007  ad branches: 1.60.2;
Merge newlock2 to head.
 1.59  04-Mar-2006  uwe branches: 1.59.14;
s/u_intN_t/uintN_t/
 1.58  21-Jan-2006  uwe branches: 1.58.2; 1.58.4;
Add lint comments. Hide computed goto in cpu_reset() from lint.
Remove infinite loop from cpu_reset(), gcc accepts computed goto as
the sign that function never returns.
 1.57  24-Dec-2005  perry branches: 1.57.2;
__asm__ -> __asm
__const__ -> const
__inline__ -> inline
__volatile__ -> volatile
 1.56  11-Dec-2005  christos merge ktrace-lwp.
 1.55  25-Apr-2005  lukem branches: 1.55.2;
Move the MI printing of `copyright' to the MD cpu_startup() code
where the printing of `version' is already performed.
This has the benefit of allowing the copyright to be available
via dmesg(8) on platforms which need the `msgbuf' to be setup
in cpu_startup() before printed output is remembered.
 1.54  30-Dec-2003  pk branches: 1.54.8;
Replace the traditional buffer memory management -- based on fixed per buffer
virtual memory reservation and a private pool of memory pages -- by a scheme
based on memory pools.

This allows better utilization of memory because buffers can now be allocated
with a granularity finer than the system's native page size (useful for
filesystems with e.g. 1k or 2k fragment sizes). It also avoids fragmentation
of virtual to physical memory mappings (due to the former fixed virtual
address reservation) resulting in better utilization of MMU resources on some
platforms. Finally, the scheme is more flexible by allowing run-time decisions
on the amount of memory to be used for buffers.

On the other hand, the effectiveness of the LRU queue for buffer recycling
may be somewhat reduced compared to the traditional method since, due to the
nature of the pool based memory allocation, the actual least recently used
buffer may release its memory to a pool different from the one needed by a
newly allocated buffer. However, this effect will kick in only if the
system is under memory pressure.
 1.53  23-Nov-2003  uwe Implement siginfo for sh3.
 1.52  26-Sep-2003  simonb Fix "constify sendsig/trapsignal" fallout for non-siginfo'd archs. Test
compiled on most architectures.
 1.51  07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.50  03-Aug-2003  uwe When passing &buffers to uvm_map, add a cast to (void *). Without it,
gcc3 with -O2 produces "dereferencing type-punned pointer will break
strict-aliasing rules" warning.
 1.49  15-Jul-2003  lukem __KERNEL_RCSID()
 1.48  11-Apr-2003  nathanw branches: 1.48.2;
Make cpu_getmcontext() run the PC through ras_lookup() so that kernel
getcontext() plus userlevel setcontext() (as used in libpthread) respects
the atomicity of RAS regions.
 1.47  02-Apr-2003  thorpej Use PAGE_SIZE rather than NBPG.
 1.46  18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.45  25-Aug-2002  thorpej Make nbuf, nswbuf, and bufpages unsigned. Make all operations on these
variables unsigned, and update places where their values are printed.
 1.44  04-Jul-2002  thorpej Add kernel support for having userland provide the signal trampoline:

* struct sigacts gets a new sigact_sigdesc structure, which has the
sigaction and the trampoline/version. Version 0 means "legacy kernel
provided trampoline". Other versions are coordinated with machine-
dependent code in libc.
* sigaction1() grows two more arguments -- the trampoline pointer and
the trampoline version.
* A new __sigaction_sigtramp() system call is provided to register a
trampoline along with a signal handler.
* The handler is no longer passed to sensig() functions. Instead,
sendsig() looks up the handler by peeking in the sigacts for the
process getting the signal (since it has to look in there for the
trampoline anyway).
* Native sendsig() functions now select the appropriate trampoline and
its arguments based on the trampoline version in the sigacts.

Changes to libc to use the new facility will be checked in later. Kernel
version not bumped; we will ride the 1.6C bump made recently.
 1.43  23-Jun-2002  thorpej When delivering a signal, arrange for the handler to be invoked
directly. The trampoline is now used only for the return, and
makes it another 2 instructions shorter.
 1.42  23-Jun-2002  thorpej When delivering a signal, don't push the signum, code, and context pointer,
or handler onto the stack. Instead, just stuff them into the correct
argument registers (handler is a "4th arg").
 1.41  10-May-2002  uch branches: 1.41.2; 1.41.6;
remove COMPAT_13 staff. No 1.3 release of sh3 port. these are trace of
i386 port.
 1.40  09-May-2002  uch new pmap designed for SH3/SH4.
 1.39  29-Apr-2002  uch remove #if 0 #endif
 1.38  28-Apr-2002  uch Use "#define<tab>", white space nits.
 1.37  22-Apr-2002  uch make these compile with gcc -O0
 1.36  24-Mar-2002  uch Rework interrupt code.
+ Fully utilize SH SR.I[0:3] interrupt level.
+ software interrupt is emulated by TMU1, 2 one shot interrupt.
+ implement generic soft interrupts.
+ implement clockframe correctly.
 1.35  18-Mar-2002  itojun s/PS_STRINGS/p->p_psstr/, as requested by christos
 1.34  17-Mar-2002  uch cosmetic changes, fix comments.
 1.33  17-Mar-2002  uch kernel stack fix. old code simply P3 address converted to P1, it
caused memory destruction when kernel stack grow over 1 page. new
code use P3 address for kernel stack. but for the sake of debug, P1
kernel stack mode remain.
 1.32  10-Mar-2002  uch proc0 and page table intialize routines are moved to sh3_machdep.c
 1.31  06-Mar-2002  tsutsui Change type of dumpmag to u_int32_t since it is actually
a 32bit unsigned magic number.
As per discussion on tech-kern, and fixes port-sparc64/11949.
 1.30  02-Mar-2002  uch Initial support for KGDB on the sh3.
 1.29  28-Feb-2002  uch cpu_reset:
Set EXPEVT to 0x20(manual reset) before jump to reset vector.
 1.28  28-Feb-2002  uch cpu_dumpconf, reserve_dumppages, dumpsys, cpu_reset are moved to sh3/sh3_machdep.c
 1.27  28-Feb-2002  uch Cleanup register definition
 1.26  24-Feb-2002  uch Move common exception vector and scheduler code to
sh3/sh3/exception_vector.S and sh3/sh3/locore_subr.S. exception
vectors are installed by sh_cpu_init(). machine/locore.S contains
kernel entry, interrupt handler, and some MD code.
 1.25  22-Feb-2002  uch New NetBSD/sh3 clock framework.
+ hardclock source is moved from TMU1 to TMU0.
+ SH3/SH4 common kernel support.
+ PCLOCK estimation.
+ remove duplicated code.
 1.24  17-Feb-2002  uch sh_cpu_init() is added. its initialize cache, MMU ops appropriately.
machine locore code call this at first.
 1.23  12-Feb-2002  uch ANSIfy KNF.
 1.22  11-Feb-2002  uch add new cache routine.
 1.21  03-Feb-2002  thorpej In setregs(), pass PS_STRINGS in r9.
 1.20  01-Feb-2002  uch if PCLOCK isn't setted, use estimated value calculated by kernel.
 1.19  28-Sep-2001  chs don't depend on other headers to include sys/proc.h for us.
 1.18  10-Sep-2001  chris Update pmap_update to now take the updated pmap as an argument.
This will allow improvements to the pmaps so that they can more easily defer expensive operations, eg tlb/cache flush, til the last possible moment.

Currently this is a no-op on most platforms, so they should see no difference.

Reviewed by Jason.
 1.17  01-Sep-2001  msaitoh branches: 1.17.2;
s/cpu_startup/sh3_startup/g in panic messages
 1.16  12-Aug-2001  jdolecek Move _insque()/_remque() to libkern. Once remaining uses would
be converted to <sys/queue.h> macros, _insque()/_remque() would be eliminated
altogether.
 1.15  02-Jun-2001  chs branches: 1.15.2;
replace vm_map{,_entry}_t with struct vm_map{,_entry} *.
 1.14  30-May-2001  lukem add missing #include "opt_kgdb.h"
 1.13  16-May-2001  msaitoh sigreturn() fix (from kleink)
 1.12  24-Apr-2001  thorpej Sprinkle pmap_update() calls after calls to:
- pmap_enter()
- pmap_remove()
- pmap_protect()
- pmap_kenter_pa()
- pmap_kremove()
as described in pmap(9).

These calls are relatively conservative. It may be possible to
optimize these a little more.
 1.11  15-Mar-2001  chs eliminate the KERN_* error codes in favor of the traditional E* codes.
the mapping is:

KERN_SUCCESS 0
KERN_INVALID_ADDRESS EFAULT
KERN_PROTECTION_FAILURE EACCES
KERN_NO_SPACE ENOMEM
KERN_INVALID_ARGUMENT EINVAL
KERN_FAILURE various, mostly turn into KASSERTs
KERN_RESOURCE_SHORTAGE ENOMEM
KERN_NOT_RECEIVER <unused>
KERN_NO_ACCESS <unused>
KERN_PAGES_LOCKED <unused>
 1.10  22-Dec-2000  jdolecek branches: 1.10.2;
split off thread specific stuff from struct sigacts to struct sigctx, leaving
only signal handler array sharable between threads
move other random signal stuff from struct proc to struct sigctx

This addresses kern/10981 by Matthew Orgass.
 1.9  13-Sep-2000  thorpej Add an align argument to uvm_map() and some callers of that
routine. Works similarly fto pmap_prefer(), but allows callers
to specify a minimum power-of-two alignment of the region.
How we ever got along without this for so long is beyond me.
 1.8  29-Jun-2000  mrg remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.7  26-Jun-2000  mrg remove/move more mach vm header files:

<vm/pglist.h> -> <uvm/uvm_pglist.h>
<vm/vm_inherit.h> -> <uvm/uvm_inherit.h>
<vm/vm_kern.h> -> into <uvm/uvm_extern.h>
<vm/vm_object.h> -> nothing
<vm/vm_pager.h> -> into <uvm/uvm_pager.h>

also includes a bunch of <vm/vm_page.h> include removals (due to redudancy
with <vm/vm.h>), and a scattering of other similar headers.
 1.6  26-May-2000  thorpej branches: 1.6.4;
First sweep at scheduler state cleanup. Collect MI scheduler
state into global and per-CPU scheduler state:

- Global state: sched_qs (run queues), sched_whichqs (bitmap
of non-empty run queues), sched_slpque (sleep queues).
NOTE: These may collectively move into a struct schedstate
at some point in the future.

- Per-CPU state, struct schedstate_percpu: spc_runtime
(time process on this CPU started running), spc_flags
(replaces struct proc's p_schedflags), and
spc_curpriority (usrpri of processes on this CPU).

- Every platform must now supply a struct cpu_info and
a curcpu() macro. Simplify existing cpu_info declarations
where appropriate.

- All references to per-CPU scheduler state now made through
curcpu(). NOTE: this will likely be adjusted in the future
after further changes to struct proc are made.

Tested on i386 and Alpha. Changes are mostly mechanical, but apologies
in advance if it doesn't compile on a particular platform.
 1.5  25-Apr-2000  tsubai Use P1SEG to map pool pages.
 1.4  06-Feb-2000  msaitoh remove COMPAT_NOMID stuff
 1.3  19-Jan-2000  thorpej Move callout initialization to a single location; no need to duplicate
that code all over the place.
 1.2  04-Dec-1999  ragge CL* discarding.
 1.1  21-Sep-1999  tsubai branches: 1.1.2; 1.1.8;
Move common parts of machdep.c to sh3_machdep.c.
 1.1.8.1  27-Dec-1999  wrstuden Pull up to last week's -current.
 1.1.2.3  27-Mar-2001  bouyer Sync with HEAD.
 1.1.2.2  05-Jan-2001  bouyer Sync with HEAD
 1.1.2.1  20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.6.4.1  26-May-2001  he Pull up revision 1.13 (requested by kleink):
Validate Status Register passed from userland in sigreturn().
 1.10.2.2  21-Jun-2001  nathanw Catch up to -current.
 1.10.2.1  09-Apr-2001  nathanw Catch up with -current.
 1.15.2.7  06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.15.2.6  23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.15.2.5  16-Mar-2002  jdolecek Catch up with -current.
 1.15.2.4  11-Feb-2002  jdolecek Sync w/ -current.
 1.15.2.3  10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.15.2.2  13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.15.2.1  25-Aug-2001  thorpej Merge Aug 24 -current into the kqueue branch.
 1.17.2.1  01-Oct-2001  fvdl Catch up with -current.
 1.41.6.9  27-Aug-2002  nathanw Catch up to -current.
 1.41.6.8  10-Aug-2002  thorpej Garbage-collect upcallcode.
 1.41.6.7  02-Aug-2002  nathanw LWPify sigexit() call.
 1.41.6.6  01-Aug-2002  nathanw Catch up to -current.
 1.41.6.5  05-Jul-2002  thorpej When delivering an upcall, invoke the upcall directly, using the
trampoline only to exit if the upcall returns.
 1.41.6.4  24-Jun-2002  nathanw Curproc->curlwp renaming.

Change uses of "curproc->l_proc" back to "curproc", which is more like the
original use. Bare uses of "curproc" are now "curlwp".

"curproc" is now #defined in proc.h as ((curlwp) ? (curlwp)->l_proc) : NULL)
so that it is always safe to reference curproc (*de*referencing curproc
is another story, but that's always been true).
 1.41.6.3  21-Jun-2002  thorpej Add support for scheduler activations on SuperH. Boots multi-user
on Dreamcast (SH4) with stock userland.
 1.41.6.2  20-Jun-2002  thorpej Machine-dependent kernel portion of {get,set}context(). From
Klaus Klein.
 1.41.6.1  10-May-2002  thorpej file sh3_machdep.c was added on branch nathanw_sa on 2002-06-20 23:00:51 +0000
 1.41.2.2  31-Aug-2002  gehenna catch up with -current.
 1.41.2.1  17-Jul-2002  gehenna catch up with -current.
 1.48.2.4  10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.48.2.3  21-Sep-2004  skrll Fix the sync with head I botched.
 1.48.2.2  18-Sep-2004  skrll Sync with HEAD.
 1.48.2.1  03-Aug-2004  skrll Sync with HEAD
 1.54.8.1  29-Apr-2005  kent sync with -current
 1.55.2.7  24-Mar-2008  yamt sync with head.
 1.55.2.6  27-Feb-2008  yamt sync with head.
 1.55.2.5  21-Jan-2008  yamt sync with head
 1.55.2.4  27-Oct-2007  yamt sync with head.
 1.55.2.3  03-Sep-2007  yamt sync with head.
 1.55.2.2  26-Feb-2007  yamt sync with head.
 1.55.2.1  21-Jun-2006  yamt sync with head.
 1.57.2.1  01-Feb-2006  yamt sync with head.
 1.58.4.1  22-Apr-2006  simonb Sync with head.
 1.58.2.1  09-Sep-2006  rpaulo sync with head
 1.59.14.2  01-Feb-2007  ad Get sh3 compiling.
 1.59.14.1  30-Jan-2007  ad Remove support for SA. Ok core@.
 1.60.2.2  12-Mar-2007  rmind Sync with HEAD.
 1.60.2.1  27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.62.10.2  16-Oct-2007  garbled Sync with HEAD
 1.62.10.1  03-Oct-2007  garbled Sync with HEAD
 1.62.4.1  11-Jul-2007  mjf Sync with head.
 1.62.2.3  23-Oct-2007  ad Sync with head.
 1.62.2.2  09-Oct-2007  ad Sync with head.
 1.62.2.1  15-Jul-2007  ad Sync with head.
 1.63.8.2  26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.63.8.1  03-Sep-2007  jmcneill Sync with HEAD.
 1.63.4.1  03-Sep-2007  skrll Sync with HEAD.
 1.64.4.1  18-Oct-2007  yamt sync with head.
 1.64.2.3  23-Mar-2008  matt sync with HEAD
 1.64.2.2  09-Jan-2008  matt sync with HEAD
 1.64.2.1  06-Nov-2007  matt sync with HEAD
 1.66.8.1  02-Jan-2008  bouyer Sync with HEAD
 1.66.4.1  26-Dec-2007  ad Sync with head.
 1.66.2.1  18-Feb-2008  mjf Sync with HEAD.
 1.69.6.4  17-Jan-2009  mjf Sync with HEAD.
 1.69.6.3  02-Jul-2008  mjf Sync with HEAD.
 1.69.6.2  02-Jun-2008  mjf Sync with HEAD.
 1.69.6.1  03-Apr-2008  mjf Sync with HEAD.
 1.70.2.2  04-Jun-2008  yamt sync with head
 1.70.2.1  18-May-2008  yamt sync with head.
 1.71.2.4  11-Mar-2010  yamt sync with head
 1.71.2.3  19-Aug-2009  yamt sync with head.
 1.71.2.2  04-May-2009  yamt sync with head.
 1.71.2.1  16-May-2008  yamt sync with head.
 1.72.2.5  18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.72.2.4  23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.72.2.3  22-Jun-2008  wrstuden Re-add cpu_upcall() and page fault code. i386 kernels now compile.
They don't boot, but that seems to be a consequence of current from the
day this branch was started.
 1.72.2.2  14-May-2008  wrstuden Per discussion with ad at n dot o, revert signal mask handling
changes.

The l_sigstk changes are most likely totally un-needed as SA will
never use a signal stack - we send an upcall (or will as other
diffs are brought in).

The l_sigmask changes were too controvertial. In all honesty, I
think it's probably best to revert them. The main reason they were
there is the fact that in an SA process, we don't mask signals per
kernel thread, we mask them per user thread. In the kernel, we want
them all to get turned into upcalls. Thus the normal state of
l_sigmask in an SA process is for it to always be empty.

While we are in the process of delivering a signal, we want to
temporarily mask a signal (so we don't recursively exhaust our
upcall stacks). However signal delivery is rare (important, but
rare), and delivering back-to-back signals is even rarer. So rather
than cause every user of a signal mask to be prepared for this very
rare case, we will just add a second check later in the signal
delivery code. Said change is not in this diff.

This also un-compensates all of our compatability code for dealing
with SA. SA is a NetBSD-specific thing, so there's no need for
Irix, Linux, Solaris, SVR4 and so on to cope with it.

As previously, everything other than kern_sa.c compiles in i386
GENERIC as of this checkin. I will switch to ALL soon for compile
testing.
 1.72.2.1  10-May-2008  wrstuden Initial checkin of re-adding SA. Everything except kern_sa.c
compiles in GENERIC for i386. This is still a work-in-progress, but
this checkin covers most of the mechanical work (changing signalling
to be able to accomidate SA's process-wide signalling and re-adding
includes of sys/sa.h and savar.h). Subsequent changes will be much
more interesting.

Also, kern_sa.c has received partial cleanup. There's still more
to do, though.
 1.74.2.1  03-Jul-2008  simonb Sync with head.
 1.75.2.2  13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.75.2.1  19-Oct-2008  haad Sync with HEAD.
 1.76.2.2  28-Apr-2009  skrll Sync with HEAD.
 1.76.2.1  19-Jan-2009  skrll Sync with HEAD.
 1.78.4.1  13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.85.2.2  27-May-2010  uebayasi Fix build.
 1.85.2.1  30-Apr-2010  uebayasi Sync with HEAD.
 1.86.2.1  05-Mar-2011  rmind sync with head
 1.88.4.2  05-Mar-2011  bouyer Sync with HEAD
 1.88.4.1  08-Feb-2011  bouyer Sync with HEAD
 1.88.2.1  06-Jun-2011  jruoho Sync with HEAD.
 1.96.6.3  02-Jun-2012  mrg sync to latest -current.
 1.96.6.2  24-Feb-2012  mrg sync to -current.
 1.96.6.1  18-Feb-2012  mrg merge to -current.
 1.96.2.4  22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.96.2.3  30-Oct-2012  yamt sync with head
 1.96.2.2  23-May-2012  yamt sync with head.
 1.96.2.1  17-Apr-2012  yamt sync with head
 1.97.2.1  21-May-2012  riz Pull up following revision(s) (requested by martin in ticket #274):
sys/arch/amd64/amd64/process_machdep.c: revision 1.20
sys/kern/sys_lwp.c: revision 1.54
sys/arch/sparc64/sparc64/machdep.c: revision 1.267
sys/arch/mips/mips/cpu_subr.c: revision 1.16
sys/arch/vax/vax/machdep.c: revision 1.188
sys/sys/lwp.h: revision 1.161
sys/arch/sparc64/sparc64/netbsd32_machdep.c: revision 1.98
sys/arch/alpha/alpha/machdep.c: revision 1.339
sys/compat/sys/ucontext.h: revision 1.6
sys/arch/hppa/hppa/hppa_machdep.c: revision 1.28
distrib/sets/lists/tests/mi: revision 1.469
sys/arch/powerpc/powerpc/sig_machdep.c: revision 1.42
tests/lib/libc/sys/t_lwp_create.c: revision 1.1
tests/lib/libc/sys/Makefile: revision 1.23
sys/arch/arm/arm/sig_machdep.c: revision 1.42
sys/arch/amd64/include/mcontext.h: revision 1.15
sys/arch/amd64/amd64/machdep.c: revision 1.183
sys/arch/sh3/sh3/sh3_machdep.c: revision 1.99
sys/arch/i386/i386/machdep.c: revision 1.727
sys/compat/netbsd32/netbsd32_lwp.c: revision 1.13
sys/arch/sparc/sparc/machdep.c: revision 1.319
sys/arch/amd64/amd64/netbsd32_machdep.c: revision 1.76
sys/arch/m68k/m68k/sig_machdep.c: revision 1.49
sys/sys/ucontext.h: revision 1.16
sys/arch/mips/mips/netbsd32_machdep.c: revision 1.9
lib/libc/sys/_lwp_create.2: revision 1.5
Calling _lwp_create() with a bogus ucontext could trigger a kernel
assertion failure (and thus a crash in DIAGNOSTIC kernels). Independently
discovered by YAMAMOTO Takashi and Joel Sing.
To avoid this, introduce a cpu_mcontext_validate() function and move all
sanity checks from cpu_setmcontext() there. Also untangle the netbsd32
compat mess slightly and add a cpu_mcontext32_validate() cousin there.
Add an exhaustive atf test case, based partly on code from Joel Sing.
Should finally fix the remaining open part of PR kern/43903.
 1.100.2.3  03-Dec-2017  jdolecek update from HEAD
 1.100.2.2  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.100.2.1  20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.101.2.1  18-May-2014  rmind sync with head
 1.102.8.2  30-Jan-2019  martin Pull up following revision(s) (requested by maxv in ticket #1677):

sys/arch/hppa/hppa/sig_machdep.c: revision 1.26
sys/arch/arm/arm/sig_machdep.c: revision 1.51
sys/arch/i386/i386/machdep.c: revision 1.813
sys/arch/alpha/alpha/machdep.c: revision 1.352
sys/arch/m68k/m68k/sig_machdep.c: revision 1.50
sys/arch/usermode/target/i386/cpu_i386.c: revision 1.8
sys/arch/sparc64/sparc64/machdep.c: revision 1.289
sys/arch/sparc64/sparc64/netbsd32_machdep.c: revision 1.111
sys/arch/powerpc/powerpc/sig_machdep.c: revision 1.46
sys/arch/amd64/amd64/netbsd32_machdep.c: revision 1.117
sys/arch/sh3/sh3/sh3_machdep.c: revision 1.106
sys/arch/mips/mips/netbsd32_machdep.c: revision 1.16
sys/arch/mips/mips/sig_machdep.c: revision 1.24
sys/arch/usermode/target/x86_64/cpu_x86_64.c: revision 1.7
sys/arch/vax/vax/sig_machdep.c: revision 1.23

Fix widespread leak in the sendsig_siginfo() functions. sigframe_siginfo
has padding, so zero it out properly. While here I'm also zeroing out some
other things in several ports, for safety. Same problem in netbsd32, so
fix that too.

I can't compile-test on each architecture, but there should be no
breakage (tm).

Overall this fixes at least 14 info leaks. Prompted by the discovery by
KLEAK of a leak in amd64's sendsig_siginfo.
 1.102.8.1  26-Dec-2015  snj Pull up following revision(s) (requested by tsutsui in ticket #1051):
sys/arch/sh3/sh3/sh3_machdep.c: revision 1.103
sys/arch/landisk/landisk/machdep.c: revision 1.18
Remove \n from set_cpumodel(), and explicitly print \n during boot instead.
Fixes dmesg on NetBSD/dreamcast 7.0 (and probably NetBSD/hpcsh 7.0):
---
NetBSD 7.0 (GENERIC.201509250726Z)
SEGA Dreamcasttotal memory = 16384 KB
avail memory = 13668 KB
---
which was mangled when cpu_getmode() and cpu_setmodel() were introduced:
http://mail-index.netbsd.org/source-changes/2014/03/24/msg053273.html
 1.102.6.3  05-Feb-2017  skrll Sync with HEAD
 1.102.6.2  05-Dec-2016  skrll Sync with HEAD
 1.102.6.1  27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.102.4.2  30-Jan-2019  martin Pull up following revision(s) (requested by maxv in ticket #1677):

sys/arch/hppa/hppa/sig_machdep.c: revision 1.26
sys/arch/arm/arm/sig_machdep.c: revision 1.51
sys/arch/i386/i386/machdep.c: revision 1.813
sys/arch/alpha/alpha/machdep.c: revision 1.352
sys/arch/m68k/m68k/sig_machdep.c: revision 1.50
sys/arch/usermode/target/i386/cpu_i386.c: revision 1.8
sys/arch/sparc64/sparc64/machdep.c: revision 1.289
sys/arch/sparc64/sparc64/netbsd32_machdep.c: revision 1.111
sys/arch/powerpc/powerpc/sig_machdep.c: revision 1.46
sys/arch/amd64/amd64/netbsd32_machdep.c: revision 1.117
sys/arch/sh3/sh3/sh3_machdep.c: revision 1.106
sys/arch/mips/mips/netbsd32_machdep.c: revision 1.16
sys/arch/mips/mips/sig_machdep.c: revision 1.24
sys/arch/usermode/target/x86_64/cpu_x86_64.c: revision 1.7
sys/arch/vax/vax/sig_machdep.c: revision 1.23

Fix widespread leak in the sendsig_siginfo() functions. sigframe_siginfo
has padding, so zero it out properly. While here I'm also zeroing out some
other things in several ports, for safety. Same problem in netbsd32, so
fix that too.

I can't compile-test on each architecture, but there should be no
breakage (tm).

Overall this fixes at least 14 info leaks. Prompted by the discovery by
KLEAK of a leak in amd64's sendsig_siginfo.
 1.102.4.1  26-Dec-2015  snj branches: 1.102.4.1.4;
Pull up following revision(s) (requested by tsutsui in ticket #1051):
sys/arch/landisk/landisk/machdep.c: revision 1.18
sys/arch/sh3/sh3/sh3_machdep.c: revision 1.103
Remove \n from set_cpumodel(), and explicitly print \n during boot instead.
Fixes dmesg on NetBSD/dreamcast 7.0 (and probably NetBSD/hpcsh 7.0):
---
NetBSD 7.0 (GENERIC.201509250726Z)
SEGA Dreamcasttotal memory = 16384 KB
avail memory = 13668 KB
---
which was mangled when cpu_getmode() and cpu_setmodel() were introduced:
http://mail-index.netbsd.org/source-changes/2014/03/24/msg053273.html
 1.102.4.1.4.1  30-Jan-2019  martin Pull up following revision(s) (requested by maxv in ticket #1677):

sys/arch/hppa/hppa/sig_machdep.c: revision 1.26
sys/arch/arm/arm/sig_machdep.c: revision 1.51
sys/arch/i386/i386/machdep.c: revision 1.813
sys/arch/alpha/alpha/machdep.c: revision 1.352
sys/arch/m68k/m68k/sig_machdep.c: revision 1.50
sys/arch/usermode/target/i386/cpu_i386.c: revision 1.8
sys/arch/sparc64/sparc64/machdep.c: revision 1.289
sys/arch/sparc64/sparc64/netbsd32_machdep.c: revision 1.111
sys/arch/powerpc/powerpc/sig_machdep.c: revision 1.46
sys/arch/amd64/amd64/netbsd32_machdep.c: revision 1.117
sys/arch/sh3/sh3/sh3_machdep.c: revision 1.106
sys/arch/mips/mips/netbsd32_machdep.c: revision 1.16
sys/arch/mips/mips/sig_machdep.c: revision 1.24
sys/arch/usermode/target/x86_64/cpu_x86_64.c: revision 1.7
sys/arch/vax/vax/sig_machdep.c: revision 1.23

Fix widespread leak in the sendsig_siginfo() functions. sigframe_siginfo
has padding, so zero it out properly. While here I'm also zeroing out some
other things in several ports, for safety. Same problem in netbsd32, so
fix that too.

I can't compile-test on each architecture, but there should be no
breakage (tm).

Overall this fixes at least 14 info leaks. Prompted by the discovery by
KLEAK of a leak in amd64's sendsig_siginfo.
 1.103.2.2  07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.103.2.1  04-Nov-2016  pgoyette Sync with HEAD
 1.105.16.2  08-Apr-2020  martin Merge changes from current as of 20200406
 1.105.16.1  10-Jun-2019  christos Sync with HEAD
 1.105.14.1  26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.105.8.1  27-Jan-2019  martin Pull up following revision(s) (requested by maxv in ticket #1173):
sys/arch/hppa/hppa/sig_machdep.c: revision 1.26
sys/arch/arm/arm/sig_machdep.c: revision 1.51
sys/arch/i386/i386/machdep.c: revision 1.813
sys/arch/alpha/alpha/machdep.c: revision 1.352
sys/arch/m68k/m68k/sig_machdep.c: revision 1.50
sys/arch/usermode/target/i386/cpu_i386.c: revision 1.8
sys/arch/sparc64/sparc64/machdep.c: revision 1.289
sys/arch/sparc64/sparc64/netbsd32_machdep.c: revision 1.111
sys/arch/powerpc/powerpc/sig_machdep.c: revision 1.46
sys/arch/amd64/amd64/netbsd32_machdep.c: revision 1.117
sys/arch/sh3/sh3/sh3_machdep.c: revision 1.106
sys/arch/mips/mips/netbsd32_machdep.c: revision 1.16
sys/arch/mips/mips/sig_machdep.c: revision 1.24
sys/arch/riscv/riscv/sig_machdep.c: revision 1.2
sys/arch/usermode/target/x86_64/cpu_x86_64.c: revision 1.7
sys/arch/vax/vax/sig_machdep.c: revision 1.23

Fix widespread leak in the sendsig_siginfo() functions. sigframe_siginfo
has padding, so zero it out properly. While here I'm also zeroing out some
other things in several ports, for safety. Same problem in netbsd32, so
fix that too.

I can't compile-test on each architecture, but there should be no
breakage (tm).

Overall this fixes at least 14 info leaks. Prompted by the discovery by
KLEAK of a leak in amd64's sendsig_siginfo.

RSS XML Feed