Commit Graph

19474 Commits

Author SHA1 Message Date
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
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