From ba8dd40bb12043c547adb14d25bf4b65217bda8b Mon Sep 17 00:00:00 2001 From: Mateusz Guzik Date: Fri, 14 Feb 2020 11:56:50 +0000 Subject: [PATCH 01/14] lockmgr: add a change missed in r357907 --- sys/kern/vfs_default.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/kern/vfs_default.c b/sys/kern/vfs_default.c index 013fd67fde64..2f78f58d0431 100644 --- a/sys/kern/vfs_default.c +++ b/sys/kern/vfs_default.c @@ -573,7 +573,7 @@ vop_lock(ap) } other: ilk = VI_MTX(vp); - return (lockmgr_lock_fast_path(&vp->v_lock, flags, + return (lockmgr_lock_flags(&vp->v_lock, flags, &ilk->lock_object, ap->a_file, ap->a_line)); } From e3741c01c624cd55762a023f977388a7db3df05b Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Fri, 14 Feb 2020 12:59:27 +0000 Subject: [PATCH 02/14] r357895: fix typo in the relocation name for i386 IRELATIVE. Reported by: antoine Sponsored by: The FreeBSD Foundation MFC after: 6 days --- libexec/rtld-elf/i386/reloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libexec/rtld-elf/i386/reloc.c b/libexec/rtld-elf/i386/reloc.c index 7f2dd0c69ef1..be4f18197cd8 100644 --- a/libexec/rtld-elf/i386/reloc.c +++ b/libexec/rtld-elf/i386/reloc.c @@ -392,7 +392,7 @@ reloc_iresolve(Obj_Entry *obj, RtldLockState *lockstate) obj->irelative = false; rellim = (const Elf_Rel *)((const char *)obj->pltrel + obj->pltrelsize); for (rel = obj->pltrel; rel < rellim; rel++) { - if (ELF_R_TYPE(rel->r_info) == R_386_RELATIVE) + if (ELF_R_TYPE(rel->r_info) == R_386_IRELATIVE) reloc_iresolve_one(obj, rel, lockstate); } return (0); From 0e84a878c0a0f0ca44a3637eac5e6a19bdcb4aa8 Mon Sep 17 00:00:00 2001 From: Mateusz Guzik Date: Fri, 14 Feb 2020 13:08:46 +0000 Subject: [PATCH 03/14] Annotate branches in the syscall path This in particular significantly shortens amd64_syscall, which otherwise keeps jumping forward over 2KB of code in total. Note some of these branches should be either eliminated altogether or coalesced. --- sys/kern/subr_syscall.c | 32 +++++++++++++++++--------------- sys/kern/subr_trap.c | 4 ++-- sys/security/audit/audit.h | 2 +- sys/sys/ktrace.h | 2 +- 4 files changed, 21 insertions(+), 19 deletions(-) diff --git a/sys/kern/subr_syscall.c b/sys/kern/subr_syscall.c index a6f8e9d6b7d1..ddc8f8427a7d 100644 --- a/sys/kern/subr_syscall.c +++ b/sys/kern/subr_syscall.c @@ -69,7 +69,7 @@ syscallenter(struct thread *td) if (__predict_false(td->td_cowgen != p->p_cowgen)) thread_cow_update(td); traced = (p->p_flag & P_TRACED) != 0; - if (traced || td->td_dbgflags & TDB_USERWR) { + if (__predict_false(traced || td->td_dbgflags & TDB_USERWR)) { PROC_LOCK(p); td->td_dbgflags &= ~TDB_USERWR; if (traced) @@ -85,19 +85,19 @@ syscallenter(struct thread *td) (uintptr_t)td, "pid:%d", td->td_proc->p_pid, "arg0:%p", sa->args[0], "arg1:%p", sa->args[1], "arg2:%p", sa->args[2]); - if (error != 0) { + if (__predict_false(error != 0)) { td->td_errno = error; goto retval; } STOPEVENT(p, S_SCE, sa->narg); - if ((p->p_flag & P_TRACED) != 0) { + if (__predict_false((p->p_flag & P_TRACED) != 0)) { PROC_LOCK(p); if (p->p_ptevents & PTRACE_SCE) ptracestop((td), SIGTRAP, NULL); PROC_UNLOCK(p); } - if ((td->td_dbgflags & TDB_USERWR) != 0) { + if (__predict_false((td->td_dbgflags & TDB_USERWR) != 0)) { /* * Reread syscall number and arguments if debugger * modified registers or memory. @@ -118,8 +118,8 @@ syscallenter(struct thread *td) * In capability mode, we only allow access to system calls * flagged with SYF_CAPENABLED. */ - if (IN_CAPABILITY_MODE(td) && - !(sa->callp->sy_flags & SYF_CAPENABLED)) { + if (__predict_false(IN_CAPABILITY_MODE(td) && + !(sa->callp->sy_flags & SYF_CAPENABLED))) { td->td_errno = error = ECAPMODE; goto retval; } @@ -152,7 +152,7 @@ syscallenter(struct thread *td) AUDIT_SYSCALL_EXIT(error, td); /* Save the latest error return value. */ - if ((td->td_pflags & TDP_NERRNO) == 0) + if (__predict_false((td->td_pflags & TDP_NERRNO) == 0)) td->td_errno = error; #ifdef KDTRACE_HOOKS @@ -168,7 +168,7 @@ syscallenter(struct thread *td) (uintptr_t)td, "pid:%d", td->td_proc->p_pid, "error:%d", error, "retval0:%#lx", td->td_retval[0], "retval1:%#lx", td->td_retval[1]); - if (traced) { + if (__predict_false(traced)) { PROC_LOCK(p); td->td_dbgflags &= ~TDB_SCE; PROC_UNLOCK(p); @@ -189,9 +189,10 @@ syscallret(struct thread *td) p = td->td_proc; sa = &td->td_sa; - if ((trap_enotcap || (p->p_flag2 & P2_TRAPCAP) != 0) && - IN_CAPABILITY_MODE(td)) { - if (td->td_errno == ENOTCAPABLE || td->td_errno == ECAPMODE) { + if (__predict_false(td->td_errno == ENOTCAPABLE || + td->td_errno == ECAPMODE)) { + if ((trap_enotcap || + (p->p_flag2 & P2_TRAPCAP) != 0) && IN_CAPABILITY_MODE(td)) { ksiginfo_init_trap(&ksi); ksi.ksi_signo = SIGTRAP; ksi.ksi_errno = td->td_errno; @@ -211,20 +212,21 @@ syscallret(struct thread *td) } #endif - if (p->p_flag & P_TRACED) { + traced = 0; + if (__predict_false(p->p_flag & P_TRACED)) { traced = 1; PROC_LOCK(p); td->td_dbgflags |= TDB_SCX; PROC_UNLOCK(p); - } else - traced = 0; + } /* * This works because errno is findable through the * register set. If we ever support an emulation where this * is not the case, this code will need to be revisited. */ STOPEVENT(p, S_SCX, sa->code); - if (traced || (td->td_dbgflags & (TDB_EXEC | TDB_FORK)) != 0) { + if (__predict_false(traced || + (td->td_dbgflags & (TDB_EXEC | TDB_FORK)) != 0)) { PROC_LOCK(p); /* * If tracing the execed process, trap to the debugger diff --git a/sys/kern/subr_trap.c b/sys/kern/subr_trap.c index a7f842a1948e..0349f4320cce 100644 --- a/sys/kern/subr_trap.c +++ b/sys/kern/subr_trap.c @@ -141,13 +141,13 @@ userret(struct thread *td, struct trapframe *frame) * If this thread tickled GEOM, we need to wait for the giggling to * stop before we return to userland */ - if (td->td_pflags & TDP_GEOM) + if (__predict_false(td->td_pflags & TDP_GEOM)) g_waitidle(); /* * Charge system time if profiling. */ - if (p->p_flag & P_PROFIL) + if (__predict_false(p->p_flag & P_PROFIL)) addupc_task(td, TRAPF_PC(frame), td->td_pticks * psratio); #ifdef HWPMC_HOOKS diff --git a/sys/security/audit/audit.h b/sys/security/audit/audit.h index 2aeb5329a4d8..0a708d0972d3 100644 --- a/sys/security/audit/audit.h +++ b/sys/security/audit/audit.h @@ -378,7 +378,7 @@ void audit_thread_free(struct thread *td); } while (0) #define AUDIT_SYSCALL_ENTER(code, td) do { \ - if (audit_syscalls_enabled) { \ + if (__predict_false(audit_syscalls_enabled)) { \ audit_syscall_enter(code, td); \ } \ } while (0) diff --git a/sys/sys/ktrace.h b/sys/sys/ktrace.h index 0a37e1dea718..a0b02f7d3ac5 100644 --- a/sys/sys/ktrace.h +++ b/sys/sys/ktrace.h @@ -73,7 +73,7 @@ struct ktr_header { #define KTRPOINT(td, type) (__predict_false(KTRCHECK((td), (type)))) #define KTRCHECKDRAIN(td) (!(STAILQ_EMPTY(&(td)->td_proc->p_ktr))) #define KTRUSERRET(td) do { \ - if (KTRCHECKDRAIN(td)) \ + if (__predict_false(KTRCHECKDRAIN(td))) \ ktruserret(td); \ } while (0) From 2f7292437d0c4b7173a3298b96a0d0e6156efa5f Mon Sep 17 00:00:00 2001 From: Mateusz Guzik Date: Fri, 14 Feb 2020 13:09:41 +0000 Subject: [PATCH 04/14] Merge audit and systrace checks This further shortens the syscall routine by not having to re-check after the system call. --- sys/kern/subr_syscall.c | 43 ++++++++++++++++++++------------------ sys/security/audit/audit.h | 9 +++++--- sys/sys/sysent.h | 4 ++++ 3 files changed, 33 insertions(+), 23 deletions(-) diff --git a/sys/kern/subr_syscall.c b/sys/kern/subr_syscall.c index ddc8f8427a7d..938e577fa9fb 100644 --- a/sys/kern/subr_syscall.c +++ b/sys/kern/subr_syscall.c @@ -131,15 +131,6 @@ syscallenter(struct thread *td) goto retval; } -#ifdef KDTRACE_HOOKS - /* Give the syscall:::entry DTrace probe a chance to fire. */ - if (__predict_false(systrace_enabled && sa->callp->sy_entry != 0)) - (*systrace_probe_func)(sa, SYSTRACE_ENTRY, 0); -#endif - - /* Let system calls set td_errno directly. */ - td->td_pflags &= ~TDP_NERRNO; - /* * Fetch fast sigblock value at the time of syscall * entry because sleepqueue primitives might call @@ -147,20 +138,32 @@ syscallenter(struct thread *td) */ fetch_sigfastblock(td); - AUDIT_SYSCALL_ENTER(sa->code, td); - error = (sa->callp->sy_call)(td, sa->args); - AUDIT_SYSCALL_EXIT(error, td); - - /* Save the latest error return value. */ - if (__predict_false((td->td_pflags & TDP_NERRNO) == 0)) - td->td_errno = error; + /* Let system calls set td_errno directly. */ + td->td_pflags &= ~TDP_NERRNO; + if (__predict_false(systrace_enabled || AUDIT_SYSCALL_ENTER(sa->code, td))) { #ifdef KDTRACE_HOOKS - /* Give the syscall:::return DTrace probe a chance to fire. */ - if (__predict_false(systrace_enabled && sa->callp->sy_return != 0)) - (*systrace_probe_func)(sa, SYSTRACE_RETURN, - error ? -1 : td->td_retval[0]); + /* Give the syscall:::entry DTrace probe a chance to fire. */ + if (__predict_false(sa->callp->sy_entry != 0)) + (*systrace_probe_func)(sa, SYSTRACE_ENTRY, 0); #endif + error = (sa->callp->sy_call)(td, sa->args); + /* Save the latest error return value. */ + if (__predict_false((td->td_pflags & TDP_NERRNO) == 0)) + td->td_errno = error; + AUDIT_SYSCALL_EXIT(error, td); +#ifdef KDTRACE_HOOKS + /* Give the syscall:::return DTrace probe a chance to fire. */ + if (__predict_false(sa->callp->sy_return != 0)) + (*systrace_probe_func)(sa, SYSTRACE_RETURN, + error ? -1 : td->td_retval[0]); +#endif + } else { + error = (sa->callp->sy_call)(td, sa->args); + /* Save the latest error return value. */ + if (__predict_false((td->td_pflags & TDP_NERRNO) == 0)) + td->td_errno = error; + } syscall_thread_exit(td, sa->callp); retval: diff --git a/sys/security/audit/audit.h b/sys/security/audit/audit.h index 0a708d0972d3..a7600d5c1f90 100644 --- a/sys/security/audit/audit.h +++ b/sys/security/audit/audit.h @@ -377,11 +377,14 @@ void audit_thread_free(struct thread *td); audit_arg_vnode2((vp)); \ } while (0) -#define AUDIT_SYSCALL_ENTER(code, td) do { \ +#define AUDIT_SYSCALL_ENTER(code, td) ({ \ + bool _audit_entered = false; \ if (__predict_false(audit_syscalls_enabled)) { \ audit_syscall_enter(code, td); \ + _audit_entered = true; \ } \ -} while (0) + _audit_entered; \ +}) /* * Wrap the audit_syscall_exit() function so that it is called only when @@ -449,7 +452,7 @@ void audit_thread_free(struct thread *td); #define AUDIT_ARG_VNODE1(vp) #define AUDIT_ARG_VNODE2(vp) -#define AUDIT_SYSCALL_ENTER(code, td) +#define AUDIT_SYSCALL_ENTER(code, td) 0 #define AUDIT_SYSCALL_EXIT(error, td) #define AUDIT_SYSCLOSE(p, fd) diff --git a/sys/sys/sysent.h b/sys/sys/sysent.h index d6213defd005..76e69b52f98e 100644 --- a/sys/sys/sysent.h +++ b/sys/sys/sysent.h @@ -54,7 +54,11 @@ typedef void (*systrace_probe_func_t)(struct syscall_args *, typedef void (*systrace_args_func_t)(int, void *, uint64_t *, int *); #ifdef _KERNEL +#ifdef KDTRACE_HOOKS extern bool systrace_enabled; +#else +#define systrace_enabled 0 +#endif #endif extern systrace_probe_func_t systrace_probe_func; From ed8cd4795c4cebccfbb165b7dba376b7cf2dabff Mon Sep 17 00:00:00 2001 From: Mateusz Guzik Date: Fri, 14 Feb 2020 13:14:19 +0000 Subject: [PATCH 05/14] amd64: only check for error != 0 in the inlined part of l1d flush check this replaces the following near the syscall exit: cmp $0x39,%rax ja 0xffffffff8108f82c movabs $0x200001800060005,%rcx bt %rax,%rcx jae 0xffffffff8108f82c with: test %edi,%edi jne 0xffffffff8091a49c --- sys/amd64/amd64/trap.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/sys/amd64/amd64/trap.c b/sys/amd64/amd64/trap.c index 08423b6182c4..2dda8f41b719 100644 --- a/sys/amd64/amd64/trap.c +++ b/sys/amd64/amd64/trap.c @@ -1068,25 +1068,32 @@ flush_l1d_hw(void) wrmsr(MSR_IA32_FLUSH_CMD, IA32_FLUSH_CMD_L1D); } -static void __inline -amd64_syscall_ret_flush_l1d_inline(int error) +static void __noinline +amd64_syscall_ret_flush_l1d_check(int error) { void (*p)(void); - if (error != 0 && error != EEXIST && error != EAGAIN && - error != EXDEV && error != ENOENT && error != ENOTCONN && - error != EINPROGRESS) { - p = syscall_ret_l1d_flush; + if (error != EEXIST && error != EAGAIN && error != EXDEV && + error != ENOENT && error != ENOTCONN && error != EINPROGRESS) { + p = (void *)atomic_load_ptr(&syscall_ret_l1d_flush); if (p != NULL) p(); } } +static void __inline +amd64_syscall_ret_flush_l1d_check_inline(int error) +{ + + if (__predict_false(error != 0)) + amd64_syscall_ret_flush_l1d_check(error); +} + void amd64_syscall_ret_flush_l1d(int error) { - amd64_syscall_ret_flush_l1d_inline(error); + amd64_syscall_ret_flush_l1d_check_inline(error); } void @@ -1190,5 +1197,5 @@ amd64_syscall(struct thread *td, int traced) if (__predict_false(td->td_frame->tf_rip >= VM_MAXUSER_ADDRESS)) set_pcb_flags(td->td_pcb, PCB_FULL_IRET); - amd64_syscall_ret_flush_l1d_inline(td->td_errno); + amd64_syscall_ret_flush_l1d_check_inline(td->td_errno); } From 15e4e740a6641612aeb6894f6bafce29575191c4 Mon Sep 17 00:00:00 2001 From: Kyle Evans Date: Fri, 14 Feb 2020 14:03:44 +0000 Subject: [PATCH 06/14] committers-ports: add koobs@ information, somewhat belatedly --- share/misc/committers-ports.dot | 1 + 1 file changed, 1 insertion(+) diff --git a/share/misc/committers-ports.dot b/share/misc/committers-ports.dot index d2917120f1dd..f306e9e468a0 100644 --- a/share/misc/committers-ports.dot +++ b/share/misc/committers-ports.dot @@ -159,6 +159,7 @@ kevlo [label="Kevin Lo\nkevlo@FreeBSD.org\n2003/02/21"] kmoore [label="Kris Moore\nkmoore@FreeBSD.org\n2009/04/14"] knu [label="Akinori Musha\nknu@FreeBSD.org\n2000/03/22"] koitsu [label="Jeremy Chadwick\nkoitsu@FreeBSD.org\n2006/11/10"] +koobs [label="Kubilay Kocak\nkoobs@FreeBSD.org\n2012/12/24"] krion [label="Kirill Ponomarew\nkrion@FreeBSD.org\n2003/07/20"] kwm [label="Koop Mast\nkwm@FreeBSD.org\n2004/09/14"] laszlof [label="Frank Laszlo\nlaszlof@FreeBSD.org\n2006/11/07"] From a6da07a3193c49ef3cffecfd2663f6bdcab850d6 Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Fri, 14 Feb 2020 14:55:40 +0000 Subject: [PATCH 07/14] Add Hygon PCI ID and description for AHCI SATA controller. Submitted by: Pu Wen MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D23556 --- sys/dev/ahci/ahci_pci.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sys/dev/ahci/ahci_pci.c b/sys/dev/ahci/ahci_pci.c index 402f4deffbbb..efbdc30a67d1 100644 --- a/sys/dev/ahci/ahci_pci.c +++ b/sys/dev/ahci/ahci_pci.c @@ -90,6 +90,7 @@ static const struct { {0x06221b21, 0x00, "ASMedia ASM106x", AHCI_Q_NOCCS|AHCI_Q_NOAUX}, {0x06241b21, 0x00, "ASMedia ASM106x", AHCI_Q_NOCCS|AHCI_Q_NOAUX}, {0x06251b21, 0x00, "ASMedia ASM106x", AHCI_Q_NOCCS|AHCI_Q_NOAUX}, + {0x79011d94, 0x00, "Hygon KERNCZ", 0}, {0x26528086, 0x00, "Intel ICH6", AHCI_Q_NOFORCE}, {0x26538086, 0x00, "Intel ICH6M", AHCI_Q_NOFORCE}, {0x26818086, 0x00, "Intel ESB2", 0}, From 0d9cef0a94115791bee5308cf40f080c5a932d34 Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Fri, 14 Feb 2020 15:04:56 +0000 Subject: [PATCH 08/14] Add support for Hygon NTB PCI device in ntb_hw_amd driver. Submitted by: Pu Wen MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D23565 --- sys/dev/ntb/ntb_hw/ntb_hw_amd.c | 15 ++++++++++++++- sys/dev/ntb/ntb_hw/ntb_hw_amd.h | 3 +++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/sys/dev/ntb/ntb_hw/ntb_hw_amd.c b/sys/dev/ntb/ntb_hw/ntb_hw_amd.c index 43f135576a3c..8fcd464c862f 100644 --- a/sys/dev/ntb/ntb_hw/ntb_hw_amd.c +++ b/sys/dev/ntb/ntb_hw/ntb_hw_amd.c @@ -101,6 +101,16 @@ static const struct amd_ntb_hw_info amd_ntb_hw_info_list[] = { .msix_vector_count = 24, .quirks = 0, .desc = "AMD Non-Transparent Bridge"}, + + { .vendor_id = NTB_HW_HYGON_VENDOR_ID, + .device_id = NTB_HW_HYGON_DEVICE_ID1, + .mw_count = 3, + .bar_start_idx = 1, + .spad_count = 16, + .db_count = 16, + .msix_vector_count = 24, + .quirks = QUIRK_MW0_32BIT, + .desc = "Hygon Non-Transparent Bridge"}, }; static const struct pci_device_table amd_ntb_devs[] = { @@ -109,7 +119,10 @@ static const struct pci_device_table amd_ntb_devs[] = { PCI_DESCR("AMD Non-Transparent Bridge") }, { PCI_DEV(NTB_HW_AMD_VENDOR_ID, NTB_HW_AMD_DEVICE_ID2), .driver_data = (uintptr_t)&amd_ntb_hw_info_list[1], - PCI_DESCR("AMD Non-Transparent Bridge") } + PCI_DESCR("AMD Non-Transparent Bridge") }, + { PCI_DEV(NTB_HW_HYGON_VENDOR_ID, NTB_HW_HYGON_DEVICE_ID1), + .driver_data = (uintptr_t)&amd_ntb_hw_info_list[0], + PCI_DESCR("Hygon Non-Transparent Bridge") } }; static unsigned g_amd_ntb_hw_debug_level; diff --git a/sys/dev/ntb/ntb_hw/ntb_hw_amd.h b/sys/dev/ntb/ntb_hw/ntb_hw_amd.h index f00094f62f85..99651767aff4 100644 --- a/sys/dev/ntb/ntb_hw/ntb_hw_amd.h +++ b/sys/dev/ntb/ntb_hw/ntb_hw_amd.h @@ -51,6 +51,9 @@ #define NTB_HW_AMD_DEVICE_ID1 0x145B #define NTB_HW_AMD_DEVICE_ID2 0x148B +#define NTB_HW_HYGON_VENDOR_ID 0x19D4 +#define NTB_HW_HYGON_DEVICE_ID1 0x145B + #define NTB_DEF_PEER_CNT 1 #define NTB_DEF_PEER_IDX 0 From 96592b7a0760795d8bf872cd16a1ad3a509e18c3 Mon Sep 17 00:00:00 2001 From: Pawel Biernacki Date: Fri, 14 Feb 2020 16:56:59 +0000 Subject: [PATCH 09/14] sysctl(9): properly use xor in ENFORCE_FLAGS macro Assert on not specifying any of the (soon to be) required flags as well as specifying both of them. Pointed out by: cem, hselasky Reviewed by: hselasky, kib Approved by: kib (mentor) Differential Revision: https://reviews.freebsd.org/D23678 --- sys/sys/sysctl.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/sys/sysctl.h b/sys/sys/sysctl.h index 3bc2a01313b3..0fb4566de482 100644 --- a/sys/sys/sysctl.h +++ b/sys/sys/sysctl.h @@ -270,9 +270,9 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry); #define __DESCR(d) "" #endif -#ifdef notyet +#ifdef notyet #define SYSCTL_ENFORCE_FLAGS(x) \ - _Static_assert(((CTLFLAG_MPSAFE ^ CTLFLAG_NEEDGIANT) & (x)), \ + _Static_assert((((x) & CTLFLAG_MPSAFE) != 0) ^ (((x) & CTLFLAG_NEEDGIANT) != 0), \ "Has to be either CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT") #else #define SYSCTL_ENFORCE_FLAGS(x) From 4c3ccd967e6b9a6c157bd38410bdccd098bdb9e1 Mon Sep 17 00:00:00 2001 From: Ed Maste Date: Fri, 14 Feb 2020 17:05:35 +0000 Subject: [PATCH 10/14] openssh: add a note about libwrap in config.h LIBWRAP is defined by the Makefile based on MK_TCP_WRAPPERS and should not be defined in config.h. PR: 210141 Sponsored by: The FreeBSD Foundation --- crypto/openssh/FREEBSD-upgrade | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crypto/openssh/FREEBSD-upgrade b/crypto/openssh/FREEBSD-upgrade index 244042ec83e4..742688f9d707 100644 --- a/crypto/openssh/FREEBSD-upgrade +++ b/crypto/openssh/FREEBSD-upgrade @@ -71,6 +71,9 @@ 0E) Review changes to config.h very carefully. + Note that libwrap should not be defined in config.h; as of + r311585 it is conditional on MK_TCP_WRAPPERS. + 0F) If source files have been added or removed, update the appropriate makefiles to reflect changes in the vendor's Makefile.in. From aac4229aac3b59dedd160793faf21e18cf85bdfc Mon Sep 17 00:00:00 2001 From: Kyle Evans Date: Fri, 14 Feb 2020 18:46:34 +0000 Subject: [PATCH 11/14] Pull in latest fixes from dtc, up to 0060471 This includes a small battery of /memreserve/ fixes to make sure dtc is properly writing these regions into the output file and reading them back out. As of this update, dtc will now also assume common defaults for -I/-O if only one is specified; namely, dts for one implies dtb for the other and vice versa (Requested by: jhibbits, preserves GPL dtc behavior too). MFC after: 1 week --- usr.bin/dtc/dtb.cc | 1 - usr.bin/dtc/dtc.cc | 22 ++++++++++++++++++++-- usr.bin/dtc/fdt.cc | 20 ++++++++++++++------ usr.bin/dtc/fdt.hh | 8 ++++++++ 4 files changed, 42 insertions(+), 9 deletions(-) diff --git a/usr.bin/dtc/dtb.cc b/usr.bin/dtc/dtb.cc index 6346d63cc0af..d7aecba02800 100644 --- a/usr.bin/dtc/dtb.cc +++ b/usr.bin/dtc/dtb.cc @@ -36,7 +36,6 @@ #include #include #include -#include #include #include diff --git a/usr.bin/dtc/dtc.cc b/usr.bin/dtc/dtc.cc index b9423f486815..0cda698011ef 100644 --- a/usr.bin/dtc/dtc.cc +++ b/usr.bin/dtc/dtc.cc @@ -94,6 +94,8 @@ void version(const char* progname) } // Anonymous namespace using fdt::device_tree; +using fdt::tree_write_fn_ptr; +using fdt::tree_read_fn_ptr; int main(int argc, char **argv) @@ -104,8 +106,8 @@ main(int argc, char **argv) const char *in_file = "-"; FILE *depfile = 0; bool debug_mode = false; - auto write_fn = &device_tree::write_binary; - auto read_fn = &device_tree::parse_dts; + tree_write_fn_ptr write_fn = nullptr; + tree_read_fn_ptr read_fn = nullptr; uint32_t boot_cpu = 0; bool boot_cpu_specified = false; bool keep_going = false; @@ -135,6 +137,10 @@ main(int argc, char **argv) if (arg == "dtb") { read_fn = &device_tree::parse_dtb; + if (write_fn == nullptr) + { + write_fn = &device_tree::write_dts; + } } else if (arg == "dts") { @@ -161,6 +167,10 @@ main(int argc, char **argv) else if (arg == "dts") { write_fn = &device_tree::write_dts; + if (read_fn == nullptr) + { + read_fn = &device_tree::parse_dtb; + } } else { @@ -298,6 +308,14 @@ main(int argc, char **argv) return EXIT_FAILURE; } } + if (read_fn == nullptr) + { + read_fn = &device_tree::parse_dts; + } + if (write_fn == nullptr) + { + write_fn = &device_tree::write_binary; + } if (optind < argc) { in_file = argv[optind]; diff --git a/usr.bin/dtc/fdt.cc b/usr.bin/dtc/fdt.cc index 606493e3521b..494604e191df 100644 --- a/usr.bin/dtc/fdt.cc +++ b/usr.bin/dtc/fdt.cc @@ -1563,11 +1563,11 @@ device_tree::parse_file(text_input_buffer &input, { input.next_token(); // Read the header - while (input.consume("/dts-v1/;")) + if (input.consume("/dts-v1/;")) { read_header = true; - input.next_token(); } + input.next_token(); if (input.consume("/plugin/;")) { is_plugin = true; @@ -1589,9 +1589,12 @@ device_tree::parse_file(text_input_buffer &input, { input.parse_error("Expected size on /memreserve/ node."); } + else + { + reservations.push_back(reservation(start, len)); + } input.next_token(); input.consume(';'); - reservations.push_back(reservation(start, len)); input.next_token(); } while (valid && !input.finished()) @@ -1661,7 +1664,7 @@ device_tree::write(int fd) reservation_writer.write_comment(string("Reservation start")); reservation_writer.write_data(i.first); reservation_writer.write_comment(string("Reservation length")); - reservation_writer.write_data(i.first); + reservation_writer.write_data(i.second); } // Write n spare reserve map entries, plus the trailing 0. for (uint32_t i=0 ; i<=spare_reserve_map_entries ; i++) @@ -1747,10 +1750,11 @@ device_tree::write_dts(int fd) if (!reservations.empty()) { const char msg[] = "/memreserve/"; - fwrite(msg, sizeof(msg), 1, file); + // Exclude the null byte when we're writing it out to the file. + fwrite(msg, sizeof(msg) - 1, 1, file); for (auto &i : reservations) { - fprintf(file, " %" PRIx64 " %" PRIx64, i.first, i.second); + fprintf(file, " 0x%" PRIx64 " 0x%" PRIx64, i.first, i.second); } fputs(";\n\n", file); } @@ -1794,6 +1798,10 @@ device_tree::parse_dtb(const string &fn, FILE *) valid = false; return; } + if (start != 0 || length != 0) + { + reservations.push_back(reservation(start, length)); + } } while (!((start == 0) && (length == 0))); input_buffer struct_table = input.buffer_from_offset(h.off_dt_struct, h.size_dt_struct); diff --git a/usr.bin/dtc/fdt.hh b/usr.bin/dtc/fdt.hh index 86c0dcede5e4..6c737cc83e3e 100644 --- a/usr.bin/dtc/fdt.hh +++ b/usr.bin/dtc/fdt.hh @@ -58,6 +58,14 @@ namespace fdt class property; class node; class device_tree; +/** + * Type for device tree write functions. + */ +typedef void (device_tree::* tree_write_fn_ptr)(int); +/** + * Type for device tree read functions. + */ +typedef void (device_tree::* tree_read_fn_ptr)(const std::string &, FILE *); /** * Type for (owned) pointers to properties. */ From d16c90f51c0ef389ed7ef7d823acc9812ce165ad Mon Sep 17 00:00:00 2001 From: Kyle Evans Date: Fri, 14 Feb 2020 18:50:03 +0000 Subject: [PATCH 12/14] dtc: re-apply r353961, r354115 I missed in final review of r357923's diff that these ones hadn't yet been sent upstream and inadvertently reverted them. =-( Re-apply now. --- usr.bin/dtc/dtb.cc | 1 + usr.bin/dtc/fdt.cc | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/usr.bin/dtc/dtb.cc b/usr.bin/dtc/dtb.cc index d7aecba02800..6346d63cc0af 100644 --- a/usr.bin/dtc/dtb.cc +++ b/usr.bin/dtc/dtb.cc @@ -36,6 +36,7 @@ #include #include #include +#include #include #include diff --git a/usr.bin/dtc/fdt.cc b/usr.bin/dtc/fdt.cc index 494604e191df..3c7b2a8bd9ab 100644 --- a/usr.bin/dtc/fdt.cc +++ b/usr.bin/dtc/fdt.cc @@ -1563,11 +1563,11 @@ device_tree::parse_file(text_input_buffer &input, { input.next_token(); // Read the header - if (input.consume("/dts-v1/;")) + while (input.consume("/dts-v1/;")) { read_header = true; + input.next_token(); } - input.next_token(); if (input.consume("/plugin/;")) { is_plugin = true; From e491358c94b67d10df1dc31929661e5948162de0 Mon Sep 17 00:00:00 2001 From: Ed Maste Date: Fri, 14 Feb 2020 18:59:50 +0000 Subject: [PATCH 13/14] sshd: add upgrade process note about TCP wrappers We need to add user-facing deprecation notices for TCP wrappers; start with a note in the upgrade process docmentation. Sponsored by: The FreeBSD Foundation --- crypto/openssh/FREEBSD-upgrade | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crypto/openssh/FREEBSD-upgrade b/crypto/openssh/FREEBSD-upgrade index 742688f9d707..35f6595fe245 100644 --- a/crypto/openssh/FREEBSD-upgrade +++ b/crypto/openssh/FREEBSD-upgrade @@ -142,6 +142,9 @@ Support for TCP wrappers was removed in upstream 6.7p1. We've added it back by porting the 6.6p1 code forward. + TCP wrappers support in sshd will be disabled in HEAD and will + be removed from FreeBSD in the future. + 6) Agent client reference counting We've added code to ssh-agent.c to implement client reference From c42c3abb9ef463c6fd4eaf100154a5d75fbe6a20 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Fri, 14 Feb 2020 19:31:24 +0000 Subject: [PATCH 14/14] Remove /usr/include/ssp from BSD.include.dist after r356356 This avoids having to delete it every time with "make delete-old". PR: 242950 MFC after: 2 weeks X-MFC-With: r356356 --- etc/mtree/BSD.include.dist | 2 -- 1 file changed, 2 deletions(-) diff --git a/etc/mtree/BSD.include.dist b/etc/mtree/BSD.include.dist index b774449a17bf..8433c093ed63 100644 --- a/etc/mtree/BSD.include.dist +++ b/etc/mtree/BSD.include.dist @@ -357,8 +357,6 @@ mac_veriexec .. .. - ssp - .. sys disk ..