Commit Graph

152618 Commits

Author SHA1 Message Date
jdolecek
dd45d45423 make COMPAT_LINUX option disabled by default
leave the option enabled only in amd64/i386 ALL kernels to make
sure it continues to be compilable also when included in kernel
2020-08-16 10:27:47 +00:00
skrll
1344fd3121 Improve comments 2020-08-16 10:08:42 +00:00
skrll
3c6d0a11a5 Welcome to 9.99.71 - changes to arm/aarch64 struct cpu_info
Thanks to mrg@ for the hint
2020-08-16 09:41:50 +00:00
skrll
a334a57f55 Define COHERENCY_UNIT and CACHE_LINE_SIZE to fix arm builds.
The recent change to cpu.h and struct cpu_info needs an early definition
for the ARM_INTR_IMPLs that want to inline the spl functions and get
{,set_}curcpl() from cpu.h
2020-08-16 09:37:30 +00:00
isaki
bc6beee95c Update and fix.
All primary bootloaders can recognize Human68k partition table.
2020-08-16 07:25:51 +00:00
isaki
76c2ed7cdd Replace boot_ustar with xxboot_ustarfs.
The old boot_ustar had many hard coding and was small(<1KB).
The new xxboot_ustarfs is a part of integrated larger(<8KB) xxboot.
We had to maintain three similar but not the same bootloaders, but
now we have two!
2020-08-16 07:03:45 +00:00
isaki
7e73c3a86c Overhaul xxboot. And merge floppy boot, taken from boot_ustar.
- Rewrite boot.S completely.
  boot.S now supports boot from SCSI HD/CD and floppy.
- Use IOCS call to identify the floppy format, instead of chkfmt.s which
  accesses hardware directly.
- Import print_hex() debug function from boot_ufs.
- Import a feature that displays initial registers (for debug) from boot_ufs,
  and restore it (this in boot_ufs has been broken).
- Add size optimized alternatives for some libkern routines.
- Stop linking libsa to prevent to link unexpected objects.
- Bump version to 2.0.
2020-08-16 06:43:43 +00:00
riastradh
ae3eedf331 Fix sloppy mistakes in previous.
1. Give the offset of the rbnode, not some other random members to
   overwrite with garbage.

2. Don't try to unlock a mutex at NULL.

3. Make sure all paths out after ugenif_acquire go via
   ugenif_release.
2020-08-16 06:17:31 +00:00
riastradh
c107c49a73 Initialize the i2c controller before using it.
Fixes mutex uninitialized panic in LOCKDEBUG.
2020-08-16 03:48:59 +00:00
riastradh
d21e522e87 Expose Yubikey CCID interface to userland via ugenif. 2020-08-16 02:38:06 +00:00
riastradh
ee406c527b Share unit numbering for ugen and ugenif.
This way putting ugenif in kernel config actually works to wire it to
the /dev/ugenN.MM device nodes in userland.

Not a fully fleshed out solution to the ugen problem -- there's no
way for a userland driver to kick out a kernel driver and take over,
but this will let us, e.g., use uhidev(4) for Yubikey OTP/U2F/FIDO2
but ugen(4), with pcscd(8), for Yubikey CCID.

Fix various MP-safety issues while here (still not MPSAFE, but more
progress).
2020-08-16 02:37:19 +00:00
riastradh
6269170c9d Convert DIAGNOSTIC prints to KASSERTs. 2020-08-16 02:34:54 +00:00
riastradh
b663bb53fc Hold the lock over access to the data structures it covers.
Still not MPSAFE, but progress.
2020-08-16 02:34:20 +00:00
riastradh
a2da0435ef Remove UGEN_ASLP microoptimization.
cv_signal already has this microoptimization.

While here, make the lock cover the relevant things we're issuing
cv_signal about -- progress toward real MP-safety.
2020-08-16 02:33:17 +00:00
chs
0d0b0c4dc4 in uvm_findpage(), when uvm_page_array_fill_and_peek() returns a page
that is not the one we want and we make an assertion about dirtiness,
check the dirty status of the page we wanted rather than the page we got.
2020-08-16 00:24:41 +00:00
thorpej
f61f342c10 Convert some #ifdef DIAGNOSTIC checks to KASSERTs. NFCI. 2020-08-15 16:09:07 +00:00
skrll
317fb4dd44 #ifdef _ARM_ARCH_7 the dmbs 2020-08-15 13:33:54 +00:00
mrg
fc8474c3ed move stacktrace_subr() from trap.c into new mips_stacktrace.c so
it can be shared between ddb, other mips kernel components (see
locore), and an upcoming crash(8) port.

