Commit Graph

5986 Commits

Author SHA1 Message Date
ad ba90a6ba38 Counter tweaks:
- Don't need to count anonpages+filepages any more; clean+unknown+dirty for
  each kind of page can be summed to get the totals.

- Track the number of free pages with a counter so that it's one less thing
  for the allocator to do, which opens up further options there.

- Remove cpu_count_sync_one().  It has no users and doesn't save a whole lot.
  For the cheap option, give cpu_count_sync() a boolean parameter indicating
  that a cached value is okay, and rate limit the updates for cached values
  to hz.
2020-06-11 22:21:05 +00:00
ad 4b8a875ae2 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.
2020-06-11 19:20:42 +00:00
dholland c76c804434 Regen after -r1.82 of compat_sunos syscalls.master last September.
(Apparently forgotten.)

"Treat valsize as unsigned"
2020-06-11 03:47:05 +00:00
ad 0eaaa024ea Move proc_lock into the data segment. It was dynamically allocated because
at the time we had mutex_obj_alloc() but not __cacheline_aligned.
2020-05-23 23:42:41 +00:00
christos 9aa2a9c323 Add ACL support for FFS. From FreeBSD. 2020-05-16 18:31:45 +00:00
rin 412770719c Fix previous; specify lwpid for curlpw in the case of pid == 0.
For linux_sys_sched_setaffinity, pid == 0 means the current thread.
On the other hand, for our native sys_sched_setaffinity, lid == 0
means all lwp's that belong to the process.
2020-05-14 08:26:29 +00:00
thorpej 6430fcd5ce Always clear FUTEX_PRIVATE_FLAG for Linux processes. NetBSD-native futexes
exist in different namespace depending on FUTEX_PRIVATE_FLAG.  This appears
not to be the case in Linux, and some futex users will mix private and non-
private ops on the same futex object.  Provide a convenience wrapper that
puts this logic in one place witn a comment explaining why.

While here, move the Linux futex wrapper out of its own file and plop
it in linux_misc.c, which is where it lives in the linux32 module.
2020-05-03 01:06:55 +00:00
riastradh 6bf9fb1500 Omit needless #include <sys/rnd.h>. 2020-04-30 03:30:10 +00:00
thorpej a05d1819c9 Fix proc lookup by distinguishing between the "tgid" and "tid" cases. 2020-04-29 01:55:52 +00:00
thorpej 5aee0edc68 Fix proc / lwp lookup processing in linux_sys_sched_getaffinity()
and linux_sys_sched_setaffinity().  They were incorrect even before
the LWP ID changes, but those changes exposed the latent bugs.
2020-04-29 01:55:18 +00:00
thorpej d69d0e707c Oops, fix a silly mistake in the Linux futex syscall stubs -- we also
copy in the timeout for FUTEX_WAIT_BITSET.
2020-04-29 01:44:03 +00:00
christos 7213386d55 data_len == 0 on mount means "the kernel knows". Fixes amd on compat32. 2020-04-27 17:37:34 +00:00
thorpej cb9aba0e17 Regen for native futex calls. 2020-04-26 19:18:52 +00:00
thorpej cc2d95549c Mirror the change made to native -- move futex calls to 166-168. 2020-04-26 19:18:36 +00:00
thorpej 276ef22378 Add a NetBSD native futex implementation, mostly written by riastradh@.
Map the COMPAT_LINUX futex calls to the native ones.
2020-04-26 18:53:31 +00:00
thorpej 156895706e Overhaul the way LWP IDs are allocated. Instead of each LWP having it's
own LWP ID space, LWP IDs came from the same number space as PIDs.  The
lead LWP of a process gets the PID as its LID.  If a multi-LWP process's
lead LWP exits, the PID persists for the process.

In addition to providing system-wide unique thread IDs, this also lets us
eliminate the per-process LWP radix tree, and some associated locks.

Remove the separate "global thread ID" map added previously; it is no longer
needed to provide this functionality.

Nudged in this direction by ad@ and chs@.
2020-04-24 03:22:06 +00:00
thorpej a1ae221d59 Regen for removal of _lwp_gettid(2). 2020-04-22 21:25:17 +00:00
thorpej 44fb992d10 Remove _lwp_gettid(2) system call. This problem is going to be solved
another way.  (Note: this call was never exposed in libc, so we can just
recycle the syscall number.)
2020-04-22 21:22:21 +00:00
ad e88c11f417 Revert the changes made in February to make cwdinfo use mostly lockless,
which relied on taking extra vnode refs.

