Commit Graph

19592 Commits

Author SHA1 Message Date
maya 53af5ae4cc Replace the link command for libpthread.a so that we create a single section
with all the libpthread symbols in it.
This makes -lpthread behave like to -Wl,--whole-archive -lpthread.

This avoids a situation where threaded static binaries use some libc thread
stubs, which are racy.

Fixes PR lib/54001: call_once2_32, call_once2_static test cases failing on
amd64 since gcc7 import.

Suggested by Jonathan Wakely, thanks!
2019-05-07 18:12:53 +00:00
wiz fd62bcefca Remove extra word. 2019-05-06 06:56:36 +00:00
christos 0e2d77f8ff document the EINVAL caused by a large nfds. 2019-05-06 00:50:26 +00:00
scole 5b44457805 add stop (;;) to elimate WAW dependency compiler warning 2019-05-04 22:55:32 +00:00
mgorny c1c809ed5e Explicitly indicate that nexttowardl() is identical to nextafterl().
Requested by kamil.
2019-05-02 15:08:35 +00:00
maxv 0d954de6fa Use the comm page to inject events, rather than ioctls, and commit them in
vcpu_run. This saves a few syscalls and copyins.

For example on Windows 10, moving the mouse from the left to right sides of
the screen generates ~500 events, which now don't result in syscalls.

The error handling is done in vcpu_run and it is less precise, but this
doesn't matter a lot, and will be solved with future NVMM error codes.
2019-05-01 09:20:21 +00:00
kamil 45dae6038c Avoid incompatible function pointer casts in thrd_create(3)
Use an intermediate function trampoline to workaround different function
pointer prototypes.

While there, correct scenario returning thrd_nomem from thrd_create(3).
In practice ENOMEM is rarely returned from pthread(3).

Older code worked on tested ports, but was depending on unneeded UB.
2019-04-29 20:11:43 +00:00
maxv 6c51ea96f5 sync with reality 2019-04-29 19:03:17 +00:00
maxv 250161fe1f Stop taking care of the INT/NMI windows in the kernel, the emulator is
supposed to do that itself.
2019-04-29 18:54:25 +00:00
maxv c49a183c64 Remove useless calls to nvmm_init(). 2019-04-29 17:27:57 +00:00
kre 63e182f423 snprintb(3) says that, in the new(?) Torek format, all fields specs end with \0
The F spec is one of those, it should be terminated with \0 just like all
the others (irrelevant that it has no extra data to delimit).

