Commit Graph

315 Commits

Author SHA1 Message Date
riastradh 9fc453562f Round of uvm.h cleanup.
The poorly named uvm.h is generally supposed to be for uvm-internal
users only.

- Narrow it to files that actually need it -- mostly files that need
  to query whether curlwp is the pagedaemon, which should maybe be
  exposed by an external header.

- Use uvm_extern.h where feasible and uvm_*.h for things not exposed
  by it.  We should split up uvm_extern.h but this will serve for now
  to reduce the uvm.h dependencies.

- Use uvm_stat.h and #ifdef UVMHIST uvm.h for files that use
  UVMHIST(ubchist), since ubchist is declared in uvm.h but the
  reference evaporates if UVMHIST is not defined, so we reduce header
  file dependencies.

- Make uvm_device.h and uvm_swap.h independently includable while
  here.

ok chs@
2020-09-05 16:30:10 +00:00
riastradh 5084c1b50f Rewrite entropy subsystem.
Primary goals:

1. Use cryptography primitives designed and vetted by cryptographers.
2. Be honest about entropy estimation.
3. Propagate full entropy as soon as possible.
4. Simplify the APIs.
5. Reduce overhead of rnd_add_data and cprng_strong.
6. Reduce side channels of HWRNG data and human input sources.
7. Improve visibility of operation with sysctl and event counters.

Caveat: rngtest is no longer used generically for RND_TYPE_RNG
rndsources.  Hardware RNG devices should have hardware-specific
health tests.  For example, checking for two repeated 256-bit outputs
works to detect AMD's 2019 RDRAND bug.  Not all hardware RNGs are
necessarily designed to produce exactly uniform output.

ENTROPY POOL

- A Keccak sponge, with test vectors, replaces the old LFSR/SHA-1
  kludge as the cryptographic primitive.

- `Entropy depletion' is available for testing purposes with a sysctl
  knob kern.entropy.depletion; otherwise it is disabled, and once the
  system reaches full entropy it is assumed to stay there as far as
  modern cryptography is concerned.

- No `entropy estimation' based on sample values.  Such `entropy
  estimation' is a contradiction in terms, dishonest to users, and a
  potential source of side channels.  It is the responsibility of the
  driver author to study the entropy of the process that generates
  the samples.

- Per-CPU gathering pools avoid contention on a global queue.

- Entropy is occasionally consolidated into global pool -- as soon as
  it's ready, if we've never reached full entropy, and with a rate
  limit afterward.  Operators can force consolidation now by running
  sysctl -w kern.entropy.consolidate=1.

- rndsink(9) API has been replaced by an epoch counter which changes
  whenever entropy is consolidated into the global pool.
  . Usage: Cache entropy_epoch() when you seed.  If entropy_epoch()
    has changed when you're about to use whatever you seeded, reseed.
  . Epoch is never zero, so initialize cache to 0 if you want to reseed
    on first use.
  . Epoch is -1 iff we have never reached full entropy -- in other
    words, the old rnd_initial_entropy is (entropy_epoch() != -1) --
    but it is better if you check for changes rather than for -1, so
    that if the system estimated its own entropy incorrectly, entropy
    consolidation has the opportunity to prevent future compromise.

- Sysctls and event counters provide operator visibility into what's
  happening:
  . kern.entropy.needed - bits of entropy short of full entropy
  . kern.entropy.pending - bits known to be pending in per-CPU pools,
    can be consolidated with sysctl -w kern.entropy.consolidate=1
  . kern.entropy.epoch - number of times consolidation has happened,
    never 0, and -1 iff we have never reached full entropy

CPRNG_STRONG

- A cprng_strong instance is now a collection of per-CPU NIST
  Hash_DRBGs.  There are only two in the system: user_cprng for
  /dev/urandom and sysctl kern.?random, and kern_cprng for kernel
  users which may need to operate in interrupt context up to IPL_VM.

  (Calling cprng_strong in interrupt context does not strike me as a
  particularly good idea, so I added an event counter to see whether
  anything actually does.)