Having benchmarked various experimental changes over the past few months it
seems that it's better to avoid vnode refs as much as possible.  cwdi_lock
as a RW lock already did that to some extent for getcwd() and will permit
the same for namei() too.
2020-04-21 21:42:47 +00:00
nia 2a2513b081 ossaudio: Avoid giving userland uninitialized memory. Noticed by maxv.
The uninitalized field in this structure is `fillers`, an array that
simply reserves space for later changes in OSSv4, which this version
of the OSS compat layer (specifically for Linux applications) makes no
effort to implement.
2020-04-19 21:37:00 +00:00
thorpej a29147fa13 - Only increment nprocs when we're creating a new process, not just
when allocating a PID.
- Per above, proc_free_pid() no longer decrements nprocs.  It's now done
  in proc_free() right after proc_free_pid().
- Ensure nprocs is accessed using atomics everywhere.
2020-04-19 20:31:59 +00:00
nia 8e9e149d7d ossaudio: Implement SNDCTL_DSP_(SET|GET)TRIGGER. 2020-04-19 13:44:50 +00:00
nia 87706eec7d ossaudio: If the user's channel count is rejected, use the hardware count 2020-04-15 16:39:06 +00:00
nia 0eb796bf71 ossaudio: Make SNDCTL_DSP_SETFMT conform with OSSv4.
The OSSv4 spec says we shouldn't really error if an invalid format is
chosen by an application. Things are especially likely to be confused
if we return MULAW, since in OSSv4 terms that means that's the native
hardware format. Instead, set and return the current hardware format
if an invalid format is chosen.

For the 24-bit sample formats, note that the NetBSD kernel currently
can't handle them in its default configuration, and will return an error
code if you attempt to use them. So, if an applicaton requests 24-bit PCM,
promote it to 32-bit PCM. According to the spec, this is valid and
applications should be checking the return value anyway.

In the Linux compat layer, we just use S16LE as a fallback. The OSSv3
headers that are still being shipped with Linux don't contain definitions
for fancier formats and we can reasonably expect all applications to
support S16LE.
2020-04-15 15:25:33 +00:00
nia 6476938d92 ossaudio: Make SNDCTL_DSP_SPEED more robust when using invalid rates.
From the perspective of reading the OSSv4 specification, NetBSD's
behaviour when an invalid sample rate is set makes no sense at all:
AUDIO_SETINFO simply returns an error code, and then we immediately
fall through to getting the sample rate, which is still set to the
legacy default of 8000 Hz.

Instead, what OSS applications generally expect is that they will be
able to receive the actual hardware sample rate. This is very, very
unlikely to be 8000 Hz on a modern machine.

No functional change when setting a sample rate between the supported
rates of 1000 and 192000 Hz. When a rate outside this range is requested,
the hardware rate is returned (on modern hardware, generally always 48000
Hz or a multiple of 48000 Hz).
2020-04-15 14:54:34 +00:00
thorpej 4626c667bc Regen for _lwp_gettid(2). 2020-04-04 20:27:27 +00:00
thorpej 98a9cebbb6 Add support for lazily generating a "global thread ID" for a LWP. This
identifier uniquely identifies an LWP across the entire system, and will
be used in future improvements in user-space synchronization primitives.

(Test disabled and libc stub not included intentionally so as to avoid
multiple libc version bumps.)
2020-04-04 20:20:12 +00:00
pgoyette 799a3b19cf When using SYSCTL_SETUP there is no guarantee of the order in which
the set-up functions will be called, so it is perfectly acceptable
for a compat code's routine to be called ahead of the code in other
parts of the kernel.

So make sure that the 2nd level sysctl node ``vfs.generic'' exists
before trying to add the 3rd level entries.