remove second copy of kdbpeek() (hidden by old DDB_TRACE
option, but they're functionally equivalent.)

tested on octeon.

ok simonb@
2020-08-15 07:42:07 +00:00
chs
b0597d5997 use uint64_t rather than int for storing the index of a page within an object. 2020-08-15 07:24:09 +00:00
mrg
073d3fd154 there was no MIPS{32,64} release 4.
XXX: missing lots and lots of evbmips CPUs.
2020-08-15 05:41:57 +00:00
simonb
9f936cf095 Fix value for SCE/SWE instructions.
Problem noticed by mrg@.
2020-08-15 04:27:28 +00:00
tnn
68cb89e9f3 add a __diagused to fix non-DIAGNOSTIC kernel 2020-08-15 01:27:22 +00:00
skrll
1e12472c15 Fix build by splitting large amount of inline assembling into a seperate
.S file.  Same stub (/trampoline) code before and after this change.
2020-08-14 16:53:06 +00:00
skrll
3565af6daa Mirror the changes to aarch64 and
- Switch to TPIDRPRW_IS_CURLWP, because curlwp is accessed much more often
  by MI code.  It also makes curlwp preemption safe,

- Make ASTs operate per-LWP rather than per-CPU, otherwise sometimes LWPs
  can see spurious ASTs (which doesn't cause a problem, it just means some
  time may be wasted).

- Make sure ASTs are always set on the same CPU as the target LWP, and
  delivered via IPI if posted from a remote CPU so that they are resolved
  quickly.

- Add some cache line padding to struct cpu_info.

- Add a memory barrier in a couple of places where ci_curlwp is set.  This
  is needed whenever an LWP that is resuming on the CPU could hold an
  adaptive mutex.  The barrier needs to drain the CPU's store buffer, so
  that the update to ci_curlwp becomes globally visible before the LWP can
  resume and call mutex_exit().
2020-08-14 16:18:36 +00:00
martin
8301aeac11 PR port-sparc/55573: remove kernel message about disabled coprocessor
instructions - it is triggered by userland trying to detect availability
of sparcv9 VIS instructions.
2020-08-14 13:45:44 +00:00
martin
284686b53f Adapt to new proplib api 2020-08-14 10:31:40 +00:00
chs
43e6f9fd5f fix a bit that I missed in the device_t/softc split 8 years ago. 2020-08-14 09:28:29 +00:00
chs
b7082a1c8a restore the initialization of icp->icp_ccbs that I removed by mistake. 2020-08-14 09:26:40 +00:00
chs
19303cecfc centralize calls from UVM to radixtree into a few functions.
in those functions, assert that the object lock is held in
the correct mode.
2020-08-14 09:06:14 +00:00
skrll
aa1b82d61b Whitespace 2020-08-14 08:19:26 +00:00
isaki
19f4b030c4 Reduce binary size as possible. These reduce filesize about 20 words.
- Use word alignment (rather than longword alignment) for text/data section.
- Use short reference.  In the bootloader, all symbols can be expressed in
  short.
2020-08-14 03:54:46 +00:00
isaki
07df2c5297 Use DEV_OPEN() macro. 2020-08-14 03:43:28 +00:00
isaki
d21129ac66 Use fixed 'xx' instead of DEV and DEVDRV for simplicity.
There is no choice other than xx for now.
2020-08-14 03:40:47 +00:00
isaki
d32126162a Add xxboot.h common header to share prototype definitions. 2020-08-14 03:34:22 +00:00
isaki
c2b719cf8b Style fixes. One entry per line for some parts. 2020-08-14 03:29:23 +00:00
isaki
b45ed32da3 - Restore display of first_kbyte. This is helpful for development.
- Check the filesize of resulting file instead of section sizes.
  If there is a gap between sections, the filesize may be exceeded even
  though the section total is not exceeded.  Of course that doesn't
  usually happen but I've experienced this during development.
2020-08-14 03:25:39 +00:00
isaki
023654acd0 Make compilable even with XXBOOT_DEBUG. 2020-08-14 02:51:48 +00:00
riastradh
d18c7c1a89 regen 2020-08-14 00:55:02 +00:00
riastradh
bdad8b2721 New system call getrandom() compatible with Linux and others.
Three ways to call:

getrandom(p, n, 0)              Blocks at boot until full entropy.
                                Returns up to n bytes at p; guarantees
                                up to 256 bytes even if interrupted
                                after blocking.  getrandom(0,0,0)
                                serves as an entropy barrier: return
                                only after system has full entropy.

getrandom(p, n, GRND_INSECURE)  Never blocks.  Guarantees up to 256
                                bytes even if interrupted.  Equivalent
                                to /dev/urandom.  Safe only after
                                successful getrandom(...,0),
                                getrandom(...,GRND_RANDOM), or read
                                from /dev/random.

getrandom(p, n, GRND_RANDOM)    May block at any time.  Returns up to n
                                bytes at p, but no guarantees about how
                                many -- may return as short as 1 byte.
                                Equivalent to /dev/random.  Legacy.
                                Provided only for source compatibility
                                with Linux.

Can also use flags|GRND_NONBLOCK to fail with EWOULDBLOCK/EAGAIN
without producing any output instead of blocking.

- The combination GRND_INSECURE|GRND_NONBLOCK is the same as
  GRND_INSECURE, since GRND_INSECURE never blocks anyway.

- The combinations GRND_INSECURE|GRND_RANDOM and
  GRND_INSECURE|GRND_RANDOM|GRND_NONBLOCK are nonsensical and fail
  with EINVAL.

As proposed on tech-userlevel, tech-crypto, tech-security, and
tech-kern, and subsequently adopted by core (minus the getentropy part
of the proposal, because other operating systems and participants in
the discussion couldn't come to an agreement about getentropy and
blocking semantics):

https://mail-index.netbsd.org/tech-userlevel/2020/05/02/msg012333.html
2020-08-14 00:53:15 +00:00
riastradh
4c526ee1ed Skip unlinked inodes.
They no longer matter on disk so we don't need to write anything out
for them.
2020-08-13 17:26:43 +00:00
riastradh
56c44c5ee7 Nix trailing whitespace. 2020-08-13 16:45:58 +00:00
msaitoh
dd0fa0d354 Set recovery_mode_timer workqueue's name correctly. 2020-08-13 08:42:18 +00:00
msaitoh
49e1fcd90c Use atomic_cas_uint() and atomic_store_relaxed(). Advised by thorpej@.
Tested by me. OK'd by knakahara.
2020-08-13 08:38:50 +00:00
skrll
0386a306a4 Trailing whitespace 2020-08-13 07:14:04 +00:00
skrll
243e94f8fd Whack-a-mole 2020-08-12 18:30:46 +00:00
skrll
0a3d29f4ed Part IV of ad's performance improvements for aarch64
- Implement pmap_growkernel(), and update kernel pmap's stats with atomics.

- Then, pmap_kenter_pa() and pmap_kremove() no longer need to allocate
  memory nor take pm_lock, because they only modify L3 PTEs.

- Then, pm_lock and pp_lock can be adaptive mutexes at IPL_NONE which are
  cheaper than spin mutexes.

- Take the pmap's lock in pmap_extract() if not the kernel's pmap, otherwise
  pmap_extract() might see inconsistent state.
2020-08-12 13:36:36 +00:00
skrll
739b4cc834 Part III of ad's performance improvements for aarch64
- Assembly language stubs for mutex_enter() and mutex_exit().
2020-08-12 13:28:46 +00:00
skrll
9f2441fc32 Part II of ad's aarch64 performance improvements (cpu_switch.S bugs are
all mine)

