Commit Graph

279660 Commits

Author SHA1 Message Date
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
15b0f0a3be Nix trailing whitespace. 2020-08-14 01:14:17 +00:00
riastradh
3245986ff3 Note getrandom. 2020-08-14 01:07:56 +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
rillig
c2a9cced9d make(1): fix type mismatch in compare_expression
This was caught by a simple "typedef double Boolean" in sprite.h.

If only there were a C compiler with "strict" mode, where pointers,
numbers and booleans were separate and unassignable data types, this
copy-and-paste typo would have been caught much earlier.
2020-08-13 20:13:46 +00:00
rillig
4356ef6a78 make(1): fix type of local variable in CondGetString
When the Boolean type from sprite.h is replaced with C99's standard bool
type, the chained assignment leads to the following compile error with
GCC 5:

cond.c:404:5: error: suggest parentheses around assignment used as truth
                     value [-Werror=parentheses]
     *quoted = qt = *condExpr == '"' ? 1 : 0;

Changing the type of qt from int to bool fixes this.
2020-08-13 19:30:37 +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
mrg
d1531a5681 set MODULE to ${EXTERNAL_GCC_SUBDIR} so this actually works.. 2020-08-13 10:57:53 +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
mrg
04ac9a9074 regen mknative files for GCC 7.5. 2020-08-13 07:19:59 +00:00
skrll
0386a306a4 Trailing whitespace 2020-08-13 07:14:04 +00:00
rillig
d07abf40f3 make(1): convert Buf_AddByte to inline function
This lets the compiler decide whether to actually inline the code (which
it does).  It also provides better type safety and avoids a few
underscores and parentheses in the code.
2020-08-13 04:25:09 +00:00
rillig
5ad3310e3a make(1): remove type alias Byte = char
This alias was only actually used in very few places, and changing it to
unsigned char or any other type would not be possible without generating
lots of compile-time errors.  Therefore there was no abstraction, only
unnecessary complexity.
2020-08-13 04:12:13 +00:00
rillig
fb8f93f536 make(1): follow naming conventions for multiple-inclusion guards
This avoids undefined behavior.
2020-08-13 03:54:57 +00:00
rillig
d4d42bc70a make(1): clean up debug logging in dir.c
In C90, the variadic macro argument __VA_ARGS__ is not known, therefore
fall back to the forms listing the number of actual printf arguments.
2020-08-13 03:33:56 +00:00
rillig
4ff1f1ac37 make(1): avoid negated conditions in DirExpandCurly 2020-08-13 03:07:49 +00:00
rillig
ef9eb65a77 make(1): clean up DirExpandCurly
Now that nested curly braces work as expected and are covered by unit
tests, the debug log is no longer necessary.
2020-08-13 03:00:44 +00:00
rillig
022d5c4ff0 make(1): use enum instead of #define for cached_stats 2020-08-13 02:53:15 +00:00
mrg
802242f985 set _OUTDIRBASE depending on $0, and then set _OUTDIR based on this.
now you can copy mknative-gcc to mknative-gcc.old without edit.
2020-08-13 01:52:37 +00:00
christos
267b66ed56 - document -d
- add -r (reverse)
- const, size_t, emalloc, EXIT_FOO
2020-08-12 23:23:04 +00:00
rillig
6616932c4a make(1): remove unnecessary UNCONST from arch.c
Somewhere in the refactorings of the last month, the parameter types of
the Arch functions had their constness fixed, therefore the UNCONST is
no longer necessary.
2020-08-12 19:36:14 +00:00
rillig
5a58c0c483 make(1): enable -Wcast-qual for var.c again
When it became disabled 9 years ago, there were 15 instances of UNCONST
in the code.  These have been removed in the latest cleanup sessions.

Tested with GCC 5 from NetBSD 8 and GCC 10 from pkgsrc.
2020-08-12 19:21:05 +00:00
rillig
872a77026d make(1): prepare var.c for WARNS=6
I'm unhappy with the (unsigned) casts for the enum constants, but there
is no way around that since the base type of enums is int by definition,
and there is no way in C90 to explicitly specify the base type of an
enum type.

The (size_t) casts on the pointer differences are another pain point,
but for these as well, C90 does not have a ready-made solution.  A
possible workaround would be an inline function ptr_diff that returns
size_t instead of ptrdiff_t, but that would make the code look even more
bloated than with the casts.

