From 20674acb7053a45f259e66f3b57076b96a4889df Mon Sep 17 00:00:00 2001 From: Cy Schubert Date: Thu, 19 Sep 2019 20:16:51 +0000 Subject: [PATCH 01/30] Follow up on r352304 which disabled default mlockall() at startup. Unfortunately though the original tarball supports this in ./configure (for Linux), to fully support disabling of mlockall() by default requires a little extra help otherwise the following is logged in syslog: Cannot set RLIMIT_MEMLOCK: Operation not permitted MFC after: 2 weeks X-MFC with: r352304 --- contrib/ntp/ntpd/ntpd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/ntp/ntpd/ntpd.c b/contrib/ntp/ntpd/ntpd.c index 2b14431dc7b4..bcfca27a5356 100644 --- a/contrib/ntp/ntpd/ntpd.c +++ b/contrib/ntp/ntpd/ntpd.c @@ -999,7 +999,7 @@ ntpdmain( # if defined(HAVE_MLOCKALL) # ifdef HAVE_SETRLIMIT ntp_rlimit(RLIMIT_STACK, DFLT_RLIMIT_STACK * 4096, 4096, "4k"); -# ifdef RLIMIT_MEMLOCK +# if defined(RLIMIT_MEMLOCK) && defined(DFLT_RLIMIT_MEMLOCK) && DFLT_RLIMIT_MEMLOCK != -1 /* * The default RLIMIT_MEMLOCK is very low on Linux systems. * Unless we increase this limit malloc calls are likely to From 12294db4ac126ae4d66cc216d3def3f6cd2a4b00 Mon Sep 17 00:00:00 2001 From: Michael Gmelin Date: Thu, 19 Sep 2019 21:13:51 +0000 Subject: [PATCH 02/30] Fix src component detection Reviewed by: emaste MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D21579 --- usr.sbin/freebsd-update/freebsd-update.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/usr.sbin/freebsd-update/freebsd-update.sh b/usr.sbin/freebsd-update/freebsd-update.sh index 7c11d61f70ff..53a95eef1fa7 100644 --- a/usr.sbin/freebsd-update/freebsd-update.sh +++ b/usr.sbin/freebsd-update/freebsd-update.sh @@ -220,6 +220,14 @@ config_KeepModifiedMetadata () { # Add to the list of components which should be kept updated. config_Components () { + for C in $@; do + COMPONENTS="${COMPONENTS} ${C}" + done +} + +# Remove src component from list if it isn't installed +finalize_components_config () { + COMPONENTS="" for C in $@; do if [ "$C" = "src" ]; then if [ -e "${BASEDIR}/usr/src/COPYRIGHT" ]; then @@ -3284,6 +3292,7 @@ get_params () { parse_cmdline $@ parse_conffile default_params + finalize_components_config ${COMPONENTS} } # Fetch command. Make sure that we're being called From b488246b458f8addb67e36a0e25601df9ee9219f Mon Sep 17 00:00:00 2001 From: Mateusz Guzik Date: Thu, 19 Sep 2019 21:23:14 +0000 Subject: [PATCH 03/30] vfs: group fields used for per-cpu ops in one cacheline Sponsored by: The FreeBSD Foundation --- sys/kern/vfs_mount.c | 2 +- sys/sys/mount.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c index 494f2a536281..76c483c5640e 100644 --- a/sys/kern/vfs_mount.c +++ b/sys/kern/vfs_mount.c @@ -157,7 +157,7 @@ vfs_mount_init(void *dummy __unused) { mount_zone = uma_zcreate("Mountpoints", sizeof(struct mount), NULL, - NULL, mount_init, mount_fini, UMA_ALIGN_PTR, UMA_ZONE_NOFREE); + NULL, mount_init, mount_fini, UMA_ALIGN_CACHE, UMA_ZONE_NOFREE); } SYSINIT(vfs_mount, SI_SUB_VFS, SI_ORDER_ANY, vfs_mount_init, NULL); diff --git a/sys/sys/mount.h b/sys/sys/mount.h index 4a5333203f91..562fa191fe24 100644 --- a/sys/sys/mount.h +++ b/sys/sys/mount.h @@ -226,7 +226,7 @@ struct mount { struct lock mnt_explock; /* vfs_export walkers lock */ TAILQ_ENTRY(mount) mnt_upper_link; /* (m) we in the all uppers */ TAILQ_HEAD(, mount) mnt_uppers; /* (m) upper mounts over us*/ - int mnt_vfs_ops; /* (i) pending vfs ops */ + int __aligned(CACHE_LINE_SIZE) mnt_vfs_ops;/* (i) pending vfs ops */ int *mnt_thread_in_ops_pcpu; int *mnt_ref_pcpu; int *mnt_lockref_pcpu; From 657dc81d90d6bb35fc3a06958151182a3501e929 Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Thu, 19 Sep 2019 22:15:57 +0000 Subject: [PATCH 04/30] Improve ioat(4) NUMA-awareness. Allocate ioat->ring memory from the device domain. Schedule ioat->poll_timer to the first CPU of the device domain. According to pcm-numa tool from intel-pcm port, this reduces number of remote DRAM accesses while copying data by 75%. And unless it is a noise, I've noticed some speed improvement when copying data to other domain. MFC after: 1 week Sponsored by: iXsystems, Inc. --- sys/dev/ioat/ioat.c | 17 ++++++++++++----- sys/dev/ioat/ioat_internal.h | 2 ++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/sys/dev/ioat/ioat.c b/sys/dev/ioat/ioat.c index b13d9da9be42..59840932f7a3 100644 --- a/sys/dev/ioat/ioat.c +++ b/sys/dev/ioat/ioat.c @@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -44,6 +45,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -266,6 +268,11 @@ ioat_attach(device_t device) ioat = DEVICE2SOFTC(device); ioat->device = device; + if (bus_get_domain(device, &ioat->domain) != 0) + ioat->domain = 0; + ioat->cpu = CPU_FFS(&cpuset_domain[ioat->domain]) - 1; + if (ioat->cpu < 0) + ioat->cpu = CPU_FIRST(); error = ioat_map_pci_bar(ioat); if (error != 0) @@ -600,8 +607,8 @@ ioat3_attach(device_t device) __func__, error); return (error); } - ioat->ring = malloc(num_descriptors * sizeof(*ring), M_IOAT, - M_ZERO | M_WAITOK); + ioat->ring = malloc_domainset(num_descriptors * sizeof(*ring), M_IOAT, + DOMAINSET_PREF(ioat->domain), M_ZERO | M_WAITOK); ring = ioat->ring; for (i = 0; i < num_descriptors; i++) { @@ -1107,8 +1114,8 @@ ioat_release(bus_dmaengine_t dmaengine) (uint16_t)ioat->head); if (!callout_pending(&ioat->poll_timer)) { - callout_reset(&ioat->poll_timer, 1, - ioat_poll_timer_callback, ioat); + callout_reset_on(&ioat->poll_timer, 1, + ioat_poll_timer_callback, ioat, ioat->cpu); } } mtx_unlock(&ioat->submit_lock); @@ -1644,7 +1651,7 @@ ioat_free_ring(struct ioat_softc *ioat, uint32_t size, struct ioat_descriptor *ring) { - free(ring, M_IOAT); + free_domain(ring, M_IOAT); } static struct ioat_descriptor * diff --git a/sys/dev/ioat/ioat_internal.h b/sys/dev/ioat/ioat_internal.h index 919e92183168..237305811814 100644 --- a/sys/dev/ioat/ioat_internal.h +++ b/sys/dev/ioat/ioat_internal.h @@ -442,6 +442,8 @@ struct ioat_softc { }) device_t device; + int domain; + int cpu; int version; unsigned chan_idx; From 23883413d4275a16759ae4795692bec4c9a8809e Mon Sep 17 00:00:00 2001 From: Toomas Soome Date: Fri, 20 Sep 2019 05:22:34 +0000 Subject: [PATCH 05/30] loader: fix typo in zalloc. --- stand/libsa/zalloc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/stand/libsa/zalloc.c b/stand/libsa/zalloc.c index 371a1449409b..e914b7ffb40b 100644 --- a/stand/libsa/zalloc.c +++ b/stand/libsa/zalloc.c @@ -125,7 +125,8 @@ znalloc(MemPool *mp, uintptr_t bytes, size_t align) continue; /* - * Cut extra from head and create new memory node from reminder. + * Cut extra from head and create new memory node from + * remainder. */ if (extra != 0) { From e6b3bd22d8eff48799c344b6a9225ca2a06be994 Mon Sep 17 00:00:00 2001 From: Michael Tuexen Date: Fri, 20 Sep 2019 08:20:20 +0000 Subject: [PATCH 06/30] Fix the handling of invalid parameters in ASCONF chunks. Thanks to Mark Wodrich from Google for reproting the issue in https://github.com/sctplab/usrsctp/issues/376 for the userland stack. MFC after: 3 days --- sys/netinet/sctp_asconf.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sys/netinet/sctp_asconf.c b/sys/netinet/sctp_asconf.c index e4ec6aaf6762..d442ead221f2 100644 --- a/sys/netinet/sctp_asconf.c +++ b/sys/netinet/sctp_asconf.c @@ -703,6 +703,7 @@ sctp_handle_asconf(struct mbuf *m, unsigned int offset, if (param_length <= sizeof(struct sctp_paramhdr)) { SCTPDBG(SCTP_DEBUG_ASCONF1, "handle_asconf: param length (%u) too short\n", param_length); sctp_m_freem(m_ack); + return; } /* get the entire parameter */ aph = (struct sctp_asconf_paramhdr *)sctp_m_getptr(m, offset, param_length, aparam_buf); From 8b43027381dc3360d784849b7b585595bc8cfae9 Mon Sep 17 00:00:00 2001 From: Ed Maste Date: Fri, 20 Sep 2019 09:04:52 +0000 Subject: [PATCH 07/30] elf_common: add ELF note names r348628 added a definition of NT_GNU_BUILD_ID. Some software (Valgrind) also expects a #define for the note name (ELF_NOTE_GNU) in the case that NT_GNU_BUILD_ID is defined. PR: 239669 Reported by: Yuichiro NAITO Sponsored by: The FreeBSD Foundation Event: EuroBSDCon FreeBSD DevSummit 2019 --- sys/sys/elf_common.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sys/sys/elf_common.h b/sys/sys/elf_common.h index 00d7dd4f4122..69aa1393fc74 100644 --- a/sys/sys/elf_common.h +++ b/sys/sys/elf_common.h @@ -769,6 +769,12 @@ typedef struct { #define LL_DELAY_LOAD 0x10 #define LL_DELTA 0x20 +/* Note section names */ +#define ELF_NOTE_FREEBSD "FreeBSD" +#define ELF_NOTE_NETBSD "NetBSD" +#define ELF_NOTE_SOLARIS "SUNW Solaris" +#define ELF_NOTE_GNU "GNU" + /* Values for n_type used in executables. */ #define NT_FREEBSD_ABI_TAG 1 #define NT_FREEBSD_NOINIT_TAG 2 From 61b8a4af71cb9ef0a155a9eed93ed7ea5a958aa1 Mon Sep 17 00:00:00 2001 From: Andrew Gallatin Date: Fri, 20 Sep 2019 09:36:07 +0000 Subject: [PATCH 08/30] remove redundant "ktls" in KTLS thr name This reducesthe string width of the ktls thread name and improves "ps" output. Glanced at by: jhb Event: EuroBSDCon hackathon Sponsored by: Netflix --- sys/kern/uipc_ktls.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/kern/uipc_ktls.c b/sys/kern/uipc_ktls.c index 62838a356f55..5736be83b6a6 100644 --- a/sys/kern/uipc_ktls.c +++ b/sys/kern/uipc_ktls.c @@ -349,7 +349,7 @@ ktls_init(void *dummy __unused) STAILQ_INIT(&ktls_wq[i].head); mtx_init(&ktls_wq[i].mtx, "ktls work queue", NULL, MTX_DEF); error = kproc_kthread_add(ktls_work_thread, &ktls_wq[i], - &ktls_proc, &td, 0, 0, "KTLS", "ktls_thr_%d", i); + &ktls_proc, &td, 0, 0, "KTLS", "thr_%d", i); if (error) panic("Can't add KTLS thread %d error %d", i, error); From af3ccc0740370e4bd2d48c28fdfa509d5869b10a Mon Sep 17 00:00:00 2001 From: Baptiste Daroussin Date: Fri, 20 Sep 2019 09:45:38 +0000 Subject: [PATCH 09/30] Ensure libthr is always built before libprivatezstd when building the startup libs Reported by: "Galazka, Krzysztof" --- Makefile.inc1 | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile.inc1 b/Makefile.inc1 index c5c3db8318e9..17a7569e232c 100644 --- a/Makefile.inc1 +++ b/Makefile.inc1 @@ -2832,6 +2832,7 @@ _lib_casper= lib/libcasper lib/libpjdlog__L: lib/libutil__L lib/libcasper__L: lib/libnv__L lib/liblzma__L: lib/libthr__L +lib/libzstd__L: lib/libthr__L _generic_libs= ${_cddl_lib} gnu/lib ${_kerberos5_lib} lib ${_secure_lib} usr.bin/lex/lib .if ${MK_IPFILTER} != "no" From 4e792e431a92f12f2be7acb20d78f7f2637d659c Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Fri, 20 Sep 2019 10:56:13 +0000 Subject: [PATCH 10/30] The maximum TD size is 31 and not 15. Found at: EuroBSDcon 2019 MFC after: 1 week Sponsored by: Mellanox Technologies --- sys/dev/usb/controller/xhci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/dev/usb/controller/xhci.c b/sys/dev/usb/controller/xhci.c index 0a1e5c95c41d..1bfdddd7d716 100644 --- a/sys/dev/usb/controller/xhci.c +++ b/sys/dev/usb/controller/xhci.c @@ -2003,7 +2003,7 @@ xhci_setup_generic_chain_sub(struct xhci_std_temp *temp) /* clear TD SIZE to zero, hence this is the last TRB */ /* remove chain bit because this is the last data TRB in the chain */ - td->td_trb[td->ntrb - 1].dwTrb2 &= ~htole32(XHCI_TRB_2_TDSZ_SET(15)); + td->td_trb[td->ntrb - 1].dwTrb2 &= ~htole32(XHCI_TRB_2_TDSZ_SET(31)); td->td_trb[td->ntrb - 1].dwTrb3 &= ~htole32(XHCI_TRB_3_CHAIN_BIT); /* remove CHAIN-BIT from last LINK TRB */ td->td_trb[td->ntrb].dwTrb3 &= ~htole32(XHCI_TRB_3_CHAIN_BIT); From 4631d7f71787c707ce5a37a337d96c82644d8f3d Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Fri, 20 Sep 2019 11:00:02 +0000 Subject: [PATCH 11/30] Increase the maximum user-space buffer size from 256kBytes to 32MBytes for libusb. This is useful for speeding up large data transfers while reducing the interrupt rate. Found at: EuroBSDcon 2019 MFC after: 1 week Sponsored by: Mellanox Technologies --- sys/dev/usb/usb_ioctl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/dev/usb/usb_ioctl.h b/sys/dev/usb/usb_ioctl.h index e7e63fb9a895..c4023cab5f16 100644 --- a/sys/dev/usb/usb_ioctl.h +++ b/sys/dev/usb/usb_ioctl.h @@ -224,7 +224,7 @@ struct usb_fs_uninit { } USB_IOCTL_STRUCT_ALIGN(1); struct usb_fs_open { -#define USB_FS_MAX_BUFSIZE (1 << 18) +#define USB_FS_MAX_BUFSIZE (1 << 25) /* 32 MBytes */ uint32_t max_bufsize; #define USB_FS_MAX_FRAMES (1U << 12) #define USB_FS_MAX_FRAMES_PRE_SCALE (1U << 31) /* for ISOCHRONOUS transfers */ From 7fca0e69f608b36b0e5e2c9b5037ca2ec06a96de Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Fri, 20 Sep 2019 11:28:45 +0000 Subject: [PATCH 12/30] Add quirk for XHCI(4) controllers to support USB control transfers above 1Kbyte. It might look like some XHCI(4) controllers do not support when the USB control transfer is split using a link TRB. The next NORMAL TRB after the link TRB is simply failing with XHCI error code 4. The quirk ensures we allocate a 64Kbyte buffer so that the data stage TRB is not broken with a link TRB. Found at: EuroBSDcon 2019 MFC after: 1 week Sponsored by: Mellanox Technologies --- sys/dev/usb/controller/xhci.c | 3 +++ sys/dev/usb/usb_bus.h | 1 + sys/dev/usb/usb_transfer.c | 33 +++++++++++++++++++++++++++++++-- 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/sys/dev/usb/controller/xhci.c b/sys/dev/usb/controller/xhci.c index 1bfdddd7d716..a6d62aa0bf15 100644 --- a/sys/dev/usb/controller/xhci.c +++ b/sys/dev/usb/controller/xhci.c @@ -601,6 +601,9 @@ xhci_init(struct xhci_softc *sc, device_t self, uint8_t dma32) device_printf(self, "%d bytes context size, %d-bit DMA\n", sc->sc_ctx_is_64_byte ? 64 : 32, (int)sc->sc_bus.dma_bits); + /* enable 64Kbyte control endpoint quirk */ + sc->sc_bus.control_ep_quirk = 1; + temp = XREAD4(sc, capa, XHCI_HCSPARAMS1); /* get number of device slots */ diff --git a/sys/dev/usb/usb_bus.h b/sys/dev/usb/usb_bus.h index 710436c16eb9..9f8586e6e9b2 100644 --- a/sys/dev/usb/usb_bus.h +++ b/sys/dev/usb/usb_bus.h @@ -131,6 +131,7 @@ struct usb_bus { uint8_t do_probe; /* set if USB should be re-probed */ uint8_t no_explore; /* don't explore USB ports */ uint8_t dma_bits; /* number of DMA address lines */ + uint8_t control_ep_quirk; /* need 64kByte buffer for data stage */ }; #endif /* _USB_BUS_H_ */ diff --git a/sys/dev/usb/usb_transfer.c b/sys/dev/usb/usb_transfer.c index 7682289831d6..da3d911563a6 100644 --- a/sys/dev/usb/usb_transfer.c +++ b/sys/dev/usb/usb_transfer.c @@ -106,6 +106,33 @@ static const struct usb_config usb_control_ep_cfg[USB_CTRL_XFER_MAX] = { }, }; +static const struct usb_config usb_control_ep_quirk_cfg[USB_CTRL_XFER_MAX] = { + + /* This transfer is used for generic control endpoint transfers */ + + [0] = { + .type = UE_CONTROL, + .endpoint = 0x00, /* Control endpoint */ + .direction = UE_DIR_ANY, + .bufsize = 65535, /* bytes */ + .callback = &usb_request_callback, + .usb_mode = USB_MODE_DUAL, /* both modes */ + }, + + /* This transfer is used for generic clear stall only */ + + [1] = { + .type = UE_CONTROL, + .endpoint = 0x00, /* Control pipe */ + .direction = UE_DIR_ANY, + .bufsize = sizeof(struct usb_device_request), + .callback = &usb_do_clear_stall_callback, + .timeout = 1000, /* 1 second */ + .interval = 50, /* 50ms */ + .usb_mode = USB_MODE_HOST, + }, +}; + /* function prototypes */ static void usbd_update_max_frame_size(struct usb_xfer *); @@ -1021,7 +1048,8 @@ usbd_transfer_setup(struct usb_device *udev, * context, else there is a chance of * deadlock! */ - if (setup_start == usb_control_ep_cfg) + if (setup_start == usb_control_ep_cfg || + setup_start == usb_control_ep_quirk_cfg) info->done_p = USB_BUS_CONTROL_XFER_PROC(udev->bus); else if (xfer_mtx == &Giant) @@ -3149,7 +3177,8 @@ usbd_ctrl_transfer_setup(struct usb_device *udev) */ iface_index = 0; if (usbd_transfer_setup(udev, &iface_index, - udev->ctrl_xfer, usb_control_ep_cfg, USB_CTRL_XFER_MAX, NULL, + udev->ctrl_xfer, udev->bus->control_ep_quirk ? + usb_control_ep_quirk_cfg : usb_control_ep_cfg, USB_CTRL_XFER_MAX, NULL, &udev->device_mtx)) { DPRINTFN(0, "could not setup default " "USB transfer\n"); From 39404490b742f23c70efc29f6be0d26f6808bd44 Mon Sep 17 00:00:00 2001 From: Justin Hibbits Date: Fri, 20 Sep 2019 13:35:28 +0000 Subject: [PATCH 13/30] powerpc/loader: Install ubldr without stripping Summary: Install's strip capability, by way of strip(1), doesn't seem to work correctly on msdosfs, and instead ends up truncating the resulting binary to 0-length. As a workaround, don't strip ubldr(8). This fixes installworld on Book-E ubldr-based platforms, which prior to this would need to manually install ubldr separately after installworld, in order to have a functional ubldr. The same thing could be done on PowerNV platforms that use msdosfs /boot volumes, since loader and loader.kboot, etc, all get truncated to 0 on install. However, PowerNV does not use loader, instead loading from petitboot, so it's not really necessary at this time. Reviewed by: kevans Differential Revision: https://reviews.freebsd.org/D21725 --- stand/powerpc/uboot/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/stand/powerpc/uboot/Makefile b/stand/powerpc/uboot/Makefile index 9124507397ad..0a26152483d9 100644 --- a/stand/powerpc/uboot/Makefile +++ b/stand/powerpc/uboot/Makefile @@ -13,6 +13,7 @@ LOADER_BZIP2_SUPPORT?= no BINDIR= /boot/uboot PROG= ubldr +STRIP= NEWVERSWHAT= "U-Boot loader" ${MACHINE_ARCH} INSTALLFLAGS= -b From b1de37fadd8d5d672065b6a9f9839b021fbeb433 Mon Sep 17 00:00:00 2001 From: Daichi GOTO Date: Fri, 20 Sep 2019 17:37:23 +0000 Subject: [PATCH 14/30] top(1): support multibyte characters in command names (ARGV array) depending on locale. - add setlocale() - remove printable() function - add VIS_OCTAL and VIS_SAFE to the flag of strvisx() to display non-printable characters that do not use C-style backslash sequences in three digit octal sequence, or remove it This change allows multibyte characters to be displayed according to locale. If it is recognized as a non-display character according to the locale, it is displayed in three digit octal sequence. Reference: https://www.mail-archive.com/svn-src-all@freebsd.org/msg165751.html https://www.mail-archive.com/svn-src-all@freebsd.org/msg165766.html https://www.mail-archive.com/svn-src-all@freebsd.org/msg165833.html https://www.mail-archive.com/svn-src-all@freebsd.org/msg165846.html https://www.mail-archive.com/svn-src-all@freebsd.org/msg165891.html Submitted by: hrs Differential Revision: https://reviews.freebsd.org/D16204 --- usr.bin/top/display.c | 25 ------------------------- usr.bin/top/display.h | 1 - usr.bin/top/machine.c | 4 ++-- usr.bin/top/top.1 | 6 +++++- usr.bin/top/top.c | 6 ++++++ 5 files changed, 13 insertions(+), 29 deletions(-) diff --git a/usr.bin/top/display.c b/usr.bin/top/display.c index 00534fd7f411..38e6657401d0 100644 --- a/usr.bin/top/display.c +++ b/usr.bin/top/display.c @@ -1291,31 +1291,6 @@ line_update(char *old, char *new, int start, int line) } } -/* - * printable(str) - make the string pointed to by "str" into one that is - * printable (i.e.: all ascii), by converting all non-printable - * characters into '?'. Replacements are done in place and a pointer - * to the original buffer is returned. - */ - -char * -printable(char str[]) -{ - char *ptr; - char ch; - - ptr = str; - while ((ch = *ptr) != '\0') - { - if (!isprint(ch)) - { - *ptr = '?'; - } - ptr++; - } - return(str); -} - void i_uptime(struct timeval *bt, time_t *tod) { diff --git a/usr.bin/top/display.h b/usr.bin/top/display.h index 546f21ce34b0..ff3ea8d3fe9a 100644 --- a/usr.bin/top/display.h +++ b/usr.bin/top/display.h @@ -11,7 +11,6 @@ int display_updatecpus(struct statics *statics); void clear_message(void); int display_resize(void); void i_header(const char *text); -char *printable(char *string); void display_header(int t); int display_init(struct statics *statics); void i_arc(int *stats); diff --git a/usr.bin/top/machine.c b/usr.bin/top/machine.c index dd2b7a110419..edfe3e659f13 100644 --- a/usr.bin/top/machine.c +++ b/usr.bin/top/machine.c @@ -1003,7 +1003,7 @@ format_next_process(struct handle * xhandle, char *(*get_userid)(int), int flags len = (argbuflen - (dst - argbuf) - 1) / 4; strvisx(dst, src, MIN(strlen(src), len), - VIS_NL | VIS_CSTYLE); + VIS_NL | VIS_CSTYLE | VIS_OCTAL | VIS_SAFE); while (*dst != '\0') dst++; if ((argbuflen - (dst - argbuf) - 1) / 4 > 0) @@ -1102,7 +1102,7 @@ format_next_process(struct handle * xhandle, char *(*get_userid)(int), int flags sbuf_printf(procbuf, "%6s ", format_time(cputime)); sbuf_printf(procbuf, "%6.2f%% ", ps.wcpu ? 100.0 * weighted_cpu(PCTCPU(pp), pp) : 100.0 * PCTCPU(pp)); } - sbuf_printf(procbuf, "%s", printable(cmdbuf)); + sbuf_printf(procbuf, "%s", cmdbuf); free(cmdbuf); return (sbuf_data(procbuf)); } diff --git a/usr.bin/top/top.1 b/usr.bin/top/top.1 index a2858003d465..83c2c3440893 100644 --- a/usr.bin/top/top.1 +++ b/usr.bin/top/top.1 @@ -1,5 +1,5 @@ .\" $FreeBSD$ -.Dd October 2, 2018 +.Dd September 20, 2019 .Dt TOP 1 .Os .Sh NAME @@ -192,6 +192,10 @@ or \*(lqall\*(rq. Boolean flags are toggles. A second specification of any of these options will negate the first. +.Pp +The display of command names changes according to the locale. +If command names displayed in the locale settings are recognized as +non-display characters, they are displayed in three digit octal sequence. .Sh "INTERACTIVE MODE" When .Nm diff --git a/usr.bin/top/top.c b/usr.bin/top/top.c index 650789689b6b..01cad421b64c 100644 --- a/usr.bin/top/top.c +++ b/usr.bin/top/top.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -265,6 +266,11 @@ main(int argc, const char *argv[]) setbuffer(stdout, stdoutbuf, Buffersize); #endif + if (setlocale(LC_ALL, "") == NULL) { + fprintf(stderr, "invalid locale.\n"); + exit(1); + } + mypid = getpid(); /* get our name */ From bb7b569d3654d76f6ebcc869e127d5e221141c32 Mon Sep 17 00:00:00 2001 From: Kyle Evans Date: Fri, 20 Sep 2019 19:43:40 +0000 Subject: [PATCH 15/30] loader: Respect loader_color=YES for serial consoles It's not uncommon these days for the terminals attached to serial consoles to support ANSI escape sequences. However, we assume escape sequences may break some serial consoles and default to not using them when boot_serial or boot_multicons (or if console contains "comconsole" in the forth loader) for broader compatibility. We also have loader_color which can be explicitly set to "NO" to disable the use of ANSI escape sequences. The problem is that loader_color=YES gets ignored when boot_serial=YES or boot_multicons=YES (or when console contains "comconsole" in the forth loader). To fix, the existing default behavior remains unchanged when loader_color is unset, loader_color=NO explicitly disables the use of ANSI escape sequences still, and the change is that loader_color=YES can now be used to explicitly allow ANSI escapes when a serial console is enabled. Submitted by: Ryan Moeller Reviewed by: tsoome (forth), kevans (lua) MFC after: 1 week Sponsored by: iXsystems, Inc. (Ryan) Differential Revision: https://reviews.freebsd.org/D21732 --- stand/forth/color.4th | 18 ++++++++++++------ stand/lua/color.lua | 4 +--- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/stand/forth/color.4th b/stand/forth/color.4th index 65e6de905ac6..fc5a4d564d0a 100644 --- a/stand/forth/color.4th +++ b/stand/forth/color.4th @@ -27,12 +27,14 @@ marker task-color.4th \ This function returns FALSE if the `loader_color' environment variable is set -\ to NO, no, or 0. Otherwise, TRUE is returned (unless booting serial). +\ to NO, no, or 0. It returns TRUE if `loader_color' is set to any other value. +\ If `loader_color' is unset, TRUE is returned (unless booting serial). \ -: loader_color? ( -- N ) +: loader_color? ( -- t ) s" loader_color" getenv dup -1 <> if - + \ `loader_color' is set. + \ Check if it is explicitly disabled. 2dup s" NO" compare-insensitive 0= if 2drop FALSE exit @@ -42,8 +44,12 @@ marker task-color.4th FALSE exit then drop + \ It is enabled. + TRUE + else + \ `loader_color' is unset. + \ Default to using color unless serial boot is active. + drop + boot_serial? 0= then - drop - - boot_serial? if FALSE else TRUE then ; diff --git a/stand/lua/color.lua b/stand/lua/color.lua index 994e7cb1edcb..af4e1f4090ad 100644 --- a/stand/lua/color.lua +++ b/stand/lua/color.lua @@ -49,9 +49,7 @@ color.DIM = 2 function color.isEnabled() local c = loader.getenv("loader_color") if c ~= nil then - if c:lower() == "no" or c == "0" then - return false - end + return c:lower() ~= "no" and c ~= "0" end return not core.isSerialBoot() end From 5fdac752228ebf4061ae050558c0db1147daab61 Mon Sep 17 00:00:00 2001 From: Kyle Evans Date: Fri, 20 Sep 2019 20:47:10 +0000 Subject: [PATCH 16/30] msdosfs: do not deget unlinked denodes When a file is unlinked, the denode is not reclaimed until the last reference is dropped, but the directory entry is immediately up for reuse. This is a problem later when createde goes to grab a denode for the newly created entry -- we search the hash and find a dead denode, then return that without even bumping the reference count and the data later gets truncated when the the last reference to the unlinked file is dropped. This manifested itself as a broken in-place strip(1) on msdosfs. elfcopy will do a sequence incredibly roughly like this: open("/mnt/foo", ...) => fd 3 mmap() unlink("/mnt/foo") open("/mnt/foo", ...) => fd 4 write(4, ...) close(4) close(3) and the resulting file would be truncated, but the write succeeded, as long as a reference to the unlinked file had not been closed. Some archaeology indicates that this bug has likely existed since msdosfs was converted to use vfs_hash instead of a home rolled hash implementation in r143570. Prior to that point, the hashget implementation would do a refcnt check while searching and explicitly only return a denode with de_refcnt != 0. vfs_hash did not yet have the callback that it does today, so this slipped away and did not come back when it later grew that functionality. The comment indicating that we want to skip these denodes has been updated to reflect where this is actually done. My repo-diving session seems to indicate that the refcnt check was likely never actually below the comment, to be pedantic, but instead a detail wrapped up in the hashget implementation since the beginning of its inclusion into FreeBSD. This bug was the cause behind the issue addressed in r352557. Reported by: jhibbits Reviewed by: kib MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D21731 --- sys/fs/msdosfs/msdosfs_denode.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sys/fs/msdosfs/msdosfs_denode.c b/sys/fs/msdosfs/msdosfs_denode.c index 858cf1b58908..b78acb4207b1 100644 --- a/sys/fs/msdosfs/msdosfs_denode.c +++ b/sys/fs/msdosfs/msdosfs_denode.c @@ -79,7 +79,7 @@ de_vncmpf(struct vnode *vp, void *arg) a = arg; de = VTODE(vp); - return (de->de_inode != *a); + return (de->de_inode != *a) || (de->de_refcnt <= 0); } /* @@ -124,8 +124,9 @@ deget(struct msdosfsmount *pmp, u_long dirclust, u_long diroffset, * address of "." entry. For root dir (if not FAT32) use cluster * MSDOSFSROOT, offset MSDOSFSROOT_OFS * - * NOTE: The check for de_refcnt > 0 below insures the denode being - * examined does not represent an unlinked but still open file. + * NOTE: de_vncmpf will explicitly skip any denodes that do not have + * a de_refcnt > 0. This insures that that we do not attempt to use + * a denode that represents an unlinked but still open file. * These files are not to be accessible even when the directory * entry that represented the file happens to be reused while the * deleted file is still open. From 740a5434e9d6d6277529b683fb8c69a23fac7fd4 Mon Sep 17 00:00:00 2001 From: Hiroki Sato Date: Sat, 21 Sep 2019 00:17:40 +0000 Subject: [PATCH 17/30] Add a workaround for servers which respond RPC_PROGNOTREGISTERED to a clnt_create() call even when it is actually a program version mismatch. Normally the server is supposed to return RPC_PROGVERSMISMATCH when it supports the specified program but not support the specified version. Some filers return RPC_PROGNOTREGISTERED to RQUOTA v2 calls and FreeBSD does not retry with the old v1 calls. This change fixes this failure scenario. Submitted by: Jian-Bo Liao PR: 236179 --- usr.bin/quota/quota.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr.bin/quota/quota.c b/usr.bin/quota/quota.c index f4481fecece6..71e63208884f 100644 --- a/usr.bin/quota/quota.c +++ b/usr.bin/quota/quota.c @@ -606,7 +606,7 @@ getnfsquota(struct statfs *fst, struct quotause *qup, long id, int quotatype) call_stat = callaurpc(host, RQUOTAPROG, EXT_RQUOTAVERS, RQUOTAPROC_GETQUOTA, (xdrproc_t)xdr_ext_getquota_args, (char *)&gq_args, (xdrproc_t)xdr_getquota_rslt, (char *)&gq_rslt); - if (call_stat == RPC_PROGVERSMISMATCH) { + if (call_stat == RPC_PROGVERSMISMATCH || call_stat == RPC_PROGNOTREGISTERED) { if (quotatype == USRQUOTA) { old_gq_args.gqa_pathp = cp + 1; old_gq_args.gqa_uid = id; From ecc2b89f96e1afd53c53d2dbf05aaa4bad7fe171 Mon Sep 17 00:00:00 2001 From: Hiroki Sato Date: Sat, 21 Sep 2019 00:44:37 +0000 Subject: [PATCH 18/30] Impove wording and move descriptions about locale to LC_CTYPE in the ENVIRONMENT section. --- usr.bin/top/top.1 | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/usr.bin/top/top.1 b/usr.bin/top/top.1 index 83c2c3440893..d1b0370eb756 100644 --- a/usr.bin/top/top.1 +++ b/usr.bin/top/top.1 @@ -1,5 +1,5 @@ .\" $FreeBSD$ -.Dd September 20, 2019 +.Dd September 21, 2019 .Dt TOP 1 .Os .Sh NAME @@ -66,6 +66,9 @@ It it useful when you want to watch applications, that puts their status information there. If the real name differs from argv[0], it will be displayed in parenthesis. +Non-printable characters in the command line are +encoded in C-style backslash sequences or +a three digit octal sequences. .It Fl b Use \*(lqbatch\*(rq mode. In this mode, all input from the terminal is @@ -192,10 +195,6 @@ or \*(lqall\*(rq. Boolean flags are toggles. A second specification of any of these options will negate the first. -.Pp -The display of command names changes according to the locale. -If command names displayed in the locale settings are recognized as -non-display characters, they are displayed in three digit octal sequence. .Sh "INTERACTIVE MODE" When .Nm @@ -426,6 +425,12 @@ bytes paged out to swap devices (last interval) .It Ev TOP Default set of arguments to .Nm . +.It Ev LC_CTYPE +The locale to use when displaying the +.Va argv +vector when +.Fl a +flag is specified. .El .Sh SEE ALSO .Xr kill 1 , From 685e059d948f77d33a05d7eaece0fe155ba897f4 Mon Sep 17 00:00:00 2001 From: Hiroki Sato Date: Sat, 21 Sep 2019 01:29:59 +0000 Subject: [PATCH 19/30] Fix build errors of test.c, which had been broken for a long time. This is a temporary fix and should be converted to a complete test scenarios by using this tool. --- usr.sbin/rpc.statd/Makefile | 5 +++-- usr.sbin/rpc.statd/test.c | 34 +++++++++++++++++----------------- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/usr.sbin/rpc.statd/Makefile b/usr.sbin/rpc.statd/Makefile index 5b0beb334785..4cbbb4639698 100644 --- a/usr.sbin/rpc.statd/Makefile +++ b/usr.sbin/rpc.statd/Makefile @@ -20,7 +20,8 @@ sm_inter_svc.c: ${RPCSRC} sm_inter.h: ${RPCSRC} ${RPCGEN} -h -o ${.TARGET} ${.ALLSRC} -test: test.c - cc -o test test.c -lrpcsvc +test: test.o + ${CC} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC} ${LIBADD:S/^/-l/} +CLEANFILES+= test test.o .include diff --git a/usr.sbin/rpc.statd/test.c b/usr.sbin/rpc.statd/test.c index 6df15011db3b..c3b342441781 100644 --- a/usr.sbin/rpc.statd/test.c +++ b/usr.sbin/rpc.statd/test.c @@ -1,14 +1,14 @@ - #ifndef lint static const char rcsid[] = "$FreeBSD$"; #endif /* not lint */ #include +#include +#include #include #include - /* Default timeout can be changed using clnt_control() */ static struct timeval TIMEOUT = { 25, 0 }; @@ -20,7 +20,8 @@ sm_stat_1(argp, clnt) static struct sm_stat_res res; bzero((char *)&res, sizeof(res)); - if (clnt_call(clnt, SM_STAT, xdr_sm_name, argp, xdr_sm_stat_res, &res, TIMEOUT) != RPC_SUCCESS) { + if (clnt_call(clnt, SM_STAT, (xdrproc_t)xdr_sm_name, argp, + (xdrproc_t)xdr_sm_stat_res, &res, TIMEOUT) != RPC_SUCCESS) { return (NULL); } return (&res); @@ -35,7 +36,8 @@ sm_mon_1(argp, clnt) static struct sm_stat_res res; bzero((char *)&res, sizeof(res)); - if (clnt_call(clnt, SM_MON, xdr_mon, argp, xdr_sm_stat_res, &res, TIMEOUT) != RPC_SUCCESS) { + if (clnt_call(clnt, SM_MON, (xdrproc_t)xdr_mon, argp, + (xdrproc_t)xdr_sm_stat_res, &res, TIMEOUT) != RPC_SUCCESS) { return (NULL); } return (&res); @@ -50,7 +52,8 @@ sm_unmon_1(argp, clnt) static struct sm_stat res; bzero((char *)&res, sizeof(res)); - if (clnt_call(clnt, SM_UNMON, xdr_mon_id, argp, xdr_sm_stat, &res, TIMEOUT) != RPC_SUCCESS) { + if (clnt_call(clnt, SM_UNMON, (xdrproc_t)xdr_mon_id, argp, + (xdrproc_t)xdr_sm_stat, &res, TIMEOUT) != RPC_SUCCESS) { return (NULL); } return (&res); @@ -65,7 +68,8 @@ sm_unmon_all_1(argp, clnt) static struct sm_stat res; bzero((char *)&res, sizeof(res)); - if (clnt_call(clnt, SM_UNMON_ALL, xdr_my_id, argp, xdr_sm_stat, &res, TIMEOUT) != RPC_SUCCESS) { + if (clnt_call(clnt, SM_UNMON_ALL, (xdrproc_t)xdr_my_id, argp, + (xdrproc_t)xdr_sm_stat, &res, TIMEOUT) != RPC_SUCCESS) { return (NULL); } return (&res); @@ -80,7 +84,8 @@ sm_simu_crash_1(argp, clnt) static char res; bzero((char *)&res, sizeof(res)); - if (clnt_call(clnt, SM_SIMU_CRASH, xdr_void, argp, xdr_void, &res, TIMEOUT) != RPC_SUCCESS) { + if (clnt_call(clnt, SM_SIMU_CRASH, (xdrproc_t)xdr_void, argp, + (xdrproc_t)xdr_void, &res, TIMEOUT) != RPC_SUCCESS) { return (NULL); } return ((void *)&res); @@ -119,25 +124,20 @@ int main(int argc, char **argv) { /* Hostname given */ struct sm_stat_res *res; - if (res = sm_mon_1(&mon, cli)) - { + + res = sm_mon_1(&mon, cli); + if (res) printf("Success!\n"); - } else - { printf("Fail\n"); - } } else { - if (out = sm_simu_crash_1(&dummy, cli)) - { + out = sm_simu_crash_1(&dummy, cli); + if (out) printf("Success!\n"); - } else - { printf("Fail\n"); - } } return 0; From aec74e0ce02ed907f703ecbc225bf714a146bdc9 Mon Sep 17 00:00:00 2001 From: Hiroki Sato Date: Sat, 21 Sep 2019 12:33:41 +0000 Subject: [PATCH 20/30] Fix warnings and set WARNS=6. --- usr.sbin/rpc.statd/Makefile | 4 +--- usr.sbin/rpc.statd/file.c | 4 ++-- usr.sbin/rpc.statd/statd.c | 15 ++++++++------- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/usr.sbin/rpc.statd/Makefile b/usr.sbin/rpc.statd/Makefile index 4cbbb4639698..0187d422ebaf 100644 --- a/usr.sbin/rpc.statd/Makefile +++ b/usr.sbin/rpc.statd/Makefile @@ -4,9 +4,7 @@ PROG= rpc.statd MAN= rpc.statd.8 SRCS= file.c sm_inter_svc.c sm_inter.h statd.c procs.c -CFLAGS+= -I. -WARNS?= 2 - +CFLAGS+= -I${.OBJDIR} LIBADD= rpcsvc CLEANFILES= sm_inter_svc.c sm_inter.h diff --git a/usr.sbin/rpc.statd/file.c b/usr.sbin/rpc.statd/file.c index ed5d00cc808c..d4fd3eda8882 100644 --- a/usr.sbin/rpc.statd/file.c +++ b/usr.sbin/rpc.statd/file.c @@ -201,8 +201,8 @@ void init_file(const char *filename) /* defective, re-create from scratch. */ if (!new_file) { - if ((status_file_len < HEADER_LEN) || (status_file_len - < (HEADER_LEN + sizeof(HostInfo) * status_info->noOfHosts)) ) + if ((status_file_len < (off_t)HEADER_LEN) || (status_file_len + < (off_t)(HEADER_LEN + sizeof(HostInfo) * status_info->noOfHosts)) ) { warnx("status file is corrupt"); new_file = TRUE; diff --git a/usr.sbin/rpc.statd/statd.c b/usr.sbin/rpc.statd/statd.c index b789f8149106..50368824756f 100644 --- a/usr.sbin/rpc.statd/statd.c +++ b/usr.sbin/rpc.statd/statd.c @@ -62,9 +62,9 @@ __FBSDID("$FreeBSD$"); int debug = 0; /* Controls syslog() calls for debug messages */ -char **hosts, *svcport_str = NULL; -int nhosts = 0; -int xcreated = 0; +static char **hosts, *svcport_str = NULL; +static int nhosts = 0; +static int xcreated = 0; static int mallocd_svcport = 0; static int *sock_fd; static int sock_fdcnt; @@ -86,7 +86,8 @@ main(int argc, char **argv) void *nc_handle; in_port_t svcport; int ch, i, s; - char *endptr, **hosts_bak; + char *endptr; + char **hosts_bak; int have_v6 = 1; int maxrec = RPC_MAXDATASIZE; int attempt_cnt, port_len, port_pos, ret; @@ -156,7 +157,7 @@ main(int argc, char **argv) if (hosts == NULL) out_of_mem(); - hosts[0] = "*"; + hosts[0] = strdup("*"); nhosts = 1; } else { hosts_bak = hosts; @@ -172,7 +173,7 @@ main(int argc, char **argv) hosts = hosts_bak; nhosts += 2; - hosts[nhosts - 2] = "::1"; + hosts[nhosts - 2] = strdup("::1"); } else { hosts_bak = realloc(hosts, (nhosts + 1) * sizeof(char *)); if (hosts_bak == NULL) { @@ -186,7 +187,7 @@ main(int argc, char **argv) hosts = hosts_bak; } } - hosts[nhosts - 1] = "127.0.0.1"; + hosts[nhosts - 1] = strdup("127.0.0.1"); } attempt_cnt = 1; From 34302d266a8b7f5f9af564aa53ba20d350135743 Mon Sep 17 00:00:00 2001 From: Hiroki Sato Date: Sat, 21 Sep 2019 13:34:06 +0000 Subject: [PATCH 21/30] - Revert WARNS to 2 because of mismatch between (xdrproc_t) and xdr_void(). - Add prototype of from_addr(). --- usr.sbin/rpc.statd/Makefile | 3 +++ usr.sbin/rpc.statd/procs.c | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/usr.sbin/rpc.statd/Makefile b/usr.sbin/rpc.statd/Makefile index 0187d422ebaf..c857f62790dc 100644 --- a/usr.sbin/rpc.statd/Makefile +++ b/usr.sbin/rpc.statd/Makefile @@ -7,6 +7,9 @@ SRCS= file.c sm_inter_svc.c sm_inter.h statd.c procs.c CFLAGS+= -I${.OBJDIR} LIBADD= rpcsvc +# XXX: mismatch between (xdrproc_t) and xdr_void(). +WARNS?= 2 + CLEANFILES= sm_inter_svc.c sm_inter.h RPCSRC= ${SYSROOT:U${DESTDIR}}/usr/include/rpcsvc/sm_inter.x diff --git a/usr.sbin/rpc.statd/procs.c b/usr.sbin/rpc.statd/procs.c index 517c3f62414e..3f1b60bd3f22 100644 --- a/usr.sbin/rpc.statd/procs.c +++ b/usr.sbin/rpc.statd/procs.c @@ -52,9 +52,10 @@ __FBSDID("$FreeBSD$"); #include "statd.h" +static const char *from_addr(struct sockaddr *); + static const char * -from_addr(saddr) - struct sockaddr *saddr; +from_addr(struct sockaddr *saddr) { static char inet_buf[INET6_ADDRSTRLEN]; From e100548404f355f626402efa6c5c5c56e674bdd8 Mon Sep 17 00:00:00 2001 From: Mateusz Piotrowski <0mp@FreeBSD.org> Date: Sat, 21 Sep 2019 14:16:37 +0000 Subject: [PATCH 22/30] ascii(7): Add STANDARDS section and update HISTORY section PR: 240727 Submitted by: Gordon Bergling Approved by: src (imp) Event: EuroBSDcon 2019 --- share/man/man7/ascii.7 | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/share/man/man7/ascii.7 b/share/man/man7/ascii.7 index 3b5c120cb004..713a4922e759 100644 --- a/share/man/man7/ascii.7 +++ b/share/man/man7/ascii.7 @@ -28,7 +28,7 @@ .\" @(#)ascii.7 8.1 (Berkeley) 6/5/93 .\" $FreeBSD$ .\" -.Dd October 30, 2017 +.Dd September 21, 2019 .Dt ASCII 7 .Os .Sh NAME @@ -146,8 +146,15 @@ ESC ; [ { 11011 .Bl -tag -width /usr/share/misc/ascii -compact .It Pa /usr/share/misc/ascii .El +.Sh STANDARDS +.Rs +.%T Information Systems - Coded Character Sets - 7-Bit American National\ + Standard Code for Information Interchange (7-Bit ASCII) +.%R INCITS 4-1986[R2017] +.%Q InterNational Committee for Information Technology Standards +.Re .Sh HISTORY An .Nm manual page appeared in -.At v7 . +.At v2 . From a811237df2db8e1ccd19113e1da3f60dc34a8be3 Mon Sep 17 00:00:00 2001 From: Mateusz Piotrowski <0mp@FreeBSD.org> Date: Sat, 21 Sep 2019 15:01:11 +0000 Subject: [PATCH 23/30] jot.1: Explain default argument values more precisely The way jot(1) defaults missing arguments doesn't match the behaviour described in the manpage, which states that with fewer than 3 arguments missing values are supplied from left to right. In fact, with one or two arguments, the last (s which is step size or seed) defaults to 1 (or -1 if begin and end specify a descending range), and then omitted arguments are set to default starting with the leftmost until three arguments are available. This is why `jot 2 1000` prints 1000 and 1001 instead of 1000 and 100. PR: 135475 Submitted by: Jonathan McKeown Approved by: doc (bcr) Differential Revision: https://reviews.freebsd.org/D21736 Event: EuroBSDcon 2019 --- usr.bin/jot/jot.1 | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/usr.bin/jot/jot.1 b/usr.bin/jot/jot.1 index d2e38c79aa45..5ba57d9117ad 100644 --- a/usr.bin/jot/jot.1 +++ b/usr.bin/jot/jot.1 @@ -28,7 +28,7 @@ .\" @(#)jot.1 8.1 (Berkeley) 6/6/93 .\" $FreeBSD$ .\" -.Dd April 7, 2015 +.Dd September 21, 2019 .Dt JOT 1 .Os .Sh NAME @@ -108,14 +108,16 @@ Any three of these arguments determines the fourth. If four are specified and the given and computed values of .Ar reps conflict, the lower value is used. -If fewer than three are specified, defaults are assigned -left to right, except for +If one or two are specified, defaults are assigned +starting with .Ar s , -which assumes a default of 1 or -1 if both +which assumes a default of 1 (or -1 if .Ar begin and .Ar end -are given. +specify a descending range). +Then the default values are assigned to the leftmost omitted arguments until +three arguments are set. .Pp Defaults for the four arguments are, respectively, 100, 1, 100, and 1, except that when random data are requested, From 36d151a2376868dc3bc9a758ab7c9422d16b98ab Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Sat, 21 Sep 2019 15:38:08 +0000 Subject: [PATCH 24/30] Allocate callout wheel from the respective memory domain. MFC after: 1 week --- sys/kern/kern_timeout.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sys/kern/kern_timeout.c b/sys/kern/kern_timeout.c index c069e5b3bb9b..b1fb59159e28 100644 --- a/sys/kern/kern_timeout.c +++ b/sys/kern/kern_timeout.c @@ -50,6 +50,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -325,8 +326,9 @@ callout_cpu_init(struct callout_cpu *cc, int cpu) mtx_init(&cc->cc_lock, "callout", NULL, MTX_SPIN | MTX_RECURSE); SLIST_INIT(&cc->cc_callfree); cc->cc_inited = 1; - cc->cc_callwheel = malloc(sizeof(struct callout_list) * callwheelsize, - M_CALLOUT, M_WAITOK); + cc->cc_callwheel = malloc_domainset(sizeof(struct callout_list) * + callwheelsize, M_CALLOUT, + DOMAINSET_PREF(pcpu_find(cpu)->pc_domain), M_WAITOK); for (i = 0; i < callwheelsize; i++) LIST_INIT(&cc->cc_callwheel[i]); TAILQ_INIT(&cc->cc_expireq); From 0c3d878d1ca2940a0ed8734e19963187c0038352 Mon Sep 17 00:00:00 2001 From: Sean Eric Fagan Date: Sat, 21 Sep 2019 17:54:42 +0000 Subject: [PATCH 25/30] Fix a regression introduced in r344601, and work properly with the -v and -n options. PR: 240640 Reported by: Andriy Gapon Reviewed by: avg MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D21709 --- .../opensolaris/lib/libzfs/common/libzfs_sendrecv.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c index cf5aedafca7e..290b8926d3a3 100644 --- a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c +++ b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c @@ -1289,13 +1289,11 @@ dump_snapshot(zfs_handle_t *zhp, void *arg) fromorigin = sdd->prevsnap[0] == '\0' && (sdd->fromorigin || sdd->replicate); - if (sdd->progress && sdd->dryrun) { + if (sdd->verbose || sdd->progress) { (void) estimate_ioctl(zhp, sdd->prevsnap_obj, fromorigin, flags, &size); sdd->size += size; - } - if (sdd->verbose) { send_print_verbose(fout, zhp->zfs_name, sdd->prevsnap[0] ? sdd->prevsnap : NULL, size, sdd->parsable); @@ -1663,7 +1661,7 @@ zfs_send_resume(libzfs_handle_t *hdl, sendflags_t *flags, int outfd, fromname = name; } - if (flags->progress) { + if (flags->progress || flags->verbose) { error = lzc_send_space(zhp->zfs_name, fromname, lzc_flags, &size); if (error == 0) @@ -1933,7 +1931,7 @@ zfs_send(zfs_handle_t *zhp, const char *fromsnap, const char *tosnap, sdd.cleanup_fd = -1; sdd.snapholds = NULL; } - if (flags->progress || sdd.snapholds != NULL) { + if (flags->progress || flags->verbose || sdd.snapholds != NULL) { /* * Do a verbose no-op dry run to get all the verbose output * or to gather snapshot hold's before generating any data, From 6320faed1067c1d9adba3f7d7ecf8fbda92c1190 Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Sat, 21 Sep 2019 17:59:15 +0000 Subject: [PATCH 26/30] amd64 pmap: Fix formats for 64bit addresses in ddb and sysctl output. Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D21737 --- sys/amd64/amd64/pmap.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c index 0deeded676d3..5798c8253d1e 100644 --- a/sys/amd64/amd64/pmap.c +++ b/sys/amd64/amd64/pmap.c @@ -10030,13 +10030,13 @@ sysctl_kmaps_dump(struct sbuf *sb, struct pmap_kernel_map_range *range, mode = "WC"; break; default: - printf("%s: unknown PAT mode %#x for range %#016lx-%#016lx\n", + printf("%s: unknown PAT mode %#x for range 0x%016lx-0x%016lx\n", __func__, i, range->sva, eva); mode = "??"; break; } - sbuf_printf(sb, "%#016lx-%#016lx r%c%c%c%c %s %d %d %d\n", + sbuf_printf(sb, "0x%016lx-0x%016lx r%c%c%c%c %s %d %d %d\n", range->sva, eva, (range->attrs & X86_PG_RW) != 0 ? 'w' : '-', (range->attrs & pg_nx) != 0 ? '-' : 'x', @@ -10271,25 +10271,25 @@ DB_SHOW_COMMAND(pte, pmap_print_pte) PG_V = pmap_valid_bit(pmap); pml4 = pmap_pml4e(pmap, va); - db_printf("VA %#016lx pml4e %#016lx", va, *pml4); + db_printf("VA 0x%016lx pml4e 0x%016lx", va, *pml4); if ((*pml4 & PG_V) == 0) { db_printf("\n"); return; } pdp = pmap_pml4e_to_pdpe(pml4, va); - db_printf(" pdpe %#016lx", *pdp); + db_printf(" pdpe 0x%016lx", *pdp); if ((*pdp & PG_V) == 0 || (*pdp & PG_PS) != 0) { db_printf("\n"); return; } pde = pmap_pdpe_to_pde(pdp, va); - db_printf(" pde %#016lx", *pde); + db_printf(" pde 0x%016lx", *pde); if ((*pde & PG_V) == 0 || (*pde & PG_PS) != 0) { db_printf("\n"); return; } pte = pmap_pde_to_pte(pde, va); - db_printf(" pte %#016lx\n", *pte); + db_printf(" pte 0x%016lx\n", *pte); } DB_SHOW_COMMAND(phys2dmap, pmap_phys2dmap) From 95aafd6900dd086461328f77c35969f07dd0e100 Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Sat, 21 Sep 2019 18:00:23 +0000 Subject: [PATCH 27/30] Make non-ASLR pie base tunable. Sponsored by: The FreeBSD Foundation MFC after: 1 week --- sys/kern/imgact_elf.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c index 305e49c2e223..4678d7465b82 100644 --- a/sys/kern/imgact_elf.c +++ b/sys/kern/imgact_elf.c @@ -135,6 +135,11 @@ SYSCTL_INT(_kern_elf32, OID_AUTO, read_exec, CTLFLAG_RW, &i386_read_exec, 0, "enable execution from readable segments"); #endif +static u_long __elfN(pie_base) = ET_DYN_LOAD_ADDR; +SYSCTL_ULONG(__CONCAT(_kern_elf, __ELF_WORD_SIZE), OID_AUTO, pie_base, + CTLFLAG_RWTUN, &__elfN(pie_base), 0, + "PIE load base without randomization"); + SYSCTL_NODE(__CONCAT(_kern_elf, __ELF_WORD_SIZE), OID_AUTO, aslr, CTLFLAG_RW, 0, ""); #define ASLR_NODE_OID __CONCAT(__CONCAT(_kern_elf, __ELF_WORD_SIZE), _aslr) @@ -1146,13 +1151,13 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *imgp) if (baddr == 0) { if ((sv->sv_flags & SV_ASLR) == 0 || (fctl0 & NT_FREEBSD_FCTL_ASLR_DISABLE) != 0) - et_dyn_addr = ET_DYN_LOAD_ADDR; + et_dyn_addr = __elfN(pie_base); else if ((__elfN(pie_aslr_enabled) && (imgp->proc->p_flag2 & P2_ASLR_DISABLE) == 0) || (imgp->proc->p_flag2 & P2_ASLR_ENABLE) != 0) et_dyn_addr = ET_DYN_ADDR_RAND; else - et_dyn_addr = ET_DYN_LOAD_ADDR; + et_dyn_addr = __elfN(pie_base); } } From cbba2cb367c2e8ebbf99b9e74a96fa1501f70093 Mon Sep 17 00:00:00 2001 From: Mateusz Guzik Date: Sat, 21 Sep 2019 19:05:38 +0000 Subject: [PATCH 28/30] lockprof: use CPUFOREACH and drop always false lp_cpu NULL checks Sponsored by: The FreeBSD Foundation --- sys/kern/subr_lock.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/sys/kern/subr_lock.c b/sys/kern/subr_lock.c index 2ebb1720267c..1efbcc807213 100644 --- a/sys/kern/subr_lock.c +++ b/sys/kern/subr_lock.c @@ -287,7 +287,7 @@ lock_prof_init(void *arg) { int cpu; - for (cpu = 0; cpu <= mp_maxid; cpu++) { + CPU_FOREACH(cpu) { lp_cpu[cpu] = malloc(sizeof(*lp_cpu[cpu]), M_DEVBUF, M_WAITOK | M_ZERO); lock_prof_init_type(&lp_cpu[cpu]->lpc_types[0]); @@ -330,14 +330,14 @@ lock_prof_reset(void) * before we zero the structures. Some items may still be linked * into per-thread lists as well. */ - for (cpu = 0; cpu <= mp_maxid; cpu++) { + CPU_FOREACH(cpu) { lpc = lp_cpu[cpu]; for (i = 0; i < LPROF_CACHE_SIZE; i++) { LIST_REMOVE(&lpc->lpc_types[0].lpt_objs[i], lpo_link); LIST_REMOVE(&lpc->lpc_types[1].lpt_objs[i], lpo_link); } } - for (cpu = 0; cpu <= mp_maxid; cpu++) { + CPU_FOREACH(cpu) { lpc = lp_cpu[cpu]; bzero(lpc, sizeof(*lpc)); lock_prof_init_type(&lpc->lpc_types[0]); @@ -378,9 +378,7 @@ lock_prof_sum(struct lock_prof *match, struct lock_prof *dst, int hash, dst->class = match->class; dst->name = match->name; - for (cpu = 0; cpu <= mp_maxid; cpu++) { - if (lp_cpu[cpu] == NULL) - continue; + CPU_FOREACH(cpu) { type = &lp_cpu[cpu]->lpc_types[spin]; SLIST_FOREACH(l, &type->lpt_hash[hash], link) { if (l->ticks == t) @@ -399,7 +397,6 @@ lock_prof_sum(struct lock_prof *match, struct lock_prof *dst, int hash, dst->cnt_contest_locking += l->cnt_contest_locking; } } - } static void @@ -438,9 +435,7 @@ dump_lock_prof_stats(SYSCTL_HANDLER_ARGS) lock_prof_enable = 0; quiesce_all_cpus("profstat", 0); t = ticks; - for (cpu = 0; cpu <= mp_maxid; cpu++) { - if (lp_cpu[cpu] == NULL) - continue; + CPU_FOREACH(cpu) { lock_prof_type_stats(&lp_cpu[cpu]->lpc_types[0], sb, 0, t); lock_prof_type_stats(&lp_cpu[cpu]->lpc_types[1], sb, 1, t); } From 2b28ec59ac8d477fab864f6610f794038e72046c Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Sat, 21 Sep 2019 19:51:57 +0000 Subject: [PATCH 29/30] In case a translation fault on the kernel address space occurs from within a critical section, we must perform a lock-free check on the faulting address. Reported by: andrew Reviewed by: andrew, markj X-MFC with: r350579 Differential Revision: https://reviews.freebsd.org/D21685 --- sys/arm64/arm64/pmap.c | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/sys/arm64/arm64/pmap.c b/sys/arm64/arm64/pmap.c index 919537e86b84..d9753073e17b 100644 --- a/sys/arm64/arm64/pmap.c +++ b/sys/arm64/arm64/pmap.c @@ -5810,23 +5810,33 @@ pmap_fault(pmap_t pmap, uint64_t esr, uint64_t far) case ISS_DATA_DFSC_TF_L1: case ISS_DATA_DFSC_TF_L2: case ISS_DATA_DFSC_TF_L3: - PMAP_LOCK(pmap); - /* Ask the MMU to check the address */ - intr = intr_disable(); - if (pmap == kernel_pmap) - par = arm64_address_translate_s1e1r(far); - else - par = arm64_address_translate_s1e0r(far); - intr_restore(intr); - PMAP_UNLOCK(pmap); - /* - * If the translation was successful the address was invalid - * due to a break-before-make sequence. We can unlock and - * return success to the trap handler. + * Retry the translation. A break-before-make sequence can + * produce a transient fault. */ - if (PAR_SUCCESS(par)) - rv = KERN_SUCCESS; + if (pmap == kernel_pmap) { + /* + * The translation fault may have occurred within a + * critical section. Therefore, we must check the + * address without acquiring the kernel pmap's lock. + */ + if (pmap_kextract(far) != 0) + rv = KERN_SUCCESS; + } else { + PMAP_LOCK(pmap); + /* Ask the MMU to check the address. */ + intr = intr_disable(); + par = arm64_address_translate_s1e0r(far); + intr_restore(intr); + PMAP_UNLOCK(pmap); + + /* + * If the translation was successful, then we can + * return success to the trap handler. + */ + if (PAR_SUCCESS(par)) + rv = KERN_SUCCESS; + } break; } From f33533da8c13431673499205b7f020d976830606 Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Sat, 21 Sep 2019 20:03:17 +0000 Subject: [PATCH 30/30] kern.elf{32,64}.pie_base sysctl: enforce page alignment. Requested by: rstone Sponsored by: The FreeBSD Foundation MFC after: 1 week --- sys/kern/imgact_elf.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c index 4678d7465b82..3683e674ddb7 100644 --- a/sys/kern/imgact_elf.c +++ b/sys/kern/imgact_elf.c @@ -136,8 +136,24 @@ SYSCTL_INT(_kern_elf32, OID_AUTO, read_exec, CTLFLAG_RW, &i386_read_exec, 0, #endif static u_long __elfN(pie_base) = ET_DYN_LOAD_ADDR; -SYSCTL_ULONG(__CONCAT(_kern_elf, __ELF_WORD_SIZE), OID_AUTO, pie_base, - CTLFLAG_RWTUN, &__elfN(pie_base), 0, +static int +sysctl_pie_base(SYSCTL_HANDLER_ARGS) +{ + u_long val; + int error; + + val = __elfN(pie_base); + error = sysctl_handle_long(oidp, &val, 0, req); + if (error != 0 || req->newptr == NULL) + return (error); + if ((val & PAGE_MASK) != 0) + return (EINVAL); + __elfN(pie_base) = val; + return (0); +} +SYSCTL_PROC(__CONCAT(_kern_elf, __ELF_WORD_SIZE), OID_AUTO, pie_base, + CTLTYPE_ULONG | CTLFLAG_MPSAFE | CTLFLAG_RW, NULL, 0, + sysctl_pie_base, "LU", "PIE load base without randomization"); SYSCTL_NODE(__CONCAT(_kern_elf, __ELF_WORD_SIZE), OID_AUTO, aslr, CTLFLAG_RW, 0,