XXX Rather than creating the 2nd level node in two places, we could
XXX add the shared ``vfs.generic'' node to sysctl_init_base.c but
XXX this is left for another day.
2020-03-26 13:39:29 +00:00
pgoyette 4af030e5b6 Deal with having to teardown sysctl entries in multiple sub-trees.
(This used to work, but I broke it recently.)
2020-03-21 16:28:56 +00:00
pgoyette 2c1f75181f Restore code to sysctl_free() the compat32 shadow tree 2020-03-21 16:17:08 +00:00
pgoyette 67a77d0bf0 Remove a debug printf() that accidentally got committed. :( 2020-03-17 17:16:26 +00:00
pgoyette 9120d4511b Use the module subsystem's ability to process SYSCTL_SETUP() entries to
automate installation of sysctl nodes.

Note that there are still a number of device and pseudo-device modules
that create entries tied to individual device units, rather than to the
module itself.  These are not changed.
2020-03-16 21:20:09 +00:00
christos bfaaad7411 Unfortunately all the clockctl ioctls contain pointers to structs instead
of the structs themselves, so they need special handling. Undo previous
and do the permissions checks explicitly. It would be better to fix the
clockctl ioctls to contain the structs themselves...
2020-03-16 01:37:51 +00:00
christos 4d739e07c5 Don't open-code ioctls, pass back to the 64 bit ones (found by maxv@), 2020-03-16 00:05:29 +00:00
pgoyette b7f6986c09 Use SYSCTL_SETUP mechanism to establish our sysctl tree, rather than
using explicit calls to netbsd32_sysctl_{init,fini}()
2020-03-15 14:15:12 +00:00
pgoyette 729c6e77de Now that we have split the quota code out of the compat_netbsd32_50
module, it no longer depends on compat_50_quota.

Should address PR kern/55073
2020-03-15 12:46:02 +00:00
ad 16d4fad635 - Hide the details of SPCF_SHOULDYIELD and related behind a couple of small
functions: preempt_point() and preempt_needed().

- preempt(): if the LWP has exceeded its timeslice in kernel, strip it of
  any priority boost gained earlier from blocking.
2020-03-14 18:08:38 +00:00
maxv 1d76b5b8cf wrong size passed to copyout 2020-03-14 04:39:15 +00:00
pgoyette 1f582b1772 regen 2020-03-12 15:03:15 +00:00
pgoyette 4b5fc12da6 Split out the quota code from the rest of compat_netbsd32 module. This
allows loading of compat_netbsd32 on kernels that don't have ``options
QUOTA'' enabled.
2020-03-12 15:02:29 +00:00
pgoyette 4e8cb9d821 Rework previous, so that the real syscall code is not invoked from within
the module_hook code.  Otherwise, if the syscall just happens to be exit()
we will exit while still holding a reference to the hook's localcount, and
nothing will ever release that reference.  Attempts to manually unload the
module will hang indefinitely, as will modstat(8).

XXX pullup-9
2020-03-09 21:49:26 +00:00
pgoyette 2ca077cdd2 If a syscall requires a module to be autoloaded, the initial invocation
of that syscall will return ERESTART.  For amd64's netbsd32_syscall()
that means we need to back up the PC saved in the trap frame so we can
re-issue the syscall instruction.  For "normal" syscall traps, we saved
the instruction length in the trap frame, but this was missing for the
oosyscall/lcall path.  Since the PC was not backed up, the kernel-only
value ERESTART was returned to userland, causing all sort of grief for
old compat_netbsd32 executables!

XXX Pullup-9
2020-03-09 01:06:34 +00:00
pgoyette 3d2be0a63f The compat_50_quota code needs quota support from ufs. Add dependency. 2020-03-09 00:42:36 +00:00
mgorny 558ea2bcab PR standards/44921: Add errno consts for robust mutexes
Add the two missing errno.h constants: EOWNERDEAD and ENOTRECOVERABLE.
While technically they're used for robust mutexes which we do not
support at the moment, they are listed in POSIX and used by libc++.
While libc++ can be made to build without it, it just locally redefines
the values then, so we may as well define them globally.
2020-03-08 22:09:42 +00:00
pgoyette 416ea473b7 fix indentation. NFCI 2020-03-08 04:17:49 +00:00
pgoyette 0020741559 Fix another left-over from last year's [pgoyette-compat] work. This
allows recognition of the oosyscall sequence for amd64.

Fixes PR kern/55038

XXX pullup-9
2020-03-08 00:53:12 +00:00
pgoyette 42845fba1f Regen 2020-03-07 00:57:31 +00:00
pgoyette 5f01cff53e Properly mark netbsd32_compat_43 syscalls that are directly implemented
by calling their compat_43 equivalents.  With these changes, and with
built-in versions of COMPAT_NETBSD32, COMPAT_NOMID, and COMPAT_09, I can
now run a netbsd-0.9 statically linked i386 (32-bit) version of /bin/ls
on a 9.99.x amd64 host!

Addresses PR kern/55047 but more changes coming to handle non-built-in
modules.

XXX pullup-9
2020-03-07 00:56:41 +00:00
pgoyette ae7f2fd37d According to mrg@ we need to include aarch64 in the list of those
that need to support COMPAT_NETBSD32
2020-03-06 04:54:08 +00:00
pgoyette 52a67c0117 Module compat_netbsd32_50 requires module compat_50_quota 2020-02-27 20:54:24 +00:00
pgoyette 7455fbbd30 Include all of the vfs syscalls in the syscall_package, not just oquota.
Should fix PR kern/55025

XXX pullup-9
2020-02-27 18:19:16 +00:00
pgoyette e846f6f4a5 Ooppss - SYSCTL_SETUP() functions return void. 2020-02-27 17:42:33 +00:00
pgoyette 72450a671b Remove explicit calls to the sysctl setup routines, since this is now
handled by the module infrastructure.
2020-02-27 16:41:59 +00:00
ad 926b25e154 Merge from ad-namecache:
- Have a stab at clustering the members of vnode_t and vnode_impl_t in a
  more cache-conscious way.  With that done, go back to adjusting v_usecount
  with atomics and keep vi_lock directly in vnode_impl_t (saves KVA).

- Allow VOP_LOCK(LK_NONE) for the benefit of VFS_VGET() and VFS_ROOT().
  Make sure LK_UPGRADE always comes with LK_NOWAIT.

- Make cwdinfo use mostly lockless.
2020-02-23 22:14:03 +00:00
ad 6bbef11ebd Don't bother with kernel_lock for kern_reboot(). 2020-02-23 15:57:09 +00:00
maxv 11fc230787 pass the address of the field, instead of relying on it being the first
field of the structure, no functional change
2020-02-22 09:42:20 +00:00
ad 980ef21298 PR kern/54922: 9.99.45@20200202 panic: diagnostic assertion linux ldconfig triggers vpp != NULL in exit1()->radixtree.c line 674
Create an lwp_renumber() from the code in emulexec() and use in
linux_e_proc_exec() and linux_e_proc_fork() too.
2020-02-15 17:13:55 +00:00
mlelstv bc41a15ec3 Where did the +1 came from ? 2020-02-11 06:33:51 +00:00
mlelstv df5586d2f8 Don't use strlcpy to copy untrusted input, it may not be NUL-terminated. 2020-02-10 22:33:28 +00:00
riastradh 8e6cd4ce57 Load struct filedesc::fd_dt with atomic_load_consume.
Exceptions: when fd_refcnt <= 1, or when holding fd_lock.

While here:

- Restore KASSERT(mutex_owned(&fdp->fd_lock)) in fd_unused.
  => This is used only in fd_close and fd_abort, where it holds.
- Move bounds check assertion in fd_putfile to where it matters.
- Store fd_dt with atomic_store_release.
- Move load of fd_dt under lock in knote_fdclose.
- Omit membar_consumer in fdesc_readdir.
  => atomic_load_consume serves the same purpose now.
  => Was needed only on alpha anyway.
2020-02-01 02:23:03 +00:00
maxv b5b20b3eea Fix copyout overflows in fhstat, found by the LGTM bot. Not a big problem
since this syscall is privileged.
2020-01-31 09:01:23 +00:00
christos 7f15810560 - make sure size is not used uninitialized
- limit size range
- fix type botch for "size"
from maxv@
2020-01-30 14:07:40 +00:00
ad d1c42b4f7b - Track LWPs in a per-process radixtree. It uses no extra memory in the
single threaded case.  Replace scans of p->p_lwps with lookups in the
  tree.  Find free LIDs for new LWPs in the tree.  Replace the hashed sleep
  queues for park/unpark with lookups in the tree under cover of a RW lock.

- lwp_wait(): if waiting on a specific LWP, find the LWP via tree lookup and
  return EINVAL if it's detached, not ESRCH.

- Group the locks in struct proc at the end of the struct in their own cache
  line.

- Add some comments.
2020-01-29 15:47:51 +00:00
thorpej 79b0645161 Don't reference ifp->if_data directly; use if_export_if_data(). 2020-01-29 05:47:12 +00:00
pgoyette 9d7a921fe1 Split the module glue out from the rest of opencrypto/ocryptodev to
make rump happy.

Rump doesn't have compat modules (the compat code is included in the
relevant librump*.so), so there's no module compat_50 listed in
link_set_modules, and thus ocryptodev's MODULE(...) can't "require"
it.

