Commit Graph

285404 Commits

Author SHA1 Message Date
rillig
a75802fa16 make: clean up and update comments in var.c
During the refactorings of the last months, several comments have become
outdated, some are now redundant since the code is as clear as the
comment, and some code benefits from a bit of explanation.
2021-02-16 17:41:23 +00:00
rillig
b3224a45e4 make: use bit-shift expressions for VarFlags constants
These are easier to read than hex constants.

There was no need to skip bits 2 and 3 (there were no constants for 0x04
and 0x08).  Close this gap, to avoid confusing future readers.  Keep the
relative order of the flags since that affects the debug output of -dv.

No functional change.
2021-02-16 16:33:40 +00:00
rillig
6e5fc7f457 make: rename constants for VarFlags
The old prefix was "VAR_" and this prefix is used for several other
constants as well, which made it ambiguous.
2021-02-16 16:28:41 +00:00
rillig
6544f8c037 make: sync comment about duplicated code with reality
There are only very few places in var.c that contain really duplicate
code anymore.

There is still lots of _almost_ duplicate, for example the code for
parsing variable modifiers.  It differs subtly in behavior:

*   The modifiers ':M' and ':N' use '$$' to escape a '$' sign, while
    almost all other modifiers use '\$' for this purpose.

*   The modifiers ':M', ':N', ':S', ':@' and several others parse
    balanced parentheses and braces, allowing '(' to '}' to match.
    The modifiers ':D' and ':U' only treat the end character special but
    not the other 3 of '(){}'.

*   When parsing the modifier ':S' but not evaluating it, the code for
    nested variable expressions is parsed differently from when it is in
    evaluation mode (VARE_WANTRES).  This applies to an outer ':S'
    modifier and an inner ':D' or ':M' modifier.

Since these inconsistencies affect the behavior in edge cases and some
users of make might depend on it, they cannot be fixed by
behavior-preserving refactorings.
2021-02-16 16:14:27 +00:00
kre
00668d1e3a PR bin/55979
Correctly handle (ie: ignore completely) \0 chars (nuls) in the
shell command input stream (script, dot file, or stdin).

Previously nul chars were ignored correctly in the line in which
they occurred, but would cause trailing chars of that line to reappear
as the start of the following line.   If there was just one \0 skipped,
this would generally result in an extra \n in the sh input, which in
most cases has no effect.   With multiple \0's in a single line, more
of the end of that line was duplicated into the following one.  This
usually manifested as a weird "command not found" error.