- Event counters provide operator visibility into when reseeding
  happens.

INTEL RDRAND/RDSEED, VIA C3 RNG (CPU_RNG)

- Unwired for now; will be rewired in a subsequent commit.
2020-04-30 03:28:18 +00:00
bouyer 70195d9f2a Merge the bouyer-xenpvh branch, bringing in Xen PV drivers support under HVM
guests in GENERIC.
Xen support can be disabled at runtime with
boot -c
disable hypervisor
2020-04-25 15:42:14 +00:00
jdolecek 5e41e58686 unhook umass_isdata.c from here too 2020-04-13 11:27:22 +00:00
christos 4bf07a2182 more smb removal. 2020-04-04 17:20:16 +00:00
jdolecek 1e03bcd0cf remove SMBFS and nsmb(4) - kernel part
it's unmaintained and supports only obsolete SMB1
2020-04-04 15:43:21 +00:00
riastradh e798caea38 Omit duplicate rnd_init in rump. 2020-02-10 07:13:06 +00:00
pgoyette a4c9570d62 Update comment to reflect recent change to the error message in question. 2020-01-27 17:10:23 +00:00
mlelstv cea9bbee01 Add error and zero targets to build. 2019-12-17 07:57:25 +00:00
kamil 77a1ad5f00 Switch the iconv(3) prototype to the POSIX conformant variation
Remove const from the 2nd argument.

const char ** and char ** are incompatible types and it was a cost to keep
the technically incompatible form for a more purist variation. NetBSD was
almost the last alive OS to still keep the const argument (known leftovers:
Minix and Illumos).

Keep the const form for the internal purposes inside citrus and rump.

Address the build breakage fallout in the same change.

There are no ABI changes.

Change accepted by core@.
2019-10-24 18:17:14 +00:00
isaki e622eac459 Merge isaki-audio2 branch, the overhaul of audio subsystem.
- Interrupt-oriented system rather than thread-oriented.
- Improve stability, quality and performance.
- Split playback and record cleanly.  Improve halfduplex support.
- Many bugs are fixed including deadlocks, resource leaks, abuses, etc.
- Simplify audio filter mechanism.  The encoding/channels/frequency
  conversions are completely handled in the upper layer.  So the hard-
  ware driver only converts its hardware encoding (if necessary).
- audio_hw_if changes:
  - Obsoletes query_encoding and add query_format instead.
  - Obsoletes set_params and add set_format instead.
  - Remove drain, setfd, mappage.
  - The call sequences are changed.