This fixes the problem of "built-in module compat_50 not found" when
starting up rump_allserver (or rump_server with -l rumpdev_opencrypto).

XXX This does not resolve the long-standing "crypto: unable to
XXX register devsw, error 17" message noted at line 78 of
XXX sys/rump/dev/lib/libopencrypto/opencrypto_component.c
2020-01-27 17:09:17 +00:00
ad 6c994951d8 Correction to previous: don't leak newuc if copyout() fails. 2020-01-26 19:08:09 +00:00
ad edf01486dd - Fix a race between the kernel and libpthread, where a new thread can start
life without its self->pt_lid being filled in.

- Fix an error path in _lwp_create().  If the new LID can't be copied out,
  then get rid of the new LWP (i.e. either succeed or fail, not both).

- Mark l_dopreempt and l_nopreempt volatile in struct lwp.
2020-01-25 15:41:52 +00:00
pgoyette 320866888c Since this used to be part of the compat_50 module, make it depend on
compat_50 rather than compat_60 module.
2020-01-22 23:41:29 +00:00
pgoyette 09a5fcaf68 Split the compat_50 module into two, separating the QUOTA-related
stuff from the rest of the module.  This allows loading of the
(main) compat_50 module on kernels that don't include ``options
QUOTA''.

Welcome to 9.99.40 !

