Commit Graph

277663 Commits

Author SHA1 Message Date
Dag-Erling Smørgrav
7ccdad905f renice: add unit tests.
Sponsored by:	Klara, Inc.
2022-08-25 20:06:20 +00:00
Dag-Erling Smørgrav
65ee0a8495 renice: fix argument order.
The target modifiers (-g, -p, -u) may occur in any position except
between -n and its argument; furthermore, we support both the old
absolute form (without -n) and the modern relative form (with -n).

Sponsored by: Klara, Inc.
2022-08-25 19:50:55 +00:00
Mateusz Guzik
e621cb0be2 amd64: dump standard registers when crashing
Sample output:

Fatal trap 12: page fault while in kernel mode
cpuid = 1; apic id = 01
fault virtual address   = 0x2
fault code              = supervisor write data, page not present
instruction pointer     = 0x20:0xffffffff80556853
stack pointer           = 0x28:0xffffffff8141bf50
frame pointer           = 0x28:0xffffffff8141bfa0
code segment            = base 0x0, limit 0xfffff, type 0x1b
		        = DPL 0, pres 1, long 1, def32 0, gran 1
processor eflags        = interrupt enabled, resume, IOPL = 0
current process         = 0 (swapper)
rdi: fffff80002c9c400 rsi: ffffffff80b89183 rdx:                0
rcx:                2  r8:               fe  r9:                1
rax: fffff80002c9c400 rbx:                1 rbp: ffffffff8141bfa0
r10:                0 r11: ffffffff80b97f8c r12:                0
r13:                0 r14:                0 r15:                0
trap number             = 12
panic: page fault
cpuid = 1
time = 1

Reviewed by:	kib
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D36348
2022-08-25 17:33:07 +00:00
Mateusz Guzik
49afea1059 proc: read the pid prior to unlocking in report_alive_proc1
In principle another thread could have reaped the process by that time.
2022-08-25 17:26:49 +00:00
Andrew Turner
5d0aebf4fa Fix the arm generic timer on 32 bit
Hide a variable when we don't use it.

Sponsored by:	The FreeBSD Foundation
2022-08-25 13:17:11 +01:00
Andrew Turner
48a7e53db7 Merge the common parts of the SMCCC handlers
To simplify adding new handlers merge the common parts of the functions
used to call into the arm SMCCC firmware.

Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D36297
2022-08-25 12:17:28 +01:00
Andrew Turner
7a060a8895 Add an IDC only arm64 icache sync function
When the IDC flag is set in the cache type register we don't need to
clean the data cache to the point of unification. Previously we
supported this flag being set only when the DIC flags was also set.
Add a new handler for when this is not the case.

Reviewed by:	kib
Sponsored by:	The FreeBSD Foundation, Ampere (hardware)
Differential Revision: https://reviews.freebsd.org/D36296
2022-08-25 12:17:28 +01:00
Andrew Turner
278111b8a5 Allow the kernel to emulate the physical counter on arm64
When running under a VM we don't have access to the physical counter.
Add support to emulate this instruction by handling the trap in the
kernel. As it is slow only enable when the hw.emulate_phys_counter
tunable is set on boot.

Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D35613
2022-08-25 12:17:23 +01:00
Peter Holm
2aba6e7aaf stress2: Added a regression test 2022-08-25 09:47:58 +02:00
Baptiste Daroussin
83e8c23178 bintrans: replace the quoted printable encoder/decoder
Replace the quoted printable code with one that respects RFC2045
Add tests about this parsers and encoders, using examples from the
wikipedia page.

Reviewed by:	pstef
Differential Revision: https://reviews.freebsd.org/D36314
2022-08-25 09:29:18 +02:00
Doug Moore
b6ce129d24 rb_tree: optimize rb_insert
In searching for where to insert a new node, RB_INSERT discards the
address of the pointer that will have to be modified, so that it must
find it again from the values of 'parent' and 'comp'. Stop discarding
that address, and so avoid having to recompute it.

Reviewed by:	alc
MFC after:	3 weeks
Differential Revision:	https://reviews.freebsd.org/D36317
2022-08-25 02:26:04 -05:00
Li-Wen Hsu
9ea2716b77
Reenable basic_signal:trap_signal_test on i386
This is fixed in dc4a2d1d0e