The remaining casts to (char), (int) and (time_t) look so suspicious
that it's easy enough to stumble upon them, as soon as someone finds the
time to fix these properly by adding a function ParseInt or
ParseSeconds.
2020-08-12 19:14:38 +00:00
rillig
eab1dadca4 make(1): replace redundant NULL tests with assertions 2020-08-12 18:53:59 +00:00
rillig
6910f1eeb2 make(1): allow optional compilation with GCC 10, use gcov from GCC 2020-08-12 18:48:36 +00:00
rillig
ee1eefc8ec make(1): remove unnecessary test from bmake_strndup
The passed memory is never NULL.
2020-08-12 18:47:21 +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
skrll
e16659bb50 Part I of ad@'s performance improvements for aarch64
- Remove memory barriers from the atomic ops.  I don't understand why those
  are there.  Is it some architectural thing, or for a CPU bug, or just
  over-caution maybe?  They're not needed for correctness.

- Have unlikely conditional branches go forwards to help the static branch
  predictor.
2020-08-12 12:59:57 +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
skrll
97e085086c No need for MIPS_EBASE_CPUNUM now that asm.h supports __BITS 2020-08-12 08:57:03 +00:00
skrll
a294f34ae4 Provide assmebler versions of BITS(3) macros. These are only good for
32 bit masks
2020-08-12 08:56:37 +00:00
mrg
5e4a6425f4 mknative-gcc is for GCC 8.4.
mknative-gcc.old is supposed to be for GCC 7, but is the GCC 6
version.  update it and mark it for GCC 7.5.
2020-08-12 08:53:20 +00:00
skrll
9b5aba56ba Don't include mips/asm.h from a C file 2020-08-12 07:37:39 +00:00
mrg
2d54d631d9 20200811:
GCC updates may require cleaning the objdir.
2020-08-12 06:48:50 +00:00
mrg
f3b893878b delete this file; it needs to be newer than the .l file or
else sys.mk will attempt to write it to the source tree,
which may be r/o and fail.

XXX may cause updates builds to fail because a file listed
in .depend won't exist anymore.
2020-08-12 06:42:53 +00:00
rillig
0fc5d0f74a make(1): in bmake_strndup, only scan the relevant part of the string
Just in case the given str is not really a string.

The POSIX 2018 documentation on strndup does not specify as clearly as
possible whether s has to be a string or whether raw memory is
acceptable as well.  It only indirectly calls the s parameter of strndup
a string.
2020-08-12 03:27:29 +00:00
rillig
6abaf3bbe5 make(1): make Dir_MakeFlags simpler
This avoids unnecessary string allocations, especially for long lists.

There is no unit test to cover this code.  Since this is an obscure,
undocumented part of make, I wasn't able to come up with a unit test.
Therefore I resorted to write a separate testing program to verify the
expected results.

$ cat <<'EOF' >dir_test.c
#include <stdio.h>

#include "make.h"
#include "dir.h"

int main(int argc, char **argv)
{
    int i;
    Lst lst;
    char *flags;

    lst = Lst_Init(FALSE);
    for (i = 1; i < argc; i++)
    	Dir_AddDir(lst, argv[i]);
    flags = Dir_MakeFlags("-I", lst);

    printf("%s\n", flags);
    free(flags);
    return 0;
}
EOF

# Needs some trivial patches to Makefile and main.c
$ make PROG=dir_test EXTRA_SRCS=dir_test.c EXTRA_CPPFLAGS=-DNO_MAIN \
       COPTS.main.c=-Wno-unused-function NOMAN=1

$ ./dir_test a b c

$ mkdir a b c
$ ./dir_test a b c
 -Ia -Ib -Ic
$ rmdir a b c
2020-08-12 03:05:57 +00:00
skrll
28c2c643ec Improve a comment 2020-08-11 19:46:56 +00:00
rillig
f271e31bca make(1): replace snprintf/malloc in ReadMakefile with str_concat3 2020-08-11 18:52:03 +00:00
rillig
431c892530 make(1): convert Suff.flags from #define to enum
This increases debugging support since the debugger can now display
symbolic names instead of an integer bit mask.
2020-08-11 18:44:52 +00:00
rillig
499d5689cb make(1): add str_concat4 to make the other code simpler
There's no need for arch.c to call strlen when there is a high-level API
for the same purpose.
2020-08-11 18:41:46 +00:00