Addresses PR kern/54875
2020-01-21 02:37:16 +00:00
pgoyette 8903567a14 Regen generated files _after_ committing changes to the source file.
This gets the "Generated from" comments to use the new version number.

No functional change.
2020-01-18 14:07:31 +00:00
kamil 1741a0b962 Catch up after getpid/getgid/getuid changes in native ABI in 2008
getpid(), getuid() and getgid() used to call respectively sys_getpid(),
sys_getuid() and sys_getgid(). In the BSD4.3 compat mode there was a
fallback to call sys_getpid_with_ppid() and related functions.

In 2008 the compat ifdef was removed in sys/kern/syscalls.master r. 1.216.

For purity reasons we probably shall restore the NetBSD original behavior
and implement BSD4.3 one as a compat module, however it is not worth the
complexity.

Align the netbsd32 compat ABI to native ABI and call functions that return
two integers as in BSD4.3.
2020-01-18 07:33:24 +00:00
ad c2e9cb9413 VFS_VGET(), VFS_ROOT(), VFS_FHTOVP(): give them a "int lktype" argument, to
allow us to get shared locks (or no lock) on the returned vnode.  Matches
FreeBSD.
2020-01-17 20:08:06 +00:00
ad f1ecb271d5 Tidy up the vnode locking around execve() on ELF images to acquire and
release the locks fewer times.  Proposed on tech-kern a very long time go.
2020-01-12 18:30:58 +00:00
mrg 63bea4ffac don't check the value of retval in netbsd32_mmap() if sys_mmap()
was not successful.
2020-01-07 07:26:21 +00:00
pgoyette 4e7fb68a54 Resurrect boottime, but only in the compat_90 module (whether built-in
or separately loaded).  This will enable running of old vmstat(1) images
on newer kernels.
2020-01-04 02:40:22 +00:00
thorpej d6c967bb85 - Eliminate the global "boottime" variable, which was being accessed
without any synchronization against changes by e.g. clock_settime().
- Replace with new getbinboottime() / getnanoboottime() / getmicroboottime()
  functions (naming mirrors that of other time access functions in kern_tc.c).
  It returns the (maybe-converted) value of timebasebin, which also tracks
  our estimate of when the system was booted (i.e. the legacy "boottime" was
  redundant).

XXX There needs to be a lockless synchronization mechanism for reading
timebasebin, but this is a problem in kern_tc.c that pre-existed these
"boottime" changes.  At least now the problem is centralized in one location.
2020-01-02 15:42:26 +00:00
thorpej 599c240526 - Introduce a new global kernel variable "shutting_down" to indicate that
the system is shutting down or rebooting.
- Set this global in a new function called kern_reboot(), which is currently
  just a basic wrapper around cpu_reboot().