PR:		265889
Sponsored by:	The FreeBSD Foundation
MFC with:	dc4a2d1d0e
2022-08-25 12:09:00 +08:00
Li-Wen Hsu
504b998def
ObsoleteFiles: Follow awk test files move
Fixes:	517e52b6c2
Sponsored by:	The FreeBSD Foundation
2022-08-25 11:28:57 +08:00
Aymeric Wibo
05c9a0158f libc: Add strverscmp(3) and versionsort(3)
Add a strverscmp(3) function to libc, a GNU extension I implemented by
reading its glibc manual page. It orders strings following a much more
natural ordering (e.g. "ent1 < ent2 < ent10" as opposed to
"ent1 < ent10 < ent2" with strcmp(3)'s lexicographic ordering).

Also add versionsort(3) for use as scandir(3)'s compar argument.

Update manual page for scandir(3) and add one for strverscmp(3).

Reviewed by:	pstef, gbe, kib
MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D35807
2022-08-25 03:29:03 +03:00
Mark Johnston
465988e9fa NOTES: Update the comment for MCLSHIFT
MFC after:	1 week
2022-08-24 19:59:32 -04:00
Mark Johnston
b0b0e4ee00 NOTES: Update the default MSIZE and MCLSHIFT values
After commit 840327e5dd ("mbuf: Don't support PAGE_SIZE < 4K"), these
defaults were causing LINT kernel builds to fail.

Reported by:	Jenkins
MFC after:	1 week
2022-08-24 19:57:33 -04:00
Mark Johnston
c4d06691c0 git-arc: Respect GIT_EDITOR and GIT_PAGER 2022-08-24 16:54:41 -04:00
Mark Johnston
43d0c4d2a2 git-arc: Fix whitespace 2022-08-24 16:53:17 -04:00
Konstantin Belousov
a294e67973 Document scandirat(3)
Reviewed by:	emaste, gbe (man pages), imp, kevans, markj, Aymeric Wibo <obiwac@gmail.com>
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D36301
2022-08-24 22:26:01 +03:00
Konstantin Belousov
9fb8e8eede libc: add scandirat(3)
Reviewed by:	emaste, imp, kevans, markj, Aymeric Wibo <obiwac@gmail.com>
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D36301
2022-08-24 22:26:00 +03:00
Konstantin Belousov
cb6e97f4da libc: split scandir() into scandir_dirp() and proper scandir()
The new helper scandir_dirp() takes DIR *, i.e. a pre-opened directory,
instead of the directory name.

Reviewed by:	emaste, imp, kevans, markj, Aymeric Wibo <obiwac@gmail.com>
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D36301
2022-08-24 22:26:00 +03:00
Konstantin Belousov
ea448a0a43 Link scandir_b(3) to scandir(3)
Reviewed by:	emaste, gbe (man pages), imp, kevans, markj, Aymeric Wibo <obiwac@gmail.com>
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D36301
2022-08-24 22:26:00 +03:00
Konstantin Belousov
aa5e19a9b3 scandir.3: Use .Fo instead of .Fn for long args
Reviewed by:	emaste, gbe (man pages), imp, kevans, markj, Aymeric Wibo <obiwac@gmail.com>
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D36301
2022-08-24 22:26:00 +03:00
Konstantin Belousov
fce3b1c327 fork_exit(): style comment
Reviewed by:	jhb
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D36302
2022-08-24 22:12:53 +03:00
Konstantin Belousov
ff32a05554 x86: improve machdep.uprintf_signal
Print %eax/%rax.
Use better format strings, like %#x.

Reviewed by:	jhb
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D36302
2022-08-24 22:12:45 +03:00
Konstantin Belousov
01a33b2af5 x86: print trap name in addition of trap number
for the "trap with interrupts disabled" warning.

Reviewed by:	jhb
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D36302
2022-08-24 22:12:37 +03:00
Konstantin Belousov
0f906b30e6 i386: print all GPRs, PSL, and CR3 on double fault
Also compactify the printfs, and remove comment about 'two prints'.
Their arguments are on same page, so one fault implies another.

Reviewed by:	jhb
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D36302
2022-08-24 22:12:30 +03:00
Konstantin Belousov
54e1546e09 i386: simplify flow control in irettraps
It is enough to have only one 'call calltrap' locally.

Reviewed by:	jhb
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D36302
2022-08-24 22:12:22 +03:00
Konstantin Belousov
e8b2980e4a i386 doreti: stop saving/restoring %ecx around calls into C
There is no reason to do this.  Instead just calculate it later.

Reviewed by:	jhb
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D36302
2022-08-24 22:12:05 +03:00
Konstantin Belousov
dc4a2d1d0e i386: do not allow userspace to set tf_trapno on sigreturn(2)
tf_trapno is checked on return from interrupt/exception to determine if
special handling is needed for switching address space.  This is due to
the possibility of NMI/MCHK/DBG to occur at arbitrary place in kernel,
where both address space and stack used could be transient.  Kernel
saves current %cr3 in tf_err for such events, to restore on return.

If user is able to set tf_trapno, it can trigger that special handling,
and since tf_err is also user-controlled by sigreturn(2), the result is
undefined.

PR:	265889
Reported by:	lwhsu
Reviewed by:	jhb
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D36302
2022-08-24 22:11:57 +03:00
Konstantin Belousov
a03e4799e7 irettraps: i386 does not push %ss/%esp when exception does not switch rings
Which means that we must not copy top 8 bytes from the trampoline stack
for the exception frame to the regular thread kstack.  As consequence,
this stops corruption of the pcb.  The visible effect was often a broken
fork(2) on the CPU where corruption occured.

Account for the detail by substracting 8 from the copy byte count when
moving exception frames from trampoline to the regular stack.

[irettraps handles segmentation/stack/protection faults which could
occur on the doreti path, where we might already switched stack and
address space]

Reported and tested by:	pho
Reviewed by:	jhb
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D36302
2022-08-24 22:11:49 +03:00
Konstantin Belousov
95f773e594 i386 copyout_fast: improve detection of a fault on accessing userspace
Do not blindly account a page fault occuring on the trampoline area,
as the userspace access fault.  Check that it occured exactly in the
instruction that does that.

This avoids unneeded switches of address space on faults not needing the
switch, effectively converting machine resets due to tripple faults,
into regular panics.

Reviewed by:	jhb
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D36302
2022-08-24 22:11:40 +03:00
Dag-Erling Smørgrav
0a9b374ecc chown: see also chmod.
Sponsored by:	Klara, Inc.
MFC after:	1 week
2022-08-24 20:21:39 +02:00
Eric van Gyzen
3b0f105ce3 shared_shadow_inval_test: fix copy-pasto in error message
MFC after:	1 week
Sponsored by:	Dell EMC Isilon
2022-08-24 13:03:11 -05:00
Brooks Davis
c46697b9cb freebsd32_sendmsg: fix control message ABI
When a freebsd32 caller uses all or most allowed space for control
messages (MCLBYTES == 2K) then the message may no longer fit when
the messages are padded for 64-bit alignment.  Historically we've just
shrugged and said there is no ABI guarantee.  We ran into this on
CheriBSD where a capsicumized 64-bit nm would fail when called with more
than 64 files.

Fix this by not gratutiously capping size of mbuf data we'll allocate
to MCLBYTES and let m_get2 allocate up to MJUMPAGESIZE (4K or larger).
Instead of hard-coding a length check, let m_get2 do it and check for a
NULL return.

Reviewed by:	markj, jhb, emaste
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D36322
2022-08-24 18:34:39 +01:00
Brooks Davis
9c3ad5ba93 cxgbe: don't support MJUMPAGESIZE != MCLBYTES
This could only happen on systems with PAGE_SIZE < 4K and FreeBSD
doesn't support such systems.

Reviewed by:	np, imp, jhb
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D36321
2022-08-24 18:34:25 +01:00
Brooks Davis
840327e5dd mbuf: Don't support PAGE_SIZE < 4K
The Vax supported such things, but FreeBSD does not.  This further
implies that MJUMPAGESIZE > MCLBYTES so assert this and remove code
handling them being equal.

Reviewed by:	kp, imp, jhb
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D36320
2022-08-24 18:34:07 +01:00
Brooks Davis
e9ad2964f5 pkg: Add limited --debug/-d support
Add an internal debug level global:
 - Level 1 (-d) currently does nothing.

 - Level 2 (-d -d) enables libfetch debugging (quite verbose) so it's
   possible to see what pkg is attempting to download without having
   to sniff traffic.

Reviewed by:	debdrup, bapt
Differential Revision:	https://reviews.freebsd.org/D35756
2022-08-24 18:32:09 +01:00
Alexander V. Chernikov
8036234c72 netinet6: fix SIOCSPFXFLUSH_IN6 by skipping manually-configured prefixes
Summary:
Currently netinet6/ code allocates IPv6 prefixes (nd_prefix) for
 both manually-assigned addresses and advertised prefixes. As a result,
 prefixes from manually-assigned prefixes can be seen in `ndp -p` list
 and be cleared via `ndp -P`. The latter relies on the SIOCSPFXFLUSH_IN6
 ioctl to clear to prefix list.
The original intent of the SIOCSPFXFLUSH_IN6 was to clear prefixes
 originated from the advertising routers:

```
1998-09-02  JINMEI, Tatuya  <jinmei@isl.rdc.toshiba.co.jp>
	* nd6.c (nd6_ioctl): added 2 new ioctls; SIOCSRTRFLUSH_IN6 and
	SIOCSPFXFLUSH_IN6. The former is to flush all default routers
	in the default router list, and the latter is to flush all the
	prefixes and the addresses derived from them in the prefix list.
```

Restore the intent by marking prefixes derived from the RA messages
with newly-added ndpr_flags.ra_derived flag and skip prefixes not marked
 with such flag during deletion and listing.

Differential Revision: https://reviews.freebsd.org/D36312
MFC after:	2 weeks
2022-08-24 13:59:13 +00:00
Emmanuel Vadot
6364180582 linuxkpi: unbreak linux_i2cbb
This is a joint work with manu.

- fixed conditions in do_i2c_transfer and i2c_transfer as linux_i2cbb
  does not set adapter->algo->master_xfer but does set
  adapter->algo_data;
- fixed parent bus specification for linux_i2cbb driver module;
- actually implemented iicbb_transfer method;
- added iicbb_pre_xfer and iicbb_post_xfer methods;
- removed unnecessary and harmful delays (and other extra logic) from
  iicbb methods as iicbb driver already has them;
- added setting of iicbb speed based on algo_data->udelay, so that iicbb
  uses correct delays;

PR:		265920
Fixes:		1961a14a47 linuxkpi: Add i2c support
MFC after:	2 weeks
Sponsored by:	Beckhoff Automation GmbH & Co. KG (manu's work)
2022-08-24 16:23:37 +03:00
Warner Losh
211053f952 arm64: Remove unused typedef
We don't use EFI_MEMORY_DESCRIPTOR that's typedef'd here. We use the one
from sys/efi.h instead. Remove the clutter here as these two are subtly
different (though wind up with the same layout due to alignment rules).

Sponsored by:		Netflix
2022-08-24 06:35:41 -06:00
Peter Holm
4e4f49fd4a stress2: Added another sigreturn(2) fuzzer test 2022-08-24 13:21:55 +02:00
Vincenzo Maffione
9a7abd9327 pkt-gen: flip IPv4 address in ping-pong mode
MFC after:	7 days
2022-08-24 08:20:57 +00:00
Kirk McKusick
345bfec109 Provide cache coherency between getnextinode() and ginode()
The fsck_ffs(8) utility has two subsystems for reading and writing
inodes. The getnextinode() interface is used in Pass 1 (and Pass
1b if needed) to sequentially walk through all the inodes in the
filesystem. The ginode() interface is used to read and write
individual inodes. Pass 1 uses a mix of both interfaces. This
change ensures that ginode() returns a pointer to the inode in the
cache maintained by getnextinode() when that interface holds the
requested inode so that all modifications to the inode are made in
a single place and are all written to the disk together.

Reported by:  Peter Holm
Tested by:    Peter Holm
Sponsored by: The FreeBSD Foundation
2022-08-23 23:48:40 -07:00
Kirk McKusick
be639cc8ee Update standard superblock when successful using an alternate superblock.
Historically fsck_ffs(8) would only use alternate superblocks when
running in manual mode. When the standard superblock fails, it now
tries to find and use a backup superblocks even when running in `preen'
mode. If an alternate superblock is found and the filesystem is
successfully cleaned up using it, write the alternate superblock
back to the standard superblock so that the filesystem can be
subsequently mounted and used.

Reported by:  Peter Holm
Tested by:    Peter Holm
Sponsored by: The FreeBSD Foundation
2022-08-23 23:29:17 -07:00
Mark Johnston
4b8feb5d61 tests: Handle platforms with MAXPAGESIZES < 2
Reported by:	Jenkins
Fixes:		1dfa8b73f6 ("tests: Add more shared shadow regression tests")
2022-08-23 19:48:06 -04:00
Brooks Davis
c2e1544f59 m_get3: add an MLINK for the manpage
Reviewed by:	kp
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D36319
2022-08-23 22:34:07 +01:00
Mateusz Guzik
4c9c0b640b vfs: fix vaccess prototype in the manpage
Reported by:	des
2022-08-23 21:01:55 +00:00
Mateusz Guzik
96d1fbf367 vfs: fix VOP_UNLOCK prototype in the manpage
Note the manpage is woefully outdated, taking about "simple lock".

Reported by:	des
2022-08-23 20:55:20 +00:00
John Baldwin
e663907366 Define _NPCM and the last PC_FREEn constant in terms of _NPCPV.
This applies one of the changes from
5567d6b441 to other architectures
besides arm64.

Reviewed by:	kib
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D36263
2022-08-23 13:31:02 -07:00