Fix <sys/mman.h> to define the snprintb() format string correctly (include
the missing \0's).   Fix the copy of that definition included into
snprintb(3) to match the updated mman.h version (ride the date bump
from the day before yesterday .. this is the same change, just corrected).

Undo the previous snprintb.c change ("off by one" fix) which was an
attempt to make the broken mman.h usage work (and did, but not the way
it should be done).   Also, after using the new * format (instead of only
when something has already matched) skip the associated data so we don't
attempt to interpret it as more field specifiers.  This func needs lots of TLC!

Fix the ATF tests for snprintb() to not assume that F format is really
exactly like f format, and has data after the field specifier.  It doesn't.
Add several more tests (including testing the '*' field operator
recently added).
2019-04-29 07:55:38 +00:00
maxv f973734497 Modify the communication layer between the kernel NVMM driver and libnvmm:
introduce a bidirectionnal "comm page", a page of memory shared between
the kernel and userland, and used to transfer data in and out in a more
performant manner than ioctls.

The comm page contains the VCPU state, plus three flags:

 - "wanted": the states the kernel must get/set when requested via ioctls
 - "cached": the states that are in the comm page
 - "commit": the states the kernel must set in vcpu_run

The idea is to avoid performing expensive syscalls, by using the VCPU
state cached, either explicitly or speculatively, in the comm page. For
example, if the state is cached we do a direct 1->5 with no syscall:

          +---------------------------------------------+
          |                    Qemu                     |
          +---------------------------------------------+
               |                                   ^
               | (0) nvmm_vcpu_getstate            | (6) Done
               |                                   |
               V                                   |
             +---------------------------------------+
             |                libnvmm                |
             +---------------------------------------+
                  |   ^          |               ^
        (1) State |   | (2) No   | (3) Ioctl:    | (5) Ok, state
        cached?   |   |          | "please cache | fetched
                  |   |          |  the state"   |
                  V   |          |               |
              +-----------+      |               |
              | Comm Page |------+---------------+
              +-----------+      |
                       ^         |
          (4) "Alright |         V
               babe"   |     +--------+
                       +-----| Kernel |
                             +--------+

The main changes in behavior are:

 - nvmm_vcpu_getstate(): won't emit a syscall if the state is already
   cached in the comm page, will just fetch from the comm page directly
 - nvmm_vcpu_setstate(): won't emit a syscall at all, will just cache
   the wanted state in the comm page
 - nvmm_vcpu_run(): will commit the to-be-set state in the comm page,
   as previously requested by nvmm_vcpu_setstate()

In addition to this, the kernel NVMM driver is changed to speculatively
cache certain states known to be of interest, so that the future
nvmm_vcpu_getstate() calls libnvmm or the emulator will perform will use
the comm page rather than expensive syscalls. For example, if an I/O
VMEXIT occurs, the I/O Assist in libnvmm will want GPRS+SEGS+CRS+MSRS,
and now the kernel caches all of that in the comm page before returning
to userland.

Overall, in a normal run of Windows 10, this saves several millions of
syscalls. Eg on a 4CPU Intel with 4VCPUs, booting the Win10 install ISO
goes from taking 1min35 to taking 1min16.

The libnvmm API is not changed, but the ABI is. If we changed the API it
would be possible to save expensive memcpys on libnvmm's side. This will
be avoided in a future version. The comm page can also be extended to
implement future services.
2019-04-28 14:22:13 +00:00
wiz 6d61444732 Remove undefined \*H 2019-04-28 07:33:02 +00:00
kamil 0c003f5999 Add a C99 symbol to libm: nexttowardl
It's an alias for an already existing symbol nextafterl.

Patch obtained from <mgorny>

Detected by the LLVM buildbot breakage in tests.
2019-04-27 23:04:31 +00:00
pgoyette 7b4757a125 s/three/multiple/
Adjust text for consistency.  There are already more than three interval
timers available, and who knows if even more might be added in the future.
2019-04-27 22:00:29 +00:00
wiz fa9ca235d8 Remove trailing whitespace. 2019-04-27 17:58:51 +00:00
christos 1d8a803c77 remove dup line 2019-04-27 17:48:13 +00:00
christos ca3496f0f1 Document the '*' field and give a more complex example with F and *. 2019-04-27 17:46:08 +00:00
maxv 6296b43f91 Reorder the NVMM headers, to make a clear(er) distinction between MI and
MD. Also use #defines for the exit reasons rather than an union. No ABI
change, and no API change except 'cap->u.{}' renamed to 'cap->arch'.
2019-04-27 15:45:21 +00:00
wiz 1dcc590110 Fix some typos, improve wording. 2019-04-27 10:57:11 +00:00
christos ef72f68d26 Follow the man page for EL_GETTC and not require a NULL terminated argument
list: https://reviews.llvm.org/D61191
2019-04-26 16:56:57 +00:00
maya 6717e848e2 Remove unused 387 implementations.
These were removed from the build for being wrong, but the implementation
stayed around. This is confusing, we have the attic for old code,
let's delete the unused implementations.
2019-04-26 10:11:14 +00:00
maya 30a5aeb5c6 Unify signbitl implementations.
(Unclear why they were different, it was only the comments that
differed)

Add a comment describing why the generic version works for both 80-bit
and 128-bit double.
2019-04-26 09:03:46 +00:00
maya 3cdbcb3e1b document cosl with MLINKS and in the man page 2019-04-25 23:17:24 +00:00
kamil c3c6e74f96 Drop error path from C11 call_once
The original implementation of C11 threads(3) contained check for error
paths, but it was stripped in the calls that are documented to return
no status from an operation. Do the same in call_once(3).
2019-04-24 21:41:15 +00:00
kamil d39119472e Introduce minor changes to the C11 threading library
Switch tss_t type from int to pthread_key_t (no functional change as
pthread_key_t was already typedefed as int).

Noted by <enh from Google>.

Use C11 _Noreturn in thrd_exit(3) instead of NetBSD specific __dead.
The former is documented in the standard as an attribute of thrd_exit(3),
the latter is more portable to pre-C11 compilers, however C11 thread
support library needs C11 compiler for TLS anyway. __dead made a little bit
more point 3 years ago than today as 3 years ago pre-C11 compilers were
more common.
2019-04-24 18:47:54 +00:00
kamil 945ffcea06 Bump the libpthread(3) minor number to 4
Added C11 Threading library support.
2019-04-24 13:01:52 +00:00
kamil a9ca1710c0 Add a complete C11 threads(3) implementation
C11 Thread support library is a portable threading C API between OSs,
similar to std::threads in the C++ world.

The library is implemented as a thin shim over POSIX interfaces.

NetBSD implements the API as a part of the POSIX threading library
(libpthread(3)).

C11 threads(3) are in the process of making them an integral part
of the POSIX standard. The interface has been implemented in major
OSs and used with stopgap libraries for older versions of them.

C11 threading library is already used (with a stopgap implementation)
in the NetBSD distribution in MESA.

Original implementation by myself from 2016.

ATF tests are new and cover almost all interfaces.

Proposed on tech-userlevel@.
2019-04-24 11:43:19 +00:00
roy a7dfaa63f1 Fix building librpcsvc for MKYP=no 2019-04-24 10:26:43 +00:00
blymn 7d6b8c3110 Add/improve debug output for some routines. 2019-04-24 07:09:44 +00:00
abhinav 63147cb59c PR lib/54131 - declare the loop variable outside the for loop 2019-04-20 08:44:10 +00:00
wiz 21e57c7819 Remove 'No' macros with no effect.
Add width to table.
Fix en-dashes.
2019-04-20 07:27:39 +00:00
pgoyette 099c595280 Note restrictions on return values from tzgetname() and tzgmtoff() 2019-04-18 11:20:17 +00:00
christos d5e956832a Pick up the latest matching (most recent) entry instead of the first one.
This fixes:
	env TZ=Australia/Melbourne date
printing
	Thu Apr 18 03:32:32 LMT 2019
instead of:
	Thu Apr 18 03:32:32 AEST 2019

XXX: To be strictly correct, the tzgetname() call should probably take a time
reference point in order to return the appropriate zone name for the time
given.
2019-04-17 17:37:29 +00:00
maya bac778e85c fix typo 2019-04-17 12:30:51 +00:00
mrg 261a15423e also want s_nexttoward.c on riscv. now tests/lib/libm links. 2019-04-17 07:45:23 +00:00
mrg 134005bc02 revert previously. we want riscv32 to have 128 bit long double...
shall fix the compiler instead.
2019-04-16 08:04:23 +00:00
mrg 9840b30120 risc32 doesn't want long double specific versions 2019-04-16 07:32:30 +00:00
maya 085f60235e we need rintl (long double) to link binaries 2019-04-15 18:44:26 +00:00
maya 0f71666ae3 Cargo cult follow the other 128bit long double architecture (sparc64). 2019-04-15 18:41:06 +00:00
maya 5377f92471 Provide a definition of quiet NaN for RISC-V, and a reference to where
it comes from.
2019-04-14 19:25:27 +00:00
maya 4dfcde7b82 build the generic 128bit long double code. 2019-04-13 17:54:13 +00:00
maya a0aab386b6 Don't alias the long double version to the double version.
We now have 128bit long double (by the upstream GCC changing things)
2019-04-13 17:18:26 +00:00
maya 3d7906cf61 Looks like libc is too big to be able to use j. use a longer distance jump 2019-04-13 16:08:54 +00:00
christos 2f37aad7a2 PR/52359: Benjamin Lorenz: When resizing because of a signal save and restore
the cursor position, since it does not change.
2019-04-12 17:30:49 +00:00
christos 7512edc245 PR/54117: Paavo Helde: Fix memory overrun: Account for the closing quote
in memory allocation if quoted.
2019-04-12 15:12:29 +00:00
abhinav 2373d24da1 Markup improvements: use Dv for kqueue filters, events and note names
ok wiz@
2019-04-12 10:57:27 +00:00
jakllsch 634d295103 fix typo in error message; database is spelled with one 'b' and three 'a's 2019-04-11 23:52:08 +00:00
wiz 6bd7c569be Avoid marking up semicolons. 2019-04-11 06:18:43 +00:00
maya 0757802169 Use the equivalent FUSE_VERSION. Probably a more adequately named macro for this 2019-04-10 21:42:52 +00:00
maya 090799ffb6 provide fuse_version 2019-04-10 21:38:02 +00:00
maxv fbb489fb52 Add the NVMM_CTL ioctl, always privileged regardless of the permissions of
/dev/nvmm. We'll use it to provide a way for an admin to control the
registered VMs in the kernel.

Add an associated wrapper in libnvmm.
2019-04-10 18:49:04 +00:00
christos 3ef12899a4 The typecnt refers the to ttis array and the timecnt refers to the type array.
The types array can have 0 elements (i.e. timecnt == 0), but the ttis array
needs to have one element (typecnt >= 1). Need to revisit and take into
account the types array.
2019-04-08 18:50:52 +00:00
pgoyette 15f13ab537 Split the description for EINVAL into two pieces, one for each operation
that can generate the error.
2019-04-08 10:47:16 +00:00
christos c807c367b6 don't print ???, requested by kre@ 2019-04-07 22:31:54 +00:00
christos efd9bf2580 only need to initialize the first type. 2019-04-07 14:58:25 +00:00
christos 6dcafb68f7 Don't try to print NULL if we can't get a timezone name. First we try dst,
then we try the non-dst name and finally we just print ??? if that did not
work. This is not needed to handle the "TZ= date" case which was crashing
before because the default timezone was not consistently initialized, but
should handle any timezone now.
2019-04-07 14:51:14 +00:00
christos d340589347 Initialize the default timezone a bit more so that tzgetname(3) works. 2019-04-07 14:44:51 +00:00
maxv 8fff5a9178 Sync, and fix grammar. 2019-04-07 14:13:03 +00:00
christos 7a6dbc347c - Padding support from FreeBSD (GNU extensions)
- add '+' for the c-locale only.
2019-04-05 21:27:44 +00:00
christos 0fdca23e1e deal with zic that's not part of libc. 2019-04-04 22:03:23 +00:00
christos 3525c763ab ALL_STATE was bought by STATE_FARM. 2019-04-04 19:42:39 +00:00
christos 8de7229d05 Make strftime_{l,z} re-entrant and always require a non-NULL timezone to be
passed in so that we can use the current timezone in all evaluations (mktime
tzgetname). Reported by Hamilton Slye.
2019-04-04 19:27:28 +00:00
christos 1ef6fb3def explicitly promote to double. 2019-04-04 19:25:38 +00:00
christos 91e14238d8 merge 2019a
Changes to code

    zic now has an -r option to limit the time range of output data.
    For example, 'zic -r @1000000000' limits the output data to
    timestamps starting 1000000000 seconds after the Epoch.
    This helps shrink output size and can be useful for applications
    not needing the full timestamp history, such as TZDIST truncation;
    see Internet RFC 8536 section 5.1.  (Inspired by a feature request
    from Christopher Wong, helped along by bug reports from Wong and
    from Tim Parenti.)

  Changes to documentation

    Mention Internet RFC 8536 (February 2019), which documents TZif.

    tz-link.html now cites tzdata-meta
    <https://tzdata-meta.timtimeonline.com/>.
2019-04-04 18:18:31 +00:00
maxv e00a8e01f5 Check the GPA permissions too in the Assists, because it is possible that
the guest traps on a page the virtualizer marked as read-only (even if it
appears as read-write in the HVA).
2019-04-04 17:33:47 +00:00
joerg 0a0d40923d Add MKLLVMRT to build a subset of the LLVM stack for JIT purposes.
Hook up AMDGPU backend for clang.
2019-04-03 15:21:58 +00:00
roy 69f3641e49 printw: rework vw_printw so it uses open_memstream rather than funopen2
This makes it more portable as open_memstream is POSIX and fixes a
potential issue with wide characters not fully being printed
due to any buffer overflow.
2019-04-01 11:39:15 +00:00
abhinav c93cba3ab2 Perform quoting of filename completions when there are multiple matches as well
Quoting of special characters in filename completion was implemented for single match
case, this enables it for multiple matches as well. For example:

$ touch 'foo bar'
$ touch 'foo baz'
$ ls fo<TAB>
autocompletes to =>
$ ls foo\ ba
hitting <TAB> again shows:
foo bar foo baz

This required unescaping escape sequences generated during last completion
in order to find the word to complete.

While there, also update the test to include cases for multiple matches.

Reviewed by christos
2019-03-31 03:04:57 +00:00
roy fb513c8258 Minor adjustment to prior to match putch 2019-03-29 18:32:45 +00:00
roy c571d3a4f2 Use WCOL rather than wcwidth(3) as we should already know the width
during refresh.
Ensure the character width is not negative when advancing during refresh
(unlikely) and we actually have something to insert in the lower right
corner depending on terminal caps.

Fixes PR lib/54085
2019-03-29 16:56:58 +00:00
uwe f03d7d49dc winwrite - using addch() on individual bytes of e.g. UTF-8 encoding
doesn't work that well.  addstr() the whole buffer instead.  This is
still not enirely correct b/c printf can run out of stdio buffer
mid-character for very long output, but deal with it later.
2019-03-28 23:24:22 +00:00
christos 15c525fbc5 fix compilation for non _REENTRANT 2019-03-28 15:05:03 +00:00
abhinav e09538bda2 Only quote the completion matches if we are doing filename completion
If the user supplies a value for the attempted_completion_function parameter
then we cannot be sure if the completion is for filename or something else, in such
a case don't attempt to quote the completion matches.

Reviewed by christos

This should address PR lib/54067
2019-03-24 16:42:49 +00:00
uwe 5190e47618 winwrite - deobfuscate a bit. 2019-03-21 21:28:55 +00:00
uwe 48efa70d76 Minor markup and wording fixes. 2019-03-21 21:13:45 +00:00
maxv e8b93c6953 Make it possible for an emulator to set the protection of the guest pages.
For some reason I had initially concluded that it wasn't doable; verily it
is, so let's do it.

The reserved 'flags' argument of nvmm_gpa_map() becomes 'prot' and takes
mmap-like protection codes.
2019-03-21 20:21:40 +00:00
mrg 1140fdffca restore the removed "function does something horrible" description,
but leave the real description as well.
2019-03-18 02:15:21 +00:00
rin 441ba19f0d Rename global variable "state" to "_cursesi_state".
Until now, if application happens to have a global variable of the same
name, it was overridden by curses routines. This is the scenario in
which aspell crashes when linked to our curses, reported in pkg/44005.

We need to wipe out global/static variables like "_cursesi_state" or
"wstate" for thread safety. But it would be a future task...

XXX pullup to netbsd-8 and netbsd-7
2019-03-14 00:36:06 +00:00
wiz 928749aba2 Fix typo. 2019-03-12 22:21:53 +00:00
christos 121f466a26 add libjemalloc for the non-standard jemalloc symbols. 2019-03-12 15:14:02 +00:00
kre df01b8ae2e PR lib/54053
When auto scaling, and the buffer is bigger than big enough
for the biggest possible number, don't try and calculate
the max value that will fit in the buffer - that calc
will overflow (guaranteed) and is useless, the value
we're formatting cannot possibly be bigger.  So simply
use the unscaled value (the raw number).

While here, also avoid returning values that are larger
than the buffer len ... while it would be nice to be able
to find out how big the buffer should be so the data will
fit, the interface doesn't really allow that (the buffer
length passed in controls the scaling - at least when
auto scaling) and the code already does "return -1" when
it detects the buffer length is too small, even before
it works out how much would have been needed.  So, rather
than returning a value > len (while truncating the result
to fit in len ... all courtesy of snprintf()) return -1
in this case as well.