- Call kern_reboot() instead of cpu_reboot() almost everywhere; a few
  places remain where it's still called directly, but those are in early
  pre-main() machdep locations.

Eventually, all of the various cpu_reboot() functions should be re-factored
and common functionality moved to kern_reboot(), but that's for another day.
2020-01-01 22:57:16 +00:00
pgoyette 6865a3028c Emove vestigial remains of the monolithic compat module. 2020-01-01 19:35:21 +00:00
maxv 8822fe6d97 Fix three stack info leaks, found by kMSan when just invoking all syscalls
with a zero page as argument.

MSan: Uninitialized Stack Memory In copyout() At Offset 0, Variable 'sb32' From compat_20_netbsd32_getfsstat()
MSan: Uninitialized Stack Memory In copyout() At Offset 12, Variable 'oss' From compat_43_sys_sigstack()
MSan: Uninitialized Stack Memory In copyout() At Offset 0, Variable 'sb' From compat_50_netbsd32___fhstat40()
2020-01-01 14:52:38 +00:00
maxv 046ef0bd0f Fix sizeof mismatch in copyin. This leads to a user-triggerable stack
overflow. On my test build at least, by luck, the compiler orders the
variables in a way that the overflow hits only local structures which
haven't yet been initialized and used, so the overflow is harmless.

Very easily seeable with kASan - just invoke the syscall from a 32bit
binary.
2020-01-01 09:17:45 +00:00
ad 5c06357c90 Rename uvm_free() -> uvm_availmem(). 2019-12-31 13:07:09 +00:00
pgoyette 7e5e70ef9c For the built-in COMPAT_30 module code, make sure to initialize the
uipc_syscalls_30 stuff, notably to include compat_30_socket().

PR kern/54804

XXX Pullup-9 XXX
2019-12-28 15:39:52 +00:00
kamil 4f79a48470 Introduce PT_LWPSTATUS + PT_LWPNEXT, obsolete PT_LWPINFO
PT_LWPINFO is a legacy ptrace(2) operation that was originally intended
to retrieve the thread (LWP) information inside a traced process.

It has a number of flaws and is confused with PT_LWPINFO from FreeBSD.

PT_LWPSTATUS and PT_LWPNEXT address the problems (shortly by: rename,
removal of pl_event) and introduces new features: signal context
(pl_sigpend, pl_sigmask), LWP name (pl_name), LWP TLS base address
(pl_private). The private pointer was so far missing information for
a debugger.

PT_LWPSTATUS@nnn is now shipped with core(5) files and contain LWP specific
information, so far missed in the core(5) files.

PT_LWPSTATUS retrieves LWP information for the prompted thread.
PT_LWPNEXT retrieves LWP information for the next thread, borrowing the
semantics from NetBSD specific PT_LWPINFO.

PT_LWPINFO is namespaced with __LEGACY_PT_LWPINFO and still available for
the foreseeable future, without plans of removing it.

Add ATF tests for PT_LWPSTATUS + PT_LWPNEXT.

Keep ATF tests for PT_LWPINFO.

Switch GDB to new API.

Proposed on tech-kern@.
2019-12-24 14:50:59 +00:00
ad ddd3a0be1e uvmexp.free -> uvm_free() 2019-12-21 13:00:20 +00:00
tsutsui 1e72df6a03 Remove clause 3 and 4 leftovers from TNF licenses in more sources.
Confirmed by martin@ in PR/54760.
2019-12-15 16:48:25 +00:00
pgoyette 8a031a1d1e Rather than keeping a separate mutex, condvar, and pserialize for each
module hook, we can share a common set of synchronization structures.
This cuts the amount of cacheline_aligned data for these structures by
50%.

Note that we still have a per-hook localcount, since we need to count
individual references.

As discussed with riastradh@

Welcome to 9.99.22 !
2019-12-12 02:15:42 +00:00
maxv 48d18df02a Fix a bunch of unimportant "Local variable hides global variable" warnings
from the LGTM bot.
2019-12-06 08:35:21 +00:00
ad 11ba4e1830 Minor scheduler cleanup:
- Adapt to cpu_need_resched() changes. Avoid lost & duplicate IPIs and ASTs.
  sched_resched_cpu() and sched_resched_lwp() contain the logic for this.