Note that any \0 chars in the sh input make the script non-conforming,
so fixing this is not crucial (no \0's should really ever be seen) but
it was an obvious bug in the code, which was attempting to ignore nul
chars (as do many other shells), so let it be fixed.

XXX pullup -9
2021-02-16 15:30:26 +00:00
kre
f49e0d69dd PR bin/55979
This fixes the MSAN detected reference to an unitialised variable
(an unitialised field in a struct) which happens when a command is
not found after a PATH search.

Aside from skipping some known to be going to fail exec*() calls
in some cases, the setting of the relevant field is irrelevant,
so this problem makes no practical difference to the shell, or any
shell script.

XXX (maybe) pullup -9
2021-02-16 15:30:12 +00:00
simonb
a9214ed12d Whitespace nit. 2021-02-16 15:06:30 +00:00
simonb
562353e3cc In netbsd32___mount50() zero out the native fs_args union before use so
we don't pass stack garbage to the lower layers in the MNT_GETARGS case.

Fixes random errors like "Bad address" from "mount -vv" with nfs mounts.
2021-02-16 14:47:20 +00:00
riastradh
14efb762fe Correct floating-point terminology.
Might want to harmonize the printf(3) and wprintf(3) descriptions of
`%a'.
2021-02-16 14:44:25 +00:00
reinoud
33a3dfef01 I forgot to add the needed conf files for the mipssim virtio addition 2021-02-16 10:58:32 +00:00
martin
b2f1163792 One more time: backout arp header alignment, now that the alignment
asserted has been aligned to reality.
Also remove unused ARP_HDR_ALIGNED_P macro. Pointed out by roy.
2021-02-16 10:22:52 +00:00
martin
6352f759f0 ARP headers only need 2 byte alignment - pointed out by roy. 2021-02-16 10:20:56 +00:00
hannken
0c0601776b Enable "/etc/zfs/exports" from "zfs share" in rc.d/mountd and rc.d/mountall. 2021-02-16 10:02:42 +00:00
wiz
0b10797fb6 Reword slightly. 2021-02-16 10:01:55 +00:00
hannken
b1564e28a9 Add support for multiple exports files. This will be useful for example for
ZFS, where we have an automatically generated /etc/zfs/exports file, which
should not be edited directly.
2021-02-16 10:00:27 +00:00
hannken
3067a266c7 Split get_exportlist() into get_exportlist() and get_exportlist_one()
in preparation to support multiple input files.

No functional change intended.
2021-02-16 09:58:35 +00:00
hannken
dc06ff169e Reorganize uvm_swap_shutdown() a bit, make sure the vnode gets
locked and referenced across the call to swap_off() and finally
use it from vfs_unmountall1() to remove swap after unmounting
the last file system.

Adresses PR kern/54969 (Disk cache is no longer flushed on shutdown)
2021-02-16 09:56:32 +00:00
hannken
368d0d651b Use the right uid / gid for nobody:nobody like FreeBSD does.
Prevents null pointer dereferences when ZFS replaces this
illegal (according to IS_EPHEMERAL()) id with another
illegal id in operation zfs_fuid_create_cred() and
finally zfs_log_create() dereferences fuidp being NULL.

Adresses PR misc/55042 (Panic when creating a directory on a NFS served ZFS)
2021-02-16 09:54:17 +00:00
kre
6974a2b259 PR bin/55979
Add a sh ATF test to demonstrate a bug in the way that \0 characters
are dropped from scripts.   This test will eventually be extended to
test other potential sh script input related issues.

When initially committed, this test should fail.  It should succeed
when the fix for the PR is committed (soon).

Nb: this tests only the \0 related issues from the PR, the MSAN
detected uninitialised variable (struct field) can only be detected
by MSAN, as it has no visible impact on the operation of the shell
when running on any real (or even emulated) hardware.
(It will, however, also be fixed).
2021-02-16 09:46:24 +00:00
skrll
622167740b Provide a pic_set_priority_psw in the case that __HAVE_PIC_SET_PRIORITY
is not defined.
2021-02-16 07:27:12 +00:00
simonb
03730acf40 Working kernel profiling for n32/n64:
- Different MCOUNT and _KERN_MCOUNT macros for n32/n64.
 - Don't profile mipsXX_lwp_trampoline().
 - Allow a few new instructions in the stub fixups.
2021-02-16 06:06:58 +00:00
martin
aee51c4b29 Undo previous backout: alignment is needed here.
The reason for the previous backout was a misunderstanding (POINTER_ALIGNED_P
was broken, but the assertion fired even after it got fixed).
2021-02-16 05:44:13 +00:00
simonb
439a3189a8 Add no-profiled attribute for splhigh_noprof() and splx_noprof(). 2021-02-16 05:11:26 +00:00
rillig
324a77845a distrib/sets/fmt-list: document how to sort by directory first
In lists/base/mi, the directory ./libdata/firmware contains several
subdirectories for which the entries do not look aligned right now, even
after normalizing the alignment.

This is because the indentation for a directory is not determined
globally for all directory entries from the complete file, but instead
for each group of items, after sorting, that have the same directory.
This results in several entries having only a single item per group,
such as ./libdata/firmware/nouveau, and this single item is obviously
consistently indented since all of its 1 lines are already indented to
the same depth.

One possible solution for this is to sort the entries in another order,
keeping all entries from a directory together.  This allows to quickly
see all entries from a certain directory, but on the other hand, when
adding a new directory plus some entries, the directory has to be listed
far away from its entries.  (This would be done automatically by
fmt-list though, which weakens this argument a bit.)

Another possible solution for this is to first determine the indentation
for all entries from each directory, no matter how far these entries are
apart, and then indent these entries to the common indentation.  This
may or may not help since there will still be single entries between
groups of differently indented entries.

Writing down the intuitive rules for how to align the entries properly
is a nontrivial task.  See pkglint/varalignblock, which is around 650
lines of code, plus around 4000 lines of test code.

No functional change.
2021-02-15 23:46:46 +00:00
oster
03e7692525 Fix a long long-standing off-by-one error in computing lastPSID.
SUsPerPU is only really supported for a value of 1, and since the
first PSID is 0, the last will be numStripe-1.  Also update the
setting of pending_writes to reflect the change to lastPSID.

Needs pullups to -8 and -9.
2021-02-15 23:27:03 +00:00
rillig
8b7ecb733b distrib/sets/list-fmt: sort commented entries like regular entries
Seen in lists/modules/ad.aarch64, among others.  These lines are not
intended as comments but as regular entries that just happen to be
commented out.

This is the same as how pkglint treats commented variable assignments,
which take part in aligning blocks of variable assignments even though
they are syntactically comments.
2021-02-15 23:00:03 +00:00
reinoud
39e1f6e936 Add VirtIO devices to the MIPSSIM target for use in Qemu. Its supported by a
local patch starting at Qemu-5.1.0nb12
2021-02-15 22:39:46 +00:00
christos
9a1851622c Undo previous; POINTER_ALIGNED_P was broken. 2021-02-15 19:49:17 +00:00
christos
7635a6b2c3 the fourth time is the charm 2021-02-15 19:46:53 +00:00
christos
356b4fcb30 put back alignment (reported by martin@) 2021-02-15 19:19:29 +00:00
christos
597bfe234a Fix pointer aligned macro to match the original (thanks @mlelstv) 2021-02-15 18:33:28 +00:00
rillig
ffd4a447e8 make: rename ExprDefined constants for debug logging 2021-02-15 18:23:32 +00:00
rillig
70b237ca8a make: rename ExprStatus to ExprDefined
The type describes the definedness of an expression, not a general
status, therefore the new name is more precise.

The constants are renamed as well since their prefix 'VES' does not
match the type name anymore, it was correct 3 days ago when the type was
still named VarExprStatus.  The name VES_NONE was misleading since
'none' does not describe its actual effect.  That name came from the
time when the status was a bit set, and 'none' simply meant 'none of the
bits are set'.

The names used in debug logging will be renamed in a follow-up commit,
to demonstrate that the changes in this commit indeed have no functional
change, especially not the change from '!=' to '==' in line 4304.

No functional change.
2021-02-15 18:21:13 +00:00
rillig
2be3d48f35 make: update comments for Expr, amending the previous commit 2021-02-15 17:59:08 +00:00
jmcneill
fb90b35074 interrupt: enable interrupts before running soft intr handlers. To avoid
stack usage going out of control, only do this at ci_intr_depth==0.
2021-02-15 17:46:36 +00:00
rillig
8c6543bd32 make: split parameters for evaluating variable expressions
The details of how variable expressions are evaluated is controlled by
several parameters: startc and endc differ for $(VAR) and ${VAR}, the
value of the expression can be interpreted as a single big word, and
when joining several words (such as with ':M' or ':S'), there may be a
custom word separator (defined with ':ts*').

The scope of half of these parameters is the whole variable expression,
the other half of the parameters are reset after each chain of indirect
modifiers.  To make this distinction obvious in the code, extract Expr
from ApplyModifiersState.  Previously, these details were hidden in how
parameters are passed and restored among ApplyModifiersIndirect and
ApplyModifiers.

The changes in the individual ApplyModifier functions are numerous but
straight-forward.  They mostly replace 'st' with 'expr'.

The changes in ApplyModifiers and ApplyModifiersIndirect are more
subtle.  The value of the expression is no longer passed around but is
stored in a fixed location, in Expr, which makes it easier to reason
about memory management.

The code in ApplyModifiers after 'cleanup' looks quite different but
preserves the existing behavior.  Expr_SetValueRefer is nothing else
than the combination of FStr_Done followed by FStr_InitRefer.  Storing
exprStatus back at the end was responsible for passing the definedness
of the expression after applying the indirect modifiers back to the
outer ApplyModifiersState.  The same effect is now achieved by having
Expr.status with a wider scope.

No functional change.
2021-02-15 17:44:09 +00:00
jmcneill
57e902207f splx: use pic_set_priority_psw in interrupts disabled case to skip a few
more daif accesses.
2021-02-15 16:32:07 +00:00
jmcneill
a774841e6c splx: restore priority even if interrupts are disabled 2021-02-15 16:04:01 +00:00
joerg
dd4f4a95ae Simplify to avoid copy based on the size of the source. 2021-02-15 15:55:50 +00:00
christos
aabf3fa15a Fix reversed test (thanks mlelstv) 2021-02-15 15:53:49 +00:00
jmcneill
c40f7260cb splx: only dispatch hard interrupts if interrupts are enabled 2021-02-15 15:42:58 +00:00
wiz
026eaf4d13 Remove reference to multibyte(3) and trailing commas. 2021-02-15 15:38:43 +00:00
christos
53b5b1c0c5 Remove FreeBSD portions that are not relevant to our implementation (pointed
out by joerg@)
2021-02-15 15:36:53 +00:00
jmcneill
71278a4c79 splx: only dispatch softints if interrupts are enabled 2021-02-15 15:07:47 +00:00
christos
e1d8873a1b new locale pages, sort 2021-02-15 14:38:06 +00:00
christos
da3ff69781 Add missing man pages (from FreeBSD) 2021-02-15 14:35:04 +00:00
isaki
0322faf76e Fix my copy-and-paste bug in rev1.160.
This fixes recording sample dropout.
2021-02-15 13:39:18 +00:00
jmcneill
765c6b80ae pic: reduce the number of daif accesses in pic_do_pending_ints
The caller has already provided daif state. No need to keep updating
daif via pic_set_priority if it's already in the state we need (interrupts
disabled).
2021-02-15 13:03:52 +00:00
martin
50cbb763c2 Fix the build.
Maybe there should be a ICMP6_HDR_ALIGNMENT, but for now there is
only IP6_HDR_ALIGNMENT.
2021-02-15 10:13:45 +00:00
kre
0b2331a3c3 Don't compare int against size_t .. since mbuf lengths should never
be negative, cast it from int to size_t (rather than the other way
around).   Hopefully fix build.
2021-02-15 09:29:56 +00:00