- ioctl AUDIO_GETFD/SETFD, AUDIO_GETCHAN/SETCHAN are obsoleted.
- ioctl AUDIO_{QUERY,GET,SET}FORMAT are introduced.
- cleanup config attributes: au*conv and mulaw.
- All hardware drivers should follow it (I've done as much as possible).

Some file paths are changed:
- dev/audio.c         -> dev/audio/audio.c (rewritten)
- dev/audiovar.h      -> dev/audio/audiovar.h
- dev/audio_dai.h     -> dev/audio/audio_dai.h
- dev/audio_if.h      -> dev/audio/audio_if.h
- dev/audiobell.c     -> dev/audio/audiobell.c
- dev/audiobellvar.h  -> dev/audio/audiobellvar.h
- dev/mulaw.[ch]      -> dev/audio/mulaw.[ch] + dev/audio/alaw.c
2019-05-08 13:40:13 +00:00
christos 38ebc08440 need subr_disklabel.c 2019-04-05 01:09:33 +00:00
bad e0888b5db5 Protect __KERNEL_RCSID. It isn't available when compile rumpkernels under e.g. Linux. 2019-03-26 08:56:17 +00:00
christos f4a7d93983 kill compat code dependencies. 2019-02-06 23:00:56 +00:00
mrg c29615453d don't assume _LP64 == supports COMPAT_NETBSD32.
this is not true for alpha, ia64 and arm32 ports, and the first two
were not building because of it, and the latter would be missing
the oabi support (likely not a big deal, but still wrong.)

add a makefile fragment that tells you if it is supported and include
it where needed to define COMPAT_NETBSD32 when building the normal
kernel (ie, modules & rump.)


fixes alpha build, probably fixes ia64 build.


XXX: still leaves some netbsd32 code in rf_netbsdkintf.c, that should
     be moved into some hooks, but first the configuration setup
     needs to be moved into a common function the netbsd32 code can
     call into, vs living in the switch case itself.
2019-02-04 21:57:47 +00:00
rin d9d37bdb59 Fix merge botches. I hope there's no more left... 2019-01-27 09:19:36 +00:00
pgoyette d91f98a871 Merge the [pgoyette-compat] branch 2019-01-27 02:08:33 +00:00
alnsn a57097d054 Add missing RCSIDs. 2018-12-12 00:48:43 +00:00
riastradh d1579b2d70 Rename min/max -> uimin/uimax for better honesty.
These functions are defined on unsigned int.  The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER!  Some subsystems have

	#define min(a, b)	((a) < (b) ? (a) : (b))
	#define max(a, b)	((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX.  Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate.  But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all.  (Who knows, maybe in some cases integer
truncation is actually intended!)
2018-09-03 16:29:22 +00:00
maya a50c06709e Remove duplicate ; 2018-06-06 01:49:07 +00:00
maxv 4070f54bcc M_CLUSTER -> M_EXT_CLUSTER, and remove M_CLUSTER completely. 2018-04-27 08:51:26 +00:00
mrg f2b04ca083 implement 32-bit compat support for raidframe.
convert several raidframe ioctls to be bitsize idempotent so that
they work the same in 32 and 64 bit worlds, allowing netbsd32 to
configure and query raid properly.  remove useless 'row' in a few
places.  add COMPAT_80 and put the old ioctls there.

raidframeio.h:
  RAIDFRAME_TEST_ACC
  - remove, unused
  RAIDFRAME_GET_COMPONENT_LABEL
  - convert to label not pointer to label
  RAIDFRAME_CHECK_RECON_STATUS_EXT
  RAIDFRAME_CHECK_PARITYREWRITE_STATUS_EXT
  RAIDFRAME_CHECK_COPYBACK_STATUS_EXT
  - convert to progress info not pointer to info
  RAIDFRAME_GET_INFO
  - version entirely.
raidframevar.h:
  - rf_recon_req{} has row, flags and raidPtr removed (they're
    not a useful part of this interface.)
  - RF_Config_s{} and RF_DeviceConfig_s{} have numRow/rows removed.
  - RF_RaidDisk_s{} is re-ordered slightly to fix alignment
    padding - the actual data was already OK.
  - InstallSpareTable() loses row argument

rf_compat32.c has code for RF_Config_s{} in 32 bit mode, used
by RAIDFRAME_CONFIGURE and RAIDFRAME_GET_INFO32.

rf_compat80.c has code for rf_recon_req{}, RF_RaidDisk_s{} and
RF_DeviceConfig_s{} to handle RAIDFRAME_FAIL_DISK,
RAIDFRAME_GET_COMPONENT_LABEL, RAIDFRAME_CHECK_RECON_STATUS_EXT,
RAIDFRAME_CHECK_PARITYREWRITE_STATUS_EXT,
RAIDFRAME_CHECK_COPYBACK_STATUS_EXT, RAIDFRAME_GET_INFO.

move several of the per-ioctl code blocks into separate functions.

add rf_recon_req_internal{} to replace old usage of global
rf_recon_req{} that had unused void * in the structure, ruining
it's 32/64 bit ABI.

add missing case for RAIDFRAME_GET_INFO50.

adjust raid tests to use the new .conf format, and add a case to
test the old method as well.