- Use tpidr_el1 to hold curlwp and not curcpu, because curlwp is accessed
  much more often by MI code.  It also makes curlwp preemption safe and
  allows aarch64_curlwp() to be a const function (curcpu must be volatile).

- Make ASTs operate per-LWP rather than per-CPU, otherwise sometimes LWPs
  can see spurious ASTs (which doesn't cause a problem, it just means some
  time may be wasted).

- Use plain stores to set/clear ASTs.  Make sure ASTs are always set on the
  same CPU as the target LWP, and delivered via IPI if posted from a remote
  CPU so that they are resolved quickly.

- Add some cache line padding to struct cpu_info, to match x86.

- Add a memory barrier in a couple of places where ci_curlwp is set.  This
  is needed whenever an LWP that is resuming on the CPU could hold an
  adaptive mutex.  The barrier needs to drain the CPU's store buffer, so
  that the update to ci_curlwp becomes globally visible before the LWP can
  resume and call mutex_exit().  By my reading of the ARM docs it looks like
  the instruction I used will do the right thing, but I'm not 100% sure.
2020-08-12 13:19:35 +00:00
jmcneill
54695ccbd8 Add CEC clock 2020-08-12 10:21:00 +00:00
msaitoh
38bc295884 Fix checking return value of atomic_cas_uint().
This change fixes a bug that extra delay() is called only once even if
atomic_cas_uint() isn't failed or delay() isn't called when atomic_cas_uint()
failed.

The reason of this bug was that I simply converted FreeBSD' atomic_cmpset_int()
to atomic_cas_uint(). The return value's semantics is different.
2020-08-12 09:13:46 +00:00