Commit Graph

19592 Commits

Author SHA1 Message Date
christos 3ecfeb8539 - KNF return
- be careful with errno, only set it when it is possibly set and not before
  a system call.
- factor out a common mask comparison.
2019-02-21 21:33:34 +00:00
christos dae7fb3e37 appease string + int warning. 2019-02-18 20:27:20 +00:00
bad c0bd86dc55 Linux doesn't have paccept(). 2019-02-17 23:35:50 +00:00
bad 340a53cf8b compile hijack.c with -D_INCOMPLETE_XOPEN_C063 so that AT_FDCWD is alwasy
defined for rumpkernels.
2019-02-17 23:33:20 +00:00
maxv 4cdf419d72 Fix handling of SIB instructions. We were jumping to the SIB node _before_
fetching the displacement, so the node would always think there was no
displacement.

This didn't alter the final GPA we would be touching - because it is
fetched from the kernel directly and not from the computation -, but it
altered the instruction length, and on some guests (like Fedora 64bit),
the VCPU would resume execution at the wrong RIP and crash.

Now these guests work.
2019-02-17 20:25:46 +00:00
christos 52b10dfde0 PR/53983: Jonathan Perkins: Fix types for readline compatibility 2019-02-15 23:20:35 +00:00
maxv 2fad18ce40 Remove the PSE check in the 32bit-PAE MMU. Setting CR4.PAE automatically
enables PSE regardless of whether CR4.PSE is set or not, so we should just
ignore it.

With this in place I can boot Windows 8.1 on NVMM.
2019-02-15 16:42:27 +00:00
christos ccbb6255be PR/53981: Jonathan Perkins: history_list should null-terminate 2019-02-14 20:09:12 +00:00
maxv 27a60aeb62 Harmonize the handling of the CPL between AMD and Intel.
AMD has a separate guest CPL field, because on AMD, the SYSCALL/SYSRET
instructions do not force SS.DPL to predefined values. On Intel they do,
so the CPL on Intel is just the guest's SS.DPL value.

Even though technically possible on AMD, there is no sane reason for a
guest kernel to set a non-three SS.DPL, doing that would mess up several
common segmentation practices and wouldn't be compatible with Intel.

So, force the Intel behavior on AMD, by always setting SS.DPL<=>CPL.
Remove the now unused CPL field from nvmm_x64_state::misc[]. This actually
increases performance on AMD: to detect interrupt windows the virtualizer
has to modify some fields of misc[], and because CPL was there, we had to
flush the SEG set of the VMCB cache. Now there is no flush necessary.

While here remove the CPL check for XSETBV on Intel, contrary to AMD
Intel checks the CPL before the intercept, so if we receive an XSETBV
VMEXIT, we are certain that it was executed at CPL=0 in the guest. By the
way my check was wrong in the first place, it was reading SS.RPL instead
of SS.DPL.
2019-02-14 14:30:20 +00:00
maxv f911f1c1e1 Optimize: fetch only 5 bytes instead of 15, the instruction can have only
up to five prefixes.
2019-02-12 14:50:21 +00:00
christos 12f8b8a214 #### is not legal. 2019-02-10 19:30:28 +00:00
maya 634157f9e8 Update comment (copied from or1k) 2019-02-10 07:28:06 +00:00
manu ef486683cc Fix directory filehandle usage with libufse. Fix lookup count
libfuse does not use filehandle the same way for directories and other
objects. As a result, filehandles obtained by OPENDIR should not be
sent on non-directory related operations like READ/WRITE/GETATTR...

While there, fix the lookup count sent to the FORGET operation, which
led to leaked nodes.
2019-02-09 02:22:45 +00:00
christos b0735e4145 Add some better error handling from FreeBSD, although we don't
suffer from the same issue, since we don't decrement p->next, like
FreeBSD does because we don't have multibyte support (yet). We
choose to do this so we can fail faster and more predictably.

Here's the original FreeBSD message:

When passed the invalid regular expression "a**", the error is
eventually detected and seterr() is called. It sets p->error
appropriatly and p->next and p->end to nuls which is a never used char
nuls[10] which is zeros due to .bss initialization. Unfortunatly,
p_ere_exp() and p_simp_re() both have fall through cases where they set
the error, decrement p->next and access it which means a read from what
ever .bss variable comes before nuls.

Found with regex_test:repet_multi and CHERI bounds checking.

Reviewed by:	ngie, pfg, emaste
Obtained from:	CheriBSD
Sponsored by:	DARPA, AFRL
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D10541
2019-02-07 22:22:31 +00:00
christos 2ebb8fd343 Fix OOB read from FreeBSD:
The bug is an out-of-bounds read detected with address sanitizer that
happens when 'sp' in p_b_coll_elems() includes NUL byte[s], e.g. if it's
equal to "GS\x00". In that case len will be equal to 4, and the
strncmp(cp->name, sp, len) call will succeed when cp->name is "GS" but the
cp->name[len] == '\0' comparison will cause the read to go out-of-bounds.

Checking the length using strlen() instead eliminates the issue.

The bug was found in LLVM with oss-fuzz:
	https://reviews.llvm.org/D39380
2019-02-07 22:13:52 +00:00
maxv 83ed0b5e52 Improvements:
- Emulate the instructions by executing them directly on the host CPU.
   This is easier and probably faster than doing it in software
   manually.

 - Decode SUB from Primary, CMP from Group1, TEST from Group3, and add
   associated tests.

 - Handle correctly the cases where an instruction that always implicitly
   reads the register operand is executed with the mem operand as source
   (eg: "orq (%rbx),%rax").

 - Fix the MMU handling of 32bit-PAE. Under PAE CR3 is not page-aligned,
   so there are extra bits that are valid.