raidctl:
deal with lack of 'row' members in a couple of places.
fail request no longer takes row.
handle "START array" sections with just "numCol numSpare", ie
no "numRow" specified.  for now, generate old-style configuration
but update raidctl.8 to specify the new style (keeping reference
to the old style.)

note that: RF_ComponentLabel_s::{row,num_rows} and
RF_SingleComponent_s::row are obsolete but not removed yet.
2018-01-18 00:32:48 +00:00
pgoyette dd351a1d64 Now that the pad module has an ioconf file, we need to provide one for
the rump-component, too.
2017-12-16 09:20:29 +00:00
knakahara e3753d8251 reduce rump waring message. pointed out by ozaki-r@n.o, thanks. 2017-06-29 08:51:27 +00:00
christos d24826313c should be umodeswitch! 2017-06-22 02:07:26 +00:00
pgoyette ab66491cc5 Add infrastructure for modularization of audio, midi, and sequencer 2017-06-01 09:44:30 +00:00
sevan a3692735fe Match the ioconf name in sys/modules.
Resolves rumprun build process.
Put together with the help & direction of riastradh & paulg.
2017-05-10 06:22:15 +00:00
riastradh c248891802 Modularize ualea(4).
Unclear why we have a separate xyz.ioconf for module and XYZ.ioconf
for rump component, but at least xyz_modcmd obviates the need for
xyz_component.c (though evidently the latter could have been replaced
anyway by RUMP_COMPONENT=ioconf in the rump component Makefile).
2017-04-19 00:01:38 +00:00
riastradh f7eaf9902f Make comment match. 2017-04-18 19:41:27 +00:00
riastradh 4299c62826 New rndsource driver for Araneus Alea II TRNG USB devices.
Disabled by default in x86/GENERIC and usbdevices.config pending
review and testing without rump ugenhc in the way, but enabled in
x86/ALL for compile-testing.

(Hi gson!  Finally found a round tuit in my pocket, next to a certain
rectangular one.)
2017-04-17 08:59:37 +00:00
riastradh ee1810e5f9 Fix bulk xfer buffer with usedma = false. 2017-04-17 07:13:30 +00:00
riastradh ebe393339f Fix order of outputs in rumpuser_open call.
Now ugenhc works again after a four-year hiatus...
2017-04-17 05:11:05 +00:00
pgoyette 163337a16d We no longer need ioconf.c - remove it to avoid "defined but not used"
compiler error.
2017-01-15 01:48:05 +00:00
pgoyette 0792f962a8 Don't call the drvctl module's initialization code during rump component
initialization.  Instead, temporarily attach the drvctl's cdevsw to
determine its device c-major, create the /dev/drvctl node using that
c-major, and then detach.  This leaves things in a state where normal
module initialization can run.

Since we're now creating the /dev/drvctl device node correctly, we don't
need to create it again.  So mark the device as DEVNODE_DONTBOTHER in
the devsw_conv0 conversion table.

This bug was introduced more than a year ago (src/sys/kern/kern_drvctl.c
rev 1.40), but was silently ignored except when running a rump_server
built with LOCKDEBUG.
2017-01-14 21:36:58 +00:00
pgoyette 2dc75bdc9e Fix variable names in previous 2016-07-30 23:07:23 +00:00
pgoyette 763a6486bb More adaptation of the rump component init, to avoid EEXIST during
regular module initialization.
2016-07-30 22:36:14 +00:00
pgoyette 7ea3f07f30 When calling devsw_attach() we need to use the expected/official driver
name (as listed in the devsw_conv[] table) to get the expected device
majors.  Once rump initialization is finished (ie, it has created its
required device nodes), we need to detach the [bc]devsw so the module
initialization code doesn't get EEXIST.
2016-07-26 01:49:48 +00:00
pgoyette 9e4ecfb022 When initializing the rump cgd component, use the correct driver name
(as found in the devsw_conv[] table).  This will get us the "official"
major numbers for the cgd device.