Also, allow suffix==NULL (meaning "") - there's no reason
not to, and requiring users to pass in an explicit "" is
not useful.
2019-03-11 15:10:51 +00:00
christos d0175ebb38 Fix previous... We need to deal with a conditional branch. 2019-03-09 02:50:07 +00:00
christos 117899b88e We don't fit anymore thanks to jemalloc:
relocation truncated to fit: R_AARCH64_CONDBR19 against symbol `cerror'
2019-03-09 02:33:02 +00:00
msaitoh 659e7a3c69 s/ are are / are /
s/ a a / a /
2019-03-08 08:35:58 +00:00
msaitoh c2f2b1bf58 s/ the the / the / 2019-03-08 08:12:39 +00:00
maxv 4977f2eb4a Micro optimizations:
- Compress x86_rexpref, x86_regmodrm, x86_opcode and x86_instr.
 - Cache-align the register, opcode and group tables.
 - Modify the opcode tables to have 256 entries, and avoid a lookup.
2019-03-07 15:47:34 +00:00
christos 2cb70116d4 Jemalloc initializes mutexes before we become threaded and expects to use
them later.
2019-03-05 22:49:38 +00:00
christos 939c050d54 Transfer all the keys that were created in the libc stub implementation
to the pthread tsd implementation when the main thread is created.
This corrects a problem where a process created keys before libpthread
was loaded (either from the libc constructor or because libpthread
was dlopened later). This fixes a problem with jemalloc which creates
keys in the constructor.
2019-03-05 01:35:52 +00:00
christos e0589ce187 bump for jemalloc 2019-03-04 19:20:12 +00:00
christos b4744953f9 Hook for jemalloc 2019-03-04 17:30:33 +00:00
maya 23353681a0 revert previous.
This breaks 64bit builds, it attempts to build a compat library too
and it fails to find headers for it.
2019-03-04 08:22:19 +00:00
maya 900a869949 s/a DARPA Internet address/an Internet address/
From OpenBSD.
2019-03-03 20:34:43 +00:00
maya d47cd4f3e8 Traverse into external/bsd/llvm/lib when building libraries.
This allows things that occur after lib (like do-x11) to depend on llvm
libraries already existing.

We need libexecinfo, so adding llvm after the 2nd library barrier.
2019-03-03 17:55:04 +00:00
maxv 7a4f551dcf Change the layout of the SEG state:
- Reorder it, to match the CPU encoding. This is the universal order,
   also used by Qemu. Drop the seg_to_nvmm[] tables.

 - Compress it. This divides its size by two.

 - Rename some of its fields, to better match the x86 spec. Also, take S
   out of Type, this was a NetBSD-ism that was likely confusing to other
   people.
2019-02-26 12:23:12 +00:00
maxv 8d8eb34b8b Set hardseg to -1 rather than 0, because 0 can be a valid segment. 2019-02-26 10:18:39 +00:00
roy 4650f8774d Fix warn macro usage.
Thanks to rofl0r.
2019-02-24 20:20:18 +00:00
maya 00b9d7ef65 fix typo. From Evil_Bob. 2019-02-24 11:51:05 +00:00
maya 92e1c52520 Default our libm to -frounding-math, if built with GCC.
The long-standing GCC default is to not respect rounding mode.
it looks like GCC 7 optimizes rint to a builtin, causing our few
rounding mode tests to fail.

Fixes PR port-amd64/54000: FP tests failing on amd64 since gcc7 import
2019-02-22 18:17:22 +00:00
christos 2252cc8ccc Mention that ENOSPC can be returned if we exhausted the max number of
semaphores.
2019-02-21 21:54:09 +00:00