- Changes for LSIDL to make the locking scheme match the intended design.
- Reduce lock contention and false sharing further.
- Numerous small bugfixes, including some corrections for SCHED_FIFO/RT.
- Use setrunnable() in more places, and merge cut & pasted code.
2019-11-23 19:42:52 +00:00
pgoyette 1d577fe379 Move all non-emulation-specific coredump code into the coredump module,
and remove all #ifdef COREDUMP conditional compilation.  Now, the
coredump module is completely separated from the emulation modules, and
they can all be independently loaded and unloaded.

Welcome to 9.99.18 !
2019-11-20 19:37:51 +00:00
rin 32c63f4c98 8-byte objects on i386 or arm-oabi are aligned in 4-byte boundary.
Therefore, we must use __attribute__((__aligned__(4))) for them.
netbsd32_{,u}int64 are provided for this purpose. However, we
cannot use it in <compat/sys/siginfo.h> due to circular dependency
b/w <machine/netbsd32_machdep.h>.

In order to distangle it, we choose here to have a duplicate type,
netbsd32_siginfo_uint64, in <compat/sys/siginfo.h>. The equivalence
with netbsd32_uint64 is asserted in <compat/netbsd32/netbsd32.h>.

Now, gdb for i386 works again on amd64 kernel.

Based on patch provided by kamil. Thanks!

XXX
pullup to netbsd-9
2019-11-18 12:06:26 +00:00
rin 76105d4897 TRAP_EXEC does not have extra fields to be filled in at the moment.
Explicitly ignore fields for now.

Pointed out by kamil. Thanks!

XXX
pullup to netbsd-9
2019-11-18 11:01:41 +00:00
rin d0bd92ff23 When converting siginfo, examine si_code at the beginning,
as explained in siginfo(2).

- If it is SI_NOINFO, there's no additional information.
- If it is non-positive, i.e., codes described in siginfo(2),
  we need to fill in _rt.

XXX
Description for SA_ASYNCIO in siginfo(2) seems outdated;
neither si_fd nor si_band are filled in with that code.

XXX
pullup to netbsd-9
2019-11-18 10:25:48 +00:00
rin 20ed113dfc Provide _ptrace_state for SIGTRAP with TRAP_EXEC, TRAP_CHLD, or TRAP_LWP.
Pointed out by kamil. Thanks!

XXX
pullup to netbsd-9
2019-11-18 10:14:52 +00:00
rin e2b2946780 Sort by signal numbers as far as possible, adjust locations of functions.
No functional changes intended.

XXX
pullup to netbsd-9
2019-11-18 04:58:42 +00:00
rin eae570da98 Sorry, revert unintentional parts of the previous commit:
http://mail-index.netbsd.org/source-changes/2019/11/18/msg110946.html

I was going to commit only netbsd32_signal.c.
2019-11-18 04:17:08 +00:00
rin c7d5ce13b1 Belatedly catch up with kern_sig.c rev 1.358:
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/kern/kern_sig.c#rev1.358

Provide syscall information with SIGTRAP TRAP_SCE/TRAP_SCX so that
picotrace/truss, for example, works fine on COMPAT_NETBSD32.

With some minor changes:

- Centralize netbsd32_si{,32}_si{32,}() into netbsd32_ksi{,32}_ksi{32,}().
- Provide si_status with SIGCHLD.
- Remove the remaining of SA.

XXX
pullup to netbsd-9
2019-11-18 04:09:53 +00:00
pgoyette 7b0f5c9e07 Convert the sendsig_sigcontext_16 function pointer to use the new
compat_hook mechanism.

XXX Despite being a kernel<-->module abi change, this should be
XXX pulled up to -9
2019-11-10 13:28:06 +00:00
jdolecek d61dd23cbc regen 2019-11-09 23:45:07 +00:00
jdolecek 54412fca0b add dummy implementation of linux fallocate() which just returns EOPNOTSUPP;
this is needed so that glibc falls back to emulation and apps behaving
properly, since EOPNOTSUPP is a documented and expected return code, but
ENOSYS is not

right now there are no filesystems in NetBSD tree supporting the fallocate
VOP, so no point trying to map this to a native call

supposed to help with problem reported in
https://mail-index.netbsd.org/tech-kern/2019/11/03/msg025641.html
2019-11-09 23:44:31 +00:00
jdolecek de940ab69b don't descend to sparc and sparc64, they don't have syscalls.master
so it just errors out
2019-11-09 22:02:45 +00:00