After creating the rump file-space nodes for /dev/cgd* we then need to
detach the [bc]devsw's because normal module initialization will do its
own attachment, and we don't want that to fail.

While here, since we're doing the devsw_attach() twice, share the
results from the first call rather than starting from scratch.
2016-07-25 12:45:13 +00:00
pgoyette 7c20c5d3bb Fix regression introduced in tests/net/bpf and tests/net/bpfilter
The rump code needs to call devsw_attach() in order to assign a dev_major
for bpf;  it then uses this to create rumps /dev/bpf node.  Unfortunately,
this leaves the devsw attached, so when the bpf module tries to initialize
itself, it gets an EEXIST error and fails.

So, once rump has figured what the dev_major should be, call devsw_detach()
to remove the devsw.  Then, when the module initialization code calls
devsw_attach() it will succeed.
2016-07-19 02:47:45 +00:00
msaitoh 8bc54e5be6 KNF. Remove extra spaces. No functional change. 2016-07-07 06:55:38 +00:00
pooka f3167874d4 Disable PR kern/51135 hack now that the problem is supposedly
fixed (to see if tests pass).
2016-05-30 14:52:06 +00:00
pooka 3bc931a0af Add workaround for PR kern/51135
If the rnd component is present, load extra initial entropy to avoid
/dev/random not being able to request it on demand.  The extra initial
entropy will allow a few instances of /dev/random, but will eventually
go into the failure mode described in the PR.
2016-05-16 16:31:07 +00:00
pooka c8a34480e3 Avoid '.' in variable names which are expected to be passed to
this Makefile via the env.

That character is strictly speaking not allowed by POSIX in an exported
variable name, and at least dash >= 0.58 refuses to export such variables.

Furthermore, since the individual CFLAGS/CPPFLAGS/etc. variables
are not comprehensive enough for all cases (e.g. HURD), just
support the .includable version from now on, i.e.
RUMPCOMP_MAKEFILEINC_rumpdev_pci.

curious failure mode debugged by Martin Lucina
2016-05-10 19:38:29 +00:00
skrll 4e8e66439e Merge nick-nhusb
- API / infrastructure changes to support memory management changes.
- Memory management improvements and bug fixes.
- HCDs should now be MP safe
- conversion to KERNHIST based debug
- FS/LS isoc support on ehci(4).
- conversion to kmem(9)
- Some USB 3 support - mostly from Takahiro HAYASHI (t-hash).
- interrupt transfers now get proper DMA operations
- general bug fixes
    - kern/48308
    - uhub status notification improvements
    - umass(4) probe fix (applied to HEAD already)
    - ohci(4) short transfer fix
2016-04-23 10:15:27 +00:00
pooka 1730d8f0cf nuke a few missed -Ifactiondir CPPFLAGSitions. 2016-01-26 23:41:15 +00:00
pooka 6bb5142288 Put the kernelside rump kernel headers into <rump-sys> instead of
sprinkling them around the faction directories.  Avoids having
to add a CPPFLAGS (or several) to pretty much every component
Makefile.

Leave compat headers around in the old locations.

The commit changes some autogenerated files, but I'll fix the
generators shortly and regen.
2016-01-26 23:12:14 +00:00
pooka a987d455cc Implement the inverse of a nop. 2016-01-18 14:37:53 +00:00
pgoyette 7594d8cd11 Detach the {b,c}devsw after obtaining the device major numbers. We'll
re-attach during module initialization.

This enables the atf tests to once again succeed.
2015-12-26 10:22:09 +00:00
pgoyette 23c592fb1a Remove local CF_DRIVER_DECL - it is now defined in the raidframe driver's
module initialization code
2015-12-26 01:01:30 +00:00
pooka 35ce72762f Fix argument to empty()
Guess none of the fast-running tests exercised the
component being initialized ...
2015-11-17 01:07:34 +00:00