With these changes in place I can boot Windows XP on Qemu+NVMM.
2019-02-07 10:58:45 +00:00
wiz fd79f0a9b0 Mark up NULL with Dv. Remove empty line. 2019-02-05 15:03:35 +00:00
maxv b25fe2ccb5 Sync with reality, and improve. 2019-02-05 13:56:32 +00:00
mrg 504bd058ec use adrp not adr, since the data is not pc-rel. fixes brk(2). 2019-02-05 13:02:35 +00:00
mrg 82974f2217 check for snprintf() truncation and fail sanely if so, rather than
attempting to use a file that won't exist or isn't secure.
2019-02-04 08:21:11 +00:00
mrg fd676684f8 - avoid uninitialised memory usage 2019-02-04 04:37:50 +00:00
mrg 1fcf7be45f - use -Wno-error=implicit-fallthrough with GCC7. 2019-02-04 04:05:15 +00:00
mrg 2c04daffef add some fallthru comments. 2019-02-04 03:30:20 +00:00
thorpej 68e270a267 Implement support for "pshared" POSIX semaphores.
Fixes lib/53273 (and Firefox's multi-process tab feature).
2019-02-03 03:20:23 +00:00
isaki 8b1980912d Fix minor bugs of SNDCTL_DSP_GETISPACE.
- hiwat is playback-only parameter.
- 'bytes' should not be rounded down.
2019-02-02 04:52:16 +00:00
maxv 2089a3819a Fix two issues:
* Uh I put the wrong masks in some GPRs, fuck.

 * When the opsize of MOVZX is 4, we need to combine the zero-extend from
   the instruction with the natural zero-extend of long mode.

Add two associated tests.
2019-02-01 06:49:58 +00:00
mrg 7d08015811 make the backtrace()'s tracer() return _URC_FOREIGN_EXCEPTION_CAUGHT
when the array is full.  it won't be able to do any more work if so,
and avoids infinite loops in unwinding as seen on arm64.

XXX:  lack of signal support here means that backtrace() is useless
XXX:  from a signal handler, such as attempting to display the stack
XXX:  when handling a SIGSEGV.
2019-01-30 22:46:49 +00:00
isaki 6b4163e9ca Revert a wrong SNDCTL_DSP_GETOSPACE part of rev1.33.
- 'fragments' is the number of full free blocks and should not be
  negative value.
- 'bytes' should not be rounded down.
It makes mpv work correctly (fixes a second half of kern/53028).
Reviewed by mlelstv@
2019-01-29 11:54:02 +00:00
dholland ad8aa774f5 fix duplicated chunk from merge 2019-01-27 04:33:29 +00:00
dholland a5dfc9a7f2 fix another mergeo 2019-01-27 02:42:32 +00:00
dholland f4d9309d1d fix mergeo 2019-01-27 02:40:49 +00:00
pgoyette d91f98a871 Merge the [pgoyette-compat] branch 2019-01-27 02:08:33 +00:00
maxv c07836be52 Ah, fix bug: when the opcode has an immediate, we fill the src with a
register storage, but then we overwrite it without zeroing out the highest
bits of the resulting immediate (which may contain garbage from the union).
2019-01-26 14:44:54 +00:00
mrg 6339cfba17 remove the new check for tlen >= PTRDIFF_MAX. the prior
checks assure the condition is met and GCC7 is happy.

suggested by kre.
2019-01-24 22:07:14 +00:00
christos c959ea2c0d PR/53904: Jintao Zhu: Use a mutex instead of an rwlock to assure thread safety 2019-01-24 18:01:38 +00:00
uwe 7142fa3957 It's section 3 page, not section 2. While here, xref puffs(3) in the
SEE ALSO section too.
2019-01-23 19:43:49 +00:00
kre bcc54a5c42 And as long as we're attempting to achieve perfection in code
that is never going to be executed, let's also check for possible
overflow in a sum that will never be computed...
2019-01-23 02:48:48 +00:00
kre 1f29642da2 There's no point setting errno, it is just overwritten by err
in the exit path ... this function never fails, it simply sometimes
doesn't actually expand the %m and just leaves the format string
intact.

And declare variables at the head of their scope, not at some random
place in the middle of the code, whatever C allows, that is just ugly.
2019-01-23 02:32:06 +00:00
christos 223b7e5915 limit allocation to PTRDIFF_T to appease gcc-7, from mrg@ 2019-01-23 02:00:00 +00:00
mrg bfe7e5d8b3 memset to zero the entire array, not just 8 bytes of it.
picked up by gcc7's checker that the array size has not
been multipled by the member size.

here, we had 8 but should have had 8 * sizeof(int).

XXX: real bug - pullup-7, pullup-8
2019-01-23 00:08:06 +00:00
mrg 1fbe8d0596 remove diag assert - the compiler demands fp is non NULL now. 2019-01-23 00:05:47 +00:00
rmind 3d9a792dd8 Major NPF improvements:
- Convert NPF connection table to thmap.  State lookup is now lock-free.
- Improve connection state G/C: it is now incremental and tunable.
- Add support for dynamic NAT address.  Translation addresses can now be
  selected from a pool of addresses.  There are two selection algorithms,
  "ip-hash" and "round-robin" (see the man page).
- Translation address can be specified as e.g. ifaddrs(wm0) in npf.conf
  to dynamically choose an IP from the interface address(es).
- Add support for the NETMAP algorithm with static NAT for net-to-net
  translation (it is equivalent to iptables NETMAP logic).
- Convert 'ipset' tables to use thmap; the table lookup is now lock-free.
- Misc improvements, bug fixes and more unit tests.
- Bump NPF_VERSION (will also bump libnpf).
2019-01-19 21:19:31 +00:00
wiz f401b5d182 Use \- for minus. 2019-01-15 07:01:01 +00:00
uwe 3e392f0443 Fly, nasal demons, fly away... 2019-01-15 03:43:15 +00:00
riastradh f5a847d300 Use the same variable for the locale example. 2019-01-15 03:30:58 +00:00
uwe 326784a6c3 Don't talk about "the first argument" when there's only one. 2019-01-15 01:23:49 +00:00
uwe 31759755bb Fix markup pasto. 2019-01-15 01:13:49 +00:00
uwe 2a102dd013 Remove the extra cast to int in the CAVEATS example.
We removed it from EXAMPLES a few releases ago.
2019-01-15 01:11:03 +00:00
uwe 893d5ca890 Fix typo in macro flag. 2019-01-15 00:43:32 +00:00
riastradh 2712861341 Expand on correct and incorrect usage, and on compiler warnings.
Give an example program with the warning, and some example nonsense
outputs.  Also note why glibc's approach doesn't solve the problem.
2019-01-15 00:31:19 +00:00
kre 4426ee8da1 Whitespace (indent with tabs, rather than spaces), and rearrange one
line that needed wrapping so it no longer does, and is (IMO) clearer.
WHile here, note that this was created in 2019, not 2018, for the
copyright notice...

NFCI.
2019-01-14 03:30:25 +00:00
maxv 7ceb32d30a Handle more corner cases, clean up a little, and add a set of instructions
in Group1.
2019-01-13 10:43:22 +00:00
kre 7b39a1eecc Always return from expandm() with errno unaltered, so on the
off chance it failed, there's still the possibility that whatever
processes the result will be able to deal with the %m that would
(presumably) be left in the format string.

And as a frill, don't call strerror() until we know we are
going to use its result (still call it only once, no matter
how many %m's are in the format string).
2019-01-13 06:10:34 +00:00
christos 3359bf52a4 check for *. integer overflow over ptrdiff. Pointed out by kre@ 2019-01-13 01:32:51 +00:00
kre c323915498 Make expandm() return a const char * so we can do away with __UNCONST()
and more importantly, so that we don't accidentally return a value
that is a const char * in reality (pointer to read only string) as a
char *.
2019-01-12 22:14:08 +00:00
christos a55f258316 Don't do %%m -> %%%m escaping, requested by gson@. 2019-01-12 21:50:29 +00:00
kre 63c2be2dac Return the buffer that has not been freed, so it can be later,
rather than the one that already was.
2019-01-12 21:05:37 +00:00
christos 94a22d4c76 Provide an extra argument to store the returned pointer so we can use
the function directly as the return format (before assigning it to a
variable) to appease clang.
2019-01-12 19:08:24 +00:00
christos feb39a8c47 Use a utility function to expand %m correctly... 2019-01-11 20:37:30 +00:00
christos f326096470 let's try one more time: prepare the format to pass to syslog instead
of trying to escape %m.
2019-01-11 16:15:20 +00:00
christos 87cda185f0 instead of handling %m inline, escape it. 2019-01-11 13:05:57 +00:00
dholland 43fda370f5 At some point we lost the text that explains the difference between
clear() and erase(). Or possibly we never had any. Put some back.
Bump date.
2019-01-11 06:14:39 +00:00
christos 11e9eb638e PR/53856: F. Aragon: editline/libedit not prompting colors in readline mode 2019-01-10 18:41:56 +00:00
christos 0b298669b8 delete unused variable 2019-01-10 13:53:58 +00:00
christos 77ae40ee4d PR/53851: Andreas Gustafsson: libwrap prints "m" instead of errno
Handle %m inline if needed, otherwise vasprintf strips the %m and...
2019-01-10 13:53:26 +00:00
maxv 06484a82be Handle REPN. FreeBSD has a "repn movs", which is a bit unusual, but doesn't
seem illegal as far as I can tell from the AMD SDM.

With that, I can boot FreeBSD on Qemu+NVMM.
2019-01-08 07:34:22 +00:00
wiz d8ad10e63e Remove leading zero from date. 2019-01-07 22:17:02 +00:00
maxv 75c7df3cfe Optimize the legpref node: omit BRN (we don't care and it's the same as
OVR_CS), inline the loops, sort the checks from most to least likely
prefix, and use a compact structure.
2019-01-07 18:13:34 +00:00
maxv 04b8bfbf75 Optimize: on single memory operand instructions, take the GPA directly from
the exit structure provided by the kernel. This saves an MMU translation,
and sometimes complex address computation (eg SIB).

Drop the GVA field, it is not useful to virtualizers.
2019-01-07 16:30:25 +00:00
maxv 960d1f7675 Improvements and fixes:
* Decode AND/OR/XOR from Group1.

 * Sign-extend the immediates and displacements in 64bit mode.

 * Fix the storage of {read,write}_guest_memory, now that we batch certain
   IO operations we can copy more than 8 bytes, and shit hits the fan.

 * Remove the CR4_PSE check in the 64bit MMU. This bit is actually ignored
   in long mode, and some systems (like FreeBSD) don't set it.
2019-01-07 13:47:33 +00:00
christos f0d7eb24ef use the pico objects if we are making a PIC profiled library. 2019-01-06 18:14:10 +00:00
maxv 809327425b Improvements and fixes in NVMM.
Kernel driver:

 * Don't take an extra (unneeded) reference to the UAO.

 * Provide npc for HLT. I'm not really happy with it right now, will
   likely be revisited.

 * Add the INT_SHADOW, INT_WINDOW_EXIT and NMI_WINDOW_EXIT states. Provide
   them in the exitstate too.

 * Don't take the TPR into account when processing INTs. The virtualizer
   can do that itself (Qemu already does).

 * Provide a hypervisor signature in CPUID, and hide SVM.

 * Ignore certain MSRs. One special case is MSR_NB_CFG in which we set
   NB_CFG_INITAPICCPUIDLO. Allow reads of MSR_TSC.

 * If the LWP has pending signals or softints, leave, rather than waiting
   for a rescheduling to happen later. This reduces interrupt processing
   time in the guest (Qemu sends a signal to the thread, and now we leave
   right away). This could be improved even more by sending an actual IPI
   to the CPU, but I'll see later.

Libnvmm:

 * Fix the MMU translation of large pages, we need to add the lower bits
   too.

 * Change the IO and Mem structures to take a pointer rather than a
   static array. This provides more flexibility.

 * Batch together the str+rep IO transactions. We do one big memory
   read/write, and then send the IO commands to the hypervisor all at
   once. This considerably increases performance.

 * Decode MOVZX.

With these changes in place, Qemu+NVMM works. I can install NetBSD 8.0
in a VM with multiple VCPUs, connect to the network, etc.
2019-01-06 16:10:51 +00:00
uwe 5b2acdab92 _wnoutrefresh - extend current position checks.
Also verify that dwin->cury >= begy (ditto for x), i.e. for pads make
sure that the current position is after the beginning of the displayed
portion.  While here refactor the checks for better readability.

We should probably combine the y and x checks b/c if one of them is
not in the range, the current position as a whole is not in the range
and it doesn't make sense to pick and set just the y or just the x
part of it.
2019-01-06 04:27:53 +00:00
uwe aa9d3f22ec _wnoutrefresh - fix current position checks for pads
maxy is an absolute value and should not be adjusted for begy when we
check also absolute cury.  Note that this change does not affect
calculations for normal windows as for them we always pass zero for
begy.  Ditto for x.
2019-01-06 03:59:17 +00:00
uwe 182a153ef7 prefresh - fix current position calculations
The code was copy-pasted from wrefresh(), but for pads we need to
adjust for (pbegy, pbegx).

PR lib/53801
2019-01-06 03:46:11 +00:00
maya 8a135c6afb Match the function prototype of encrypthandler instead of casting to it.
Make GCC 9 snapshot happier with the code

While here, remove unnecessary braces around return (KNF).
2019-01-05 08:55:58 +00:00
maxv 2e9744b39f In !64bit mode RIP-relative is null+disp32, handle that correctly. 2019-01-04 10:25:39 +00:00
uwe 13b962ac1e Fix mis-applied change in previous. Don't increment r_oldcv twice.
PR lib/53803
2019-01-04 03:03:44 +00:00
maxv 579fb4792d When there's no DecodeAssist in hardware, decode manually in software. This
is needed on certain AMD CPUs (like mine): the segment base of OUTS can be
overridden, and it is wrong to just assume DS.

We fetch the instruction and look at the prefixes if any to determine the
correct segment.
2019-01-02 12:18:08 +00:00
christos 76c767265c Release 2018i - 2018-12-30 11:05:43 -0800
Briefly:
    São Tomé and Príncipe switches from +01 to +00 on 2019-01-01.

  Changes to future timestamps

    Due to a change in government, São Tomé and Príncipe switches back
    from +01 to +00 on 2019-01-01 at 02:00.  (Thanks to Vadim
    Nasardinov and Michael Deckers.)


Release 2018h - 2018-12-23 17:59:32 -0800

  Briefly:
    Qyzylorda, Kazakhstan moved from +06 to +05 on 2018-12-21.
    New zone Asia/Qostanay because Qostanay, Kazakhstan didn't move.
    Metlakatla, Alaska observes PST this winter only.
    Guess Morocco will continue to adjust clocks around Ramadan.
    Add predictions for Iran from 2038 through 2090.

  Changes to future timestamps

    Guess that Morocco will continue to fall back just before and
    spring forward just after Ramadan, the practice since 2012.
    (Thanks to Maamar Abdelkader.)  This means Morocco will observe
    negative DST during Ramadan in main and vanguard formats, and in
    rearguard format it stays in the +00 timezone and observes
    ordinary DST in all months other than Ramadan.  As before, extend
    this guesswork to the year 2037.  As a consequence, Morocco is
    scheduled to observe three DST transitions in some Gregorian years
    (e.g., 2033) due to the mismatch between the Gregorian and Islamic
    calendars.

    The table of exact transitions for Iranian DST has been extended.
    It formerly cut off before the year 2038 in a nod to 32-bit time_t.
    It now cuts off before 2091 as there is doubt about how the Persian
    calendar will treat 2091.  This change predicts DST transitions in
    2038-9, 2042-3, and 2046-7 to occur one day later than previously
    predicted.  As before, post-cutoff transitions are approximated.

  Changes to past and future timestamps

    Qyzylorda (aka Kyzylorda) oblast in Kazakhstan moved from +06 to
    +05 on 2018-12-21.  This is a zone split as Qostanay (aka
    Kostanay) did not switch, so create a zone Asia/Qostanay.

    Metlakatla moved from Alaska to Pacific standard time on 2018-11-04.
    It did not change clocks that day and remains on -08 this winter.
    (Thanks to Ryan Stanley.)  It will revert to the usual Alaska
    rules next spring, so this change affects only timestamps
    from 2018-11-04 through 2019-03-10.

  Change to past timestamps

    Kwajalein's 1993-08-20 transition from -12 to +12 was at 24:00,
    not 00:00.  I transcribed the time incorrectly from Shanks.
    (Thanks to Phake Nick.)

    Nauru's 1979 transition was on 02-10 at 02:00, not 05-01 at 00:00.
    (Thanks to Phake Nick.)

    Guam observed DST irregularly from 1959 through 1977.
    (Thanks to Phake Nick.)

    Hong Kong observed DST in 1941 starting 06-15 (not 04-01), then on
    10-01 changed standard time to +08:30 (not +08).  Its transition
    back to +08 after WWII was on 1945-09-15, not the previous day.
    Its 1904-10-30 change took effect at 01:00 +08 (not 00:00 LMT).
    (Thanks to Phake Nick, Steve Allen, and Joseph Myers.)  Also,
    its 1952 fallback was on 11-02 (not 10-25).

    This release contains many changes to timestamps before 1946 due
    to Japanese possession or occupation of Pacific/Chuuk,
    Pacific/Guam, Pacific/Kosrae, Pacific/Kwajalein, Pacific/Majuro,
    Pacific/Nauru, Pacific/Palau, and Pacific/Pohnpei.
    (Thanks to Phake Nick.)

    Assume that the Spanish East Indies was like the Philippines and
    observed American time until the end of 1844.  This affects
    Pacific/Chuuk, Pacific/Kosrae, Pacific/Palau, and Pacific/Pohnpei.

  Changes to past tm_isdst flags

    For the recent Morocco change, the tm_isdst flag should be 1 from
    2018-10-27 00:00 to 2018-10-28 03:00.  (Thanks to Michael Deckers.)
    Give a URL to the official decree.  (Thanks to Matt Johnson.)
2019-01-01 03:04:56 +00:00
maxv 4aa536c2db Fix the segmentation check, the limit is relative, not absolute. 2018-12-29 17:54:54 +00:00
christos 7a3b8449d8 Re-do previous (always make available preinit/initarray/finiarray), with
less disruption.
2018-12-28 20:12:35 +00:00
alnsn f4bc8af01c Document "ROOT." syntax before documenting a generic . 2018-12-28 18:44:11 +00:00
christos 12faa81882 Undo previous; breaks macppc/m68k (at least) 2018-12-28 18:17:10 +00:00
christos 96e2e1e315 Avoid duplicate definitions on arm (reported by kre@) 2018-12-28 13:53:17 +00:00
alnsn a2fe1bd34b No need to quadruple a buffer because strunvis(3) doesn't expand. 2018-12-27 21:35:48 +00:00
christos 7848d457d8 Allow both array and non-array constructors for transition. 2018-12-27 19:32:32 +00:00
christos 312d62b9b5 Enable initfini array support for everyone. 2018-12-27 18:57:14 +00:00
mlelstv 70cf95aac9 Clean up double free in some error paths that did trigger
an assertion in libprop.
2018-12-27 14:05:54 +00:00
maxv 38b2a665bf Several improvements and fixes:
* Change the Assist API. Rather than passing callbacks in each call, the
   callbacks are now registered beforehand. Then change the I/O Assist to
   fetch MMIO data via the Mem callback. This allows a guest to perform an
   I/O string operation on a memory that is itself an MMIO.

 * Introduce two new functions internal to libnvmm, read_guest_memory and
   write_guest_memory. They can handle mapped memory, MMIO memory and
   cross-page transactions.

 * Allow nvmm_gva_to_gpa and nvmm_gpa_to_hva to take non-page-aligned
   addresses. This simplifies a lot of things.

 * Support the MOVS instruction, and add a test for it. This instruction
   is special, in that it takes two implicit memory operands. In
   particular, it means that the two buffers can both be in MMIO memory,
   and we handle this case.

 * Fix gross copy-pasto in nvmm_hva_unmap. Also fix a few things here and
   there.
2018-12-27 07:22:31 +00:00
mrg 1958a4b9ee move sqlite earlier in its section. my build often sits with only 3
processes active here for quite some time otherwise.
2018-12-24 22:02:32 +00:00
mrg cffa8474c3 be consistent about uint64_t and bit masks. 2018-12-19 11:02:21 +00:00
mrg 35db1fca91 use uint64_t for idx_mask. fixes lookups for some PAs. from skrll.
bump copyright.  we updated this a lot of this in 2018.
2018-12-19 11:00:09 +00:00
skrll 9181a215b8 Fix _kvm_kvatop so that it now works. 2018-12-18 16:25:47 +00:00
wiz 76792de36e Use An in AUTHORS section. 2018-12-17 08:18:06 +00:00
maya fa8f034bc1 unifdef RSA_ENCPWD. The matching code does not exist. 2018-12-16 16:06:39 +00:00
abhinav 3cf9f52098 Remove self reference in SEE ALSO
Add references consistent with those in md4(3) and md5(3)

Reported by kamil
2018-12-16 14:08:48 +00:00
hannken 650b07c895 Add an option "modctl" to capture modctl(). 2018-12-16 14:03:37 +00:00
maya 87f1587c95 G/C SPX support
It was presented as a draft in 1993. I don't see any mentions since. it
was not enabled.
2018-12-15 23:22:51 +00:00
maxv 506b4248b0 Invert the mapping logic.
Until now, the "owner" of the memory was the guest, and by calling
nvmm_gpa_map(), the virtualizer was creating a view towards the guest
memory.

Qemu expects the contrary: it wants the owner to be the virtualizer, and
nvmm_gpa_map should just create a view from the guest towards the
virtualizer's address space. Under this scheme, it is legal to have two
GPAs that point to the same HVA.

Introduce nvmm_hva_map() and nvmm_hva_unmap(), that map/unamp the HVA into
a dedicated UOBJ. Change nvmm_gpa_map() and nvmm_gpa_unmap() to just
perform an enter into the desired UOBJ.

With this change in place, all the mapping-related problems in Qemu+NVMM
are fixed.
2018-12-15 13:39:43 +00:00
maxv 3f62f34a84 Two changes:
- Fix the I/O Assist, for INS* it is RDI and not RSI, and the register
   gets updated regardless of the REP prefix.

 - Fill in the Mem Assist. We decode and emulate certain instructions,
   and pass a mem descriptor to the callback to handle the transaction.
   The disassembler could use some polishing, and there are still a
   few instructions missing; but basically it works.
2018-12-15 13:09:02 +00:00
christos 57aff58910 more const 2018-12-14 23:42:39 +00:00
uwe cb6634cf44 Don't leave a subordinate clause out in the cold. 2018-12-14 03:43:22 +00:00
uwe e8277867b9 Fix typo in the function comment. 2018-12-14 03:29:54 +00:00
maya 60dcd2644e Remove unused code 2018-12-13 09:09:32 +00:00
maya 62523467d4 Remove unused macro 2018-12-13 08:45:29 +00:00
maya 3ba1def22c Remove unused macro. 2018-12-13 08:39:34 +00:00
dholland c46ad0a300 Adjust English usage in message for EAI_NONAME. 2018-12-13 04:41:41 +00:00
dholland aaa03614bc Return EAI_NODATA, not EAI_NONAME, for nonexistent hosts.
This causes e.g. "ssh nosuchname" to print "No address associated with
hostname", which is correct, rather than "hostname nor servname
provided, or not known", which is not.
2018-12-13 04:30:55 +00:00
wiz ea293cc938 Remove superfluous dot. 2018-12-12 11:40:08 +00:00
maxv 6c8db606f2 Change the map/unmap functions, again. 2018-12-12 10:42:34 +00:00
maxv 0c0c8940d2 Change the "FILES" section, in the end I don't want to commit toyvirt
and smallkern, there is little interest installing them by default,
rather they can be downloaded from www. It's better this way.

While here add NVMM(4) in "SEE ALSO".
2018-12-12 09:09:08 +00:00
sevan 0f1014292f Reword post mortem description. It tries to get the tree averages if it can. 2018-12-11 23:02:19 +00:00
sevan e67a3558e2 Clarify the difference to getloadavg(3). 2018-12-11 02:29:11 +00:00
christos dda6d8cae4 fix grammar. 2018-12-09 20:29:53 +00:00
tih 138c67b5ef Summary: Align softfloat float128 with libgcc.
While libgcc adapts its float128 data structure to the endianness of
the architecture, the softfloat code in libc didn't.  With both of
them handling the same values, softfloat must follow the toolchain.

OK: riastradh
2018-12-06 19:17:13 +00:00
kamil cae5584ffc Correct handling of minval > maxval in strtonum(3)
The original implementation in OpenBSD returns "invalid" and avoids reading
the input string. The replaced behavior was interpreting the input string
ignoring the invalid arguments.
2018-12-06 06:29:56 +00:00
christos 85390d7315 Add a couple more readline compat functions. 2018-12-02 16:58:13 +00:00
kamil cfb2a8fe4d Correct the documentation of cdbr_open_mem(3)
Fix function prototype in the man-page.
Add link cdbr_open_mem(3) -> cdbr(3).
2018-12-01 02:43:43 +00:00
roy ae8e2e2858 curses: Fix inverted logic when drawing LR corner with auto margins
Thanks to M. Levinson.
2018-11-30 04:38:14 +00:00
maxv a026d6cb92 Rewrite the gpa map/unmap functions. Dig holes in the mapped areas when
there is an overlap. Close to what Qemu expects.
2018-11-29 19:55:20 +00:00
christos f04c2e3e34 Fix off by one <tsahara at iij> 2018-11-29 03:10:20 +00:00
wiz f3f43bfe46 More macros, less whitespace. 2018-11-27 10:38:14 +00:00
kamil 80ee9b513a Fix link sha1.3 <- SHA1File.3
This SHA1File used to link to sha2(3).
2018-11-27 03:56:37 +00:00
kamil 99255a5dff Document SHA1FileChunk(3) in sha1(3)
Description taken from OpenBSD.
2018-11-27 03:29:36 +00:00
joerg 463db15fc5 Do not pass the main object handle from the assembler startup stub to
the common ___start routine. It's only used for a pointless magic
version check. Thanks to martin@ for testing various architectures.
2018-11-26 17:37:44 +00:00
christos e9933f923a From Yuichiro Naito (FreeBSD):
hrs@ says that
(cbp >= MB_LEN_MAX) condition is necessary for checking invalid
byte sequences.  If malicious input was given, libedit would read
byte sequences forever.
2018-11-25 16:21:04 +00:00
christos 2cb4fa4296 From Yuichiro Naito (FreeBSD):
hrs@ says that wctomb(3) has an internal shift state,
if wctomb(3) is called outside of libedit,
the internal state can be changed and causes miscalculate multibyte size.

So in this part, wcrtomb(3) should be used.
wcrtomb(3) requires that shift state is given in the argument.
We always initialize the shift state in ct_enc_width() to keep independent
from outside of libedit.
2018-11-25 16:20:28 +00:00
christos e06500e20d PR/53682: Jordan Lewis: use newlines instead of padded spaces when restoring
multi-line histories.
2018-11-24 12:17:35 +00:00
wiz 9be4740cf8 Grammar improvements. 2018-11-24 11:04:39 +00:00
uwe 80d62aa1ec attron(), attroff() - don't take a shortcut. 2018-11-24 01:04:18 +00:00
skrll 031e68cbb9 Update comments to help explain what's going on 2018-11-23 12:39:18 +00:00
skrll 5c89cda337 Fix so the setcontext call is via the PLT and libpthread can override 2018-11-23 11:38:07 +00:00
uwe 3981bd4fdf wattr_set - turn off all wide attributes (fix unedited copy/paste). 2018-11-23 11:16:59 +00:00
uwe 19b437abe9 Rename the reserved argument from "opt" to "opts" to match SUS text. 2018-11-23 11:15:14 +00:00
uwe 44b007ca68 Refactor. Move code to turn attributes on/off into separate
functions.  Express both old and new functions to manipulate
attributes using those functions.  Check that the the new API's opts
argument (reserved by the standard for future use) is NULL and error
out if not (like getcchar/setcchar).  No functional change intended.
2018-11-23 11:11:59 +00:00
uwe 801bc96314 Drop a few redundant casts of a variable to its own type. 2018-11-22 23:37:31 +00:00
uwe 485cf0548e Move getattrs() and wcolor_set() so that they are with their peers and
so that wide and non-wide functions are in the same order.  While here,
make __wcolor_set() static.  No functional change intended.
2018-11-22 23:29:09 +00:00
uwe b717da4cab Drop HAVE_WCHAR ifdefs from code that is not even compiled with !HAVE_WCHAR.
We still try to mainain the ability to build our curses with
!HAVE_WCHAR, but it doesn't make sense to provide stubs for new wide
API functions that just error out when !HAVE_WCHAR.  Any code that
only uses old API (and can work with !HAVE_WCHAR curses) doesn't use
those new functions.  The code that uses new API obviosly cannot work
when all the new API is stubbed out.

So the plan is to drop the stubs.  This commit does that for files
that are not even compiled with !HAVE_WCHAR (not only those stubs are
useless, they were not even there to begin with).

Same object code is generated for the normal HAVE_WCHAR case.  Nothing
is even recompiled for !HAVE_WCHAR.

Ok by blymn@ jdc@ roy@
2018-11-22 22:16:45 +00:00
uwe e0a45a7a9d We need insstr.c for !HAVE_WCHAR too. 2018-11-22 22:00:49 +00:00
skrll e9071591eb G/C __APCS_26__ support 2018-11-22 20:38:59 +00:00
ryo 466808d25b fix condition code. x1==0 is parent. 2018-11-22 08:30:58 +00:00
skrll df8c50d73f _REG_LR should be _lwp_exit 2018-11-21 21:24:42 +00:00
skrll 81f196752c Fix some register names in comments 2018-11-21 21:04:15 +00:00
skrll 916ea5ef0d Fix a comment 2018-11-21 21:01:41 +00:00
uwe 9d5d4061af Compare pointers to NULL, not to zero. 2018-11-20 22:02:31 +00:00
uwe 042640f557 Drop bogus cast. 2018-11-20 21:42:52 +00:00
uwe 039bdd2780 Don't hide assignments inside tests. 2018-11-20 21:41:31 +00:00
uwe 49cc439a5a Fix color pair handling. color_pair argument is a pair number. 2018-11-20 17:48:19 +00:00
maxv 15051740bd Fix error handling of realloc, and use memmove because the areas overlap;
noted by agc@. These _nvmm_area_add/delete functions don't make a lot of
sense right now and will likely be rewritten to match the behavior
expected by Qemu; but still fix for the time being.

Also fix a collision check while here.
2018-11-19 21:45:37 +00:00
uwe ce63d7aabc wbkgd - when updating window rendition for the new background character,
it's the old background characters that need to be updated, not spaces.

While here, simplify and also fix the bug introduced in 1.20 (that
lost the default color) - actually use the results of wbkgdset().
2018-11-19 20:37:04 +00:00
uwe 22b16841d0 Provide basic documentation on getcchar(3) and setcchar(3).
Looks like we don't have any of wide curses stuff documented, so this
seems to be a good place to start.  Needs more exposition on wide
attr_t and how it's related to non-wide chtype, etc, etc.
2018-11-19 01:08:21 +00:00
uwe af85389f73 wbkgrnd - do not duplicate code that's already in wbkgrndset() 2018-11-18 22:53:22 +00:00
uwe 76bb992903 When we remove default color from attributes, just clear all __COLOR.
It's both a nono-optmization and matches the test used in counterpart
code that adds default color when none is set.
2018-11-18 22:34:32 +00:00
uwe 0b616789d6 Reorder "bkgrnd" functions to match the order of old "bkgd" functions. 2018-11-18 22:18:02 +00:00
uwe 5fc077791a Don't fuse HAVE_WCHAR and (trivial) !HAVE_WCHAR bodies into single
function definition.  Instead provide two sets of definitions under
single #ifdef.  Same object code is generated for both HAVE_WCHAR and
!HAVE_WCHAR.
2018-11-18 22:11:38 +00:00
uwe ee4af76d2e wbkgd - do not duplicate the code that's already in wbkgdset()
that we do call anyway.
2018-11-18 21:01:16 +00:00
uwe 14d0245468 Fix comments on bkgdset() and friends to match reality. 2018-11-18 20:26:29 +00:00
uwe 3f33c7bd5f Don't mix private and public names for the same thing in one statement.
While here, fix harmless edito in a debug call.
2018-11-18 18:52:29 +00:00
christos e91c30539f fix compilation 2018-11-18 17:15:41 +00:00
christos 18bb6ea433 Remove utf-8 requirement (Yuichiro NAITO) 2018-11-18 17:09:39 +00:00
uwe 5938495dd2 Reindent a few lineeq() calls now that we can w/out exceeding 80
columns limit.  Whitespace change only.
2018-11-18 02:46:24 +00:00
uwe 47498e515e Further tweak previous. Change the check order to be more logical.
No functional change intentded.  While here fix indentation.
2018-11-18 02:39:44 +00:00
uwe 89ed91e019 Merge one more #ifdef with mostly identical code in both branches.
The same object code is generated modulo gratuitously different order
of checks.
2018-11-18 02:34:39 +00:00
uwe 7013a4d9a5 Merge another #ifdefs that now has identical code in both branches
modulo swapped arguments to celleq() call.  Same object code is
generated otherwise for both HAVE_WCHAR and !HAVE_WCHAR
2018-11-18 02:17:24 +00:00
uwe 7539fe2666 Merge few #ifdefs that now have identical code in both branches.
Same object code is generated for both HAVE_WCHAR and !HAVE_WCHAR.
2018-11-18 01:54:30 +00:00
uwe 05cd1d4d96 Define celleq() and lineeq() for !HAVE_WCHAR too and use them instead
of explicit memcmp() calls.  Same object code is generated for both
HAVE_WCHAR and !HAVE_WCHAR, but we can now try to merge some of the
#ifdefs
2018-11-18 01:39:55 +00:00
uwe d2a41e949e Oops, revert previous. Wrong tree. 2018-11-18 01:23:57 +00:00
uwe e573989caa Comment out LIBDPLIBS so that this can be built outside of the tree. 2018-11-18 01:22:49 +00:00
uwe e156886d4b Rename cellcmp() and linecmp() to celleq() and lineeq() respectively
and make them static.
2018-11-18 01:19:29 +00:00
uwe 291b9ad5db quickch - fix inverted checks.
I have to admit I have no idea what's going on here, but HAVE_WCHAR
code here inverted the sense of linecmp and cellcmp checks w.r.t the
!HAVE_WCHAR variant just above it.  Cf. also all other similar #ifdefs
in this file.

Found through source code inspection, not really tested.
2018-11-18 01:05:30 +00:00
uwe 02236eecfb cellcmp - use logical && not bitwise & 2018-11-18 00:45:44 +00:00
maxv 07310f302a Don't forget to set 'prot' when the guest has paging disabled. 2018-11-17 16:11:33 +00:00
ryo b3731ba225 fix type of argument for va_arg; don't round to 32bit. 2018-11-16 10:51:08 +00:00
blymn a887f4aff9 Fix for PR lib/52063
Many thanks to  Onno van der Linden (o.vd.linden@quicknet.nl) for providing
the bulk of the patch that fixes the issue.
2018-11-16 10:12:00 +00:00
manu b553c427d4 Use reclaim2 to fix reclaim/lookup race conditions
The PUFFS reclaim operation had a race condition with lookups: we could
be asked to lookup a node, then to reclaim it before lookup completion.
At lookup completion, we would then create a leaked node.

Enter the PUFFS reclaim2 operation, which features a nlookup argument.
That let us count how many lookups are pending and avoid the above
described scenario. It also makes the codes simplier.
2018-11-16 02:39:02 +00:00
uwe 540f2c17fd _cursesi_addbyte - fix function comment after what looks like an
editing accident.
2018-11-15 03:17:51 +00:00
martin 53fe79071f Too much magic involved - revert previous. 2018-11-13 09:24:37 +00:00
martin 94c721a4e0 Need some minimalistic support for additional things that ../Makefile
requires, even if we do nothing here
2018-11-13 09:14:14 +00:00
martin 9b49821e7c Move conditionals for libnvmm to subdir makefile, requested boy mrg. 2018-11-13 09:00:08 +00:00
maya c587647461 Revert my own rev 1.2, the missing include was only when building the 32-bit
compat library, we no longer do this.
2018-11-13 06:57:14 +00:00
nakayama 996407034c No need to install shared libraries to /lib. 2018-11-12 17:46:53 +00:00
martin c0f5d6f2fc Do not build a compat i386 version of libnvmm. 2018-11-12 09:25:42 +00:00
maya dd1f793151 Add missing include for struct nvmm_x64_state
(Pointed out by the clang build)
2018-11-11 00:06:48 +00:00
maxv 823f3f6003 Add copyright and RCSID, from wiz@. 2018-11-10 10:57:06 +00:00
maxv 2760ca24b5 Add libnvmm, NetBSD's new virtualization API. It provides a way for VMM
software to effortlessly create and manage virtual machines via NVMM.

It is mostly complete, only nvmm_assist_mem needs to be filled -- I have
a draft for that, but it needs some more care. This Mem Assist should
not be needed when emulating a system in x2apic mode, so theoretically
the current form of libnvmm is sufficient to emulate a whole class of
systems.

Generally speaking, there are so many modes in x86 that it is difficult
to handle each corner case without introducing a ton of checks that just
slow down the common-case execution. Currently we check a limited number
of things; we may add more checks in the future if they turn out to be
needed, but that's rather low priority.

Libnvmm is compiled and installed only on amd64. A man page (reviewed by
wiz@) is provided.
2018-11-10 09:28:56 +00:00
martin 6b62e867ad Add modfl alias. 2018-11-09 10:19:47 +00:00
mrg 33cbd42a21 tg1 is a 64 bit value, store it in a 64 bit variable. 2018-11-09 04:06:40 +00:00
riastradh 0cc7838e19 Attempt to implement fabsf by copying fabs and s/d/f/g.
Vax wizards, please vaxinate if I flubbed this!
2018-11-08 18:19:37 +00:00
riastradh 7b66ed5df0 Use the generic C fabs/fabsl on ia64 for now to unbreak the build. 2018-11-08 16:36:16 +00:00
riastradh 3e49d37969 powerpc64 needs fabsl too. (Apparently no __HAVE_LONG_DOUBLE?) 2018-11-08 16:31:46 +00:00
riastradh e84f49ed3d Try speling it rite, riasthradhdadhaa or whatever your name is. 2018-11-08 16:29:50 +00:00
msaitoh 169880b3b2 "s/ an an / an /" in comment. No functional change. 2018-11-08 06:43:52 +00:00
msaitoh 54c9821e53 "s/ are are / are /" in comment. No functional change. 2018-11-08 06:34:40 +00:00
riastradh cdb65da578 On ports without __HAVE_LONG_DOUBLE, make fabsl alias fabs.
For some reason, fabs lives in libc, not in libm, and our tests now
detect when fabs or fabsl is missing from libm.  For those ports that
sometimes have long double and sometimes don't, make it conditional.

Still missing: fabs _and_ fabsl on ia64.  Need help from an itanium
wizard!  Other portmasters: Please take a look and see if I missed
any ports that might have long double where this alias will not work.
2018-11-07 22:21:42 +00:00
riastradh 7374a22668 When hardware subnormal support is available, disable flush-to-zero.
Similarly, when hardware NaN propagation is available, disable
default-NaN substitution.

This enables IEEE 754 semantics on any hardware that supports it by
default.  Programs that want flush-to-zero or default-NaN substitution
can enable them explicitly.

ok ryo@
2018-11-07 06:47:38 +00:00
riastradh 6059a086c9 Disable x87 implementations of sin, cos, tan.
The x87 hardware uses a bad approximation to pi for argument
reduction, and consequently yields bad answers for inputs near pi or
pi/2.

Tweak one tanf test whose doubly rounded output is a little too far
from the correct answer on the doubly rounded input.
2018-11-07 04:00:12 +00:00
wiz b572c9cad3 Fix xref. 2018-11-05 09:18:55 +00:00
maya 81e6878869 Suggest to remove lfs_ stubs on a major bump.
they're deprecated, ioctl is used instead.
2018-11-05 04:08:39 +00:00
mrg 19db227738 initialise the kvm errbuf so that if an error occurs, but the
internal _kvm_*err() functions aren't called, stack garbage is
not reported as an error string.

call _kvm_err() if _kvm_kvatop() fails.  now the above is not
triggered anymore :-)
2018-11-05 00:43:30 +00:00