Re: svn commit: r362333 - in head: contrib/flex contrib/flex/src usr.bin/lex usr.bin/lex/lib
On Sat, Feb 13, 2021 at 02:39:56AM -0500, Jung-uk Kim wrote: > On 21. 2. 13., Jung-uk Kim wrote: > > On 21. 2. 12., Mark Johnston wrote: > >> On Thu, Jun 18, 2020 at 06:09:16PM +, Jung-uk Kim wrote: > >>> Author: jkim > >>> Date: Thu Jun 18 18:09:16 2020 > >>> New Revision: 362333 > >>> URL: https://svnweb.freebsd.org/changeset/base/362333 > >>> > >>> Log: > >>> MFV:r362286 > >>> > >>> Merge flex 2.6.4. > >> > >> This seems to have introduced a regression: input() now returns 0 > >> instead of EOF to indicate that the end of input was reached. This has > >> been reported in a few places: > >> > >> https://github.com/westes/flex/issues/448 > >> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=911415 > >> > >> It breaks the scanner used by libdtrace, and as a result dtrace is > >> unable to resolve some probe argument types: > >> https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=253440 > >> > >> I have a small patch to libdtrace which works around this. The upstream > >> commit that introduced the change is fairly old at this point, and > >> upstream seems somewhat unresponsive, so I'm not sure it'll get > >> reverted. Some other scanners in the tree look like they'd be affected, > >> like crypto/heimdal/lib/asn1/lex.l or > >> sys/contrib/dev/acpica/compiler/aslsupport.l, so I'm wondering if we > >> should revert this particular change for 13.0. Certainly we should fix > >> the DTrace bug one way or another for 13.0. > > > > I think it does not make much sense and we should revert the upstream > > change. Does the attached patch work for you? The original patch fixes it, the updated one does not since libdtrace sets -l in LFLAGS. :) Removing it causes a build failure but it is trivial to resolve. I am running some tests now to see if anything regressed. > Now I believe the author wanted Lex compatibility. Maybe we should do > the attached patch instead? Is it common to use the base system's flex for ports and out-of-tree code generally? I have no real idea. I'd be worried about configure scripts that use the flex version to determine whether or not to apply a workaround for this change. I also note that Debian does not seem to have patched this. Looking through consumers in the tree (all *.l files), the following scanners could be affected: - libdtrace - contrib/com_err/lex.l - contrib/ipfilter/iplang/iplang_l.l - does not appear to be built - crypto/heimdal/lib/asn1/lex.l - crypto/heimdal/lib/com_err/lex.l - crypto/heimdal/lib/hx509/sel-lex.l - crypto/heimdal/lib/sl/slc-lex.l - sys/contrib/dev/acpica/compiler/aslsupport.l - sys/contrib/dev/acpica/compiler/prparser.l It would not be too difficult to patch them, and I think in most cases the problem is not very severe and is only triggered by invalid input. For instance, asn1_compile enters an infinite loop if the input file contains an unterminated comment. So for 13.0 I am kind of inclined to just patch consumers. If you think we should revert the change in flex, I'm ok with that too and will remove the use of -l in libdtrace. > diff --git a/contrib/flex/src/flex.skl b/contrib/flex/src/flex.skl > index 242645f53245..c23b944ea473 100644 > --- a/contrib/flex/src/flex.skl > +++ b/contrib/flex/src/flex.skl > @@ -1863,7 +1863,11 @@ m4_ifdef( [[M4_YY_USE_LINENO]], > case EOB_ACT_END_OF_FILE: > { > if ( yywrap( M4_YY_CALL_ONLY_ARG ) ) > +#ifdef YY_FLEX_LEX_COMPAT > return 0; > +#else > + return EOF; > +#endif > > if ( ! > YY_G(yy_did_buffer_switch_on_eof) ) > YY_NEW_FILE; ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
Re: svn commit: r362333 - in head: contrib/flex contrib/flex/src usr.bin/lex usr.bin/lex/lib
On Thu, Jun 18, 2020 at 06:09:16PM +, Jung-uk Kim wrote: > Author: jkim > Date: Thu Jun 18 18:09:16 2020 > New Revision: 362333 > URL: https://svnweb.freebsd.org/changeset/base/362333 > > Log: > MFV:r362286 > > Merge flex 2.6.4. This seems to have introduced a regression: input() now returns 0 instead of EOF to indicate that the end of input was reached. This has been reported in a few places: https://github.com/westes/flex/issues/448 https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=911415 It breaks the scanner used by libdtrace, and as a result dtrace is unable to resolve some probe argument types: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=253440 I have a small patch to libdtrace which works around this. The upstream commit that introduced the change is fairly old at this point, and upstream seems somewhat unresponsive, so I'm not sure it'll get reverted. Some other scanners in the tree look like they'd be affected, like crypto/heimdal/lib/asn1/lex.l or sys/contrib/dev/acpica/compiler/aslsupport.l, so I'm wondering if we should revert this particular change for 13.0. Certainly we should fix the DTrace bug one way or another for 13.0. ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r368763 - head/sys/dev/acpica
Author: markj Date: Fri Dec 18 16:04:48 2020 New Revision: 368763 URL: https://svnweb.freebsd.org/changeset/base/368763 Log: acpi: Ensure that adjacent memory affinity table entries are coalesced The SRAT may contain multiple distinct entries that together describe a contiguous region of physical memory. In this case we were not coalescing the corresponding entries in the memory affinity table, which led to fragmented phys_avail[] entries. Since r338431 the vm_phys_segs[] entries derived from phys_avail[] will be coalesced, resulting in a situation where vm_phys_segs[] entries do not have a covering phys_avail[] entry. vm_page_startup() will not add such segments to the physical memory allocator, leaving them unused. Reported by: Don Morris Reviewed by: kib, vangyzen MFC after:2 weeks Sponsored by: The FreeBSD Foundation Differential Revision:https://reviews.freebsd.org/D27620 Modified: head/sys/dev/acpica/acpi_pxm.c Modified: head/sys/dev/acpica/acpi_pxm.c == --- head/sys/dev/acpica/acpi_pxm.c Fri Dec 18 16:02:28 2020 (r368762) +++ head/sys/dev/acpica/acpi_pxm.c Fri Dec 18 16:04:48 2020 (r368763) @@ -265,6 +265,7 @@ srat_parse_entry(ACPI_SUBTABLE_HEADER *entry, void *ar ACPI_SRAT_MEM_AFFINITY *mem; ACPI_SRAT_GICC_AFFINITY *gicc; static struct cpu_info *cpup; + uint64_t base, length; int domain, i, slot; switch (entry->Type) { @@ -327,20 +328,22 @@ srat_parse_entry(ACPI_SUBTABLE_HEADER *entry, void *ar break; case ACPI_SRAT_TYPE_MEMORY_AFFINITY: mem = (ACPI_SRAT_MEM_AFFINITY *)entry; + base = mem->BaseAddress; + length = mem->Length; + domain = mem->ProximityDomain; + if (bootverbose) printf( "SRAT: Found memory domain %d addr 0x%jx len 0x%jx: %s\n", - mem->ProximityDomain, (uintmax_t)mem->BaseAddress, - (uintmax_t)mem->Length, + domain, (uintmax_t)base, (uintmax_t)length, (mem->Flags & ACPI_SRAT_MEM_ENABLED) ? "enabled" : "disabled"); if (!(mem->Flags & ACPI_SRAT_MEM_ENABLED)) break; - if (mem->BaseAddress >= maxphyaddr || - !overlaps_phys_avail(mem->BaseAddress, - mem->BaseAddress + mem->Length)) { + if (base >= maxphyaddr || + !overlaps_phys_avail(base, base + length)) { printf("SRAT: Ignoring memory at addr 0x%jx\n", - (uintmax_t)mem->BaseAddress); + (uintmax_t)base); break; } if (num_mem == VM_PHYSSEG_MAX) { @@ -350,10 +353,20 @@ srat_parse_entry(ACPI_SUBTABLE_HEADER *entry, void *ar } slot = num_mem; for (i = 0; i < num_mem; i++) { - if (mem_info[i].end <= mem->BaseAddress) + if (mem_info[i].domain == domain) { + /* Try to extend an existing segment. */ + if (base == mem_info[i].end) { + mem_info[i].end += length; + return; + } + if (base + length == mem_info[i].start) { + mem_info[i].start -= length; + return; + } + } + if (mem_info[i].end <= base) continue; - if (mem_info[i].start < - (mem->BaseAddress + mem->Length)) { + if (mem_info[i].start < base + length) { printf("SRAT: Overlapping memory entries\n"); *(int *)arg = ENXIO; return; @@ -362,9 +375,9 @@ srat_parse_entry(ACPI_SUBTABLE_HEADER *entry, void *ar } for (i = num_mem; i > slot; i--) mem_info[i] = mem_info[i - 1]; - mem_info[slot].start = mem->BaseAddress; - mem_info[slot].end = mem->BaseAddress + mem->Length; - mem_info[slot].domain = mem->ProximityDomain; + mem_info[slot].start = base; + mem_info[slot].end = base + length; + mem_info[slot].domain = domain; num_mem++; break; } ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all
svn commit: r368762 - head/libexec/rc/rc.d
Author: markj Date: Fri Dec 18 16:02:28 2020 New Revision: 368762 URL: https://svnweb.freebsd.org/changeset/base/368762 Log: Fix the ipfw service status output when ipfw.ko isn't loaded Reported by: lme Reviewed by: lme MFC after:1 week Differential Revision:https://reviews.freebsd.org/D27657 Modified: head/libexec/rc/rc.d/ipfw Modified: head/libexec/rc/rc.d/ipfw == --- head/libexec/rc/rc.d/ipfw Fri Dec 18 15:07:14 2020(r368761) +++ head/libexec/rc/rc.d/ipfw Fri Dec 18 16:02:28 2020(r368762) @@ -129,7 +129,9 @@ ipfw_status() status=$(sysctl -i -n net.inet.ip.fw.enable) : ${status:=0} if afexists inet6; then - status=$((${status} + $(sysctl -i -n net.inet6.ip6.fw.enable))) + status6=$(sysctl -i -n net.inet6.ip6.fw.enable) + : ${status6:=0} + status=$((${status} + ${status6})) fi if [ ${status} -eq 0 ]; then echo "ipfw is not enabled" ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r368726 - stable/12/sys/cddl/dev/sdt
Author: markj Date: Thu Dec 17 17:21:12 2020 New Revision: 368726 URL: https://svnweb.freebsd.org/changeset/base/368726 Log: MFC r368306: sdt: Create providers and probes in separate passes when loading sdt.ko Modified: stable/12/sys/cddl/dev/sdt/sdt.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/cddl/dev/sdt/sdt.c == --- stable/12/sys/cddl/dev/sdt/sdt.cThu Dec 17 17:11:14 2020 (r368725) +++ stable/12/sys/cddl/dev/sdt/sdt.cThu Dec 17 17:21:12 2020 (r368726) @@ -271,26 +271,24 @@ sdt_destroy(void *arg, dtrace_id_t id, void *parg) { } -/* - * Called from the kernel linker when a module is loaded, before - * dtrace_module_loaded() is called. This is done so that it's possible to - * register new providers when modules are loaded. The DTrace framework - * explicitly disallows calling into the framework from the provide_module - * provider method, so we cannot do this there. - */ static void -sdt_kld_load(void *arg __unused, struct linker_file *lf) +sdt_kld_load_providers(struct linker_file *lf) { struct sdt_provider **prov, **begin, **end; - struct sdt_probe **probe, **p_begin, **p_end; - struct sdt_argtype **argtype, **a_begin, **a_end; if (linker_file_lookup_set(lf, "sdt_providers_set", , , NULL) == 0) { for (prov = begin; prov < end; prov++) sdt_create_provider(*prov); } +} +static void +sdt_kld_load_probes(struct linker_file *lf) +{ + struct sdt_probe **probe, **p_begin, **p_end; + struct sdt_argtype **argtype, **a_begin, **a_end; + if (linker_file_lookup_set(lf, "sdt_probes_set", _begin, _end, NULL) == 0) { for (probe = p_begin; probe < p_end; probe++) { @@ -310,7 +308,21 @@ sdt_kld_load(void *arg __unused, struct linker_file *l } } +/* + * Called from the kernel linker when a module is loaded, before + * dtrace_module_loaded() is called. This is done so that it's possible to + * register new providers when modules are loaded. The DTrace framework + * explicitly disallows calling into the framework from the provide_module + * provider method, so we cannot do this there. + */ static void +sdt_kld_load(void *arg __unused, struct linker_file *lf) +{ + sdt_kld_load_providers(lf); + sdt_kld_load_probes(lf); +} + +static void sdt_kld_unload_try(void *arg __unused, struct linker_file *lf, int *error) { struct sdt_provider *prov, **curr, **begin, **end, *tmp; @@ -348,16 +360,21 @@ sdt_kld_unload_try(void *arg __unused, struct linker_f } static int -sdt_linker_file_cb(linker_file_t lf, void *arg __unused) +sdt_load_providers_cb(linker_file_t lf, void *arg __unused) { + sdt_kld_load_providers(lf); + return (0); +} - sdt_kld_load(NULL, lf); - +static int +sdt_load_probes_cb(linker_file_t lf, void *arg __unused) +{ + sdt_kld_load_probes(lf); return (0); } static void -sdt_load() +sdt_load(void) { TAILQ_INIT(_prov_list); @@ -369,12 +386,17 @@ sdt_load() sdt_kld_unload_try_tag = EVENTHANDLER_REGISTER(kld_unload_try, sdt_kld_unload_try, NULL, EVENTHANDLER_PRI_ANY); - /* Pick up probes from the kernel and already-loaded linker files. */ - linker_file_foreach(sdt_linker_file_cb, NULL); + /* +* Pick up probes from the kernel and already-loaded linker files. +* Define providers in a separate pass since a linker file may be using +* providers defined in a file that appears later in the list. +*/ + linker_file_foreach(sdt_load_providers_cb, NULL); + linker_file_foreach(sdt_load_probes_cb, NULL); } static int -sdt_unload() +sdt_unload(void) { struct sdt_provider *prov, *tmp; int ret; ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
Re: svn commit: r368523 - head/sys/vm
On Tue, Dec 15, 2020 at 03:33:09PM +0100, Hans Petter Selasky wrote: > On 12/15/20 3:27 PM, Mark Johnston wrote: > >> I'm seeing the following panic: > >> > >> panic("vm_wait in early boot") > >> vm_wait_domain() > >> kmem_alloc_contig_pages() > >> kmem_alloc_contig_domainset() > >> kmem_alloc_contig() > >> contigmalloc() > >> x86bios_alloc() > >> vesa_configure() > >> vesa_mod_event() > >> vesa_module_register_init() > >> mi_startup() > > Is it on a NUMA system? I see that the new logic won't work properly if > > there are empty domains, so this suggests that we really do need a > > special contig iterator as discussed in the review. > > Yes, this is a numa system. > > I just noticed, that before r368523 "flags" was updated by > _vm_domainset_iter_policy_init() to always contain M_NOWAIT and that > avoids the wait logic, but I think x86bios_alloc() doesn't get its > memory then. Yes, but note that vm_domainset_iter_policy() will also call vm_wait_doms() if a M_NOWAIT allocation from each domain fails. x86bios_alloc() requests memory from the first 1MB of physical memory, but because contigmalloc() uses a round-robin iterator initialized from per-thread state it may try from the "wrong" domain first. So really a different solution to the original problem is needed. > I'm not sure if x86bios_alloc() needs to be attached a bit later anyway? > > --HPS ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
Re: svn commit: r368523 - head/sys/vm
On Tue, Dec 15, 2020 at 01:59:22PM +0100, Hans Petter Selasky wrote: > On 12/10/20 9:44 PM, Bryan Drewery wrote: > > Author: bdrewery > > Date: Thu Dec 10 20:44:29 2020 > > New Revision: 368523 > > URL: https://svnweb.freebsd.org/changeset/base/368523 > > > > Log: > >contig allocs: Don't retry forever on M_WAITOK. > > > >This restores behavior from before domain iterators were added in > >r327895 and r327896. > > > >The vm_domainset_iter_policy() will do a vm_wait_doms() and then > >restart its iterator when M_WAITOK is set. It will also force > >the containing loop to have M_NOWAIT. So we get an unbounded > >retry loop rather than the intended bounded retries that > >kmem_alloc_contig_pages() already handles. > > > >This also restores M_WAITOK to the vmem_alloc() call in > >kmem_alloc_attr_domain() and kmem_alloc_contig_domain(). > > > >Reviewed by: markj, kib > >MFC after: 2 weeks > >Sponsored by:Dell EMC > >Differential Revision: https://reviews.freebsd.org/D27507 > > > > Modified: > >head/sys/vm/vm_kern.c > > > > Modified: head/sys/vm/vm_kern.c > > == > > --- head/sys/vm/vm_kern.c Thu Dec 10 20:44:05 2020(r368522) > > +++ head/sys/vm/vm_kern.c Thu Dec 10 20:44:29 2020(r368523) > > @@ -264,9 +264,15 @@ kmem_alloc_attr_domainset(struct domainset *ds, vm_siz > > { > > struct vm_domainset_iter di; > > vm_offset_t addr; > > - int domain; > > + int domain, iflags; > > > > - vm_domainset_iter_policy_init(, ds, , ); > > + /* > > +* Do not allow the domainset iterator to override wait flags. The > > +* contiguous memory allocator defines special semantics for M_WAITOK > > +* that do not match the iterator's implementation. > > +*/ > > + iflags = (flags & ~M_WAITOK) | M_NOWAIT; > > + vm_domainset_iter_policy_init(, ds, , ); > > do { > > addr = kmem_alloc_attr_domain(domain, size, flags, low, high, > > memattr); > > @@ -346,9 +352,15 @@ kmem_alloc_contig_domainset(struct domainset *ds, vm_s > > { > > struct vm_domainset_iter di; > > vm_offset_t addr; > > - int domain; > > + int domain, iflags; > > > > - vm_domainset_iter_policy_init(, ds, , ); > > + /* > > +* Do not allow the domainset iterator to override wait flags. The > > +* contiguous memory allocator defines special semantics for M_WAITOK > > +* that do not match the iterator's implementation. > > +*/ > > + iflags = (flags & ~M_WAITOK) | M_NOWAIT; > > + vm_domainset_iter_policy_init(, ds, , ); > > do { > > addr = kmem_alloc_contig_domain(domain, size, flags, low, high, > > alignment, boundary, memattr); > > > > Hi, > > Should "iflags" also be passed to kmem_alloc_contig_domain() !? It is intentional, iflags is modified to ensure that the domainset iterator does not loop until the allocation is successful, and kmem_alloc_contig_pages() implements its own M_WAITOK handling. > I'm seeing the following panic: > > panic("vm_wait in early boot") > vm_wait_domain() > kmem_alloc_contig_pages() > kmem_alloc_contig_domainset() > kmem_alloc_contig() > contigmalloc() > x86bios_alloc() > vesa_configure() > vesa_mod_event() > vesa_module_register_init() > mi_startup() Is it on a NUMA system? I see that the new logic won't work properly if there are empty domains, so this suggests that we really do need a special contig iterator as discussed in the review. ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r368636 - in stable/12/sys/arm: arm include
Author: markj Date: Mon Dec 14 14:54:20 2020 New Revision: 368636 URL: https://svnweb.freebsd.org/changeset/base/368636 Log: MFC r368414: arm: Let the GDB stub write to SP, LR and GP registers PR: 251463 Modified: stable/12/sys/arm/arm/gdb_machdep.c stable/12/sys/arm/include/gdb_machdep.h Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/arm/arm/gdb_machdep.c == --- stable/12/sys/arm/arm/gdb_machdep.c Mon Dec 14 14:00:54 2020 (r368635) +++ stable/12/sys/arm/arm/gdb_machdep.c Mon Dec 14 14:54:20 2020 (r368636) @@ -98,11 +98,25 @@ gdb_cpu_getreg(int regnum, size_t *regsz) void gdb_cpu_setreg(int regnum, void *val) { + if (kdb_thread != curthread) + return; switch (regnum) { case GDB_REG_PC: - if (kdb_thread == curthread) - kdb_frame->tf_pc = *(register_t *)val; + kdb_frame->tf_pc = *(register_t *)val; + break; + case GDB_REG_SP: + kdb_frame->tf_svc_sp = *(register_t *)val; + break; + case GDB_REG_LR: + kdb_frame->tf_svc_lr = *(register_t *)val; + break; + default: + /* Write to the general purpose registers r0-r12. */ + if (regnum >= 0 && regnum <= 12) { + *(_frame->tf_r0 + regnum) = *(register_t *)val; + } + break; } } Modified: stable/12/sys/arm/include/gdb_machdep.h == --- stable/12/sys/arm/include/gdb_machdep.h Mon Dec 14 14:00:54 2020 (r368635) +++ stable/12/sys/arm/include/gdb_machdep.h Mon Dec 14 14:54:20 2020 (r368636) @@ -33,6 +33,8 @@ #defineGDB_BUFSZ 400 #defineGDB_NREGS 26 +#defineGDB_REG_SP 13 +#defineGDB_REG_LR 14 #defineGDB_REG_PC 15 static __inline size_t ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r368535 - stable/12/sys/arm/include
Author: markj Date: Fri Dec 11 00:25:34 2020 New Revision: 368535 URL: https://svnweb.freebsd.org/changeset/base/368535 Log: MFC r368108: arm: Correctly report the size of FPA registers to GDB PR: 251022 Modified: stable/12/sys/arm/include/gdb_machdep.h Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/arm/include/gdb_machdep.h == --- stable/12/sys/arm/include/gdb_machdep.h Fri Dec 11 00:20:04 2020 (r368534) +++ stable/12/sys/arm/include/gdb_machdep.h Fri Dec 11 00:25:34 2020 (r368535) @@ -36,9 +36,13 @@ #defineGDB_REG_PC 15 static __inline size_t -gdb_cpu_regsz(int regnum __unused) +gdb_cpu_regsz(int regnum) { - return (sizeof(int)); + /* +* GDB expects the FPA registers f0-f7, each 96 bits wide, to be placed +* in between the PC and CSPR in response to a "g" packet. +*/ + return (regnum >= 16 && regnum <= 23 ? 12 : sizeof(int)); } static __inline int ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r368486 - head/sys/kern
Author: markj Date: Wed Dec 9 14:05:08 2020 New Revision: 368486 URL: https://svnweb.freebsd.org/changeset/base/368486 Log: Plug a race between fd table teardown and several loops To export information from fd tables we have several loops which do this: FILDESC_SLOCK(fdp); for (i = 0; fdp->fd_refcount > 0 && i <= lastfile; i++) ; FILDESC_SUNLOCK(fdp); Before r36, fdescfree() acquired the fd table exclusive lock between decrementing fdp->fd_refcount and freeing table entries. This serialized with the loop above, so the file at descriptor i would remain valid until the lock is dropped. Now there is no serialization, so the loops may race with teardown of file descriptor tables. Acquire the exclusive fdtable lock after releasing the final table reference to provide a barrier synchronizing with these loops. Reported by: pho Reviewed by: kib (previous version), mjg Sponsored by: The FreeBSD Foundation Differential Revision:https://reviews.freebsd.org/D27513 Modified: head/sys/kern/kern_descrip.c Modified: head/sys/kern/kern_descrip.c == --- head/sys/kern/kern_descrip.cWed Dec 9 14:04:54 2020 (r368485) +++ head/sys/kern/kern_descrip.cWed Dec 9 14:05:08 2020 (r368486) @@ -2463,6 +2463,13 @@ fdescfree_fds(struct thread *td, struct filedesc *fdp, struct file *fp; int i, lastfile; + KASSERT(refcount_load(>fd_refcnt) == 0, + ("%s: fd table %p carries references", __func__, fdp)); + + /* Serialize with threads iterating over the table. */ + FILEDESC_XLOCK(fdp); + FILEDESC_XUNLOCK(fdp); + lastfile = fdlastfile_single(fdp); for (i = 0; i <= lastfile; i++) { fde = >fd_ofiles[i]; @@ -2536,6 +2543,11 @@ pdescfree(struct thread *td) void fdescfree_remapped(struct filedesc *fdp) { +#ifdef INVARIANTS + /* fdescfree_fds() asserts that fd_refcnt == 0. */ + if (!refcount_release(>fd_refcnt)) + panic("%s: fd table %p has extra references", __func__, fdp); +#endif fdescfree_fds(curthread, fdp, 0); } ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r368485 - head/sys/kern
Author: markj Date: Wed Dec 9 14:04:54 2020 New Revision: 368485 URL: https://svnweb.freebsd.org/changeset/base/368485 Log: Use refcount_load(9) to load fd table reference counts No functional change intended. Reviewed by: kib, mjg Sponsored by: The FreeBSD Foundation Differential Revision:https://reviews.freebsd.org/D27512 Modified: head/sys/kern/kern_descrip.c Modified: head/sys/kern/kern_descrip.c == --- head/sys/kern/kern_descrip.cWed Dec 9 09:53:21 2020 (r368484) +++ head/sys/kern/kern_descrip.cWed Dec 9 14:04:54 2020 (r368485) @@ -1830,7 +1830,8 @@ fdgrowtable(struct filedesc *fdp, int nfd) * which must not be freed. */ if (onfiles > NDFILE) { - if (curproc->p_numthreads == 1 && fdp->fd_refcnt == 1) + if (curproc->p_numthreads == 1 && + refcount_load(>fd_refcnt) == 1) free(otable, M_FILEDESC); else { ft = (struct freetable *)>fdt_ofiles[onfiles]; @@ -2160,7 +2161,7 @@ static void fddrop(struct filedesc *fdp) { - if (fdp->fd_holdcnt > 1) { + if (refcount_load(>fd_holdcnt) > 1) { if (refcount_release(>fd_holdcnt) == 0) return; } @@ -2221,7 +,7 @@ fdunshare(struct thread *td) struct filedesc *tmp; struct proc *p = td->td_proc; - if (p->p_fd->fd_refcnt == 1) + if (refcount_load(>p_fd->fd_refcnt) == 1) return; tmp = fdcopy(p->p_fd); @@ -2570,7 +2571,8 @@ fdsetugidsafety(struct thread *td) int i; fdp = td->td_proc->p_fd; - KASSERT(fdp->fd_refcnt == 1, ("the fdtable should not be shared")); + KASSERT(refcount_load(>fd_refcnt) == 1, + ("the fdtable should not be shared")); MPASS(fdp->fd_nfiles >= 3); for (i = 0; i <= 2; i++) { fp = fdp->fd_ofiles[i].fde_file; @@ -2621,7 +2623,8 @@ fdcloseexec(struct thread *td) int i, lastfile; fdp = td->td_proc->p_fd; - KASSERT(fdp->fd_refcnt == 1, ("the fdtable should not be shared")); + KASSERT(refcount_load(>fd_refcnt) == 1, + ("the fdtable should not be shared")); lastfile = fdlastfile_single(fdp); for (i = 0; i <= lastfile; i++) { fde = >fd_ofiles[i]; @@ -2651,7 +2654,8 @@ fdcheckstd(struct thread *td) int i, error, devnull; fdp = td->td_proc->p_fd; - KASSERT(fdp->fd_refcnt == 1, ("the fdtable should not be shared")); + KASSERT(refcount_load(>fd_refcnt) == 1, + ("the fdtable should not be shared")); MPASS(fdp->fd_nfiles >= 3); devnull = -1; for (i = 0; i <= 2; i++) { @@ -3974,7 +3978,8 @@ sysctl_kern_file(SYSCTL_HANDLER_ARGS) continue; FILEDESC_SLOCK(fdp); lastfile = fdlastfile(fdp); - for (n = 0; fdp->fd_refcnt > 0 && n <= lastfile; ++n) { + for (n = 0; refcount_load(>fd_refcnt) > 0 && n <= lastfile; + n++) { if ((fp = fdp->fd_ofiles[n].fde_file) == NULL) continue; xf.xf_fd = n; @@ -4245,7 +4250,7 @@ kern_proc_filedesc_out(struct proc *p, struct sbuf *s pwd_drop(pwd); FILEDESC_SLOCK(fdp); lastfile = fdlastfile(fdp); - for (i = 0; fdp->fd_refcnt > 0 && i <= lastfile; i++) { + for (i = 0; refcount_load(>fd_refcnt) > 0 && i <= lastfile; i++) { if ((fp = fdp->fd_ofiles[i].fde_file) == NULL) continue; #ifdef CAPABILITIES @@ -4400,7 +4405,7 @@ sysctl_kern_proc_ofiledesc(SYSCTL_HANDLER_ARGS) pwd_drop(pwd); FILEDESC_SLOCK(fdp); lastfile = fdlastfile(fdp); - for (i = 0; fdp->fd_refcnt > 0 && i <= lastfile; i++) { + for (i = 0; refcount_load(>fd_refcnt) > 0 && i <= lastfile; i++) { if ((fp = fdp->fd_ofiles[i].fde_file) == NULL) continue; export_file_to_kinfo(fp, i, NULL, kif, fdp, ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r368471 - stable/12/usr.sbin/rtsold
Author: markj Date: Wed Dec 9 00:56:38 2020 New Revision: 368471 URL: https://svnweb.freebsd.org/changeset/base/368471 Log: MFC r368278: rtsold: Fix bugs reported by Coverity Modified: stable/12/usr.sbin/rtsold/cap_llflags.c stable/12/usr.sbin/rtsold/dump.c stable/12/usr.sbin/rtsold/if.c stable/12/usr.sbin/rtsold/rtsock.c Directory Properties: stable/12/ (props changed) Modified: stable/12/usr.sbin/rtsold/cap_llflags.c == --- stable/12/usr.sbin/rtsold/cap_llflags.c Wed Dec 9 00:56:14 2020 (r368470) +++ stable/12/usr.sbin/rtsold/cap_llflags.c Wed Dec 9 00:56:38 2020 (r368471) @@ -72,9 +72,12 @@ llflags_get(const char *ifname, int *flagsp) if (s < 0) return (-1); - if (getifaddrs() != 0) - return (-1); - error = -1; + ifap = NULL; + if (getifaddrs() != 0) { + error = errno; + goto out; + } + error = ENOENT; for (ifa = ifap; ifa != NULL; ifa = ifa->ifa_next) { if (strcmp(ifa->ifa_name, ifname) != 0) continue; @@ -88,27 +91,29 @@ llflags_get(const char *ifname, int *flagsp) memset(, 0, sizeof(ifr6)); if (strlcpy(ifr6.ifr_name, ifname, sizeof(ifr6.ifr_name)) >= sizeof(ifr6.ifr_name)) { - freeifaddrs(ifap); - errno = EINVAL; - return (-1); + error = errno; + goto out; } memcpy(_ifru.ifru_addr, sin6, sin6->sin6_len); if (ioctl(s, SIOCGIFAFLAG_IN6, ) < 0) { error = errno; - freeifaddrs(ifap); - errno = error; - return (-1); + goto out; } *flagsp = ifr6.ifr_ifru.ifru_flags6; error = 0; break; } +out: (void)close(s); - freeifaddrs(ifap); - if (error == -1) - errno = ENOENT; - return (error); + if (ifap != NULL) + freeifaddrs(ifap); + if (error != 0) { + errno = error; + return (-1); + } else { + return (0); + } } int Modified: stable/12/usr.sbin/rtsold/dump.c == --- stable/12/usr.sbin/rtsold/dump.cWed Dec 9 00:56:14 2020 (r368470) +++ stable/12/usr.sbin/rtsold/dump.cWed Dec 9 00:56:38 2020 (r368471) @@ -148,6 +148,7 @@ rtsold_init_dumpfile(const char *dumpfile) if (caph_rights_limit(fileno(fp), ) != 0) { warnmsg(LOG_WARNING, __func__, "caph_rights_limit(%s): %s", dumpfile, strerror(errno)); + (void)fclose(fp); return (NULL); } return (fp); Modified: stable/12/usr.sbin/rtsold/if.c == --- stable/12/usr.sbin/rtsold/if.c Wed Dec 9 00:56:14 2020 (r368470) +++ stable/12/usr.sbin/rtsold/if.c Wed Dec 9 00:56:38 2020 (r368471) @@ -327,7 +327,7 @@ if_nametosdl(char *name) } } } - if (next == lim) { + if (next >= lim) { /* search failed */ free(buf); return (NULL); Modified: stable/12/usr.sbin/rtsold/rtsock.c == --- stable/12/usr.sbin/rtsold/rtsock.c Wed Dec 9 00:56:14 2020 (r368470) +++ stable/12/usr.sbin/rtsold/rtsock.c Wed Dec 9 00:56:38 2020 (r368471) @@ -84,7 +84,7 @@ rtsock_open(void) if (caph_rights_limit(s, ) != 0) { error = errno; (void)close(s); - errno = errno; + errno = error; return (-1); } return (s); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r368470 - stable/12/sys/netpfil/pf
Author: markj Date: Wed Dec 9 00:56:14 2020 New Revision: 368470 URL: https://svnweb.freebsd.org/changeset/base/368470 Log: MFC r368276: pf: Fix table entry counter toggling PR: 251414 Modified: stable/12/sys/netpfil/pf/pf_table.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/netpfil/pf/pf_table.c == --- stable/12/sys/netpfil/pf/pf_table.c Wed Dec 9 00:28:27 2020 (r368469) +++ stable/12/sys/netpfil/pf/pf_table.c Wed Dec 9 00:56:14 2020 (r368470) @@ -1642,6 +1642,7 @@ pfr_ina_commit(struct pfr_table *trs, u_int32_t ticket static void pfr_commit_ktable(struct pfr_ktable *kt, long tzero) { + counter_u64_t *pkc, *qkc; struct pfr_ktable *shadow = kt->pfrkt_shadow; int nflags; @@ -1663,14 +1664,17 @@ pfr_commit_ktable(struct pfr_ktable *kt, long tzero) SLIST_INIT(); SLIST_INIT(); pfr_clean_node_mask(shadow, ); - for (p = SLIST_FIRST(); p != NULL; p = next) { - next = SLIST_NEXT(p, pfrke_workq); /* XXX */ + SLIST_FOREACH_SAFE(p, , pfrke_workq, next) { pfr_copyout_addr(, p); q = pfr_lookup_addr(kt, , 1); if (q != NULL) { if (q->pfrke_not != p->pfrke_not) SLIST_INSERT_HEAD(, q, pfrke_workq); + pkc = >pfrke_counters.pfrkc_counters; + qkc = >pfrke_counters.pfrkc_counters; + if ((*pkc == NULL) != (*qkc == NULL)) + SWAP(counter_u64_t, *pkc, *qkc); q->pfrke_mark = 1; SLIST_INSERT_HEAD(, p, pfrke_workq); } else { ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r368414 - in head/sys/arm: arm include
Author: markj Date: Mon Dec 7 15:09:28 2020 New Revision: 368414 URL: https://svnweb.freebsd.org/changeset/base/368414 Log: arm: Let the GDB stub write to SP, LR and GP registers This can be handy if gdb's stack unwinder fails, for example because of a bug in kgdb's trap frame unwinder. PR: 251463 Submitted by: Dmitry Salychev MFC after:1 week Modified: head/sys/arm/arm/gdb_machdep.c head/sys/arm/include/gdb_machdep.h Modified: head/sys/arm/arm/gdb_machdep.c == --- head/sys/arm/arm/gdb_machdep.c Mon Dec 7 14:53:34 2020 (r368413) +++ head/sys/arm/arm/gdb_machdep.c Mon Dec 7 15:09:28 2020 (r368414) @@ -97,11 +97,25 @@ gdb_cpu_getreg(int regnum, size_t *regsz) void gdb_cpu_setreg(int regnum, void *val) { + if (kdb_thread != curthread) + return; switch (regnum) { case GDB_REG_PC: - if (kdb_thread == curthread) - kdb_frame->tf_pc = *(register_t *)val; + kdb_frame->tf_pc = *(register_t *)val; + break; + case GDB_REG_SP: + kdb_frame->tf_svc_sp = *(register_t *)val; + break; + case GDB_REG_LR: + kdb_frame->tf_svc_lr = *(register_t *)val; + break; + default: + /* Write to the general purpose registers r0-r12. */ + if (regnum >= 0 && regnum <= 12) { + *(_frame->tf_r0 + regnum) = *(register_t *)val; + } + break; } } Modified: head/sys/arm/include/gdb_machdep.h == --- head/sys/arm/include/gdb_machdep.h Mon Dec 7 14:53:34 2020 (r368413) +++ head/sys/arm/include/gdb_machdep.h Mon Dec 7 15:09:28 2020 (r368414) @@ -33,6 +33,8 @@ #defineGDB_BUFSZ 400 #defineGDB_NREGS 26 +#defineGDB_REG_SP 13 +#defineGDB_REG_LR 14 #defineGDB_REG_PC 15 static __inline size_t ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r368413 - head/share/man/man9
Author: markj Date: Mon Dec 7 14:53:34 2020 New Revision: 368413 URL: https://svnweb.freebsd.org/changeset/base/368413 Log: Add missing refcount.9 MLINKS Modified: head/share/man/man9/Makefile Modified: head/share/man/man9/Makefile == --- head/share/man/man9/MakefileMon Dec 7 14:53:14 2020 (r368412) +++ head/share/man/man9/MakefileMon Dec 7 14:53:34 2020 (r368413) @@ -1778,8 +1778,13 @@ MLINKS+=random_harvest.9 random_harvest_direct.9 \ random_harvest.9 random_harvest_queue.9 MLINKS+=ratecheck.9 ppsratecheck.9 MLINKS+=refcount.9 refcount_acquire.9 \ + refcount.9 refcount_acquire_checked.9 \ + refcount.9 refcount_acquire_if_not_zero.9 \ refcount.9 refcount_init.9 \ - refcount.9 refcount_release.9 + refcount.9 refcount_load.9 \ + refcount.9 refcount_release.9 \ + refcount.9 refcount_release_if_last.9 \ + refcount.9 refcount_release_if_not_last.9 MLINKS+=resource_int_value.9 resource_long_value.9 \ resource_int_value.9 resource_string_value.9 MLINKS+=rman.9 rman_activate_resource.9 \ ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r368412 - head/sys/net
Author: markj Date: Mon Dec 7 14:53:14 2020 New Revision: 368412 URL: https://svnweb.freebsd.org/changeset/base/368412 Log: iflib: Avoid leaking the freelist bitmaps upon driver detach Submitted by: Sai Rajesh Tallamraju MFC after:2 weeks Sponsored by: NetApp, Inc. Differential Revision:https://reviews.freebsd.org/D27342 Modified: head/sys/net/iflib.c Modified: head/sys/net/iflib.c == --- head/sys/net/iflib.cMon Dec 7 14:52:57 2020(r368411) +++ head/sys/net/iflib.cMon Dec 7 14:53:14 2020(r368412) @@ -2259,10 +2259,12 @@ iflib_rx_sds_free(iflib_rxq_t rxq) free(fl->ifl_sds.ifsd_cl, M_IFLIB); free(fl->ifl_sds.ifsd_ba, M_IFLIB); free(fl->ifl_sds.ifsd_map, M_IFLIB); + free(fl->ifl_rx_bitmap, M_IFLIB); fl->ifl_sds.ifsd_m = NULL; fl->ifl_sds.ifsd_cl = NULL; fl->ifl_sds.ifsd_ba = NULL; fl->ifl_sds.ifsd_map = NULL; + fl->ifl_rx_bitmap = NULL; } free(rxq->ifr_fl, M_IFLIB); rxq->ifr_fl = NULL; ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r368411 - head/sys/net
Author: markj Date: Mon Dec 7 14:52:57 2020 New Revision: 368411 URL: https://svnweb.freebsd.org/changeset/base/368411 Log: iflib: Detach tasks upon device registration failure In some error paths we would fail to detach from the iflib taskqueue groups. Also move the detach code into its own subroutine instead of duplicating it. Submitted by: Sai Rajesh Tallamraju MFC after:2 weeks Sponsored by: NetApp, Inc. Differential Revision:https://reviews.freebsd.org/D27342 Modified: head/sys/net/iflib.c Modified: head/sys/net/iflib.c == --- head/sys/net/iflib.cMon Dec 7 11:25:18 2020(r368410) +++ head/sys/net/iflib.cMon Dec 7 14:52:57 2020(r368411) @@ -142,6 +142,7 @@ struct iflib_ctx; static void iru_init(if_rxd_update_t iru, iflib_rxq_t rxq, uint8_t flid); static void iflib_timer(void *arg); +static void iflib_tqg_detach(if_ctx_t ctx); typedef struct iflib_filter_info { driver_filter_t *ifi_filter; @@ -4842,7 +4843,7 @@ fail_intr_free: fail_queues: iflib_tx_structures_free(ctx); iflib_rx_structures_free(ctx); - taskqgroup_detach(qgroup_if_config_tqg, >ifc_admin_task); + iflib_tqg_detach(ctx); IFDI_DETACH(ctx); fail_unlock: CTX_UNLOCK(ctx); @@ -5042,6 +5043,7 @@ fail_detach: fail_queues: iflib_tx_structures_free(ctx); iflib_rx_structures_free(ctx); + iflib_tqg_detach(ctx); fail_iflib_detach: IFDI_DETACH(ctx); fail_unlock: @@ -5058,11 +5060,6 @@ iflib_pseudo_deregister(if_ctx_t ctx) { if_t ifp = ctx->ifc_ifp; if_shared_ctx_t sctx = ctx->ifc_sctx; - iflib_txq_t txq; - iflib_rxq_t rxq; - int i, j; - struct taskqgroup *tqg; - iflib_fl_t fl; /* Unregister VLAN event handlers early */ iflib_unregister_vlan_handlers(ctx); @@ -5074,30 +5071,8 @@ iflib_pseudo_deregister(if_ctx_t ctx) } else { ether_ifdetach(ifp); } - /* XXX drain any dependent tasks */ - tqg = qgroup_if_io_tqg; - for (txq = ctx->ifc_txqs, i = 0; i < NTXQSETS(ctx); i++, txq++) { - callout_drain(>ift_timer); -#ifdef DEV_NETMAP - callout_drain(>ift_netmap_timer); -#endif /* DEV_NETMAP */ - if (txq->ift_task.gt_uniq != NULL) - taskqgroup_detach(tqg, >ift_task); - } - for (i = 0, rxq = ctx->ifc_rxqs; i < NRXQSETS(ctx); i++, rxq++) { - callout_drain(>ifr_watchdog); - if (rxq->ifr_task.gt_uniq != NULL) - taskqgroup_detach(tqg, >ifr_task); - for (j = 0, fl = rxq->ifr_fl; j < rxq->ifr_nfl; j++, fl++) - free(fl->ifl_rx_bitmap, M_IFLIB); - } - tqg = qgroup_if_config_tqg; - if (ctx->ifc_admin_task.gt_uniq != NULL) - taskqgroup_detach(tqg, >ifc_admin_task); - if (ctx->ifc_vflr_task.gt_uniq != NULL) - taskqgroup_detach(tqg, >ifc_vflr_task); - + iflib_tqg_detach(ctx); iflib_tx_structures_free(ctx); iflib_rx_structures_free(ctx); @@ -5127,12 +5102,7 @@ int iflib_device_deregister(if_ctx_t ctx) { if_t ifp = ctx->ifc_ifp; - iflib_txq_t txq; - iflib_rxq_t rxq; device_t dev = ctx->ifc_dev; - int i, j; - struct taskqgroup *tqg; - iflib_fl_t fl; /* Make sure VLANS are not using driver */ if (if_vlantrunkinuse(ifp)) { @@ -5163,28 +5133,8 @@ iflib_device_deregister(if_ctx_t ctx) iflib_rem_pfil(ctx); if (ctx->ifc_led_dev != NULL) led_destroy(ctx->ifc_led_dev); - /* XXX drain any dependent tasks */ - tqg = qgroup_if_io_tqg; - for (txq = ctx->ifc_txqs, i = 0; i < NTXQSETS(ctx); i++, txq++) { - callout_drain(>ift_timer); -#ifdef DEV_NETMAP - callout_drain(>ift_netmap_timer); -#endif /* DEV_NETMAP */ - if (txq->ift_task.gt_uniq != NULL) - taskqgroup_detach(tqg, >ift_task); - } - for (i = 0, rxq = ctx->ifc_rxqs; i < NRXQSETS(ctx); i++, rxq++) { - if (rxq->ifr_task.gt_uniq != NULL) - taskqgroup_detach(tqg, >ifr_task); - for (j = 0, fl = rxq->ifr_fl; j < rxq->ifr_nfl; j++, fl++) - free(fl->ifl_rx_bitmap, M_IFLIB); - } - tqg = qgroup_if_config_tqg; - if (ctx->ifc_admin_task.gt_uniq != NULL) - taskqgroup_detach(tqg, >ifc_admin_task); - if (ctx->ifc_vflr_task.gt_uniq != NULL) - taskqgroup_detach(tqg, >ifc_vflr_task); + iflib_tqg_detach(ctx); CTX_LOCK(ctx); IFDI_DETACH(ctx); CTX_UNLOCK(ctx); @@ -5205,6 +5155,35 @@ iflib_device_deregister(if_ctx_t ctx) unref_ctx_core_offset(ctx); free(ctx, M_IFLIB); return (0); +} + +static void
svn commit: r368400 - head/sys/vm
Author: markj Date: Sun Dec 6 22:45:50 2020 New Revision: 368400 URL: https://svnweb.freebsd.org/changeset/base/368400 Log: uma: Make uma_zone_set_maxcache() work better with small limits The old implementation chose the largest bucket zone such that if the per-CPU caches are fully populated, the total number of items cached is no larger than the specified limit. If no such zone existed, UMA would not do any caching. We can now use uz_bucket_size_max to set a precise limit on the number of items in a zone's bucket, so the total size of per-CPU caches can be bounded more easily. Implement a new policy in uma_zone_set_maxcache(): choose a bucket size such that up to half of the limit can be cached in per-CPU caches, with the rest going to the full bucket cache. This fixes a problem with the kstack_cache zone: the limit of 4 * mp_ncpus items meant that the zone would not do any caching, defeating the whole purpose of the zone. That's because the smallest bucket size holds up to 2 items and we may cache up to 3 full buckets per CPU, and 2 * 3 * mp_ncpus > 4 * mp_ncpus. Reported by: mjg Sponsored by: The FreeBSD Foundation Differential Revision:https://reviews.freebsd.org/D27168 Modified: head/sys/vm/uma.h head/sys/vm/uma_core.c Modified: head/sys/vm/uma.h == --- head/sys/vm/uma.h Sun Dec 6 22:45:39 2020(r368399) +++ head/sys/vm/uma.h Sun Dec 6 22:45:50 2020(r368400) @@ -492,7 +492,7 @@ void uma_zone_reserve(uma_zone_t zone, int nitems); int uma_zone_reserve_kva(uma_zone_t zone, int nitems); /* - * Sets a high limit on the number of items allowed in a zone + * Sets an upper limit on the number of items allocated from a zone * * Arguments: * zone The zone to limit @@ -504,7 +504,7 @@ int uma_zone_reserve_kva(uma_zone_t zone, int nitems); int uma_zone_set_max(uma_zone_t zone, int nitems); /* - * Sets a high limit on the number of items allowed in zone's bucket cache + * Sets an upper limit on the number of items allowed in zone's caches * * Arguments: * zone The zone to limit Modified: head/sys/vm/uma_core.c == --- head/sys/vm/uma_core.c Sun Dec 6 22:45:39 2020(r368399) +++ head/sys/vm/uma_core.c Sun Dec 6 22:45:50 2020(r368400) @@ -438,27 +438,6 @@ bucket_zone_lookup(int entries) return (ubz); } -static struct uma_bucket_zone * -bucket_zone_max(uma_zone_t zone, int nitems) -{ - struct uma_bucket_zone *ubz; - int bpcpu; - - bpcpu = 2; - if ((zone->uz_flags & UMA_ZONE_FIRSTTOUCH) != 0) - /* Count the cross-domain bucket. */ - bpcpu++; - - for (ubz = _zones[0]; ubz->ubz_entries != 0; ubz++) - if (ubz->ubz_entries * bpcpu * mp_ncpus > nitems) - break; - if (ubz == _zones[0]) - ubz = NULL; - else - ubz--; - return (ubz); -} - static int bucket_select(int size) { @@ -2478,10 +2457,10 @@ zone_alloc_sysctl(uma_zone_t zone, void *unused) SYSCTL_ADD_PROC(NULL, SYSCTL_CHILDREN(oid), OID_AUTO, "items", CTLFLAG_RD | CTLTYPE_U64 | CTLFLAG_MPSAFE, zone, 0, sysctl_handle_uma_zone_items, "QU", - "current number of allocated items if limit is set"); + "Current number of allocated items if limit is set"); SYSCTL_ADD_U64(NULL, SYSCTL_CHILDREN(oid), OID_AUTO, "max_items", CTLFLAG_RD, >uz_max_items, 0, - "Maximum number of cached items"); + "Maximum number of allocated and cached items"); SYSCTL_ADD_U32(NULL, SYSCTL_CHILDREN(oid), OID_AUTO, "sleepers", CTLFLAG_RD, >uz_sleepers, 0, "Number of threads sleeping at limit"); @@ -4570,20 +4549,19 @@ zone_free_item(uma_zone_t zone, void *item, void *udat int uma_zone_set_max(uma_zone_t zone, int nitems) { - struct uma_bucket_zone *ubz; - int count; /* +* If the limit is small, we may need to constrain the maximum per-CPU +* cache size, or disable caching entirely. +*/ + uma_zone_set_maxcache(zone, nitems); + + /* * XXX This can misbehave if the zone has any allocations with * no limit and a limit is imposed. There is currently no * way to clear a limit. */ ZONE_LOCK(zone); - ubz = bucket_zone_max(zone, nitems); - count = ubz != NULL ? ubz->ubz_entries : 0; - zone->uz_bucket_size_max = zone->uz_bucket_size = count; - if (zone->uz_bucket_size_min > zone->uz_bucket_size_max) - zone->uz_bucket_size_min = zone->uz_bucket_size_max; zone->uz_max_items = nitems; zone->uz_flags |= UMA_ZFLAG_LIMIT; zone_update_caches(zone); @@ -4598,24 +4576,35 @@
svn commit: r368399 - head/sys/vm
Author: markj Date: Sun Dec 6 22:45:39 2020 New Revision: 368399 URL: https://svnweb.freebsd.org/changeset/base/368399 Log: uma: Enforce the use of uz_bucket_size_max in the free path uz_bucket_size_max is the maximum permitted bucket size. When filling a new bucket to satisfy uma_zalloc(), the bucket is populated with at most uz_bucket_size_max items. The maximum number of entries in the bucket may be larger. When freeing items, however, we will fill per-CPPU buckets up to their maximum number of entries, potentially exceeding uz_bucket_size_max. This makes it difficult to precisely limit the number of items that may be cached in a zone. For example, if one wants to limit buckets to 1 entry for a particular zone, that's not possible since the smallest bucket holds up to 2 entries. Try to solve the problem by using uz_bucket_size_max to limit the number of entries in a bucket. Note that the ub_entries field is initialized upon every bucket allocation. Most zones are not affected since they do not impose any specific limit on the maximum bucket size. While here, remove the UMA_ZONE_MINBUCKET flag. It was unused and we now have uma_zone_set_maxcache() to control the zone's cache size more precisely. Sponsored by: The FreeBSD Foundation Differential Revision:https://reviews.freebsd.org/D27167 Modified: head/sys/vm/uma.h head/sys/vm/uma_core.c Modified: head/sys/vm/uma.h == --- head/sys/vm/uma.h Sun Dec 6 22:45:22 2020(r368398) +++ head/sys/vm/uma.h Sun Dec 6 22:45:39 2020(r368399) @@ -250,7 +250,6 @@ uma_zone_t uma_zcache_create(const char *name, int siz #defineUMA_ZONE_SECONDARY 0x0200 /* Zone is a Secondary Zone */ #defineUMA_ZONE_NOBUCKET 0x0400 /* Do not use buckets. */ #defineUMA_ZONE_MAXBUCKET 0x0800 /* Use largest buckets. */ -#defineUMA_ZONE_MINBUCKET 0x1000 /* Use smallest buckets. */ #defineUMA_ZONE_CACHESPREAD0x2000 /* * Spread memory start locations across * all possible cache lines. May Modified: head/sys/vm/uma_core.c == --- head/sys/vm/uma_core.c Sun Dec 6 22:45:22 2020(r368398) +++ head/sys/vm/uma_core.c Sun Dec 6 22:45:39 2020(r368399) @@ -248,7 +248,6 @@ struct uma_bucket_zone { (((sizeof(void *) * (n)) - sizeof(struct uma_bucket)) / sizeof(void *)) #defineBUCKET_MAX BUCKET_SIZE(256) -#defineBUCKET_MIN 2 struct uma_bucket_zone bucket_zones[] = { /* Literal bucket sizes. */ @@ -507,7 +506,7 @@ bucket_alloc(uma_zone_t zone, void *udata, int flags) } if (((uintptr_t)udata & UMA_ZONE_VM) != 0) flags |= M_NOVM; - ubz = bucket_zone_lookup(zone->uz_bucket_size); + ubz = bucket_zone_lookup(atomic_load_16(>uz_bucket_size)); if (ubz->ubz_zone == zone && (ubz + 1)->ubz_entries != 0) ubz++; bucket = uma_zalloc_arg(ubz->ubz_zone, udata, flags); @@ -516,7 +515,8 @@ bucket_alloc(uma_zone_t zone, void *udata, int flags) bzero(bucket->ub_bucket, sizeof(void *) * ubz->ubz_entries); #endif bucket->ub_cnt = 0; - bucket->ub_entries = ubz->ubz_entries; + bucket->ub_entries = min(ubz->ubz_entries, + zone->uz_bucket_size_max); bucket->ub_seq = SMR_SEQ_INVALID; CTR3(KTR_UMA, "bucket_alloc: zone %s(%p) allocated bucket %p", zone->uz_name, zone, bucket); @@ -2724,8 +2724,6 @@ out: zone->uz_bucket_size_max = zone->uz_bucket_size = 0; if ((arg->flags & UMA_ZONE_MAXBUCKET) != 0) zone->uz_bucket_size = BUCKET_MAX; - else if ((arg->flags & UMA_ZONE_MINBUCKET) != 0) - zone->uz_bucket_size_max = zone->uz_bucket_size = BUCKET_MIN; else if ((arg->flags & UMA_ZONE_NOBUCKET) != 0) zone->uz_bucket_size = 0; else ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r368398 - head/sys/vm
Author: markj Date: Sun Dec 6 22:45:22 2020 New Revision: 368398 URL: https://svnweb.freebsd.org/changeset/base/368398 Log: uma: Use atomic load for uz_sleepers This field is updated locklessly. Sponsored by: The FreeBSD Foundation Modified: head/sys/vm/uma_core.c Modified: head/sys/vm/uma_core.c == --- head/sys/vm/uma_core.c Sun Dec 6 21:34:04 2020(r368397) +++ head/sys/vm/uma_core.c Sun Dec 6 22:45:22 2020(r368398) @@ -4186,7 +4186,7 @@ uma_zfree_arg(uma_zone_t zone, void *item, void *udata * a little longer for the limits to be reset. */ if (__predict_false(uz_flags & UMA_ZFLAG_LIMIT)) { - if (zone->uz_sleepers > 0) + if (atomic_load_32(>uz_sleepers) > 0) goto zfree_item; } ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r368307 - in head: lib/libkvm sys/arm/arm sys/kern sys/mips/mips
Author: markj Date: Thu Dec 3 17:12:31 2020 New Revision: 368307 URL: https://svnweb.freebsd.org/changeset/base/368307 Log: Always use 64-bit physical addresses for dump_avail[] in minidumps As of r365978, minidumps include a copy of dump_avail[]. This is an array of vm_paddr_t ranges. libkvm walks the array assuming that sizeof(vm_paddr_t) is equal to the platform "word size", but that's not correct on some platforms. For instance, i386 uses a 64-bit vm_paddr_t. Fix the problem by always dumping 64-bit addresses. On platforms where vm_paddr_t is 32 bits wide, namely arm and mips (sometimes), translate dump_avail[] to an array of uint64_t ranges. With this change, libkvm no longer needs to maintain a notion of the target word size, so get rid of it. This is a no-op on platforms where sizeof(vm_paddr_t) == 8. Reviewed by: alc, kib Sponsored by: The FreeBSD Foundation Differential Revision:https://reviews.freebsd.org/D27082 Modified: head/lib/libkvm/kvm_minidump_aarch64.c head/lib/libkvm/kvm_minidump_amd64.c head/lib/libkvm/kvm_minidump_arm.c head/lib/libkvm/kvm_minidump_i386.c head/lib/libkvm/kvm_minidump_mips.c head/lib/libkvm/kvm_minidump_powerpc64.c head/lib/libkvm/kvm_minidump_riscv.c head/lib/libkvm/kvm_private.c head/lib/libkvm/kvm_private.h head/sys/arm/arm/minidump_machdep.c head/sys/kern/kern_dump.c head/sys/mips/mips/minidump_machdep.c Modified: head/lib/libkvm/kvm_minidump_aarch64.c == --- head/lib/libkvm/kvm_minidump_aarch64.c Thu Dec 3 17:10:00 2020 (r368306) +++ head/lib/libkvm/kvm_minidump_aarch64.c Thu Dec 3 17:12:31 2020 (r368307) @@ -127,8 +127,7 @@ _aarch64_minidump_initvtop(kvm_t *kd) sparse_off = off + aarch64_round_page(vmst->hdr.bitmapsize) + aarch64_round_page(vmst->hdr.pmapsize); if (_kvm_pt_init(kd, vmst->hdr.dumpavailsize, dump_avail_off, - vmst->hdr.bitmapsize, off, sparse_off, AARCH64_PAGE_SIZE, - sizeof(uint64_t)) == -1) { + vmst->hdr.bitmapsize, off, sparse_off, AARCH64_PAGE_SIZE) == -1) { return (-1); } off += aarch64_round_page(vmst->hdr.bitmapsize); Modified: head/lib/libkvm/kvm_minidump_amd64.c == --- head/lib/libkvm/kvm_minidump_amd64.cThu Dec 3 17:10:00 2020 (r368306) +++ head/lib/libkvm/kvm_minidump_amd64.cThu Dec 3 17:12:31 2020 (r368307) @@ -169,8 +169,7 @@ _amd64_minidump_initvtop(kvm_t *kd) sparse_off = off + amd64_round_page(vmst->hdr.bitmapsize) + amd64_round_page(vmst->hdr.pmapsize); if (_kvm_pt_init(kd, vmst->hdr.dumpavailsize, dump_avail_off, - vmst->hdr.bitmapsize, off, sparse_off, AMD64_PAGE_SIZE, - sizeof(uint64_t)) == -1) { + vmst->hdr.bitmapsize, off, sparse_off, AMD64_PAGE_SIZE) == -1) { return (-1); } off += amd64_round_page(vmst->hdr.bitmapsize); Modified: head/lib/libkvm/kvm_minidump_arm.c == --- head/lib/libkvm/kvm_minidump_arm.c Thu Dec 3 17:10:00 2020 (r368306) +++ head/lib/libkvm/kvm_minidump_arm.c Thu Dec 3 17:12:31 2020 (r368307) @@ -135,8 +135,7 @@ _arm_minidump_initvtop(kvm_t *kd) sparse_off = off + arm_round_page(vmst->hdr.bitmapsize) + arm_round_page(vmst->hdr.ptesize); if (_kvm_pt_init(kd, vmst->hdr.dumpavailsize, dump_avail_off, - vmst->hdr.bitmapsize, off, sparse_off, ARM_PAGE_SIZE, - sizeof(uint32_t)) == -1) { + vmst->hdr.bitmapsize, off, sparse_off, ARM_PAGE_SIZE) == -1) { return (-1); } off += arm_round_page(vmst->hdr.bitmapsize); Modified: head/lib/libkvm/kvm_minidump_i386.c == --- head/lib/libkvm/kvm_minidump_i386.c Thu Dec 3 17:10:00 2020 (r368306) +++ head/lib/libkvm/kvm_minidump_i386.c Thu Dec 3 17:12:31 2020 (r368307) @@ -131,8 +131,7 @@ _i386_minidump_initvtop(kvm_t *kd) sparse_off = off + i386_round_page(vmst->hdr.bitmapsize) + i386_round_page(vmst->hdr.ptesize); if (_kvm_pt_init(kd, vmst->hdr.dumpavailsize, dump_avail_off, - vmst->hdr.bitmapsize, off, sparse_off, I386_PAGE_SIZE, - sizeof(uint32_t)) == -1) { + vmst->hdr.bitmapsize, off, sparse_off, I386_PAGE_SIZE) == -1) { return (-1); } off += i386_round_page(vmst->hdr.bitmapsize); Modified: head/lib/libkvm/kvm_minidump_mips.c == --- head/lib/libkvm/kvm_minidump_mips.c Thu Dec 3 17:10:00 2020 (r368306) +++ head/lib/libkvm/kvm_minidump_mips.c Thu Dec 3
svn commit: r368306 - head/sys/cddl/dev/sdt
Author: markj Date: Thu Dec 3 17:10:00 2020 New Revision: 368306 URL: https://svnweb.freebsd.org/changeset/base/368306 Log: sdt: Create providers and probes in separate passes when loading sdt.ko The sdt module's load handler iterates over SDT linker sets for the kernel and all loaded modules to create probes and providers defined by SDT(9). Probes in one module may belong to a provider in a different module, but when a probe is created we assume that the provider is already defined. To maintain this invariant, modify the load handler to perform two separate passes over loaded modules: one to define providers and the other to define probes. The problem manifests when loading linux.ko, which depends on linux_common.ko, which defines providers used by probes defined in linux.ko. Reported by: gallatin MFC after:2 weeks Sponsored by: The FreeBSD Foundation Modified: head/sys/cddl/dev/sdt/sdt.c Modified: head/sys/cddl/dev/sdt/sdt.c == --- head/sys/cddl/dev/sdt/sdt.c Thu Dec 3 16:54:59 2020(r368305) +++ head/sys/cddl/dev/sdt/sdt.c Thu Dec 3 17:10:00 2020(r368306) @@ -272,26 +272,24 @@ sdt_destroy(void *arg, dtrace_id_t id, void *parg) { } -/* - * Called from the kernel linker when a module is loaded, before - * dtrace_module_loaded() is called. This is done so that it's possible to - * register new providers when modules are loaded. The DTrace framework - * explicitly disallows calling into the framework from the provide_module - * provider method, so we cannot do this there. - */ static void -sdt_kld_load(void *arg __unused, struct linker_file *lf) +sdt_kld_load_providers(struct linker_file *lf) { struct sdt_provider **prov, **begin, **end; - struct sdt_probe **probe, **p_begin, **p_end; - struct sdt_argtype **argtype, **a_begin, **a_end; if (linker_file_lookup_set(lf, "sdt_providers_set", , , NULL) == 0) { for (prov = begin; prov < end; prov++) sdt_create_provider(*prov); } +} +static void +sdt_kld_load_probes(struct linker_file *lf) +{ + struct sdt_probe **probe, **p_begin, **p_end; + struct sdt_argtype **argtype, **a_begin, **a_end; + if (linker_file_lookup_set(lf, "sdt_probes_set", _begin, _end, NULL) == 0) { for (probe = p_begin; probe < p_end; probe++) { @@ -311,7 +309,21 @@ sdt_kld_load(void *arg __unused, struct linker_file *l } } +/* + * Called from the kernel linker when a module is loaded, before + * dtrace_module_loaded() is called. This is done so that it's possible to + * register new providers when modules are loaded. The DTrace framework + * explicitly disallows calling into the framework from the provide_module + * provider method, so we cannot do this there. + */ static void +sdt_kld_load(void *arg __unused, struct linker_file *lf) +{ + sdt_kld_load_providers(lf); + sdt_kld_load_probes(lf); +} + +static void sdt_kld_unload_try(void *arg __unused, struct linker_file *lf, int *error) { struct sdt_provider *prov, **curr, **begin, **end, *tmp; @@ -349,16 +361,21 @@ sdt_kld_unload_try(void *arg __unused, struct linker_f } static int -sdt_linker_file_cb(linker_file_t lf, void *arg __unused) +sdt_load_providers_cb(linker_file_t lf, void *arg __unused) { + sdt_kld_load_providers(lf); + return (0); +} - sdt_kld_load(NULL, lf); - +static int +sdt_load_probes_cb(linker_file_t lf, void *arg __unused) +{ + sdt_kld_load_probes(lf); return (0); } static void -sdt_load() +sdt_load(void) { TAILQ_INIT(_prov_list); @@ -370,12 +387,17 @@ sdt_load() sdt_kld_unload_try_tag = EVENTHANDLER_REGISTER(kld_unload_try, sdt_kld_unload_try, NULL, EVENTHANDLER_PRI_ANY); - /* Pick up probes from the kernel and already-loaded linker files. */ - linker_file_foreach(sdt_linker_file_cb, NULL); + /* +* Pick up probes from the kernel and already-loaded linker files. +* Define providers in a separate pass since a linker file may be using +* providers defined in a file that appears later in the list. +*/ + linker_file_foreach(sdt_load_providers_cb, NULL); + linker_file_foreach(sdt_load_probes_cb, NULL); } static int -sdt_unload() +sdt_unload(void) { struct sdt_provider *prov, *tmp; int ret; ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r368304 - in stable/12/sys: dev/qat modules/qatfw/qat_c2xxx modules/qatfw/qat_c3xxx modules/qatfw/qat_c62x modules/qatfw/qat_d15xx modules/qatfw/qat_dh895xcc
Author: markj Date: Thu Dec 3 15:55:07 2020 New Revision: 368304 URL: https://svnweb.freebsd.org/changeset/base/368304 Log: MFC r368193: qat: Fix firmware module autoloading Modified: stable/12/sys/dev/qat/qat_c2xxxreg.h stable/12/sys/dev/qat/qat_c3xxxreg.h stable/12/sys/dev/qat/qat_c62xreg.h stable/12/sys/dev/qat/qat_d15xxreg.h stable/12/sys/dev/qat/qat_dh895xccreg.h stable/12/sys/modules/qatfw/qat_c2xxx/Makefile stable/12/sys/modules/qatfw/qat_c3xxx/Makefile stable/12/sys/modules/qatfw/qat_c62x/Makefile stable/12/sys/modules/qatfw/qat_d15xx/Makefile stable/12/sys/modules/qatfw/qat_dh895xcc/Makefile Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/qat/qat_c2xxxreg.h == --- stable/12/sys/dev/qat/qat_c2xxxreg.hThu Dec 3 15:54:41 2020 (r368303) +++ stable/12/sys/dev/qat/qat_c2xxxreg.hThu Dec 3 15:55:07 2020 (r368304) @@ -169,7 +169,7 @@ /* AE firmware */ #define AE_FW_PROD_TYPE_C2XXX 0x0080 -#define AE_FW_MOF_NAME_C2XXX "mof_firmware_c2xxx" +#define AE_FW_MOF_NAME_C2XXX "qat_c2xxxfw" #define AE_FW_MMP_NAME_C2XXX "mmp_firmware_c2xxx" #define AE_FW_UOF_NAME_C2XXX_A0"icp_qat_nae.uof" #define AE_FW_UOF_NAME_C2XXX_B0"icp_qat_nae_b0.uof" Modified: stable/12/sys/dev/qat/qat_c3xxxreg.h == --- stable/12/sys/dev/qat/qat_c3xxxreg.hThu Dec 3 15:54:41 2020 (r368303) +++ stable/12/sys/dev/qat/qat_c3xxxreg.hThu Dec 3 15:55:07 2020 (r368304) @@ -168,7 +168,7 @@ /* AE firmware */ #define AE_FW_PROD_TYPE_C3XXX 0x0200 -#define AE_FW_MOF_NAME_C3XXX "qat_c3xxx" +#define AE_FW_MOF_NAME_C3XXX "qat_c3xxxfw" #define AE_FW_MMP_NAME_C3XXX "qat_c3xxx_mmp" #define AE_FW_UOF_NAME_C3XXX "icp_qat_ae.suof" Modified: stable/12/sys/dev/qat/qat_c62xreg.h == --- stable/12/sys/dev/qat/qat_c62xreg.h Thu Dec 3 15:54:41 2020 (r368303) +++ stable/12/sys/dev/qat/qat_c62xreg.h Thu Dec 3 15:55:07 2020 (r368304) @@ -191,7 +191,7 @@ /* AE firmware */ #define AE_FW_PROD_TYPE_C62X 0x0100 -#define AE_FW_MOF_NAME_C62X"qat_c62x" +#define AE_FW_MOF_NAME_C62X"qat_c62xfw" #define AE_FW_MMP_NAME_C62X"qat_c62x_mmp" #define AE_FW_UOF_NAME_C62X"icp_qat_ae.suof" Modified: stable/12/sys/dev/qat/qat_d15xxreg.h == --- stable/12/sys/dev/qat/qat_d15xxreg.hThu Dec 3 15:54:41 2020 (r368303) +++ stable/12/sys/dev/qat/qat_d15xxreg.hThu Dec 3 15:55:07 2020 (r368304) @@ -191,7 +191,7 @@ /* AE firmware */ #define AE_FW_PROD_TYPE_D15XX 0x0100 -#define AE_FW_MOF_NAME_D15XX "qat_d15xx" +#define AE_FW_MOF_NAME_D15XX "qat_d15xxfw" #define AE_FW_MMP_NAME_D15XX "qat_d15xx_mmp" #define AE_FW_UOF_NAME_D15XX "icp_qat_ae.suof" Modified: stable/12/sys/dev/qat/qat_dh895xccreg.h == --- stable/12/sys/dev/qat/qat_dh895xccreg.h Thu Dec 3 15:54:41 2020 (r368303) +++ stable/12/sys/dev/qat/qat_dh895xccreg.h Thu Dec 3 15:55:07 2020 (r368304) @@ -109,7 +109,7 @@ /* AE firmware */ #define AE_FW_PROD_TYPE_DH895XCC 0x0040 -#define AE_FW_MOF_NAME_DH895XCC"qat_895xcc" +#define AE_FW_MOF_NAME_DH895XCC"qat_895xccfw" #define AE_FW_MMP_NAME_DH895XCC"qat_895xcc_mmp" #define AE_FW_UOF_NAME_DH895XCC"icp_qat_ae.uof" Modified: stable/12/sys/modules/qatfw/qat_c2xxx/Makefile == --- stable/12/sys/modules/qatfw/qat_c2xxx/Makefile Thu Dec 3 15:54:41 2020(r368303) +++ stable/12/sys/modules/qatfw/qat_c2xxx/Makefile Thu Dec 3 15:55:07 2020(r368304) @@ -6,6 +6,6 @@ KMOD= qat_c2xxxfw IMG1= mmp_firmware_c2xxx IMG2= mof_firmware_c2xxx -FIRMWS=${IMG1}.bin:${IMG1}:111 ${IMG2}.bin:${IMG2}:111 +FIRMWS=${IMG1}.bin:${KMOD}:111 ${IMG2}.bin:${IMG2}:111 .include Modified: stable/12/sys/modules/qatfw/qat_c3xxx/Makefile == --- stable/12/sys/modules/qatfw/qat_c3xxx/Makefile Thu Dec 3 15:54:41 2020(r368303) +++ stable/12/sys/modules/qatfw/qat_c3xxx/Makefile Thu Dec 3 15:55:07 2020(r368304) @@ -6,6 +6,6 @@ KMOD= qat_c3xxxfw IMG1= qat_c3xxx IMG2= qat_c3xxx_mmp -FIRMWS=${IMG1}.bin:${IMG1}:111 ${IMG2}.bin:${IMG2}:111 +FIRMWS=${IMG1}.bin:${KMOD}:111 ${IMG2}.bin:${IMG2}:111 .include Modified: stable/12/sys/modules/qatfw/qat_c62x/Makefile
svn commit: r368303 - stable/12/sys/dev/qat
Author: markj Date: Thu Dec 3 15:54:41 2020 New Revision: 368303 URL: https://svnweb.freebsd.org/changeset/base/368303 Log: MFC r368194: qat: Initialize the crypto device ID to -1 instead of 0 Modified: stable/12/sys/dev/qat/qat.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/qat/qat.c == --- stable/12/sys/dev/qat/qat.c Thu Dec 3 14:41:11 2020(r368302) +++ stable/12/sys/dev/qat/qat.c Thu Dec 3 15:54:41 2020(r368303) @@ -357,6 +357,7 @@ qat_attach(device_t dev) sc->sc_dev = dev; sc->sc_rev = pci_get_revid(dev); + sc->sc_crypto.qcy_cid = -1; qatp = qat_lookup(dev); memcpy(>sc_hw, qatp->qatp_hw, sizeof(struct qat_hw)); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r368278 - head/usr.sbin/rtsold
Author: markj Date: Wed Dec 2 16:46:45 2020 New Revision: 368278 URL: https://svnweb.freebsd.org/changeset/base/368278 Log: rtsold: Fix bugs reported by Coverity - Avoid leaking a socket if llflags_get() fails. - Avoid leaking a file handle if rtsold_init_dumpfile() fails. - Tighten the check in if_nametosdl() which determines whether we failed to find the specified interface. - Fix errno handling in an error path in rtsock_open(). MFC after:1 week Modified: head/usr.sbin/rtsold/cap_llflags.c head/usr.sbin/rtsold/dump.c head/usr.sbin/rtsold/if.c head/usr.sbin/rtsold/rtsock.c Modified: head/usr.sbin/rtsold/cap_llflags.c == --- head/usr.sbin/rtsold/cap_llflags.c Wed Dec 2 16:33:23 2020 (r368277) +++ head/usr.sbin/rtsold/cap_llflags.c Wed Dec 2 16:46:45 2020 (r368278) @@ -72,9 +72,12 @@ llflags_get(const char *ifname, int *flagsp) if (s < 0) return (-1); - if (getifaddrs() != 0) - return (-1); - error = -1; + ifap = NULL; + if (getifaddrs() != 0) { + error = errno; + goto out; + } + error = ENOENT; for (ifa = ifap; ifa != NULL; ifa = ifa->ifa_next) { if (strcmp(ifa->ifa_name, ifname) != 0) continue; @@ -88,27 +91,29 @@ llflags_get(const char *ifname, int *flagsp) memset(, 0, sizeof(ifr6)); if (strlcpy(ifr6.ifr_name, ifname, sizeof(ifr6.ifr_name)) >= sizeof(ifr6.ifr_name)) { - freeifaddrs(ifap); - errno = EINVAL; - return (-1); + error = errno; + goto out; } memcpy(_ifru.ifru_addr, sin6, sin6->sin6_len); if (ioctl(s, SIOCGIFAFLAG_IN6, ) < 0) { error = errno; - freeifaddrs(ifap); - errno = error; - return (-1); + goto out; } *flagsp = ifr6.ifr_ifru.ifru_flags6; error = 0; break; } +out: (void)close(s); - freeifaddrs(ifap); - if (error == -1) - errno = ENOENT; - return (error); + if (ifap != NULL) + freeifaddrs(ifap); + if (error != 0) { + errno = error; + return (-1); + } else { + return (0); + } } int Modified: head/usr.sbin/rtsold/dump.c == --- head/usr.sbin/rtsold/dump.c Wed Dec 2 16:33:23 2020(r368277) +++ head/usr.sbin/rtsold/dump.c Wed Dec 2 16:46:45 2020(r368278) @@ -148,6 +148,7 @@ rtsold_init_dumpfile(const char *dumpfile) if (caph_rights_limit(fileno(fp), ) != 0) { warnmsg(LOG_WARNING, __func__, "caph_rights_limit(%s): %s", dumpfile, strerror(errno)); + (void)fclose(fp); return (NULL); } return (fp); Modified: head/usr.sbin/rtsold/if.c == --- head/usr.sbin/rtsold/if.c Wed Dec 2 16:33:23 2020(r368277) +++ head/usr.sbin/rtsold/if.c Wed Dec 2 16:46:45 2020(r368278) @@ -327,7 +327,7 @@ if_nametosdl(char *name) } } } - if (next == lim) { + if (next >= lim) { /* search failed */ free(buf); return (NULL); Modified: head/usr.sbin/rtsold/rtsock.c == --- head/usr.sbin/rtsold/rtsock.c Wed Dec 2 16:33:23 2020 (r368277) +++ head/usr.sbin/rtsold/rtsock.c Wed Dec 2 16:46:45 2020 (r368278) @@ -84,7 +84,7 @@ rtsock_open(void) if (caph_rights_limit(s, ) != 0) { error = errno; (void)close(s); - errno = errno; + errno = error; return (-1); } return (s); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r368276 - head/sys/netpfil/pf
Author: markj Date: Wed Dec 2 16:01:43 2020 New Revision: 368276 URL: https://svnweb.freebsd.org/changeset/base/368276 Log: pf: Fix table entry counter toggling When updating a table, pf will keep existing table entry structures corresponding to addresses that are in both of the old and new tables. However, the update may also enable or disable per-entry counters which are allocated separately. Thus when toggling PFR_TFLAG_COUNTERS, the entries may be missing counters or may have unused counters allocated. Fix the problem by modifying pfr_ina_commit() to transfer counters from or to entries in the shadow table. PR: 251414 Reported by: sig...@gmail.com Reviewed by: kp MFC after:1 week Sponsored by: The FreeBSD Foundation Differential Revision:https://reviews.freebsd.org/D27440 Modified: head/sys/netpfil/pf/pf_table.c Modified: head/sys/netpfil/pf/pf_table.c == --- head/sys/netpfil/pf/pf_table.c Wed Dec 2 15:59:08 2020 (r368275) +++ head/sys/netpfil/pf/pf_table.c Wed Dec 2 16:01:43 2020 (r368276) @@ -1641,6 +1641,7 @@ pfr_ina_commit(struct pfr_table *trs, u_int32_t ticket static void pfr_commit_ktable(struct pfr_ktable *kt, long tzero) { + counter_u64_t *pkc, *qkc; struct pfr_ktable *shadow = kt->pfrkt_shadow; int nflags; @@ -1662,14 +1663,17 @@ pfr_commit_ktable(struct pfr_ktable *kt, long tzero) SLIST_INIT(); SLIST_INIT(); pfr_clean_node_mask(shadow, ); - for (p = SLIST_FIRST(); p != NULL; p = next) { - next = SLIST_NEXT(p, pfrke_workq); /* XXX */ + SLIST_FOREACH_SAFE(p, , pfrke_workq, next) { pfr_copyout_addr(, p); q = pfr_lookup_addr(kt, , 1); if (q != NULL) { if (q->pfrke_not != p->pfrke_not) SLIST_INSERT_HEAD(, q, pfrke_workq); + pkc = >pfrke_counters.pfrkc_counters; + qkc = >pfrke_counters.pfrkc_counters; + if ((*pkc == NULL) != (*qkc == NULL)) + SWAP(counter_u64_t, *pkc, *qkc); q->pfrke_mark = 1; SLIST_INSERT_HEAD(, p, pfrke_workq); } else { ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r368253 - stable/11/usr.sbin/rtsold
Author: markj Date: Tue Dec 1 19:36:37 2020 New Revision: 368253 URL: https://svnweb.freebsd.org/changeset/base/368253 Log: MFC r368248: rtsold: Fix multiple buffer overflows Approved by: so Security: CVE-2020-25577 Modified: stable/11/usr.sbin/rtsold/rtsol.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.sbin/rtsold/rtsol.c == --- stable/11/usr.sbin/rtsold/rtsol.c Tue Dec 1 19:36:36 2020 (r368252) +++ stable/11/usr.sbin/rtsold/rtsol.c Tue Dec 1 19:36:37 2020 (r368253) @@ -390,8 +390,8 @@ rtsol_input(int s) newent_rai = 1; } -#defineRA_OPT_NEXT_HDR(x) (struct nd_opt_hdr *)((char *)x + \ - (((struct nd_opt_hdr *)x)->nd_opt_len * 8)) +#defineRA_OPT_NEXT_HDR(x) (struct nd_opt_hdr *)((char *)(x) + \ + (((struct nd_opt_hdr *)(x))->nd_opt_len * 8)) /* Process RA options. */ warnmsg(LOG_DEBUG, __func__, "Processing RA"); raoptp = (char *)icp + sizeof(struct nd_router_advert); @@ -403,6 +403,15 @@ rtsol_input(int s) warnmsg(LOG_DEBUG, __func__, "ndo->nd_opt_len = %d", ndo->nd_opt_len); + if (ndo->nd_opt_len == 0) { + warnmsg(LOG_INFO, __func__, "invalid option length 0."); + break; + } + if ((char *)RA_OPT_NEXT_HDR(raoptp) > (char *)icp + msglen) { + warnmsg(LOG_INFO, __func__, "option length overflow."); + break; + } + switch (ndo->nd_opt_type) { case ND_OPT_RDNSS: rdnss = (struct nd_opt_rdnss *)raoptp; @@ -932,15 +941,18 @@ dname_labeldec(char *dst, size_t dlen, const char *src src_last = strchr(src, '\0'); dst_origin = dst; memset(dst, '\0', dlen); - while (src && (len = (uint8_t)(*src++) & 0x3f) && - (src + len) <= src_last && - (dst - dst_origin < (ssize_t)dlen)) { - if (dst != dst_origin) + while ((len = (*src++) & 0x3f) && + src + len <= src_last && + len + (dst == dst_origin ? 0 : 1) < dlen) { + if (dst != dst_origin) { *dst++ = '.'; + dlen--; + } warnmsg(LOG_DEBUG, __func__, "labellen = %zd", len); memcpy(dst, src, len); src += len; dst += len; + dlen -= len; } *dst = '\0'; ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r368250 - stable/12/usr.sbin/rtsold
Author: markj Date: Tue Dec 1 19:35:48 2020 New Revision: 368250 URL: https://svnweb.freebsd.org/changeset/base/368250 Log: MFC r368248: rtsold: Fix multiple buffer overflows Approved by: so Security: CVE-2020-25577 Modified: stable/12/usr.sbin/rtsold/rtsol.c Directory Properties: stable/12/ (props changed) Modified: stable/12/usr.sbin/rtsold/rtsol.c == --- stable/12/usr.sbin/rtsold/rtsol.c Tue Dec 1 19:34:45 2020 (r368249) +++ stable/12/usr.sbin/rtsold/rtsol.c Tue Dec 1 19:35:48 2020 (r368250) @@ -337,8 +337,8 @@ rtsol_input(int sock) newent_rai = 1; } -#defineRA_OPT_NEXT_HDR(x) (struct nd_opt_hdr *)((char *)x + \ - (((struct nd_opt_hdr *)x)->nd_opt_len * 8)) +#defineRA_OPT_NEXT_HDR(x) (struct nd_opt_hdr *)((char *)(x) + \ + (((struct nd_opt_hdr *)(x))->nd_opt_len * 8)) /* Process RA options. */ warnmsg(LOG_DEBUG, __func__, "Processing RA"); raoptp = (char *)icp + sizeof(struct nd_router_advert); @@ -350,6 +350,15 @@ rtsol_input(int sock) warnmsg(LOG_DEBUG, __func__, "ndo->nd_opt_len = %d", ndo->nd_opt_len); + if (ndo->nd_opt_len == 0) { + warnmsg(LOG_INFO, __func__, "invalid option length 0."); + break; + } + if ((char *)RA_OPT_NEXT_HDR(raoptp) > (char *)icp + msglen) { + warnmsg(LOG_INFO, __func__, "option length overflow."); + break; + } + switch (ndo->nd_opt_type) { case ND_OPT_RDNSS: rdnss = (struct nd_opt_rdnss *)raoptp; @@ -760,15 +769,18 @@ dname_labeldec(char *dst, size_t dlen, const char *src src_last = strchr(src, '\0'); dst_origin = dst; memset(dst, '\0', dlen); - while (src && (len = (uint8_t)(*src++) & 0x3f) && - (src + len) <= src_last && - (dst - dst_origin < (ssize_t)dlen)) { - if (dst != dst_origin) + while ((len = (*src++) & 0x3f) && + src + len <= src_last && + len + (dst == dst_origin ? 0 : 1) < dlen) { + if (dst != dst_origin) { *dst++ = '.'; + dlen--; + } warnmsg(LOG_DEBUG, __func__, "labellen = %zd", len); memcpy(dst, src, len); src += len; dst += len; + dlen -= len; } *dst = '\0'; ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r368248 - head/usr.sbin/rtsold
Author: markj Date: Tue Dec 1 19:34:44 2020 New Revision: 368248 URL: https://svnweb.freebsd.org/changeset/base/368248 Log: rtsold: Fix multiple buffer overflows Approved by: so Security: CVE-2020-25577 MFC after:now Modified: head/usr.sbin/rtsold/rtsol.c Modified: head/usr.sbin/rtsold/rtsol.c == --- head/usr.sbin/rtsold/rtsol.cTue Dec 1 18:57:37 2020 (r368247) +++ head/usr.sbin/rtsold/rtsol.cTue Dec 1 19:34:44 2020 (r368248) @@ -337,8 +337,8 @@ rtsol_input(int sock) newent_rai = 1; } -#defineRA_OPT_NEXT_HDR(x) (struct nd_opt_hdr *)((char *)x + \ - (((struct nd_opt_hdr *)x)->nd_opt_len * 8)) +#defineRA_OPT_NEXT_HDR(x) (struct nd_opt_hdr *)((char *)(x) + \ + (((struct nd_opt_hdr *)(x))->nd_opt_len * 8)) /* Process RA options. */ warnmsg(LOG_DEBUG, __func__, "Processing RA"); raoptp = (char *)icp + sizeof(struct nd_router_advert); @@ -350,6 +350,15 @@ rtsol_input(int sock) warnmsg(LOG_DEBUG, __func__, "ndo->nd_opt_len = %d", ndo->nd_opt_len); + if (ndo->nd_opt_len == 0) { + warnmsg(LOG_INFO, __func__, "invalid option length 0."); + break; + } + if ((char *)RA_OPT_NEXT_HDR(raoptp) > (char *)icp + msglen) { + warnmsg(LOG_INFO, __func__, "option length overflow."); + break; + } + switch (ndo->nd_opt_type) { case ND_OPT_RDNSS: rdnss = (struct nd_opt_rdnss *)raoptp; @@ -760,15 +769,18 @@ dname_labeldec(char *dst, size_t dlen, const char *src src_last = strchr(src, '\0'); dst_origin = dst; memset(dst, '\0', dlen); - while (src && (len = (uint8_t)(*src++) & 0x3f) && - (src + len) <= src_last && - (dst - dst_origin < (ssize_t)dlen)) { - if (dst != dst_origin) + while ((len = (*src++) & 0x3f) && + src + len <= src_last && + len + (dst == dst_origin ? 0 : 1) < dlen) { + if (dst != dst_origin) { *dst++ = '.'; + dlen--; + } warnmsg(LOG_DEBUG, __func__, "labellen = %zd", len); memcpy(dst, src, len); src += len; dst += len; + dlen -= len; } *dst = '\0'; ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r368236 - head/sys/kern
Author: markj Date: Tue Dec 1 16:06:31 2020 New Revision: 368236 URL: https://svnweb.freebsd.org/changeset/base/368236 Log: vmem: Revert r364744 A pair of bugs are believed to have caused the hangs described in the commit log message for r364744: 1. uma_reclaim() could trigger reclamation of the reserve of boundary tags used to avoid deadlock. This was fixed by r366840. 2. The loop in vmem_xalloc() would in some cases try to allocate more boundary tags than the expected upper bound of BT_MAXALLOC. The reserve is sized based on the value BT_MAXMALLOC, so this behaviour could deplete the reserve without guaranteeing a successful allocation, resulting in a hang. This was fixed by r366838. PR: 248008 Tested by:rmacklem Modified: head/sys/kern/subr_vmem.c Modified: head/sys/kern/subr_vmem.c == --- head/sys/kern/subr_vmem.c Tue Dec 1 16:02:52 2020(r368235) +++ head/sys/kern/subr_vmem.c Tue Dec 1 16:06:31 2020(r368236) @@ -706,14 +706,10 @@ vmem_startup(void) vmem_zone = uma_zcreate("vmem", sizeof(struct vmem), NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, 0); -#ifdef UMA_MD_SMALL_ALLOC vmem_bt_zone = uma_zcreate("vmem btag", sizeof(struct vmem_btag), NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_VM); -#else - vmem_bt_zone = uma_zcreate("vmem btag", - sizeof(struct vmem_btag), NULL, NULL, NULL, NULL, - UMA_ALIGN_PTR, UMA_ZONE_VM | UMA_ZONE_NOFREE); +#ifndef UMA_MD_SMALL_ALLOC mtx_init(_bt_lock, "btag lock", NULL, MTX_DEF); uma_prealloc(vmem_bt_zone, BT_MAXALLOC); /* ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r368232 - stable/12/sys/netpfil/pf
Author: markj Date: Tue Dec 1 15:11:16 2020 New Revision: 368232 URL: https://svnweb.freebsd.org/changeset/base/368232 Log: MFC r367987: pf: Make tag hashing more robust Modified: stable/12/sys/netpfil/pf/pf_ioctl.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/netpfil/pf/pf_ioctl.c == --- stable/12/sys/netpfil/pf/pf_ioctl.c Tue Dec 1 15:09:02 2020 (r368231) +++ stable/12/sys/netpfil/pf/pf_ioctl.c Tue Dec 1 15:11:16 2020 (r368232) @@ -513,8 +513,10 @@ pf_cleanup_tagset(struct pf_tagset *ts) static uint16_t tagname2hashindex(const struct pf_tagset *ts, const char *tagname) { + size_t len; - return (murmur3_32_hash(tagname, strlen(tagname), ts->seed) & ts->mask); + len = strnlen(tagname, PF_TAG_NAME_SIZE - 1); + return (murmur3_32_hash(tagname, len, ts->seed) & ts->mask); } static uint16_t ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r368231 - stable/12/sbin/ping
Author: markj Date: Tue Dec 1 15:09:02 2020 New Revision: 368231 URL: https://svnweb.freebsd.org/changeset/base/368231 Log: MFC r367988: ping(8): Improve parameter validation PR: 239974, 239977, 239978 Modified: stable/12/sbin/ping/ping.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sbin/ping/ping.c == --- stable/12/sbin/ping/ping.c Tue Dec 1 15:01:10 2020(r368230) +++ stable/12/sbin/ping/ping.c Tue Dec 1 15:09:02 2020(r368231) @@ -236,6 +236,7 @@ main(int argc, char *const *argv) struct sigaction si_sa; size_t sz; u_char *datap, packet[IP_MAXPACKET] __aligned(4); + const char *errstr; char *ep, *source, *target, *payload; struct hostent *hp; #ifdef IPSEC_POLICY_IPSEC @@ -244,7 +245,7 @@ main(int argc, char *const *argv) struct sockaddr_in *to; double t; u_long alarmtimeout; - long ltmp; + long long ltmp; int almost_done, ch, df, hold, i, icmp_len, mib[4], preload; int ssend_errno, srecv_errno, tos, ttl; char ctrl[CMSG_SPACE(sizeof(struct timespec))]; @@ -315,12 +316,12 @@ main(int argc, char *const *argv) options |= F_AUDIBLE; break; case 'c': - ltmp = strtol(optarg, , 0); - if (*ep || ep == optarg || ltmp <= 0) + ltmp = strtonum(optarg, 1, LONG_MAX, ); + if (errstr != NULL) errx(EX_USAGE, "invalid count of packets to transmit: `%s'", optarg); - npackets = ltmp; + npackets = (long)ltmp; break; case 'D': options |= F_HDRINCL; @@ -338,46 +339,46 @@ main(int argc, char *const *argv) setbuf(stdout, (char *)NULL); break; case 'G': /* Maximum packet size for ping sweep */ - ltmp = strtol(optarg, , 0); - if (*ep || ep == optarg || ltmp <= 0) + ltmp = strtonum(optarg, 1, INT_MAX, ); + if (errstr != NULL) { errx(EX_USAGE, "invalid packet size: `%s'", optarg); - if (uid != 0 && ltmp > DEFDATALEN) { - errno = EPERM; - err(EX_NOPERM, - "packet size too large: %ld > %u", - ltmp, DEFDATALEN); } + sweepmax = (int)ltmp; + if (uid != 0 && sweepmax > DEFDATALEN) { + errc(EX_NOPERM, EPERM, + "packet size too large: %d > %u", + sweepmax, DEFDATALEN); + } options |= F_SWEEP; - sweepmax = ltmp; break; case 'g': /* Minimum packet size for ping sweep */ - ltmp = strtol(optarg, , 0); - if (*ep || ep == optarg || ltmp <= 0) + ltmp = strtonum(optarg, 1, INT_MAX, ); + if (errstr != NULL) { errx(EX_USAGE, "invalid packet size: `%s'", optarg); - if (uid != 0 && ltmp > DEFDATALEN) { - errno = EPERM; - err(EX_NOPERM, - "packet size too large: %ld > %u", - ltmp, DEFDATALEN); } + sweepmin = (int)ltmp; + if (uid != 0 && sweepmin > DEFDATALEN) { + errc(EX_NOPERM, EPERM, + "packet size too large: %d > %u", + sweepmin, DEFDATALEN); + } options |= F_SWEEP; - sweepmin = ltmp; break; case 'h': /* Packet size increment for ping sweep */ - ltmp = strtol(optarg, , 0); - if (*ep || ep == optarg || ltmp < 1) - errx(EX_USAGE, "invalid increment size: `%s'", + ltmp = strtonum(optarg, 1, INT_MAX, ); + if (errstr != NULL) { + errx(EX_USAGE, "invalid packet size: `%s'", optarg); - if (uid != 0 && ltmp > DEFDATALEN) { -
svn commit: r368230 - stable/12/sys/dev/ata
Author: markj Date: Tue Dec 1 15:01:10 2020 New Revision: 368230 URL: https://svnweb.freebsd.org/changeset/base/368230 Log: MFC r367989: ata(4): Release the ioport resource if device initialization fails PR: 251346 Modified: stable/12/sys/dev/ata/ata-pci.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/ata/ata-pci.c == --- stable/12/sys/dev/ata/ata-pci.c Tue Dec 1 13:58:14 2020 (r368229) +++ stable/12/sys/dev/ata/ata-pci.c Tue Dec 1 15:01:10 2020 (r368230) @@ -111,8 +111,12 @@ ata_pci_attach(device_t dev) RF_ACTIVE); } -if (ctlr->chipinit(dev)) +if (ctlr->chipinit(dev)) { + if (ctlr->r_res1) + bus_release_resource(dev, ctlr->r_type1, ctlr->r_rid1, +ctlr->r_res1); return ENXIO; +} /* attach all channels on this controller */ for (unit = 0; unit < ctlr->channels; unit++) { ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r368202 - stable/11/sys/netinet6
Author: markj Date: Tue Dec 1 03:07:26 2020 New Revision: 368202 URL: https://svnweb.freebsd.org/changeset/base/368202 Log: MFC r367114 (by melifaro): Fix use-after-free in icmp6_notify_error(). Modified: stable/11/sys/netinet6/icmp6.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/netinet6/icmp6.c == --- stable/11/sys/netinet6/icmp6.c Mon Nov 30 22:35:30 2020 (r368201) +++ stable/11/sys/netinet6/icmp6.c Tue Dec 1 03:07:26 2020 (r368202) @@ -903,6 +903,7 @@ icmp6_notify_error(struct mbuf **mp, int off, int icmp } #endif eip6 = (struct ip6_hdr *)(icmp6 + 1); + bzero(, sizeof(icmp6dst)); /* Detect the upper level protocol */ { @@ -911,7 +912,6 @@ icmp6_notify_error(struct mbuf **mp, int off, int icmp int eoff = off + sizeof(struct icmp6_hdr) + sizeof(struct ip6_hdr); struct ip6ctlparam ip6cp; - struct in6_addr *finaldst = NULL; int icmp6type = icmp6->icmp6_type; struct ip6_frag *fh; struct ip6_rthdr *rth; @@ -994,7 +994,7 @@ icmp6_notify_error(struct mbuf **mp, int off, int icmp /* just ignore a bogus header */ if ((rth0->ip6r0_len % 2) == 0 && (hops = rth0->ip6r0_len/2)) - finaldst = (struct in6_addr *)(rth0 + 1) + (hops - 1); + icmp6dst.sin6_addr = *((struct in6_addr *)(rth0 + 1) + (hops - 1)); } eoff += rthlen; nxt = rth->ip6r_nxt; @@ -1059,13 +1059,10 @@ icmp6_notify_error(struct mbuf **mp, int off, int icmp */ eip6 = (struct ip6_hdr *)(icmp6 + 1); - bzero(, sizeof(icmp6dst)); icmp6dst.sin6_len = sizeof(struct sockaddr_in6); icmp6dst.sin6_family = AF_INET6; - if (finaldst == NULL) + if (IN6_IS_ADDR_UNSPECIFIED(_addr)) icmp6dst.sin6_addr = eip6->ip6_dst; - else - icmp6dst.sin6_addr = *finaldst; if (in6_setscope(_addr, m->m_pkthdr.rcvif, NULL)) goto freeit; bzero(, sizeof(icmp6src)); @@ -1077,13 +1074,11 @@ icmp6_notify_error(struct mbuf **mp, int off, int icmp icmp6src.sin6_flowinfo = (eip6->ip6_flow & IPV6_FLOWLABEL_MASK); - if (finaldst == NULL) - finaldst = >ip6_dst; ip6cp.ip6c_m = m; ip6cp.ip6c_icmp6 = icmp6; ip6cp.ip6c_ip6 = (struct ip6_hdr *)(icmp6 + 1); ip6cp.ip6c_off = eoff; - ip6cp.ip6c_finaldst = finaldst; + ip6cp.ip6c_finaldst = _addr; ip6cp.ip6c_src = ip6cp.ip6c_nxt = nxt; ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r368194 - head/sys/dev/qat
Author: markj Date: Mon Nov 30 20:53:45 2020 New Revision: 368194 URL: https://svnweb.freebsd.org/changeset/base/368194 Log: qat: Initialize the crypto device ID to -1 instead of 0 Otherwise qat_detach() may attempt to deregister an unrelated crypto driver if an error occurs in qat_attach() before crypto_get_driverid() is called, since 0 is a valid driver ID. MFC after:3 days Sponsored by: Rubicon Communications, LLC (Netgate) Modified: head/sys/dev/qat/qat.c Modified: head/sys/dev/qat/qat.c == --- head/sys/dev/qat/qat.c Mon Nov 30 20:53:25 2020(r368193) +++ head/sys/dev/qat/qat.c Mon Nov 30 20:53:45 2020(r368194) @@ -357,6 +357,7 @@ qat_attach(device_t dev) sc->sc_dev = dev; sc->sc_rev = pci_get_revid(dev); + sc->sc_crypto.qcy_cid = -1; qatp = qat_lookup(dev); memcpy(>sc_hw, qatp->qatp_hw, sizeof(struct qat_hw)); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r368193 - in head/sys: dev/qat modules/qatfw/qat_c2xxx modules/qatfw/qat_c3xxx modules/qatfw/qat_c62x modules/qatfw/qat_d15xx modules/qatfw/qat_dh895xcc
Author: markj Date: Mon Nov 30 20:53:25 2020 New Revision: 368193 URL: https://svnweb.freebsd.org/changeset/base/368193 Log: qat: Fix firmware module autoloading If firmware_get() fails to find a loaded firmware image, it searches for candidate KLDs to load. It will search for a KLD containing a module with the same name as the requested image, and failing that, will load a KLD with the same basename as the requested image. The module name given by fw_stub.awk is simply "_fw". QAT firmware modules contain two images, neither of which match either of the names used during lookup, so automatic loading of firmware images after mountroot does not work. Work around this by using the same string for the first image name and for the KLD basename. MFC after:3 days Sponsored by: Rubicon Communications, LLC (Netgate) Modified: head/sys/dev/qat/qat_c2xxxreg.h head/sys/dev/qat/qat_c3xxxreg.h head/sys/dev/qat/qat_c62xreg.h head/sys/dev/qat/qat_d15xxreg.h head/sys/dev/qat/qat_dh895xccreg.h head/sys/modules/qatfw/qat_c2xxx/Makefile head/sys/modules/qatfw/qat_c3xxx/Makefile head/sys/modules/qatfw/qat_c62x/Makefile head/sys/modules/qatfw/qat_d15xx/Makefile head/sys/modules/qatfw/qat_dh895xcc/Makefile Modified: head/sys/dev/qat/qat_c2xxxreg.h == --- head/sys/dev/qat/qat_c2xxxreg.h Mon Nov 30 19:18:50 2020 (r368192) +++ head/sys/dev/qat/qat_c2xxxreg.h Mon Nov 30 20:53:25 2020 (r368193) @@ -169,7 +169,7 @@ /* AE firmware */ #define AE_FW_PROD_TYPE_C2XXX 0x0080 -#define AE_FW_MOF_NAME_C2XXX "mof_firmware_c2xxx" +#define AE_FW_MOF_NAME_C2XXX "qat_c2xxxfw" #define AE_FW_MMP_NAME_C2XXX "mmp_firmware_c2xxx" #define AE_FW_UOF_NAME_C2XXX_A0"icp_qat_nae.uof" #define AE_FW_UOF_NAME_C2XXX_B0"icp_qat_nae_b0.uof" Modified: head/sys/dev/qat/qat_c3xxxreg.h == --- head/sys/dev/qat/qat_c3xxxreg.h Mon Nov 30 19:18:50 2020 (r368192) +++ head/sys/dev/qat/qat_c3xxxreg.h Mon Nov 30 20:53:25 2020 (r368193) @@ -168,7 +168,7 @@ /* AE firmware */ #define AE_FW_PROD_TYPE_C3XXX 0x0200 -#define AE_FW_MOF_NAME_C3XXX "qat_c3xxx" +#define AE_FW_MOF_NAME_C3XXX "qat_c3xxxfw" #define AE_FW_MMP_NAME_C3XXX "qat_c3xxx_mmp" #define AE_FW_UOF_NAME_C3XXX "icp_qat_ae.suof" Modified: head/sys/dev/qat/qat_c62xreg.h == --- head/sys/dev/qat/qat_c62xreg.h Mon Nov 30 19:18:50 2020 (r368192) +++ head/sys/dev/qat/qat_c62xreg.h Mon Nov 30 20:53:25 2020 (r368193) @@ -191,7 +191,7 @@ /* AE firmware */ #define AE_FW_PROD_TYPE_C62X 0x0100 -#define AE_FW_MOF_NAME_C62X"qat_c62x" +#define AE_FW_MOF_NAME_C62X"qat_c62xfw" #define AE_FW_MMP_NAME_C62X"qat_c62x_mmp" #define AE_FW_UOF_NAME_C62X"icp_qat_ae.suof" Modified: head/sys/dev/qat/qat_d15xxreg.h == --- head/sys/dev/qat/qat_d15xxreg.h Mon Nov 30 19:18:50 2020 (r368192) +++ head/sys/dev/qat/qat_d15xxreg.h Mon Nov 30 20:53:25 2020 (r368193) @@ -191,7 +191,7 @@ /* AE firmware */ #define AE_FW_PROD_TYPE_D15XX 0x0100 -#define AE_FW_MOF_NAME_D15XX "qat_d15xx" +#define AE_FW_MOF_NAME_D15XX "qat_d15xxfw" #define AE_FW_MMP_NAME_D15XX "qat_d15xx_mmp" #define AE_FW_UOF_NAME_D15XX "icp_qat_ae.suof" Modified: head/sys/dev/qat/qat_dh895xccreg.h == --- head/sys/dev/qat/qat_dh895xccreg.h Mon Nov 30 19:18:50 2020 (r368192) +++ head/sys/dev/qat/qat_dh895xccreg.h Mon Nov 30 20:53:25 2020 (r368193) @@ -109,7 +109,7 @@ /* AE firmware */ #define AE_FW_PROD_TYPE_DH895XCC 0x0040 -#define AE_FW_MOF_NAME_DH895XCC"qat_895xcc" +#define AE_FW_MOF_NAME_DH895XCC"qat_895xccfw" #define AE_FW_MMP_NAME_DH895XCC"qat_895xcc_mmp" #define AE_FW_UOF_NAME_DH895XCC"icp_qat_ae.uof" Modified: head/sys/modules/qatfw/qat_c2xxx/Makefile == --- head/sys/modules/qatfw/qat_c2xxx/Makefile Mon Nov 30 19:18:50 2020 (r368192) +++ head/sys/modules/qatfw/qat_c2xxx/Makefile Mon Nov 30 20:53:25 2020 (r368193) @@ -6,6 +6,6 @@ KMOD= qat_c2xxxfw IMG1= mmp_firmware_c2xxx IMG2= mof_firmware_c2xxx -FIRMWS=${IMG1}.bin:${IMG1}:111 ${IMG2}.bin:${IMG2}:111 +FIRMWS=${IMG1}.bin:${KMOD}:111 ${IMG2}.bin:${IMG2}:111 .include Modified: head/sys/modules/qatfw/qat_c3xxx/Makefile == ---
svn commit: r368189 - head/sys/vm
Author: markj Date: Mon Nov 30 16:18:33 2020 New Revision: 368189 URL: https://svnweb.freebsd.org/changeset/base/368189 Log: uma: Avoid allocating buckets with the cross-domain lock held Allocation of a bucket can trigger a cross-domain free in the bucket zone, e.g., if the per-CPU alloc bucket is empty, we free it and get migrated to a remote domain. This can lead to deadlocks since a bucket zone may allocate buckets from itself or a pair of bucket zones could be allocating from each other. Fix the problem by dropping the cross-domain lock before allocating a new bucket and handling refill races. Use a list of empty buckets to ensure that we can make forward progress. Reported by: imp, mjg (witness(9) warnings) Discussed with: jeff Sponsored by: The FreeBSD Foundation Differential Revision:https://reviews.freebsd.org/D27341 Modified: head/sys/vm/uma_core.c Modified: head/sys/vm/uma_core.c == --- head/sys/vm/uma_core.c Mon Nov 30 15:04:35 2020(r368188) +++ head/sys/vm/uma_core.c Mon Nov 30 16:18:33 2020(r368189) @@ -4250,7 +4250,7 @@ zfree_item: static void zone_free_cross(uma_zone_t zone, uma_bucket_t bucket, void *udata) { - struct uma_bucketlist fullbuckets; + struct uma_bucketlist emptybuckets, fullbuckets; uma_zone_domain_t zdom; uma_bucket_t b; smr_seq_t seq; @@ -4274,31 +4274,57 @@ zone_free_cross(uma_zone_t zone, uma_bucket_t bucket, * lock on the current crossfree bucket. A full matrix with * per-domain locking could be used if necessary. */ + STAILQ_INIT(); STAILQ_INIT(); ZONE_CROSS_LOCK(zone); - while (bucket->ub_cnt > 0) { + for (; bucket->ub_cnt > 0; bucket->ub_cnt--) { item = bucket->ub_bucket[bucket->ub_cnt - 1]; domain = item_domain(item); zdom = ZDOM_GET(zone, domain); if (zdom->uzd_cross == NULL) { - zdom->uzd_cross = bucket_alloc(zone, udata, M_NOWAIT); - if (zdom->uzd_cross == NULL) - break; + if ((b = STAILQ_FIRST()) != NULL) { + STAILQ_REMOVE_HEAD(, ub_link); + zdom->uzd_cross = b; + } else { + /* +* Avoid allocating a bucket with the cross lock +* held, since allocation can trigger a +* cross-domain free and bucket zones may +* allocate from each other. +*/ + ZONE_CROSS_UNLOCK(zone); + b = bucket_alloc(zone, udata, M_NOWAIT); + if (b == NULL) + goto out; + ZONE_CROSS_LOCK(zone); + if (zdom->uzd_cross != NULL) { + STAILQ_INSERT_HEAD(, b, + ub_link); + } else { + zdom->uzd_cross = b; + } + } } b = zdom->uzd_cross; b->ub_bucket[b->ub_cnt++] = item; b->ub_seq = seq; if (b->ub_cnt == b->ub_entries) { STAILQ_INSERT_HEAD(, b, ub_link); - zdom->uzd_cross = NULL; + if ((b = STAILQ_FIRST()) != NULL) + STAILQ_REMOVE_HEAD(, ub_link); + zdom->uzd_cross = b; } - bucket->ub_cnt--; } ZONE_CROSS_UNLOCK(zone); +out: if (bucket->ub_cnt == 0) bucket->ub_seq = SMR_SEQ_INVALID; bucket_free(zone, bucket, udata); + while ((b = STAILQ_FIRST()) != NULL) { + STAILQ_REMOVE_HEAD(, ub_link); + bucket_free(zone, b, udata); + } while ((b = STAILQ_FIRST()) != NULL) { STAILQ_REMOVE_HEAD(, ub_link); domain = item_domain(b->ub_bucket[0]); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r368112 - in head/sys: kern sys
Author: markj Date: Fri Nov 27 20:46:02 2020 New Revision: 368112 URL: https://svnweb.freebsd.org/changeset/base/368112 Log: callout(9): Remove some leftover APM BIOS support This code is obsolete since r366546. Reviewed by: imp Sponsored by: The FreeBSD Foundation Differential Revision:https://reviews.freebsd.org/D27267 Modified: head/sys/kern/kern_timeout.c head/sys/sys/systm.h Modified: head/sys/kern/kern_timeout.c == --- head/sys/kern/kern_timeout.cFri Nov 27 18:40:51 2020 (r368111) +++ head/sys/kern/kern_timeout.cFri Nov 27 20:46:02 2020 (r368112) @@ -1339,71 +1339,6 @@ _callout_init_lock(struct callout *c, struct lock_obje c->c_cpu = cc_default_cpu; } -#ifdef APM_FIXUP_CALLTODO -/* - * Adjust the kernel calltodo timeout list. This routine is used after - * an APM resume to recalculate the calltodo timer list values with the - * number of hz's we have been sleeping. The next hardclock() will detect - * that there are fired timers and run softclock() to execute them. - * - * Please note, I have not done an exhaustive analysis of what code this - * might break. I am motivated to have my select()'s and alarm()'s that - * have expired during suspend firing upon resume so that the applications - * which set the timer can do the maintanence the timer was for as close - * as possible to the originally intended time. Testing this code for a - * week showed that resuming from a suspend resulted in 22 to 25 timers - * firing, which seemed independent on whether the suspend was 2 hours or - * 2 days. Your milage may vary. - Ken Key - */ -void -adjust_timeout_calltodo(struct timeval *time_change) -{ - struct callout *p; - unsigned long delta_ticks; - - /* -* How many ticks were we asleep? -* (stolen from tvtohz()). -*/ - - /* Don't do anything */ - if (time_change->tv_sec < 0) - return; - else if (time_change->tv_sec <= LONG_MAX / 100) - delta_ticks = howmany(time_change->tv_sec * 100 + - time_change->tv_usec, tick) + 1; - else if (time_change->tv_sec <= LONG_MAX / hz) - delta_ticks = time_change->tv_sec * hz + - howmany(time_change->tv_usec, tick) + 1; - else - delta_ticks = LONG_MAX; - - if (delta_ticks > INT_MAX) - delta_ticks = INT_MAX; - - /* -* Now rip through the timer calltodo list looking for timers -* to expire. -*/ - - /* don't collide with softclock() */ - CC_LOCK(cc); - for (p = calltodo.c_next; p != NULL; p = p->c_next) { - p->c_time -= delta_ticks; - - /* Break if the timer had more time on it than delta_ticks */ - if (p->c_time > 0) - break; - - /* take back the ticks the timer didn't use (p->c_time <= 0) */ - delta_ticks = -p->c_time; - } - CC_UNLOCK(cc); - - return; -} -#endif /* APM_FIXUP_CALLTODO */ - static int flssbt(sbintime_t sbt) { Modified: head/sys/sys/systm.h == --- head/sys/sys/systm.hFri Nov 27 18:40:51 2020(r368111) +++ head/sys/sys/systm.hFri Nov 27 20:46:02 2020(r368112) @@ -482,11 +482,6 @@ extern cpu_tick_f *cpu_ticks; uint64_t cpu_tickrate(void); uint64_t cputick2usec(uint64_t tick); -#ifdef APM_FIXUP_CALLTODO -struct timeval; -void adjust_timeout_calltodo(struct timeval *time_change); -#endif /* APM_FIXUP_CALLTODO */ - #include /* Initialize the world */ ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r368108 - head/sys/arm/include
Author: markj Date: Fri Nov 27 16:35:43 2020 New Revision: 368108 URL: https://svnweb.freebsd.org/changeset/base/368108 Log: arm: Correctly report the size of FPA registers to GDB Modern ARM systems do not have an FPA unit but GDB reserves register indices for FPA registers and expects the stub to know their sizes. PR: 251022 Submitted by: Dmitry Salychev MFC after:2 weeks Modified: head/sys/arm/include/gdb_machdep.h Modified: head/sys/arm/include/gdb_machdep.h == --- head/sys/arm/include/gdb_machdep.h Fri Nov 27 16:29:54 2020 (r368107) +++ head/sys/arm/include/gdb_machdep.h Fri Nov 27 16:35:43 2020 (r368108) @@ -36,9 +36,13 @@ #defineGDB_REG_PC 15 static __inline size_t -gdb_cpu_regsz(int regnum __unused) +gdb_cpu_regsz(int regnum) { - return (sizeof(int)); + /* +* GDB expects the FPA registers f0-f7, each 96 bits wide, to be placed +* in between the PC and CSPR in response to a "g" packet. +*/ + return (regnum >= 16 && regnum <= 23 ? 12 : sizeof(int)); } static __inline int ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r368057 - stable/12/sys/kern
Author: markj Date: Thu Nov 26 14:57:30 2020 New Revision: 368057 URL: https://svnweb.freebsd.org/changeset/base/368057 Log: MFC r367849: callout(9): Fix a race between CPU migration and callout_drain() Modified: stable/12/sys/kern/kern_timeout.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/kern/kern_timeout.c == --- stable/12/sys/kern/kern_timeout.c Thu Nov 26 14:42:16 2020 (r368056) +++ stable/12/sys/kern/kern_timeout.c Thu Nov 26 14:57:30 2020 (r368057) @@ -1274,7 +1274,7 @@ again: * just wait for the current invocation to * finish. */ - while (cc_exec_curr(cc, direct) == c) { + if (cc_exec_curr(cc, direct) == c) { /* * Use direct calls to sleepqueue interface * instead of cv/msleep in order to avoid @@ -1322,7 +1322,7 @@ again: /* Reacquire locks previously released. */ PICKUP_GIANT(); - CC_LOCK(cc); + goto again; } c->c_flags &= ~CALLOUT_ACTIVE; } else if (use_lock && ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r367989 - head/sys/dev/ata
Author: markj Date: Tue Nov 24 17:13:08 2020 New Revision: 367989 URL: https://svnweb.freebsd.org/changeset/base/367989 Log: ata(4): Release the ioport resource if device initialization fails PR: 251346 Submitted by: j...@transactionware.com MFC after:1 week Modified: head/sys/dev/ata/ata-pci.c Modified: head/sys/dev/ata/ata-pci.c == --- head/sys/dev/ata/ata-pci.c Tue Nov 24 17:12:40 2020(r367988) +++ head/sys/dev/ata/ata-pci.c Tue Nov 24 17:13:08 2020(r367989) @@ -111,8 +111,12 @@ ata_pci_attach(device_t dev) RF_ACTIVE); } -if (ctlr->chipinit(dev)) +if (ctlr->chipinit(dev)) { + if (ctlr->r_res1) + bus_release_resource(dev, ctlr->r_type1, ctlr->r_rid1, +ctlr->r_res1); return ENXIO; +} /* attach all channels on this controller */ for (unit = 0; unit < ctlr->channels; unit++) { ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r367988 - head/sbin/ping
Author: markj Date: Tue Nov 24 17:12:40 2020 New Revision: 367988 URL: https://svnweb.freebsd.org/changeset/base/367988 Log: ping(8): Improve parameter validation - Use strtonum(3) to simplify bounds checking of numeric parameters. - Fix bounds checking when filling out packet data in "sweep" mode. PR: 239974, 239977, 239978 Reported by: Neeraj MFC after:1 week Differential Revision:https://reviews.freebsd.org/D25622 Modified: head/sbin/ping/ping.c Modified: head/sbin/ping/ping.c == --- head/sbin/ping/ping.c Tue Nov 24 16:18:47 2020(r367987) +++ head/sbin/ping/ping.c Tue Nov 24 17:12:40 2020(r367988) @@ -238,6 +238,7 @@ main(int argc, char *const *argv) struct sigaction si_sa; size_t sz; u_char *datap, packet[IP_MAXPACKET] __aligned(4); + const char *errstr; char *ep, *source, *target, *payload; struct hostent *hp; #ifdef IPSEC_POLICY_IPSEC @@ -246,7 +247,7 @@ main(int argc, char *const *argv) struct sockaddr_in *to; double t; u_long alarmtimeout; - long ltmp; + long long ltmp; int almost_done, ch, df, hold, i, icmp_len, mib[4], preload; int ssend_errno, srecv_errno, tos, ttl, pcp; char ctrl[CMSG_SPACE(sizeof(struct timespec))]; @@ -317,18 +318,18 @@ main(int argc, char *const *argv) break; case 'C': options |= F_IP_VLAN_PCP; - ltmp = strtol(optarg, , 0); - if (*ep || ep == optarg || ltmp > 7 || ltmp < -1) + ltmp = strtonum(optarg, -1, 7, ); + if (errstr != NULL) errx(EX_USAGE, "invalid PCP: `%s'", optarg); pcp = ltmp; break; case 'c': - ltmp = strtol(optarg, , 0); - if (*ep || ep == optarg || ltmp <= 0) + ltmp = strtonum(optarg, 1, LONG_MAX, ); + if (errstr != NULL) errx(EX_USAGE, "invalid count of packets to transmit: `%s'", optarg); - npackets = ltmp; + npackets = (long)ltmp; break; case 'D': options |= F_HDRINCL; @@ -346,49 +347,49 @@ main(int argc, char *const *argv) setbuf(stdout, (char *)NULL); break; case 'G': /* Maximum packet size for ping sweep */ - ltmp = strtol(optarg, , 0); - if (*ep || ep == optarg || ltmp <= 0) + ltmp = strtonum(optarg, 1, INT_MAX, ); + if (errstr != NULL) { errx(EX_USAGE, "invalid packet size: `%s'", optarg); - if (uid != 0 && ltmp > DEFDATALEN) { - errno = EPERM; - err(EX_NOPERM, - "packet size too large: %ld > %u", - ltmp, DEFDATALEN); } + sweepmax = (int)ltmp; + if (uid != 0 && sweepmax > DEFDATALEN) { + errc(EX_NOPERM, EPERM, + "packet size too large: %d > %u", + sweepmax, DEFDATALEN); + } options |= F_SWEEP; - sweepmax = ltmp; break; case 'g': /* Minimum packet size for ping sweep */ - ltmp = strtol(optarg, , 0); - if (*ep || ep == optarg || ltmp <= 0) + ltmp = strtonum(optarg, 1, INT_MAX, ); + if (errstr != NULL) { errx(EX_USAGE, "invalid packet size: `%s'", optarg); - if (uid != 0 && ltmp > DEFDATALEN) { - errno = EPERM; - err(EX_NOPERM, - "packet size too large: %ld > %u", - ltmp, DEFDATALEN); } + sweepmin = (int)ltmp; + if (uid != 0 && sweepmin > DEFDATALEN) { + errc(EX_NOPERM, EPERM, + "packet size too large: %d > %u", + sweepmin, DEFDATALEN); + } options |= F_SWEEP; - sweepmin = ltmp;
svn commit: r367987 - head/sys/netpfil/pf
Author: markj Date: Tue Nov 24 16:18:47 2020 New Revision: 367987 URL: https://svnweb.freebsd.org/changeset/base/367987 Log: pf: Make tag hashing more robust tagname2tag() hashes the tag name before truncating it to 63 characters. tag_unref() removes the tag from the name hash by computing the hash over the truncated name. Ensure that both operations compute the same hash for a given tag. The larger issue is a lack of string validation in pf(4) ioctl handlers. This is intended to be fixed with some future work, but an extra safety belt in tagname2hashindex() is worthwhile regardless. Reported by: syzbot+a0988828aafb00de7...@syzkaller.appspotmail.com Reviewed by: kp MFC after:1 week Sponsored by: The FreeBSD Foundation Differential Revision:https://reviews.freebsd.org/D27346 Modified: head/sys/netpfil/pf/pf_ioctl.c Modified: head/sys/netpfil/pf/pf_ioctl.c == --- head/sys/netpfil/pf/pf_ioctl.c Tue Nov 24 15:32:25 2020 (r367986) +++ head/sys/netpfil/pf/pf_ioctl.c Tue Nov 24 16:18:47 2020 (r367987) @@ -512,8 +512,10 @@ pf_cleanup_tagset(struct pf_tagset *ts) static uint16_t tagname2hashindex(const struct pf_tagset *ts, const char *tagname) { + size_t len; - return (murmur3_32_hash(tagname, strlen(tagname), ts->seed) & ts->mask); + len = strnlen(tagname, PF_TAG_NAME_SIZE - 1); + return (murmur3_32_hash(tagname, len, ts->seed) & ts->mask); } static uint16_t ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r367939 - in stable/12: share/man/man4 sys/dev/ntb/ntb_hw
Author: markj Date: Sun Nov 22 18:54:14 2020 New Revision: 367939 URL: https://svnweb.freebsd.org/changeset/base/367939 Log: MFC r366969, r366973: ntb: Add Intel Xeon Gen3 support Modified: stable/12/share/man/man4/ntb_hw_intel.4 stable/12/sys/dev/ntb/ntb_hw/ntb_hw_intel.c stable/12/sys/dev/ntb/ntb_hw/ntb_hw_intel.h Directory Properties: stable/12/ (props changed) Modified: stable/12/share/man/man4/ntb_hw_intel.4 == --- stable/12/share/man/man4/ntb_hw_intel.4 Sun Nov 22 18:42:08 2020 (r367938) +++ stable/12/share/man/man4/ntb_hw_intel.4 Sun Nov 22 18:54:14 2020 (r367939) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd August 30, 2017 +.Dd October 11, 2020 .Dt NTB_HW_INTEL 4 .Os .Sh NAME @@ -50,16 +50,18 @@ The driver provides support for the Non-Transparent Bridge (NTB) hardware in Intel Xeon E3/E5 and S1200 processor families, which allow one of their PCIe ports to be switched from transparent to non-transparent bridge mode. -In this mode bridge looks not as a PCI bridge, but as PCI endpoint device. +In this mode the bridge looks not like a PCI bridge, but like a PCI endpoint +device. The driver hides hardware details, exposing memory windows, scratchpads -and doorbells of the other side via hardware independent KPI to +and doorbells of the other side via a hardware independent KPI to the .Xr ntb 4 subsystem. .Pp The hardware provides 2 or 3 memory windows to the other system's memory, -16 scratchpad registers and 14 or 34 doorbells to interrupt the other system. -On Xeon processors one of memory windows is typically consumed by the driver -itself to workaround multiple hardware erratas. +16 scratchpad registers and 14, 31 or 34 doorbells to interrupt the other +system, depending on the platform. +On Xeon processors one of the memory windows is typically consumed by the driver +itself to work around multiple hardware errata. .Sh CONFIGURATION The NTB configuration should be set by BIOS. It includes enabling NTB, choosing between NTB-to-NTB (back-to-back) or @@ -67,9 +69,10 @@ NTB-to-Root Port mode, enabling split BAR mode (one of two 64-bit BARs can be split into two 32-bit ones) and configuring BAR sizes in bits (from 12 to 29/39) for both NTB sides. .Pp -The recommended configuration is NTB-to-NTB mode, split bar is enabled and -all BAR sizes are set to 20 (1 MiB). +The recommended configuration is NTB-to-NTB mode, split bar enabled and +all BAR sizes set to 20 (1 MiB). This needs to be done on both systems. +Note, on Xeon SkyLake and newer platforms, split bar mode is not available. .Sh SEE ALSO .Xr if_ntb 4 , .Xr ntb_transport 4 , Modified: stable/12/sys/dev/ntb/ntb_hw/ntb_hw_intel.c == --- stable/12/sys/dev/ntb/ntb_hw/ntb_hw_intel.c Sun Nov 22 18:42:08 2020 (r367938) +++ stable/12/sys/dev/ntb/ntb_hw/ntb_hw_intel.c Sun Nov 22 18:54:14 2020 (r367939) @@ -64,7 +64,8 @@ __FBSDID("$FreeBSD$"); #include "ntb_hw_intel.h" #include "../ntb.h" -#define MAX_MSIX_INTERRUPTS MAX(XEON_DB_COUNT, ATOM_DB_COUNT) +#define MAX_MSIX_INTERRUPTS\ + MAX(MAX(XEON_DB_COUNT, ATOM_DB_COUNT), XEON_GEN3_DB_COUNT) #define NTB_HB_TIMEOUT 1 /* second */ #define ATOM_LINK_RECOVERY_TIME500 /* ms */ @@ -83,7 +84,8 @@ __FBSDID("$FreeBSD$"); #definePCI_MSIX_ENTRY_DATA 8 enum ntb_device_type { - NTB_XEON, + NTB_XEON_GEN1, + NTB_XEON_GEN3, NTB_ATOM }; @@ -334,6 +336,7 @@ static int map_memory_window_bar(struct ntb_softc *ntb static void intel_ntb_unmap_pci_bar(struct ntb_softc *ntb); static int intel_ntb_remap_msix(device_t, uint32_t desired, uint32_t avail); static int intel_ntb_init_isr(struct ntb_softc *ntb); +static int intel_ntb_xeon_gen3_init_isr(struct ntb_softc *ntb); static int intel_ntb_setup_legacy_interrupt(struct ntb_softc *ntb); static int intel_ntb_setup_msix(struct ntb_softc *ntb, uint32_t num_vectors); static void intel_ntb_teardown_interrupts(struct ntb_softc *ntb); @@ -351,8 +354,10 @@ static void intel_ntb_exchange_msix(void *); static struct ntb_hw_info *intel_ntb_get_device_info(uint32_t device_id); static void intel_ntb_detect_max_mw(struct ntb_softc *ntb); static int intel_ntb_detect_xeon(struct ntb_softc *ntb); +static int intel_ntb_detect_xeon_gen3(struct ntb_softc *ntb); static int intel_ntb_detect_atom(struct ntb_softc *ntb); static int intel_ntb_xeon_init_dev(struct ntb_softc *ntb); +static int intel_ntb_xeon_gen3_init_dev(struct ntb_softc *ntb); static int intel_ntb_atom_init_dev(struct ntb_softc *ntb); static void intel_ntb_teardown_xeon(struct ntb_softc *ntb); static void configure_atom_secondary_side_bars(struct ntb_softc *ntb); @@ -364,6 +369,9 @@ static void xeon_set_pbar_xlat(struct ntb_softc *, uin enum ntb_bar idx); static int xeon_setup_b2b_mw(struct ntb_softc *,
svn commit: r367849 - head/sys/kern
Author: markj Date: Thu Nov 19 18:37:28 2020 New Revision: 367849 URL: https://svnweb.freebsd.org/changeset/base/367849 Log: callout(9): Fix a race between CPU migration and callout_drain() Suppose a running callout re-arms itself, and before the callout finishes running another CPU calls callout_drain() and goes to sleep. softclock_call_cc() will wake up the draining thread, which may not run immediately if there is a lot of CPU load. Furthermore, the callout is still in the callout wheel so it can continue to run and re-arm itself. Then, suppose that the callout migrates to another CPU before the draining thread gets a chance to run. The draining thread is in this loop in _callout_stop_safe(): while (cc_exec_curr(cc) == c) { CC_UNLOCK(cc); sleep(); CC_LOCK(cc); } but after the migration, cc points to the wrong CPU's callout state. Then the draining thread goes off and removes the callout from the wheel, but does so using the wrong lock and per-CPU callout state. Fix the problem by doing a re-lookup of the callout CPU after sleeping. Reported by: syzbot+79569cd4d76636b2c...@syzkaller.appspotmail.com Reported by: syzbot+1b27e0237aa22d8ad...@syzkaller.appspotmail.com Reported by: syzbot+e21aa5b85a9aff90e...@syzkaller.appspotmail.com Reviewed by: emaste, hselasky Tested by:pho MFC after:1 week Sponsored by: The FreeBSD Foundation Differential Revision:https://reviews.freebsd.org/D27266 Modified: head/sys/kern/kern_timeout.c Modified: head/sys/kern/kern_timeout.c == --- head/sys/kern/kern_timeout.cThu Nov 19 18:03:40 2020 (r367848) +++ head/sys/kern/kern_timeout.cThu Nov 19 18:37:28 2020 (r367849) @@ -1145,7 +1145,7 @@ again: * just wait for the current invocation to * finish. */ - while (cc_exec_curr(cc, direct) == c) { + if (cc_exec_curr(cc, direct) == c) { /* * Use direct calls to sleepqueue interface * instead of cv/msleep in order to avoid @@ -1193,7 +1193,7 @@ again: /* Reacquire locks previously released. */ PICKUP_GIANT(); - CC_LOCK(cc); + goto again; } c->c_flags &= ~CALLOUT_ACTIVE; } else if (use_lock && ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r367845 - head/sys/vm
Author: markj Date: Thu Nov 19 15:41:42 2020 New Revision: 367845 URL: https://svnweb.freebsd.org/changeset/base/367845 Log: Wrap a long line in vm_pqbatch_process_page() Modified: head/sys/vm/vm_page.c Modified: head/sys/vm/vm_page.c == --- head/sys/vm/vm_page.c Thu Nov 19 15:40:58 2020(r367844) +++ head/sys/vm/vm_page.c Thu Nov 19 15:41:42 2020(r367845) @@ -3545,7 +3545,8 @@ vm_pqbatch_process_page(struct vm_pagequeue *pq, vm_pa counter_u64_add(queue_nops, 1); break; } - KASSERT(old.queue != PQ_NONE || (old.flags & PGA_QUEUE_STATE_MASK) == 0, + KASSERT(old.queue != PQ_NONE || + (old.flags & PGA_QUEUE_STATE_MASK) == 0, ("%s: page %p has unexpected queue state", __func__, m)); new = old; ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r367844 - head/sys/vm
Author: markj Date: Thu Nov 19 15:40:58 2020 New Revision: 367844 URL: https://svnweb.freebsd.org/changeset/base/367844 Log: Micro-optimize vm_page_pqbatch_submit() Avoid calling vm_page_domain() twice. Discussed with: alc (in D27207) Modified: head/sys/vm/vm_page.c Modified: head/sys/vm/vm_page.c == --- head/sys/vm/vm_page.c Thu Nov 19 14:27:01 2020(r367843) +++ head/sys/vm/vm_page.c Thu Nov 19 15:40:58 2020(r367844) @@ -3598,8 +3598,6 @@ vm_page_pqbatch_submit(vm_page_t m, uint8_t queue) KASSERT(queue < PQ_COUNT, ("invalid queue %d", queue)); domain = vm_page_domain(m); - pq = _pagequeue_domain(m)->vmd_pagequeues[queue]; - critical_enter(); bq = DPCPU_PTR(pqbatch[domain][queue]); if (vm_batchqueue_insert(bq, m)) { @@ -3607,6 +3605,8 @@ vm_page_pqbatch_submit(vm_page_t m, uint8_t queue) return; } critical_exit(); + + pq = _DOMAIN(domain)->vmd_pagequeues[queue]; vm_pagequeue_lock(pq); critical_enter(); bq = DPCPU_PTR(pqbatch[domain][queue]); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
Re: svn commit: r367695 - in head/sys: kern sys
On Wed, Nov 18, 2020 at 03:37:36PM -0800, John Baldwin wrote: > On 11/18/20 2:16 PM, Mateusz Guzik wrote: > > On 11/17/20, John Baldwin wrote: > >> On 11/14/20 11:22 AM, Mateusz Guzik wrote: > > Interested parties can check the consumer (also seen in the diff) to > > see this is for consistency. I don't think any comments are warranted > > in the header. > > I did read the consumer, and there didn't seem tremendous value in the > extra line there. > > >> These changes would benefit from review. > >> > > > > I don't think it's feasible to ask for review for everything lest it > > degardes to rubber stamping and I don't think this change warranted > > it, regardless of the cosmetic issues which can always show up. > > That is not consistent with the direction the project is moving. If you > check the commit logs of other high-volume committers such as markj@, > kib@, or myself, you will find that a substantial number of those commits > are reviewed (typically in phabricator) without preventing us from > making useful progress. Also, while the previous core did not mandate > reviews, we moved closer to it when the Pre-Commit Review chapter was > added to the Committer's Guide: > > https://www.freebsd.org/doc/en_US.ISO8859-1/articles/committers-guide/pre-commit-review.html > > In the related thread on developers@ we indicated that while weren't yet > making pre-commit review mandatory, we collectively want to move in that > direction. So, I personally don't really like the idea of mandatory reviews. It's a drag, especially for volunteers. It works ok in areas that have active maintainers, but lots of FreeBSD does not. For instance, pretty much every change to sys/vm gets a review, but only by convention. It's not perfect, and in particular it discourages me from making some changes both because getting review is a hassle and because I don't want to spam other VM developers (especially volunteers) with minor things. If all changes require some sort of sign-off, even if it's effectively rubber-stamping, I fear it'll discourage a lot of small, worthwhile contributions while also burning out reviewers. Meanwhile, we had issues for a long time where changes to the CSPRNG code were blocked for lack of review, and we have some problems with the LOCALBASE changes despite review. For better or worse, FreeBSD has no sole technical authority to direct development. More than many other projects, we rely on consensus and more broadly the ability of developers to engage with each other even when their communication styles differ. Since Phabricator was introduced it's been a lot easier to get feedback on patches, and non-committers have a better vehicle to propose patches. No edict was needed for that. On the other hand, FCP doesn't seem to have been successful. I suspect that mailing lists are sufficient for the same purpose that FCP is for; if someone doesn't care to socialize some changes on the lists, it's unlikely that they'll do so in a FCP, and because FreeBSD has no one who can really mandate development process, FCP doesn't buy us much. I tried adding RELNOTES so that it's easier for us to advertise our work to users; it's worked so-so, and I suspect that a lot of developers don't care about advertising their work or just don't know about RELNOTES. Our development processes end up being largely dictated by social norms, which are influenced by the most prolific committers. Mateusz is making a lot of commits to the kernel without any review. Most other committers would try to get a review for similar changes. For what it's worth I personally trust Mateusz to make well-reasoned changes, and to own his bugs. He does regularly ask for review and testing and I don't spend as much time as I should on his reviews. The problem, though, is the default assumption that most changes are not worth reviewing at all because they're small, mechanical, no one cares, whatever. It's worth soliciting review if only so that at least one other person has an idea of what's changing in the tree, because there _will_ come a time when it helps that person make changes of their own, or find a bug. Even if a reviewer doesn't deeply understand a diff, they might suggest stylistic changes that make the code more readable, or comment on related code in a way that's useful later. Similarly, verbose commit logs can seem pointless but are a huge help down the road. I know this is a common observation but it comes up all the time for me. With regard to the future direction of src development, I would propose a middle ground. Most, if not all, changes should get a Phabricator review. There should be some minimum period between creation of that review and a commit. The developer should make some effort to cc active committers to the code. Some areas of the tree will have stricter rules, but in general absence of feedback means that it's ok to commit. Exceptions might apply to build fixes, etc.. This still imposes
svn commit: r367828 - in head/sys: amd64/amd64 dev/mem powerpc/aim vm
Author: markj Date: Thu Nov 19 03:59:21 2020 New Revision: 367828 URL: https://svnweb.freebsd.org/changeset/base/367828 Log: vm_phys: Try to clean up NUMA KPIs It can useful for code outside the VM system to look up the NUMA domain of a page backing a virtual or physical address, specifically when creating NUMA-aware data structures. We have _vm_phys_domain() for this, but the leading underscore implies that it's an internal function, and vm_phys.h has dependencies on a number of other headers. Rename vm_phys_domain() to vm_page_domain(), and _vm_phys_domain() to vm_phys_domain(). Make the latter an inline function. Add _vm_phys.h and define struct vm_phys_seg there so that it's easier to use in other headers. Include it from vm_page.h so that vm_page_domain() can be defined there. Include machine/vmparam.h from _vm_phys.h since it depends directly on some constants defined there. Reviewed by: alc Reviewed by: dougm, kib (earlier versions) Differential Revision:https://reviews.freebsd.org/D27207 Added: head/sys/vm/_vm_phys.h (contents, props changed) Modified: head/sys/amd64/amd64/mp_machdep.c head/sys/amd64/amd64/pmap.c head/sys/dev/mem/memdev.c head/sys/powerpc/aim/mmu_oea64.c head/sys/powerpc/aim/mmu_radix.c head/sys/vm/uma_core.c head/sys/vm/vm_kern.c head/sys/vm/vm_page.c head/sys/vm/vm_page.h head/sys/vm/vm_pagequeue.h head/sys/vm/vm_phys.c head/sys/vm/vm_phys.h head/sys/vm/vm_reserv.c Modified: head/sys/amd64/amd64/mp_machdep.c == --- head/sys/amd64/amd64/mp_machdep.c Thu Nov 19 02:53:29 2020 (r367827) +++ head/sys/amd64/amd64/mp_machdep.c Thu Nov 19 03:59:21 2020 (r367828) @@ -380,7 +380,7 @@ mp_realloc_pcpu(int cpuid, int domain) vm_offset_t oa, na; oa = (vm_offset_t)&__pcpu[cpuid]; - if (_vm_phys_domain(pmap_kextract(oa)) == domain) + if (vm_phys_domain(pmap_kextract(oa)) == domain) return; m = vm_page_alloc_domain(NULL, 0, domain, VM_ALLOC_NORMAL | VM_ALLOC_NOOBJ); Modified: head/sys/amd64/amd64/pmap.c == --- head/sys/amd64/amd64/pmap.c Thu Nov 19 02:53:29 2020(r367827) +++ head/sys/amd64/amd64/pmap.c Thu Nov 19 03:59:21 2020(r367828) @@ -452,7 +452,7 @@ static __inline int pc_to_domain(struct pv_chunk *pc) { - return (_vm_phys_domain(DMAP_TO_PHYS((vm_offset_t)pc))); + return (vm_phys_domain(DMAP_TO_PHYS((vm_offset_t)pc))); } #else static __inline int @@ -4611,7 +4611,7 @@ pmap_page_array_startup(long pages) end = start + pages * sizeof(struct vm_page); for (va = start; va < end; va += NBPDR) { pfn = first_page + (va - start) / sizeof(struct vm_page); - domain = _vm_phys_domain(ptoa(pfn)); + domain = vm_phys_domain(ptoa(pfn)); pdpe = pmap_pdpe(kernel_pmap, va); if ((*pdpe & X86_PG_V) == 0) { pa = vm_phys_early_alloc(domain, PAGE_SIZE); @@ -5147,7 +5147,7 @@ retry: pc->pc_map[0] = PC_FREE0 & ~1ul;/* preallocated bit 0 */ pc->pc_map[1] = PC_FREE1; pc->pc_map[2] = PC_FREE2; - pvc = _chunks[_vm_phys_domain(m->phys_addr)]; + pvc = _chunks[vm_phys_domain(m->phys_addr)]; mtx_lock(>pvc_lock); TAILQ_INSERT_TAIL(>pvc_list, pc, pc_lru); mtx_unlock(>pvc_lock); Modified: head/sys/dev/mem/memdev.c == --- head/sys/dev/mem/memdev.c Thu Nov 19 02:53:29 2020(r367827) +++ head/sys/dev/mem/memdev.c Thu Nov 19 03:59:21 2020(r367828) @@ -111,7 +111,7 @@ memioctl(struct cdev *dev, u_long cmd, caddr_t data, i >td_proc->p_vmspace->vm_pmap, me->me_vaddr); if (me->me_paddr != 0) { me->me_state = ME_STATE_MAPPED; - me->me_domain = _vm_phys_domain(me->me_paddr); + me->me_domain = vm_phys_domain(me->me_paddr); } else { me->me_state = ME_STATE_VALID; } Modified: head/sys/powerpc/aim/mmu_oea64.c == --- head/sys/powerpc/aim/mmu_oea64.cThu Nov 19 02:53:29 2020 (r367827) +++ head/sys/powerpc/aim/mmu_oea64.cThu Nov 19 03:59:21 2020 (r367828) @@ -3470,7 +3470,7 @@ moea64_page_array_startup(long pages) } for (i = 0; phys_avail[i + 1] != 0; i+= 2) { - domain = _vm_phys_domain(phys_avail[i]); + domain = vm_phys_domain(phys_avail[i]); KASSERT(domain < MAXMEMDOM, ("Invalid phys_avail NUMA domain
svn commit: r367827 - head/sys/conf
Author: markj Date: Thu Nov 19 02:53:29 2020 New Revision: 367827 URL: https://svnweb.freebsd.org/changeset/base/367827 Log: Move kern_clocksource.c to sys/conf/files Sponsored by: The FreeBSD Foundation Modified: head/sys/conf/files head/sys/conf/files.amd64 head/sys/conf/files.arm head/sys/conf/files.arm64 head/sys/conf/files.i386 head/sys/conf/files.mips head/sys/conf/files.powerpc head/sys/conf/files.riscv Modified: head/sys/conf/files == --- head/sys/conf/files Thu Nov 19 02:50:48 2020(r367826) +++ head/sys/conf/files Thu Nov 19 02:53:29 2020(r367827) @@ -3777,6 +3777,7 @@ kern/ksched.c optional _kposix_priority_scheduling kern/kern_acct.c standard kern/kern_alq.coptional alq kern/kern_clock.c standard +kern/kern_clocksource.cstandard kern/kern_condvar.cstandard kern/kern_conf.c standard kern/kern_cons.c standard Modified: head/sys/conf/files.amd64 == --- head/sys/conf/files.amd64 Thu Nov 19 02:50:48 2020(r367826) +++ head/sys/conf/files.amd64 Thu Nov 19 02:53:29 2020(r367827) @@ -388,7 +388,6 @@ dev/xen/pci/xen_acpi_pci.c optionalxenhvm dev/xen/pci/xen_pci.c optionalxenhvm isa/syscons_isa.c optionalsc isa/vga_isa.c optionalvga -kern/kern_clocksource.cstandard kern/imgact_aout.c optional compat_aout kern/link_elf_obj.cstandard # Modified: head/sys/conf/files.arm == --- head/sys/conf/files.arm Thu Nov 19 02:50:48 2020(r367826) +++ head/sys/conf/files.arm Thu Nov 19 02:53:29 2020(r367827) @@ -1,7 +1,5 @@ # $FreeBSD$ -kern/kern_clocksource.cstandard - arm/arm/autoconf.c standard arm/arm/bcopy_page.S standard arm/arm/bcopyinout.S standard Modified: head/sys/conf/files.arm64 == --- head/sys/conf/files.arm64 Thu Nov 19 02:50:48 2020(r367826) +++ head/sys/conf/files.arm64 Thu Nov 19 02:53:29 2020(r367827) @@ -367,7 +367,6 @@ dev/vnic/thunder_bgx.c optionalvnic pci dev/vnic/thunder_mdio_fdt.coptionalvnic fdt dev/vnic/thunder_mdio.coptionalvnic dev/vnic/lmac_if.m optionalinet | inet6 | vnic -kern/kern_clocksource.cstandard kern/msi_if.m optionalintrng kern/pic_if.m optionalintrng kern/subr_devmap.c standard Modified: head/sys/conf/files.i386 == --- head/sys/conf/files.i386Thu Nov 19 02:50:48 2020(r367826) +++ head/sys/conf/files.i386Thu Nov 19 02:53:29 2020(r367827) @@ -211,7 +211,6 @@ i386/pci/pci_cfgreg.c optional pci i386/pci/pci_pir.c optional pci isa/syscons_isa.c optional sc isa/vga_isa.c optional vga -kern/kern_clocksource.cstandard kern/imgact_aout.c optional compat_aout kern/subr_sfbuf.c standard libkern/divdi3.c standard Modified: head/sys/conf/files.mips == --- head/sys/conf/files.mipsThu Nov 19 02:50:48 2020(r367826) +++ head/sys/conf/files.mipsThu Nov 19 02:53:29 2020(r367827) @@ -48,7 +48,6 @@ mips/mips/uma_machdep.c standard mips/mips/vm_machdep.c standard # misc opt-in bits -kern/kern_clocksource.cstandard kern/link_elf_obj.cstandard kern/subr_atomic64.c optionalmips | mipsel | mipshf | mipselhf kern/subr_busdma_bufalloc.cstandard Modified: head/sys/conf/files.powerpc == --- head/sys/conf/files.powerpc Thu Nov 19 02:50:48 2020(r367826) +++ head/sys/conf/files.powerpc Thu Nov 19 02:53:29 2020(r367827) @@ -110,7 +110,6 @@ dev/tsec/if_tsec_fdt.c optionaltsec dev/uart/uart_cpu_powerpc.coptionaluart dev/usb/controller/ehci_fsl.c optionalehci mpc85xx dev/vt/hw/ofwfb/ofwfb.coptionalvt aim -kern/kern_clocksource.cstandard kern/subr_atomic64.c optionalpowerpc | powerpcspe kern/subr_dummy_vdso_tc.c standard kern/syscalls.coptionalktr Modified:
svn commit: r367826 - in head/sys: arm/arm arm/include conf kern
Author: markj Date: Thu Nov 19 02:50:48 2020 New Revision: 367826 URL: https://svnweb.freebsd.org/changeset/base/367826 Log: Remove NO_EVENTTIMERS support The arm configs that required it have been removed from the tree. Removing this option makes the callout code easier to read and discourages developers from adding new configs without eventtimer drivers. Reviewed by: ian, imp, mav Sponsored by: The FreeBSD Foundation Differential Revision:https://reviews.freebsd.org/D27270 Modified: head/sys/arm/arm/machdep.c head/sys/arm/include/machdep.h head/sys/conf/options head/sys/conf/options.arm head/sys/kern/kern_et.c head/sys/kern/kern_timeout.c Modified: head/sys/arm/arm/machdep.c == --- head/sys/arm/arm/machdep.c Thu Nov 19 02:44:08 2020(r367825) +++ head/sys/arm/arm/machdep.c Thu Nov 19 02:50:48 2020(r367826) @@ -48,7 +48,6 @@ #include "opt_kstack_pages.h" #include "opt_platform.h" #include "opt_sched.h" -#include "opt_timer.h" #include __FBSDID("$FreeBSD$"); @@ -304,16 +303,12 @@ cpu_idle(int busy) CTR2(KTR_SPARE2, "cpu_idle(%d) at %d", busy, curcpu); spinlock_enter(); -#ifndef NO_EVENTTIMERS if (!busy) cpu_idleclock(); -#endif if (!sched_runnable()) cpu_sleep(0); -#ifndef NO_EVENTTIMERS if (!busy) cpu_activeclock(); -#endif spinlock_exit(); CTR2(KTR_SPARE2, "cpu_idle(%d) at %d done", busy, curcpu); } @@ -325,22 +320,7 @@ cpu_idle_wakeup(int cpu) return (0); } -#ifdef NO_EVENTTIMERS -/* - * Most ARM platforms don't need to do anything special to init their clocks - * (they get intialized during normal device attachment), and by not defining a - * cpu_initclocks() function they get this generic one. Any platform that needs - * to do something special can just provide their own implementation, which will - * override this one due to the weak linkage. - */ void -arm_generic_initclocks(void) -{ -} -__weak_reference(arm_generic_initclocks, cpu_initclocks); - -#else -void cpu_initclocks(void) { @@ -353,7 +333,6 @@ cpu_initclocks(void) cpu_initclocks_bsp(); #endif } -#endif #ifdef PLATFORM void Modified: head/sys/arm/include/machdep.h == --- head/sys/arm/include/machdep.h Thu Nov 19 02:44:08 2020 (r367825) +++ head/sys/arm/include/machdep.h Thu Nov 19 02:50:48 2020 (r367826) @@ -39,7 +39,6 @@ vm_offset_t parse_boot_param(struct arm_boot_params *a void arm_parse_fdt_bootargs(void); void arm_print_kenv(void); -void arm_generic_initclocks(void); int arm_get_vfpstate(struct thread *td, void *args); /* Board-specific attributes */ Modified: head/sys/conf/options == --- head/sys/conf/options Thu Nov 19 02:44:08 2020(r367825) +++ head/sys/conf/options Thu Nov 19 02:50:48 2020(r367826) @@ -180,7 +180,6 @@ NEW_PCIBopt_global.h NO_ADAPTIVE_MUTEXESopt_adaptive_mutexes.h NO_ADAPTIVE_RWLOCKS NO_ADAPTIVE_SX -NO_EVENTTIMERS opt_timer.h NO_OBSOLETE_CODE opt_global.h NO_SYSCTL_DESCRopt_global.h NSWBUF_MIN opt_param.h Modified: head/sys/conf/options.arm == --- head/sys/conf/options.arm Thu Nov 19 02:44:08 2020(r367825) +++ head/sys/conf/options.arm Thu Nov 19 02:50:48 2020(r367826) @@ -6,7 +6,6 @@ ARM_KERN_DIRECTMAP opt_vm.h ARM_L2_PIPTopt_global.h ARM_MANY_BOARD opt_global.h ARM_WANT_TP_ADDRESSopt_global.h -COUNTS_PER_SEC opt_timer.h CPSW_ETHERSWITCH opt_cpsw.h CPU_ARM9E opt_global.h CPU_ARM1176opt_global.h @@ -61,7 +60,6 @@ SOC_ROCKCHIP_RK3188 opt_global.h SOC_TI_AM335X opt_global.h SOC_TEGRA2 opt_global.h XSCALE_CACHE_READ_WRITE_ALLOCATE opt_global.h -XSACLE_DISABLE_CCNTopt_timer.h VERBOSE_INIT_ARM opt_global.h VM_MAXUSER_ADDRESS opt_global.h GFB_DEBUG opt_gfb.h Modified: head/sys/kern/kern_et.c == --- head/sys/kern/kern_et.c Thu Nov 19 02:44:08 2020(r367825) +++ head/sys/kern/kern_et.c Thu Nov 19 02:50:48 2020(r367826) @@ -37,8 +37,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include "opt_timer.h" - SLIST_HEAD(et_eventtimers_list, eventtimer); static struct et_eventtimers_list eventtimers = SLIST_HEAD_INITIALIZER(et_eventtimers); @@ -130,9 +128,7 @@ void et_change_frequency(struct eventtimer *et, uint64_t newfreq) { -#ifndef NO_EVENTTIMERS cpu_et_frequency(et, newfreq); -#endif } /* Modified: head/sys/kern/kern_timeout.c
svn commit: r367792 - stable/12/sys/net
Author: markj Date: Wed Nov 18 14:27:47 2020 New Revision: 367792 URL: https://svnweb.freebsd.org/changeset/base/367792 Log: MFC r367596: iflib: Free full mbuf chains when draining transmit queues Modified: stable/12/sys/net/iflib.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/net/iflib.c == --- stable/12/sys/net/iflib.c Wed Nov 18 14:27:24 2020(r367791) +++ stable/12/sys/net/iflib.c Wed Nov 18 14:27:47 2020(r367792) @@ -1860,7 +1860,7 @@ iflib_txsd_free(if_ctx_t ctx, iflib_txq_t txq, int i) bus_dmamap_unload(txq->ift_tso_buf_tag, txq->ift_sds.ifsd_tso_map[i]); } - m_free(*mp); + m_freem(*mp); DBG_COUNTER_INC(tx_frees); *mp = NULL; } @@ -3680,7 +3680,7 @@ iflib_txq_drain(struct ifmp_ring *r, uint32_t cidx, ui DBG_COUNTER_INC(txq_drain_flushing); for (i = 0; i < avail; i++) { if (__predict_true(r->items[(cidx + i) & (r->size-1)] != (void *)txq)) - m_free(r->items[(cidx + i) & (r->size-1)]); + m_freem(r->items[(cidx + i) & (r->size-1)]); r->items[(cidx + i) & (r->size-1)] = NULL; } return (avail); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r367791 - in stable/12/sys: kern sys
Author: markj Date: Wed Nov 18 14:27:24 2020 New Revision: 367791 URL: https://svnweb.freebsd.org/changeset/base/367791 Log: MFC r367588: Fix a pair of races in SIGIO registration Modified: stable/12/sys/kern/kern_descrip.c stable/12/sys/kern/kern_exit.c stable/12/sys/kern/kern_proc.c stable/12/sys/sys/signalvar.h Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/kern/kern_descrip.c == --- stable/12/sys/kern/kern_descrip.c Wed Nov 18 13:52:13 2020 (r367790) +++ stable/12/sys/kern/kern_descrip.c Wed Nov 18 14:27:24 2020 (r367791) @@ -954,6 +954,40 @@ unlock: return (error); } +static void +sigiofree(struct sigio *sigio) +{ + crfree(sigio->sio_ucred); + free(sigio, M_SIGIO); +} + +static struct sigio * +funsetown_locked(struct sigio *sigio) +{ + struct proc *p; + struct pgrp *pg; + + SIGIO_ASSERT_LOCKED(); + + if (sigio == NULL) + return (NULL); + *(sigio->sio_myref) = NULL; + if (sigio->sio_pgid < 0) { + pg = sigio->sio_pgrp; + PGRP_LOCK(pg); + SLIST_REMOVE(>sio_pgrp->pg_sigiolst, sigio, + sigio, sio_pgsigio); + PGRP_UNLOCK(pg); + } else { + p = sigio->sio_proc; + PROC_LOCK(p); + SLIST_REMOVE(>sio_proc->p_sigiolst, sigio, + sigio, sio_pgsigio); + PROC_UNLOCK(p); + } + return (sigio); +} + /* * If sigio is on the list associated with a process or process group, * disable signalling from the device, remove sigio from the list and @@ -964,92 +998,82 @@ funsetown(struct sigio **sigiop) { struct sigio *sigio; + /* Racy check, consumers must provide synchronization. */ if (*sigiop == NULL) return; + SIGIO_LOCK(); - sigio = *sigiop; - if (sigio == NULL) { - SIGIO_UNLOCK(); - return; - } - *(sigio->sio_myref) = NULL; - if ((sigio)->sio_pgid < 0) { - struct pgrp *pg = (sigio)->sio_pgrp; - PGRP_LOCK(pg); - SLIST_REMOVE(>sio_pgrp->pg_sigiolst, sigio, - sigio, sio_pgsigio); - PGRP_UNLOCK(pg); - } else { - struct proc *p = (sigio)->sio_proc; - PROC_LOCK(p); - SLIST_REMOVE(>sio_proc->p_sigiolst, sigio, - sigio, sio_pgsigio); - PROC_UNLOCK(p); - } + sigio = funsetown_locked(*sigiop); SIGIO_UNLOCK(); - crfree(sigio->sio_ucred); - free(sigio, M_SIGIO); + if (sigio != NULL) + sigiofree(sigio); } /* - * Free a list of sigio structures. - * We only need to lock the SIGIO_LOCK because we have made ourselves - * inaccessible to callers of fsetown and therefore do not need to lock - * the proc or pgrp struct for the list manipulation. + * Free a list of sigio structures. The caller must ensure that new sigio + * structures cannot be added after this point. For process groups this is + * guaranteed using the proctree lock; for processes, the P_WEXIT flag serves + * as an interlock. */ void funsetownlst(struct sigiolst *sigiolst) { struct proc *p; struct pgrp *pg; - struct sigio *sigio; + struct sigio *sigio, *tmp; + /* Racy check. */ sigio = SLIST_FIRST(sigiolst); if (sigio == NULL) return; + p = NULL; pg = NULL; + SIGIO_LOCK(); + sigio = SLIST_FIRST(sigiolst); + if (sigio == NULL) { + SIGIO_UNLOCK(); + return; + } + /* -* Every entry of the list should belong -* to a single proc or pgrp. +* Every entry of the list should belong to a single proc or pgrp. */ if (sigio->sio_pgid < 0) { pg = sigio->sio_pgrp; - PGRP_LOCK_ASSERT(pg, MA_NOTOWNED); + sx_assert(_lock, SX_XLOCKED); + PGRP_LOCK(pg); } else /* if (sigio->sio_pgid > 0) */ { p = sigio->sio_proc; - PROC_LOCK_ASSERT(p, MA_NOTOWNED); + PROC_LOCK(p); + KASSERT((p->p_flag & P_WEXIT) != 0, + ("%s: process %p is not exiting", __func__, p)); } - SIGIO_LOCK(); - while ((sigio = SLIST_FIRST(sigiolst)) != NULL) { - *(sigio->sio_myref) = NULL; + SLIST_FOREACH(sigio, sigiolst, sio_pgsigio) { + *sigio->sio_myref = NULL; if (pg != NULL) { KASSERT(sigio->sio_pgid < 0, ("Proc sigio in pgrp sigio list")); KASSERT(sigio->sio_pgrp == pg, ("Bogus pgrp in sigio list")); -
svn commit: r367727 - stable/12/sys/dev/qat
Author: markj Date: Mon Nov 16 16:53:46 2020 New Revision: 367727 URL: https://svnweb.freebsd.org/changeset/base/367727 Log: MFC r367617: qat: Fix nits reported by Coverity Modified: stable/12/sys/dev/qat/qat.c stable/12/sys/dev/qat/qat_ae.c stable/12/sys/dev/qat/qatvar.h Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/qat/qat.c == --- stable/12/sys/dev/qat/qat.c Mon Nov 16 15:37:09 2020(r367726) +++ stable/12/sys/dev/qat/qat.c Mon Nov 16 16:53:46 2020(r367727) @@ -573,7 +573,8 @@ qat_detach(device_t dev) sc->sc_ih_cookie = NULL; } if (sc->sc_ih != NULL) { - (void)bus_release_resource(dev, SYS_RES_IRQ, i + 1, sc->sc_ih); + (void)bus_release_resource(dev, SYS_RES_IRQ, + sc->sc_hw.qhw_num_banks + 1, sc->sc_ih); sc->sc_ih = NULL; } pci_release_msi(dev); Modified: stable/12/sys/dev/qat/qat_ae.c == --- stable/12/sys/dev/qat/qat_ae.c Mon Nov 16 15:37:09 2020 (r367726) +++ stable/12/sys/dev/qat/qat_ae.c Mon Nov 16 16:53:46 2020 (r367727) @@ -2616,7 +2616,7 @@ qat_aefw_suof_load(struct qat_softc *sc, struct qat_dm static int qat_aefw_suof_write(struct qat_softc *sc) { - struct qat_suof_image *qsi = NULL; + struct qat_suof_image *qsi; int i, error = 0; for (i = 0; i < sc->sc_aefw_suof.qafs_num_simgs; i++) { @@ -2626,21 +2626,20 @@ qat_aefw_suof_write(struct qat_softc *sc) if (error) return error; error = qat_aefw_auth(sc, >qsi_dma); - if (error) - goto fail; + if (error) { + qat_free_dmamem(sc, >qsi_dma); + return error; + } error = qat_aefw_suof_load(sc, >qsi_dma); - if (error) - goto fail; - + if (error) { + qat_free_dmamem(sc, >qsi_dma); + return error; + } qat_free_dmamem(sc, >qsi_dma); } qat_free_mem(sc->sc_aefw_suof.qafs_simg); return 0; -fail: - if (qsi != NULL) - qat_free_dmamem(sc, >qsi_dma); - return error; } static int Modified: stable/12/sys/dev/qat/qatvar.h == --- stable/12/sys/dev/qat/qatvar.h Mon Nov 16 15:37:09 2020 (r367726) +++ stable/12/sys/dev/qat/qatvar.h Mon Nov 16 16:53:46 2020 (r367727) @@ -596,7 +596,7 @@ struct qat_crypto_desc { bus_addr_t qcd_desc_paddr; bus_addr_t qcd_hash_state_paddr; - enum fw_slice qcd_slices[MAX_FW_SLICE]; + enum fw_slice qcd_slices[MAX_FW_SLICE + 1]; enum fw_la_cmd_id qcd_cmd_id; enum hw_cipher_dir qcd_cipher_dir; ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r367642 - head/bin/df
Author: markj Date: Fri Nov 13 16:47:42 2020 New Revision: 367642 URL: https://svnweb.freebsd.org/changeset/base/367642 Log: df: Remove support for mounting devices This was marked deprecated in r329092, over two and a half years ago. This functionality is also buggy per PR 237368. PR: 237368 Reviewed by: brooks, cem, emaste, imp Differential Revision:https://reviews.freebsd.org/D27197 Modified: head/bin/df/Makefile head/bin/df/df.1 head/bin/df/df.c Modified: head/bin/df/Makefile == --- head/bin/df/MakefileFri Nov 13 14:56:34 2020(r367641) +++ head/bin/df/MakefileFri Nov 13 16:47:42 2020(r367642) @@ -10,9 +10,6 @@ SRCS= df.c vfslist.c CFLAGS+= -I${MOUNT} -CFLAGS+= -DMOUNT_CHAR_DEVS -SRCS+= getmntopts.c - LIBADD=xo util .include Modified: head/bin/df/df.1 == --- head/bin/df/df.1Fri Nov 13 14:56:34 2020(r367641) +++ head/bin/df/df.1Fri Nov 13 16:47:42 2020(r367642) @@ -48,6 +48,7 @@ The .Nm utility displays statistics about the amount of free disk space on the specified +mounted .Ar file system or on the file system of which .Ar file Modified: head/bin/df/df.c == --- head/bin/df/df.cFri Nov 13 14:56:34 2020(r367641) +++ head/bin/df/df.cFri Nov 13 16:47:42 2020(r367642) @@ -52,16 +52,10 @@ __FBSDID("$FreeBSD$"); #include #include #include -#ifdef MOUNT_CHAR_DEVS -#include -#endif #include #include #include #include -#ifdef MOUNT_CHAR_DEVS -#include -#endif #include #include #include @@ -106,9 +100,6 @@ imax(int a, int b) static int aflag = 0, cflag, hflag, iflag, kflag, lflag = 0, nflag, Tflag; static int thousands; -#ifdef MOUNT_CHAR_DEVS -static struct ufs_args mdev; -#endif static const struct option long_options[] = { @@ -123,21 +114,11 @@ main(int argc, char *argv[]) struct statfs statfsbuf, totalbuf; struct maxwidths maxwidths; struct statfs *mntbuf; -#ifdef MOUNT_CHAR_DEVS - struct iovec *iov = NULL; -#endif const char *fstype; -#ifdef MOUNT_CHAR_DEVS - char *mntpath; - char errmsg[255] = {0}; -#endif char *mntpt; const char **vfslist; int i, mntsize; int ch, rv; -#ifdef MOUNT_CHAR_DEVS - int iovlen = 0; -#endif fstype = "ufs"; (void)setlocale(LC_ALL, ""); @@ -255,66 +236,15 @@ main(int argc, char *argv[]) continue; } } else if (S_ISCHR(stbuf.st_mode)) { - if ((mntpt = getmntpt(*argv)) == NULL) { -#ifdef MOUNT_CHAR_DEVS - xo_warnx( - "df on unmounted devices is deprecated"); - mdev.fspec = *argv; - mntpath = strdup("/tmp/df.XX"); - if (mntpath == NULL) { - xo_warn("strdup failed"); - rv = 1; - continue; - } - mntpt = mkdtemp(mntpath); - if (mntpt == NULL) { - xo_warn("mkdtemp(\"%s\") failed", mntpath); - rv = 1; - free(mntpath); - continue; - } - if (iov != NULL) - free_iovec(, ); - build_iovec_argf(, , "fstype", "%s", - fstype); - build_iovec_argf(, , "fspath", "%s", - mntpath); - build_iovec_argf(, , "from", "%s", - *argv); - build_iovec(, , "errmsg", errmsg, - sizeof(errmsg)); - if (nmount(iov, iovlen, - MNT_RDONLY|MNT_NOEXEC) < 0) { - if (errmsg[0]) - xo_warn("%s: %s", *argv, - errmsg); - else - xo_warn("%s", *argv); - rv = 1; - (void)rmdir(mntpt); - free(mntpath); - continue; - }
svn commit: r367617 - head/sys/dev/qat
Author: markj Date: Thu Nov 12 15:00:48 2020 New Revision: 367617 URL: https://svnweb.freebsd.org/changeset/base/367617 Log: qat: Fix nits reported by Coverity MFC after:3 days Sponsored by: Rubicon Communications, LLC (Netgate) Modified: head/sys/dev/qat/qat.c head/sys/dev/qat/qat_ae.c head/sys/dev/qat/qatvar.h Modified: head/sys/dev/qat/qat.c == --- head/sys/dev/qat/qat.c Thu Nov 12 14:04:08 2020(r367616) +++ head/sys/dev/qat/qat.c Thu Nov 12 15:00:48 2020(r367617) @@ -573,7 +573,8 @@ qat_detach(device_t dev) sc->sc_ih_cookie = NULL; } if (sc->sc_ih != NULL) { - (void)bus_release_resource(dev, SYS_RES_IRQ, i + 1, sc->sc_ih); + (void)bus_release_resource(dev, SYS_RES_IRQ, + sc->sc_hw.qhw_num_banks + 1, sc->sc_ih); sc->sc_ih = NULL; } pci_release_msi(dev); Modified: head/sys/dev/qat/qat_ae.c == --- head/sys/dev/qat/qat_ae.c Thu Nov 12 14:04:08 2020(r367616) +++ head/sys/dev/qat/qat_ae.c Thu Nov 12 15:00:48 2020(r367617) @@ -2616,7 +2616,7 @@ qat_aefw_suof_load(struct qat_softc *sc, struct qat_dm static int qat_aefw_suof_write(struct qat_softc *sc) { - struct qat_suof_image *qsi = NULL; + struct qat_suof_image *qsi; int i, error = 0; for (i = 0; i < sc->sc_aefw_suof.qafs_num_simgs; i++) { @@ -2626,21 +2626,20 @@ qat_aefw_suof_write(struct qat_softc *sc) if (error) return error; error = qat_aefw_auth(sc, >qsi_dma); - if (error) - goto fail; + if (error) { + qat_free_dmamem(sc, >qsi_dma); + return error; + } error = qat_aefw_suof_load(sc, >qsi_dma); - if (error) - goto fail; - + if (error) { + qat_free_dmamem(sc, >qsi_dma); + return error; + } qat_free_dmamem(sc, >qsi_dma); } qat_free_mem(sc->sc_aefw_suof.qafs_simg); return 0; -fail: - if (qsi != NULL) - qat_free_dmamem(sc, >qsi_dma); - return error; } static int Modified: head/sys/dev/qat/qatvar.h == --- head/sys/dev/qat/qatvar.h Thu Nov 12 14:04:08 2020(r367616) +++ head/sys/dev/qat/qatvar.h Thu Nov 12 15:00:48 2020(r367617) @@ -594,7 +594,7 @@ struct qat_crypto_desc { bus_addr_t qcd_desc_paddr; bus_addr_t qcd_hash_state_paddr; - enum fw_slice qcd_slices[MAX_FW_SLICE]; + enum fw_slice qcd_slices[MAX_FW_SLICE + 1]; enum fw_la_cmd_id qcd_cmd_id; enum hw_cipher_dir qcd_cipher_dir; ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r367596 - head/sys/net
Author: markj Date: Wed Nov 11 18:00:06 2020 New Revision: 367596 URL: https://svnweb.freebsd.org/changeset/base/367596 Log: iflib: Free full mbuf chains when draining transmit queues Submitted by: Sai Rajesh Tallamraju Reviewed by: gallatin, hselasky MFC after:1 week Sponsored by: NetApp, Inc. Differential Revision:https://reviews.freebsd.org/D27179 Modified: head/sys/net/iflib.c Modified: head/sys/net/iflib.c == --- head/sys/net/iflib.cWed Nov 11 17:16:39 2020(r367595) +++ head/sys/net/iflib.cWed Nov 11 18:00:06 2020(r367596) @@ -1781,7 +1781,7 @@ iflib_txsd_free(if_ctx_t ctx, iflib_txq_t txq, int i) bus_dmamap_unload(txq->ift_tso_buf_tag, txq->ift_sds.ifsd_tso_map[i]); } - m_free(*mp); + m_freem(*mp); DBG_COUNTER_INC(tx_frees); *mp = NULL; } @@ -3660,7 +3660,7 @@ iflib_txq_drain(struct ifmp_ring *r, uint32_t cidx, ui DBG_COUNTER_INC(txq_drain_flushing); for (i = 0; i < avail; i++) { if (__predict_true(r->items[(cidx + i) & (r->size-1)] != (void *)txq)) - m_free(r->items[(cidx + i) & (r->size-1)]); + m_freem(r->items[(cidx + i) & (r->size-1)]); r->items[(cidx + i) & (r->size-1)] = NULL; } return (avail); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r367595 - head/sys/vm
Author: markj Date: Wed Nov 11 17:16:39 2020 New Revision: 367595 URL: https://svnweb.freebsd.org/changeset/base/367595 Log: vm_map: Handle kernel map entry allocator recursion On platforms without a direct map[*], vm_map_insert() may in rare situations need to allocate a kernel map entry in order to allocate kernel map entries. This poses a problem similar to the one solved for vmem boundary tags by vmem_bt_alloc(). In fact the kernel map case is a bit more complicated since we must allocate entries with the kernel map locked, whereas vmem can recurse into itself because boundary tags are allocated up-front. The solution is to add a custom slab allocator for kmapentzone which allocates KVA directly from kernel_map, bypassing the kmem_* layer. This avoids mutual recursion with the vmem btag allocator. Then, when vm_map_insert() allocates a new kernel map entry, it avoids triggering allocation of a new slab with M_NOVM until after the insertion is complete. Instead, vm_map_insert() allocates from the reserve and sets a flag in kernel_map to trigger re-population of the reserve just before the map is unlocked. This places an implicit upper bound on the number of kernel map entries that may be allocated before the kernel map lock is released, but in general a bound of 1 suffices. [*] This also comes up on amd64 with UMA_MD_SMALL_ALLOC undefined, a configuration required by some kernel sanitizers. Discussed with: kib, rlibby Reported by: andrew Tested by:pho (i386 and amd64 with !UMA_MD_SMALL_ALLOC) Sponsored by: The FreeBSD Foundation Differential Revision:https://reviews.freebsd.org/D26851 Modified: head/sys/vm/vm_map.c head/sys/vm/vm_map.h Modified: head/sys/vm/vm_map.c == --- head/sys/vm/vm_map.cWed Nov 11 15:53:36 2020(r367594) +++ head/sys/vm/vm_map.cWed Nov 11 17:16:39 2020(r367595) @@ -175,29 +175,106 @@ static void vm_map_wire_entry_failure(vm_map_t map, vm start = end;\ } +#ifndef UMA_MD_SMALL_ALLOC + /* + * Allocate a new slab for kernel map entries. The kernel map may be locked or + * unlocked, depending on whether the request is coming from the kernel map or a + * submap. This function allocates a virtual address range directly from the + * kernel map instead of the kmem_* layer to avoid recursion on the kernel map + * lock and also to avoid triggering allocator recursion in the vmem boundary + * tag allocator. + */ +static void * +kmapent_alloc(uma_zone_t zone, vm_size_t bytes, int domain, uint8_t *pflag, +int wait) +{ + vm_offset_t addr; + int error, locked; + + *pflag = UMA_SLAB_PRIV; + + if (!(locked = vm_map_locked(kernel_map))) + vm_map_lock(kernel_map); + addr = vm_map_findspace(kernel_map, vm_map_min(kernel_map), bytes); + if (addr + bytes < addr || addr + bytes > vm_map_max(kernel_map)) + panic("%s: kernel map is exhausted", __func__); + error = vm_map_insert(kernel_map, NULL, 0, addr, addr + bytes, + VM_PROT_RW, VM_PROT_RW, MAP_NOFAULT); + if (error != KERN_SUCCESS) + panic("%s: vm_map_insert() failed: %d", __func__, error); + if (!locked) + vm_map_unlock(kernel_map); + error = kmem_back_domain(domain, kernel_object, addr, bytes, M_NOWAIT | + M_USE_RESERVE | (wait & M_ZERO)); + if (error == KERN_SUCCESS) { + return ((void *)addr); + } else { + if (!locked) + vm_map_lock(kernel_map); + vm_map_delete(kernel_map, addr, bytes); + if (!locked) + vm_map_unlock(kernel_map); + return (NULL); + } +} + +static void +kmapent_free(void *item, vm_size_t size, uint8_t pflag) +{ + vm_offset_t addr; + int error; + + if ((pflag & UMA_SLAB_PRIV) == 0) + /* XXX leaked */ + return; + + addr = (vm_offset_t)item; + kmem_unback(kernel_object, addr, size); + error = vm_map_remove(kernel_map, addr, addr + size); + KASSERT(error == KERN_SUCCESS, + ("%s: vm_map_remove failed: %d", __func__, error)); +} + +/* + * The worst-case upper bound on the number of kernel map entries that may be + * created before the zone must be replenished in _vm_map_unlock(). + */ +#defineKMAPENT_RESERVE 1 + +#endif /* !UMD_MD_SMALL_ALLOC */ + +/* * vm_map_startup: * - * Initialize the vm_map module. Must be called before - * any other vm_map routines. + * Initialize the vm_map module. Must be called before any other vm_map + * routines. * - * Map and entry structures are allocated from the general - * purpose memory pool with some exceptions: - * - * - The kernel map and
svn commit: r367593 - in head/sys/amd64: amd64 include vmm/amd vmm/intel
Author: markj Date: Wed Nov 11 15:01:17 2020 New Revision: 367593 URL: https://svnweb.freebsd.org/changeset/base/367593 Log: vmm: Make pmap_invalidate_ept() wait synchronously for guest exits Currently EPT TLB invalidation is done by incrementing a generation counter and issuing an IPI to all CPUs currently running vCPU threads. The VMM inner loop caches the most recently observed generation on each host CPU and invalidates TLB entries before executing the VM if the cached generation number is not the most recent value. pmap_invalidate_ept() issues IPIs to force each vCPU to stop executing guest instructions and reload the generation number. However, it does not actually wait for vCPUs to exit, potentially creating a window where guests may continue to reference stale TLB entries. Fix the problem by bracketing guest execution with an SMR read section which is entered before loading the invalidation generation. Then, pmap_invalidate_ept() increments the current write sequence before loading pm_active and sending IPIs, and polls readers to ensure that all vCPUs potentially operating with stale TLB entries have exited before pmap_invalidate_ept() returns. Also ensure that unsynchronized loads of the generation counter are wrapped with atomic(9), and stop (inconsistently) updating the invalidation counter and pm_active bitmask with acquire semantics. Reviewed by: grehan, kib Sponsored by: The FreeBSD Foundation Differential Revision:https://reviews.freebsd.org/D26910 Modified: head/sys/amd64/amd64/pmap.c head/sys/amd64/include/pmap.h head/sys/amd64/vmm/amd/svm.c head/sys/amd64/vmm/intel/vmx.c Modified: head/sys/amd64/amd64/pmap.c == --- head/sys/amd64/amd64/pmap.c Wed Nov 11 14:53:03 2020(r367592) +++ head/sys/amd64/amd64/pmap.c Wed Nov 11 15:01:17 2020(r367593) @@ -125,6 +125,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -2647,7 +2648,7 @@ pmap_update_pde_store(pmap_t pmap, pd_entry_t *pde, pd * "all" host cpus and force any vcpu context to exit as a * side-effect. */ - atomic_add_acq_long(>pm_eptgen, 1); + atomic_add_long(>pm_eptgen, 1); break; default: panic("pmap_update_pde_store: bad pm_type %d", pmap->pm_type); @@ -2722,6 +2723,7 @@ pmap_update_pde_invalidate(pmap_t pmap, vm_offset_t va static __inline void pmap_invalidate_ept(pmap_t pmap) { + smr_seq_t goal; int ipinum; sched_pin(); @@ -2742,15 +2744,30 @@ pmap_invalidate_ept(pmap_t pmap) * Each vcpu keeps a cache of this counter and compares it * just before a vmresume. If the counter is out-of-date an * invept will be done to flush stale mappings from the TLB. +* +* To ensure that all vCPU threads have observed the new counter +* value before returning, we use SMR. Ordering is important here: +* the VMM enters an SMR read section before loading the counter +* and after updating the pm_active bit set. Thus, pm_active is +* a superset of active readers, and any reader that has observed +* the goal has observed the new counter value. */ - atomic_add_acq_long(>pm_eptgen, 1); + atomic_add_long(>pm_eptgen, 1); + goal = smr_advance(pmap->pm_eptsmr); + /* * Force the vcpu to exit and trap back into the hypervisor. */ ipinum = pmap->pm_flags & PMAP_NESTED_IPIMASK; ipi_selected(pmap->pm_active, ipinum); sched_unpin(); + + /* +* Ensure that all active vCPUs will observe the new generation counter +* value before executing any more guest instructions. +*/ + smr_wait(pmap->pm_eptsmr, goal); } static cpuset_t @@ -4086,7 +4103,8 @@ pmap_pinit_type(pmap_t pmap, enum pmap_type pm_type, i * address space. * Install minimal kernel mappings in PTI case. */ - if (pm_type == PT_X86) { + switch (pm_type) { + case PT_X86: pmap->pm_cr3 = pmltop_phys; if (pmap_is_la57(pmap)) pmap_pinit_pml5(pmltop_pg); @@ -4107,6 +4125,11 @@ pmap_pinit_type(pmap_t pmap, enum pmap_type pm_type, i rangeset_init(>pm_pkru, pkru_dup_range, pkru_free_range, pmap, M_NOWAIT); } + break; + case PT_EPT: + case PT_RVI: + pmap->pm_eptsmr = smr_create("pmap", 0, 0); + break; } pmap->pm_root.rt_root = 0; Modified: head/sys/amd64/include/pmap.h == --- head/sys/amd64/include/pmap.h Wed Nov 11 14:53:03 2020
svn commit: r367591 - in stable/12/sys/amd64: amd64 include
Author: markj Date: Wed Nov 11 14:06:45 2020 New Revision: 367591 URL: https://svnweb.freebsd.org/changeset/base/367591 Log: MFC r367335: amd64: Make it easier to configure exception stack sizes Modified: stable/12/sys/amd64/amd64/machdep.c stable/12/sys/amd64/amd64/mp_machdep.c stable/12/sys/amd64/amd64/pmap.c stable/12/sys/amd64/include/intr_machdep.h Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/amd64/amd64/machdep.c == --- stable/12/sys/amd64/amd64/machdep.c Wed Nov 11 14:03:49 2020 (r367590) +++ stable/12/sys/amd64/amd64/machdep.c Wed Nov 11 14:06:45 2020 (r367591) @@ -679,10 +679,10 @@ struct user_segment_descriptor gdt[NGDT * MAXCPU];/* g static struct gate_descriptor idt0[NIDT]; struct gate_descriptor *idt = [0];/* interrupt descriptor table */ -static char dblfault_stack[PAGE_SIZE] __aligned(16); -static char mce0_stack[PAGE_SIZE] __aligned(16); -static char nmi0_stack[PAGE_SIZE] __aligned(16); -static char dbg0_stack[PAGE_SIZE] __aligned(16); +static char dblfault_stack[DBLFAULT_STACK_SIZE] __aligned(16); +static char mce0_stack[MCE_STACK_SIZE] __aligned(16); +static char nmi0_stack[NMI_STACK_SIZE] __aligned(16); +static char dbg0_stack[DBG_STACK_SIZE] __aligned(16); CTASSERT(sizeof(struct nmi_pcpu) == 16); struct amd64tss common_tss[MAXCPU]; Modified: stable/12/sys/amd64/amd64/mp_machdep.c == --- stable/12/sys/amd64/amd64/mp_machdep.c Wed Nov 11 14:03:49 2020 (r367590) +++ stable/12/sys/amd64/amd64/mp_machdep.c Wed Nov 11 14:06:45 2020 (r367591) @@ -300,18 +300,19 @@ init_secondary(void) common_tss[cpu] = common_tss[0]; common_tss[cpu].tss_iobase = sizeof(struct amd64tss) + IOPERM_BITMAP_SIZE; - common_tss[cpu].tss_ist1 = (long)_stack[PAGE_SIZE]; + common_tss[cpu].tss_ist1 = + (long)_stack[DBLFAULT_STACK_SIZE]; /* The NMI stack runs on IST2. */ - np = ((struct nmi_pcpu *) _stack[PAGE_SIZE]) - 1; + np = ((struct nmi_pcpu *)_stack[NMI_STACK_SIZE]) - 1; common_tss[cpu].tss_ist2 = (long) np; /* The MC# stack runs on IST3. */ - np = ((struct nmi_pcpu *) _stack[PAGE_SIZE]) - 1; + np = ((struct nmi_pcpu *)_stack[MCE_STACK_SIZE]) - 1; common_tss[cpu].tss_ist3 = (long) np; /* The DB# stack runs on IST4. */ - np = ((struct nmi_pcpu *) _stack[PAGE_SIZE]) - 1; + np = ((struct nmi_pcpu *)_stack[DBG_STACK_SIZE]) - 1; common_tss[cpu].tss_ist4 = (long) np; /* Prepare private GDT */ @@ -353,15 +354,15 @@ init_secondary(void) common_tss[cpu].tss_rsp0 = 0; /* Save the per-cpu pointer for use by the NMI handler. */ - np = ((struct nmi_pcpu *) _stack[PAGE_SIZE]) - 1; + np = ((struct nmi_pcpu *)_stack[NMI_STACK_SIZE]) - 1; np->np_pcpu = (register_t) pc; /* Save the per-cpu pointer for use by the MC# handler. */ - np = ((struct nmi_pcpu *) _stack[PAGE_SIZE]) - 1; + np = ((struct nmi_pcpu *)_stack[MCE_STACK_SIZE]) - 1; np->np_pcpu = (register_t) pc; /* Save the per-cpu pointer for use by the DB# handler. */ - np = ((struct nmi_pcpu *) _stack[PAGE_SIZE]) - 1; + np = ((struct nmi_pcpu *)_stack[DBG_STACK_SIZE]) - 1; np->np_pcpu = (register_t) pc; wrmsr(MSR_FSBASE, 0); /* User value */ @@ -488,13 +489,14 @@ native_start_all_aps(void) /* allocate and set up an idle stack data page */ bootstacks[cpu] = (void *)kmem_malloc(kstack_pages * PAGE_SIZE, M_WAITOK | M_ZERO); - doublefault_stack = (char *)kmem_malloc(PAGE_SIZE, M_WAITOK | - M_ZERO); - mce_stack = (char *)kmem_malloc(PAGE_SIZE, M_WAITOK | M_ZERO); + doublefault_stack = (char *)kmem_malloc(DBLFAULT_STACK_SIZE, + M_WAITOK | M_ZERO); + mce_stack = (char *)kmem_malloc(MCE_STACK_SIZE, + M_WAITOK | M_ZERO); nmi_stack = (char *)kmem_malloc_domainset( - DOMAINSET_PREF(domain), PAGE_SIZE, M_WAITOK | M_ZERO); + DOMAINSET_PREF(domain), NMI_STACK_SIZE, M_WAITOK | M_ZERO); dbg_stack = (char *)kmem_malloc_domainset( - DOMAINSET_PREF(domain), PAGE_SIZE, M_WAITOK | M_ZERO); + DOMAINSET_PREF(domain), DBG_STACK_SIZE, M_WAITOK | M_ZERO); dpcpu = (void *)kmem_malloc_domainset(DOMAINSET_PREF(domain), DPCPU_SIZE, M_WAITOK | M_ZERO); Modified: stable/12/sys/amd64/amd64/pmap.c == --- stable/12/sys/amd64/amd64/pmap.cWed Nov 11 14:03:49 2020 (r367590) +++ stable/12/sys/amd64/amd64/pmap.c
Re: svn commit: r367588 - in head/sys: kern sys
On Wed, Nov 11, 2020 at 02:58:32PM +0100, Hans Petter Selasky wrote: > On 11/11/20 2:44 PM, Mark Johnston wrote: > > +#defineSIGIO_ASSERT_LOCKED(type) mtx_assert(_lock, MA_OWNED) > > > > Minor nit: "type" argument can be removed from macro. Fixed, thanks. ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r367590 - head/sys/sys
Author: markj Date: Wed Nov 11 14:03:49 2020 New Revision: 367590 URL: https://svnweb.freebsd.org/changeset/base/367590 Log: Remove an extraneous parameter from SIGIO_ASSERT_LOCKED() Reported by: hselasky MFC with: r367588 Modified: head/sys/sys/signalvar.h Modified: head/sys/sys/signalvar.h == --- head/sys/sys/signalvar.hWed Nov 11 13:48:07 2020(r367589) +++ head/sys/sys/signalvar.hWed Nov 11 14:03:49 2020(r367590) @@ -337,7 +337,7 @@ struct thread; #defineSIGIO_TRYLOCK() mtx_trylock(_lock) #defineSIGIO_UNLOCK() mtx_unlock(_lock) #defineSIGIO_LOCKED() mtx_owned(_lock) -#defineSIGIO_ASSERT_LOCKED(type) mtx_assert(_lock, MA_OWNED) +#defineSIGIO_ASSERT_LOCKED() mtx_assert(_lock, MA_OWNED) extern struct mtx sigio_lock; ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r367589 - in head/sys: geom ufs/ffs
Author: markj Date: Wed Nov 11 13:48:07 2020 New Revision: 367589 URL: https://svnweb.freebsd.org/changeset/base/367589 Log: ffs: Clamp BIO_SPEEDUP length On 32-bit platforms, the computed size of the BIO_SPEEDUP requested by softdep_request_cleanup() may be negative when assigned to bp->b_bcount, which has type "long". Clamp the size to LONG_MAX. Also convert the unused g_io_speedup() to use an off_t for the magnitude of the shortage for consistency with softdep_send_speedup(). Reviewed by: chs, kib Reported by: pho Tested by:pho Sponsored by: The FreeBSD Foundation Differential Revision:https://reviews.freebsd.org/D27081 Modified: head/sys/geom/geom.h head/sys/geom/geom_io.c head/sys/ufs/ffs/ffs_softdep.c Modified: head/sys/geom/geom.h == --- head/sys/geom/geom.hWed Nov 11 13:44:27 2020(r367588) +++ head/sys/geom/geom.hWed Nov 11 13:48:07 2020(r367589) @@ -334,7 +334,8 @@ void g_io_deliver(struct bio *bp, int error); int g_io_getattr(const char *attr, struct g_consumer *cp, int *len, void *ptr); int g_io_zonecmd(struct disk_zone_args *zone_args, struct g_consumer *cp); int g_io_flush(struct g_consumer *cp); -int g_io_speedup(size_t shortage, u_int flags, size_t *resid, struct g_consumer *cp); +int g_io_speedup(off_t shortage, u_int flags, size_t *resid, +struct g_consumer *cp); void g_io_request(struct bio *bp, struct g_consumer *cp); struct bio *g_new_bio(void); struct bio *g_alloc_bio(void); Modified: head/sys/geom/geom_io.c == --- head/sys/geom/geom_io.c Wed Nov 11 13:44:27 2020(r367588) +++ head/sys/geom/geom_io.c Wed Nov 11 13:48:07 2020(r367589) @@ -341,15 +341,15 @@ g_io_zonecmd(struct disk_zone_args *zone_args, struct * operation should be done. */ int -g_io_speedup(size_t shortage, u_int flags, size_t *resid, struct g_consumer *cp) +g_io_speedup(off_t shortage, u_int flags, size_t *resid, struct g_consumer *cp) { struct bio *bp; int error; KASSERT((flags & (BIO_SPEEDUP_TRIM | BIO_SPEEDUP_WRITE)) != 0, ("Invalid flags passed to g_io_speedup: %#x", flags)); - g_trace(G_T_BIO, "bio_speedup(%s, %zu, %#x)", cp->provider->name, - shortage, flags); + g_trace(G_T_BIO, "bio_speedup(%s, %jd, %#x)", cp->provider->name, + (intmax_t)shortage, flags); bp = g_new_bio(); if (bp == NULL) return (ENOMEM); Modified: head/sys/ufs/ffs/ffs_softdep.c == --- head/sys/ufs/ffs/ffs_softdep.c Wed Nov 11 13:44:27 2020 (r367588) +++ head/sys/ufs/ffs/ffs_softdep.c Wed Nov 11 13:48:07 2020 (r367589) @@ -1464,7 +1464,7 @@ worklist_speedup(mp) } static void -softdep_send_speedup(struct ufsmount *ump, size_t shortage, u_int flags) +softdep_send_speedup(struct ufsmount *ump, off_t shortage, u_int flags) { struct buf *bp; @@ -1474,7 +1474,7 @@ softdep_send_speedup(struct ufsmount *ump, size_t shor bp = malloc(sizeof(*bp), M_TRIM, M_WAITOK | M_ZERO); bp->b_iocmd = BIO_SPEEDUP; bp->b_ioflags = flags; - bp->b_bcount = shortage; + bp->b_bcount = omin(shortage, LONG_MAX); g_vfs_strategy(ump->um_bo, bp); bufwait(bp); free(bp, M_TRIM); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r367588 - in head/sys: kern sys
Author: markj Date: Wed Nov 11 13:44:27 2020 New Revision: 367588 URL: https://svnweb.freebsd.org/changeset/base/367588 Log: Fix a pair of races in SIGIO registration First, funsetownlst() list looks at the first element of the list to see whether it's processing a process or a process group list. Then it acquires the global sigio lock and processes the list. However, nothing prevents the first sigio tracker from being freed by a concurrent funsetown() before the sigio lock is acquired. Fix this by acquiring the global sigio lock immediately after checking whether the list is empty. Callers of funsetownlst() ensure that new sigio trackers cannot be added concurrently. Second, fsetown() uses funsetown() to remove an existing sigio structure from a file object. However, funsetown() uses a racy check to avoid the sigio lock, so two threads may call fsetown() on the same file object, both observe that no sigio tracker is present, and enqueue two sigio trackers for the same file object. However, if the file object is destroyed, funsetown() will only remove one sigio tracker, and funsetownlst() may later trigger a use-after-free when it clears the file object reference for each entry in the list. Fix this by introducing funsetown_locked(), which avoids the racy check. Reviewed by: kib Reported by: pho Tested by:pho MFC after:1 week Sponsored by: The FreeBSD Foundation Differential Revision:https://reviews.freebsd.org/D27157 Modified: head/sys/kern/kern_descrip.c head/sys/kern/kern_exit.c head/sys/kern/kern_proc.c head/sys/sys/signalvar.h Modified: head/sys/kern/kern_descrip.c == --- head/sys/kern/kern_descrip.cWed Nov 11 11:26:36 2020 (r367587) +++ head/sys/kern/kern_descrip.cWed Nov 11 13:44:27 2020 (r367588) @@ -1001,6 +1001,40 @@ unlock: return (error); } +static void +sigiofree(struct sigio *sigio) +{ + crfree(sigio->sio_ucred); + free(sigio, M_SIGIO); +} + +static struct sigio * +funsetown_locked(struct sigio *sigio) +{ + struct proc *p; + struct pgrp *pg; + + SIGIO_ASSERT_LOCKED(); + + if (sigio == NULL) + return (NULL); + *(sigio->sio_myref) = NULL; + if (sigio->sio_pgid < 0) { + pg = sigio->sio_pgrp; + PGRP_LOCK(pg); + SLIST_REMOVE(>sio_pgrp->pg_sigiolst, sigio, + sigio, sio_pgsigio); + PGRP_UNLOCK(pg); + } else { + p = sigio->sio_proc; + PROC_LOCK(p); + SLIST_REMOVE(>sio_proc->p_sigiolst, sigio, + sigio, sio_pgsigio); + PROC_UNLOCK(p); + } + return (sigio); +} + /* * If sigio is on the list associated with a process or process group, * disable signalling from the device, remove sigio from the list and @@ -1011,92 +1045,82 @@ funsetown(struct sigio **sigiop) { struct sigio *sigio; + /* Racy check, consumers must provide synchronization. */ if (*sigiop == NULL) return; + SIGIO_LOCK(); - sigio = *sigiop; - if (sigio == NULL) { - SIGIO_UNLOCK(); - return; - } - *(sigio->sio_myref) = NULL; - if ((sigio)->sio_pgid < 0) { - struct pgrp *pg = (sigio)->sio_pgrp; - PGRP_LOCK(pg); - SLIST_REMOVE(>sio_pgrp->pg_sigiolst, sigio, - sigio, sio_pgsigio); - PGRP_UNLOCK(pg); - } else { - struct proc *p = (sigio)->sio_proc; - PROC_LOCK(p); - SLIST_REMOVE(>sio_proc->p_sigiolst, sigio, - sigio, sio_pgsigio); - PROC_UNLOCK(p); - } + sigio = funsetown_locked(*sigiop); SIGIO_UNLOCK(); - crfree(sigio->sio_ucred); - free(sigio, M_SIGIO); + if (sigio != NULL) + sigiofree(sigio); } /* - * Free a list of sigio structures. - * We only need to lock the SIGIO_LOCK because we have made ourselves - * inaccessible to callers of fsetown and therefore do not need to lock - * the proc or pgrp struct for the list manipulation. + * Free a list of sigio structures. The caller must ensure that new sigio + * structures cannot be added after this point. For process groups this is + * guaranteed using the proctree lock; for processes, the P_WEXIT flag serves + * as an interlock. */ void funsetownlst(struct sigiolst *sigiolst) { struct proc *p; struct pgrp *pg; - struct sigio *sigio; + struct sigio *sigio, *tmp; + /* Racy check. */ sigio = SLIST_FIRST(sigiolst); if (sigio == NULL) return; + p = NULL; pg = NULL; + SIGIO_LOCK(); + sigio = SLIST_FIRST(sigiolst); + if (sigio
svn commit: r367527 - stable/12/tests/sys/opencrypto
Author: markj Date: Mon Nov 9 15:37:57 2020 New Revision: 367527 URL: https://svnweb.freebsd.org/changeset/base/367527 Log: MFC r367388: cryptotest: Add qat(4) coverage Modified: stable/12/tests/sys/opencrypto/cryptotest.py Directory Properties: stable/12/ (props changed) Modified: stable/12/tests/sys/opencrypto/cryptotest.py == --- stable/12/tests/sys/opencrypto/cryptotest.pyMon Nov 9 15:37:12 2020(r367526) +++ stable/12/tests/sys/opencrypto/cryptotest.pyMon Nov 9 15:37:57 2020(r367527) @@ -49,9 +49,9 @@ def katg(base, glob): raise unittest.SkipTest("Missing %s test vectors" % (base)) return iglob(os.path.join(katdir, base, glob)) -aesmodules = [ 'cryptosoft0', 'aesni0', 'ccr0', 'ccp0', 'safexcel0' ] +aesmodules = [ 'cryptosoft0', 'aesni0', 'ccr0', 'ccp0', 'safexcel0', 'qat0' ] desmodules = [ 'cryptosoft0', ] -shamodules = [ 'cryptosoft0', 'aesni0', 'ccr0', 'ccp0', 'safexcel0' ] +shamodules = [ 'cryptosoft0', 'aesni0', 'ccr0', 'ccp0', 'safexcel0', 'qat0' ] def GenTestCase(cname): try: @@ -471,6 +471,7 @@ aesni = GenTestCase('aesni0') ccr = GenTestCase('ccr0') ccp = GenTestCase('ccp0') safexcel = GenTestCase('safexcel0') +qat = GenTestCase('qat0') if __name__ == '__main__': unittest.main() ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r367526 - in stable/12/sys: contrib/dev/qat modules modules/qatfw
Author: markj Date: Mon Nov 9 15:37:12 2020 New Revision: 367526 URL: https://svnweb.freebsd.org/changeset/base/367526 Log: MFC r367387, r367422: Add firmware modules for qat(4) Added: stable/12/sys/contrib/dev/qat/ - copied from r367387, head/sys/contrib/dev/qat/ stable/12/sys/modules/qatfw/ - copied from r367387, head/sys/modules/qatfw/ Modified: stable/12/sys/contrib/dev/qat/mmp_firmware_c2xxx.bin (contents, props changed) stable/12/sys/contrib/dev/qat/mof_firmware_c2xxx.bin (contents, props changed) stable/12/sys/contrib/dev/qat/qat_895xcc.bin (contents, props changed) stable/12/sys/contrib/dev/qat/qat_895xcc_mmp.bin (contents, props changed) stable/12/sys/contrib/dev/qat/qat_c3xxx.bin (contents, props changed) stable/12/sys/contrib/dev/qat/qat_c3xxx_mmp.bin (contents, props changed) stable/12/sys/contrib/dev/qat/qat_c62x.bin (contents, props changed) stable/12/sys/contrib/dev/qat/qat_c62x_mmp.bin (contents, props changed) stable/12/sys/contrib/dev/qat/qat_d15xx.bin (contents, props changed) stable/12/sys/contrib/dev/qat/qat_d15xx_mmp.bin (contents, props changed) stable/12/sys/modules/Makefile Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/contrib/dev/qat/mmp_firmware_c2xxx.bin == Binary file (source and/or target). No diff available. Modified: stable/12/sys/contrib/dev/qat/mof_firmware_c2xxx.bin == Binary file (source and/or target). No diff available. Modified: stable/12/sys/contrib/dev/qat/qat_895xcc.bin == Binary file (source and/or target). No diff available. Modified: stable/12/sys/contrib/dev/qat/qat_895xcc_mmp.bin == Binary file (source and/or target). No diff available. Modified: stable/12/sys/contrib/dev/qat/qat_c3xxx.bin == Binary file (source and/or target). No diff available. Modified: stable/12/sys/contrib/dev/qat/qat_c3xxx_mmp.bin == Binary file (source and/or target). No diff available. Modified: stable/12/sys/contrib/dev/qat/qat_c62x.bin == Binary file (source and/or target). No diff available. Modified: stable/12/sys/contrib/dev/qat/qat_c62x_mmp.bin == Binary file (source and/or target). No diff available. Modified: stable/12/sys/contrib/dev/qat/qat_d15xx.bin == Binary file (source and/or target). No diff available. Modified: stable/12/sys/contrib/dev/qat/qat_d15xx_mmp.bin == Binary file (source and/or target). No diff available. Modified: stable/12/sys/modules/Makefile == --- stable/12/sys/modules/Makefile Mon Nov 9 15:36:11 2020 (r367525) +++ stable/12/sys/modules/Makefile Mon Nov 9 15:37:12 2020 (r367526) @@ -324,6 +324,7 @@ SUBDIR= \ puc \ pwm \ ${_qat} \ + ${_qatfw} \ ${_qlxge} \ ${_qlxgb} \ ${_qlxgbe} \ @@ -663,6 +664,7 @@ _ndis= ndis _ocs_fc= ocs_fc _pccard= pccard _qat= qat +_qatfw=qatfw .if ${MK_OFED} != "no" || defined(ALL_MODULES) _rdma= rdma .endif ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r367525 - in stable/12: share/man/man4 sys/amd64/conf sys/conf sys/dev/qat sys/modules sys/modules/qat
Author: markj Date: Mon Nov 9 15:36:11 2020 New Revision: 367525 URL: https://svnweb.freebsd.org/changeset/base/367525 Log: MFC r367386: Add qat(4) Added: stable/12/share/man/man4/qat.4 - copied unchanged from r367386, head/share/man/man4/qat.4 stable/12/sys/dev/qat/ - copied from r367386, head/sys/dev/qat/ stable/12/sys/modules/qat/ - copied from r367386, head/sys/modules/qat/ Modified: stable/12/share/man/man4/Makefile stable/12/sys/amd64/conf/NOTES stable/12/sys/conf/files.amd64 stable/12/sys/dev/qat/qat.c stable/12/sys/dev/qat/qat_hw15.c stable/12/sys/dev/qat/qat_hw15var.h stable/12/sys/dev/qat/qat_hw17.c stable/12/sys/dev/qat/qat_hw17var.h stable/12/sys/dev/qat/qatvar.h stable/12/sys/modules/Makefile Directory Properties: stable/12/ (props changed) Modified: stable/12/share/man/man4/Makefile == --- stable/12/share/man/man4/Makefile Mon Nov 9 14:15:06 2020 (r367524) +++ stable/12/share/man/man4/Makefile Mon Nov 9 15:36:11 2020 (r367525) @@ -442,6 +442,7 @@ MAN=aac.4 \ pty.4 \ puc.4 \ pwmc.4 \ + ${_qat.4} \ ${_qlxge.4} \ ${_qlxgb.4} \ ${_qlxgbe.4} \ @@ -845,6 +846,7 @@ _nvd.4= nvd.4 _nvme.4= nvme.4 _nvram.4= nvram.4 _padlock.4=padlock.4 +_qat.4=qat.4 _rr232x.4= rr232x.4 _speaker.4=speaker.4 _spkr.4= spkr.4 Copied: stable/12/share/man/man4/qat.4 (from r367386, head/share/man/man4/qat.4) == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/12/share/man/man4/qat.4 Mon Nov 9 15:36:11 2020 (r367525, copy of r367386, head/share/man/man4/qat.4) @@ -0,0 +1,99 @@ +.\"- +.\" Copyright (c) 2020 Rubicon Communications, LLC (Netgate) +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\"notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\"notice, this list of conditions and the following disclaimer in the +.\"documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" $FreeBSD$ +.\" +.Dd November 5, 2020 +.Dt QAT 4 +.Os +.Sh NAME +.Nm qat +.Nd Intel QuickAssist Technology (QAT) driver +.Sh SYNOPSIS +To compile this driver into the kernel, +place the following lines in your +kernel configuration file: +.Bd -ragged -offset indent +.Cd "device crypto" +.Cd "device cryptodev" +.Cd "device qat" +.Ed +.Pp +Alternatively, to load the driver as a +module at boot time, place the following lines in +.Xr loader.conf 5 : +.Bd -literal -offset indent +qat_load="YES" +qat_c2xxxfw_load="YES" +qat_c3xxxfw_load="YES" +qat_c63xfw_load="YES" +qat_d15xxfw_load="YES" +qat_dh895xcc_load="YES" +.Ed +.Sh DESCRIPTION +The +.Nm +driver implements +.Xr crypto 4 +support for some of the cryptographic acceleration functions of the Intel +QuickAssist device. +The +.Nm +driver supports the QAT devices integrated with Atom C2000 and C3000 and Xeon +C620 and D-1500 chipsets, and the Intel QAT Adapter 8950. +It can accelerate AES in CBC, CTR, XTS (except for the C2000) and GCM modes, +and can perform authenticated encryption combining the CBC, CTR and XTS modes +with SHA1-HMAC and SHA2-HMAC. +The +.Nm +driver can also compute SHA1 and SHA2 digests. +.Sh SEE ALSO +.Xr crypto 4 , +.Xr ipsec 4 , +.Xr pci 4 , +.Xr random 4 , +.Xr crypto 7 , +.Xr crypto 9 +.Sh HISTORY +The +.Nm +driver first appeared in +.Fx 13.0 . +.Sh AUTHORS +The +.Nm +driver was written for +.Nx +by +.An Hikaru Abe Aq Mt hik...@iij.ad.jp +and ported to +.Fx +by +.An Mark Johnston Aq Mt ma...@fre
svn commit: r367524 - stable/12/sys/opencrypto
Author: markj Date: Mon Nov 9 14:15:06 2020 New Revision: 367524 URL: https://svnweb.freebsd.org/changeset/base/367524 Log: Add hmac_init_ipad() and hmac_init_opad() This is a merge of a small portion of r359374 which makes it easier to maintain OpenCrypto drivers in stable/12. No functional change intended; this is a direct commit to stable/12. Discussed with: jhb Modified: stable/12/sys/opencrypto/crypto.c stable/12/sys/opencrypto/cryptodev.h Modified: stable/12/sys/opencrypto/crypto.c == --- stable/12/sys/opencrypto/crypto.c Mon Nov 9 13:54:29 2020 (r367523) +++ stable/12/sys/opencrypto/crypto.c Mon Nov 9 14:15:06 2020 (r367524) @@ -380,6 +380,53 @@ crypto_terminate(struct proc **pp, void *q) } static void +hmac_init_pad(const struct auth_hash *axf, const char *key, int klen, +void *auth_ctx, uint8_t padval) +{ + uint8_t hmac_key[HMAC_MAX_BLOCK_LEN]; + u_int i; + + KASSERT(axf->blocksize <= sizeof(hmac_key), + ("Invalid HMAC block size %d", axf->blocksize)); + + /* +* If the key is larger than the block size, use the digest of +* the key as the key instead. +*/ + memset(hmac_key, 0, sizeof(hmac_key)); + if (klen > axf->blocksize) { + axf->Init(auth_ctx); + axf->Update(auth_ctx, key, klen); + axf->Final(hmac_key, auth_ctx); + klen = axf->hashsize; + } else + memcpy(hmac_key, key, klen); + + for (i = 0; i < axf->blocksize; i++) + hmac_key[i] ^= padval; + + axf->Init(auth_ctx); + axf->Update(auth_ctx, hmac_key, axf->blocksize); + explicit_bzero(hmac_key, sizeof(hmac_key)); +} + +void +hmac_init_ipad(const struct auth_hash *axf, const char *key, int klen, +void *auth_ctx) +{ + + hmac_init_pad(axf, key, klen, auth_ctx, HMAC_IPAD_VAL); +} + +void +hmac_init_opad(const struct auth_hash *axf, const char *key, int klen, +void *auth_ctx) +{ + + hmac_init_pad(axf, key, klen, auth_ctx, HMAC_OPAD_VAL); +} + +static void crypto_destroy(void) { struct crypto_ret_worker *ret_worker; Modified: stable/12/sys/opencrypto/cryptodev.h == --- stable/12/sys/opencrypto/cryptodev.hMon Nov 9 13:54:29 2020 (r367523) +++ stable/12/sys/opencrypto/cryptodev.hMon Nov 9 14:15:06 2020 (r367524) @@ -546,6 +546,14 @@ extern int crypto_usercrypto; /* userland may do cryp extern int crypto_userasymcrypto; /* userland may do asym crypto reqs */ extern int crypto_devallowsoft;/* only use hardware crypto */ +/* Helper routines for drivers to initialize auth contexts for HMAC. */ +struct auth_hash; + +void hmac_init_ipad(const struct auth_hash *axf, const char *key, int klen, +void *auth_ctx); +void hmac_init_opad(const struct auth_hash *axf, const char *key, int klen, +void *auth_ctx); + /* * Crypto-related utility routines used mainly by drivers. * ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r367523 - stable/12/usr.sbin/syslogd
Author: markj Date: Mon Nov 9 13:54:29 2020 New Revision: 367523 URL: https://svnweb.freebsd.org/changeset/base/367523 Log: MFC r366576: syslogd: Avoid trimming host names in RFC 5424 mode PR: 250014 Modified: stable/12/usr.sbin/syslogd/syslogd.c Directory Properties: stable/12/ (props changed) Modified: stable/12/usr.sbin/syslogd/syslogd.c == --- stable/12/usr.sbin/syslogd/syslogd.cMon Nov 9 13:20:44 2020 (r367522) +++ stable/12/usr.sbin/syslogd/syslogd.cMon Nov 9 13:54:29 2020 (r367523) @@ -2226,7 +2226,9 @@ cvthname(struct sockaddr *f) hl = strlen(hname); if (hl > 0 && hname[hl-1] == '.') hname[--hl] = '\0'; - trimdomain(hname, hl); + /* RFC 5424 prefers logging FQDNs. */ + if (RFC3164OutputFormat) + trimdomain(hname, hl); return (hname); } @@ -2853,7 +2855,9 @@ cfline(const char *line, const char *prog, const char hl = strlen(f->f_host); if (hl > 0 && f->f_host[hl-1] == '.') f->f_host[--hl] = '\0'; - trimdomain(f->f_host, hl); + /* RFC 5424 prefers logging FQDNs. */ + if (RFC3164OutputFormat) + trimdomain(f->f_host, hl); } /* save program name if any */ ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r367422 - head/sys/contrib/dev/qat
Author: markj Date: Fri Nov 6 16:12:06 2020 New Revision: 367422 URL: https://svnweb.freebsd.org/changeset/base/367422 Log: Add firmware modules for qat(4), take two My script to convert git commits to svn patch does not handle binary files correctly, and r367387 committed a set of empty files as a result. MFC with: r367387 Sponsored by: Rubicon Communications, LLC (Netgate) Modified: head/sys/contrib/dev/qat/mmp_firmware_c2xxx.bin (contents, props changed) head/sys/contrib/dev/qat/mof_firmware_c2xxx.bin (contents, props changed) head/sys/contrib/dev/qat/qat_895xcc.bin (contents, props changed) head/sys/contrib/dev/qat/qat_895xcc_mmp.bin (contents, props changed) head/sys/contrib/dev/qat/qat_c3xxx.bin (contents, props changed) head/sys/contrib/dev/qat/qat_c3xxx_mmp.bin (contents, props changed) head/sys/contrib/dev/qat/qat_c62x.bin (contents, props changed) head/sys/contrib/dev/qat/qat_c62x_mmp.bin (contents, props changed) head/sys/contrib/dev/qat/qat_d15xx.bin (contents, props changed) head/sys/contrib/dev/qat/qat_d15xx_mmp.bin (contents, props changed) Modified: head/sys/contrib/dev/qat/mmp_firmware_c2xxx.bin == Binary file (source and/or target). No diff available. Modified: head/sys/contrib/dev/qat/mof_firmware_c2xxx.bin == Binary file (source and/or target). No diff available. Modified: head/sys/contrib/dev/qat/qat_895xcc.bin == Binary file (source and/or target). No diff available. Modified: head/sys/contrib/dev/qat/qat_895xcc_mmp.bin == Binary file (source and/or target). No diff available. Modified: head/sys/contrib/dev/qat/qat_c3xxx.bin == Binary file (source and/or target). No diff available. Modified: head/sys/contrib/dev/qat/qat_c3xxx_mmp.bin == Binary file (source and/or target). No diff available. Modified: head/sys/contrib/dev/qat/qat_c62x.bin == Binary file (source and/or target). No diff available. Modified: head/sys/contrib/dev/qat/qat_c62x_mmp.bin == Binary file (source and/or target). No diff available. Modified: head/sys/contrib/dev/qat/qat_d15xx.bin == Binary file (source and/or target). No diff available. Modified: head/sys/contrib/dev/qat/qat_d15xx_mmp.bin == Binary file (source and/or target). No diff available. ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r367421 - svnadmin/conf
Author: markj Date: Fri Nov 6 16:10:04 2020 New Revision: 367421 URL: https://svnweb.freebsd.org/changeset/base/367421 Log: Add myself to the sizelimit exemption list Modified: svnadmin/conf/sizelimit.conf Modified: svnadmin/conf/sizelimit.conf == --- svnadmin/conf/sizelimit.confFri Nov 6 15:55:13 2020 (r367420) +++ svnadmin/conf/sizelimit.confFri Nov 6 16:10:04 2020 (r367421) @@ -22,3 +22,4 @@ jkim mm np mmacy 21064397 +markj ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r367388 - head/tests/sys/opencrypto
Author: markj Date: Thu Nov 5 16:00:57 2020 New Revision: 367388 URL: https://svnweb.freebsd.org/changeset/base/367388 Log: cryptotest: Add qat(4) coverage MFC after:3 days Sponsored by: Rubicon Communications, LLC (Netgate) Modified: head/tests/sys/opencrypto/cryptotest.py Modified: head/tests/sys/opencrypto/cryptotest.py == --- head/tests/sys/opencrypto/cryptotest.py Thu Nov 5 16:00:30 2020 (r367387) +++ head/tests/sys/opencrypto/cryptotest.py Thu Nov 5 16:00:57 2020 (r367388) @@ -50,8 +50,8 @@ def katg(base, glob): raise unittest.SkipTest("Missing %s test vectors" % (base)) return iglob(os.path.join(katdir, base, glob)) -aesmodules = [ 'cryptosoft0', 'aesni0', 'armv8crypto0', 'ccr0', 'ccp0', 'safexcel0' ] -shamodules = [ 'cryptosoft0', 'aesni0', 'armv8crypto0', 'ccr0', 'ccp0', 'ossl0', 'safexcel0' ] +aesmodules = [ 'cryptosoft0', 'aesni0', 'armv8crypto0', 'ccr0', 'ccp0', 'safexcel0', 'qat0' ] +shamodules = [ 'cryptosoft0', 'aesni0', 'armv8crypto0', 'ccr0', 'ccp0', 'ossl0', 'safexcel0', 'qat0' ] def GenTestCase(cname): try: @@ -458,6 +458,7 @@ ccr = GenTestCase('ccr0') ccp = GenTestCase('ccp0') ossl = GenTestCase('ossl0') safexcel = GenTestCase('safexcel0') +qat = GenTestCase('qat0') if __name__ == '__main__': unittest.main() ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r367387 - in head/sys: contrib/dev/qat modules modules/qatfw modules/qatfw/qat_c2xxx modules/qatfw/qat_c3xxx modules/qatfw/qat_c62x modules/qatfw/qat_d15xx modules/qatfw/qat_dh895xcc
Author: markj Date: Thu Nov 5 16:00:30 2020 New Revision: 367387 URL: https://svnweb.freebsd.org/changeset/base/367387 Log: Add firmware modules for qat(4) MFC after:3 days Sponsored by: Rubicon Communications, LLC (Netgate) Added: head/sys/contrib/dev/qat/ head/sys/contrib/dev/qat/LICENSE head/sys/contrib/dev/qat/mmp_firmware_c2xxx.bin head/sys/contrib/dev/qat/mof_firmware_c2xxx.bin head/sys/contrib/dev/qat/qat_895xcc.bin head/sys/contrib/dev/qat/qat_895xcc_mmp.bin head/sys/contrib/dev/qat/qat_c3xxx.bin head/sys/contrib/dev/qat/qat_c3xxx_mmp.bin head/sys/contrib/dev/qat/qat_c62x.bin head/sys/contrib/dev/qat/qat_c62x_mmp.bin head/sys/contrib/dev/qat/qat_d15xx.bin head/sys/contrib/dev/qat/qat_d15xx_mmp.bin head/sys/modules/qatfw/ head/sys/modules/qatfw/Makefile (contents, props changed) head/sys/modules/qatfw/qat_c2xxx/ head/sys/modules/qatfw/qat_c2xxx/Makefile (contents, props changed) head/sys/modules/qatfw/qat_c3xxx/ head/sys/modules/qatfw/qat_c3xxx/Makefile (contents, props changed) head/sys/modules/qatfw/qat_c62x/ head/sys/modules/qatfw/qat_c62x/Makefile (contents, props changed) head/sys/modules/qatfw/qat_d15xx/ head/sys/modules/qatfw/qat_d15xx/Makefile (contents, props changed) head/sys/modules/qatfw/qat_dh895xcc/ head/sys/modules/qatfw/qat_dh895xcc/Makefile (contents, props changed) Modified: head/sys/modules/Makefile Added: head/sys/contrib/dev/qat/LICENSE == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/contrib/dev/qat/LICENSEThu Nov 5 16:00:30 2020 (r367387) @@ -0,0 +1,11 @@ +Copyright (c) 2007-2016 Intel Corporation. +All rights reserved. +Redistribution. Redistribution and use in binary form, without modification, are permitted provided that the following conditions are met: + + Redistributions must reproduce the above copyright notice and the following disclaimer in the documentation and/or other materials provided with the distribution. + Neither the name of Intel Corporation nor the names of its suppliers may be used to endorse or promote products derived from this software without specific prior written permission. + No reverse engineering, decompilation, or disassembly of this software is permitted. + +Limited patent license. Intel Corporation grants a world-wide, royalty-free, non-exclusive license under patents it now or hereafter owns or controls to make, have made, use, import, offer to sell and sell ("Utilize") this software, but solely to the extent that any such patent is necessary to Utilize the software alone. The patent license shall not apply to any combinations which include this software. No hardware per se is licensed hereunder. + +DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Added: head/sys/contrib/dev/qat/mmp_firmware_c2xxx.bin == Added: head/sys/contrib/dev/qat/mof_firmware_c2xxx.bin == Added: head/sys/contrib/dev/qat/qat_895xcc.bin == Added: head/sys/contrib/dev/qat/qat_895xcc_mmp.bin == Added: head/sys/contrib/dev/qat/qat_c3xxx.bin == Added: head/sys/contrib/dev/qat/qat_c3xxx_mmp.bin == Added: head/sys/contrib/dev/qat/qat_c62x.bin == Added: head/sys/contrib/dev/qat/qat_c62x_mmp.bin == Added: head/sys/contrib/dev/qat/qat_d15xx.bin == Added: head/sys/contrib/dev/qat/qat_d15xx_mmp.bin == Modified: head/sys/modules/Makefile
svn commit: r367386 - in head: share/man/man4 sys/amd64/conf sys/conf sys/dev/qat sys/modules sys/modules/qat
ryptodev" +.Cd "device qat" +.Ed +.Pp +Alternatively, to load the driver as a +module at boot time, place the following lines in +.Xr loader.conf 5 : +.Bd -literal -offset indent +qat_load="YES" +qat_c2xxxfw_load="YES" +qat_c3xxxfw_load="YES" +qat_c63xfw_load="YES" +qat_d15xxfw_load="YES" +qat_dh895xcc_load="YES" +.Ed +.Sh DESCRIPTION +The +.Nm +driver implements +.Xr crypto 4 +support for some of the cryptographic acceleration functions of the Intel +QuickAssist device. +The +.Nm +driver supports the QAT devices integrated with Atom C2000 and C3000 and Xeon +C620 and D-1500 chipsets, and the Intel QAT Adapter 8950. +It can accelerate AES in CBC, CTR, XTS (except for the C2000) and GCM modes, +and can perform authenticated encryption combining the CBC, CTR and XTS modes +with SHA1-HMAC and SHA2-HMAC. +The +.Nm +driver can also compute SHA1 and SHA2 digests. +.Sh SEE ALSO +.Xr crypto 4 , +.Xr ipsec 4 , +.Xr pci 4 , +.Xr random 4 , +.Xr crypto 7 , +.Xr crypto 9 +.Sh HISTORY +The +.Nm +driver first appeared in +.Fx 13.0 . +.Sh AUTHORS +The +.Nm +driver was written for +.Nx +by +.An Hikaru Abe Aq Mt hik...@iij.ad.jp +and ported to +.Fx +by +.An Mark Johnston Aq Mt ma...@freebsd.org . +.Sh BUGS +Some Atom C2000 QAT devices have two acceleration engines instead of one. +The +.Nm +driver currently misbehaves when both are enabled and thus does not enable +the second acceleration engine if one is present. Modified: head/sys/amd64/conf/NOTES == --- head/sys/amd64/conf/NOTES Thu Nov 5 15:27:38 2020(r367385) +++ head/sys/amd64/conf/NOTES Thu Nov 5 15:55:23 2020(r367386) @@ -471,6 +471,10 @@ device vmd_bus # bus for VMD children device pmspcv # +# Intel QuickAssist +device qat + +# # SafeNet crypto driver: can be moved to the MI NOTES as soon as # it's tested on a big-endian machine # Modified: head/sys/conf/files.x86 == --- head/sys/conf/files.x86 Thu Nov 5 15:27:38 2020(r367385) +++ head/sys/conf/files.x86 Thu Nov 5 15:55:23 2020(r367386) @@ -291,6 +291,15 @@ dev/isci/scil/scif_sas_task_request_state_handlers.c dev/isci/scil/scif_sas_task_request_states.c optional isci dev/isci/scil/scif_sas_timer.c optional isci dev/itwd/itwd.c optional itwd +dev/qat/qat.c optional qat +dev/qat/qat_ae.c optional qat +dev/qat/qat_c2xxx.coptional qat +dev/qat/qat_c3xxx.coptional qat +dev/qat/qat_c62x.c optional qat +dev/qat/qat_d15xx.coptional qat +dev/qat/qat_dh895xcc.c optional qat +dev/qat/qat_hw15.c optional qat +dev/qat/qat_hw17.c optional qat libkern/x86/crc32_sse42.c standard # # x86 shared code between IA32 and AMD64 architectures Added: head/sys/dev/qat/qat.c == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/dev/qat/qat.c Thu Nov 5 15:55:23 2020(r367386) @@ -0,0 +1,2140 @@ +/* SPDX-License-Identifier: BSD-2-Clause-NetBSD AND BSD-3-Clause */ +/* $NetBSD: qat.c,v 1.6 2020/06/14 23:23:12 riastradh Exp $*/ + +/* + * Copyright (c) 2019 Internet Initiative Japan, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * Copyri
svn commit: r367335 - in head/sys/amd64: amd64 include
Author: markj Date: Wed Nov 4 16:42:20 2020 New Revision: 367335 URL: https://svnweb.freebsd.org/changeset/base/367335 Log: amd64: Make it easier to configure exception stack sizes The amd64 kernel handles certain types of exceptions on a dedicated stack. Currently the sizes of these stacks are all hard-coded to PAGE_SIZE, but for at least NMI handling it can be useful to use larger stacks. Add constants to intr_machdep.h to make this easier to tweak. No functional change intended. Reviewed by: kib MFC after:1 week Sponsored by: NetApp, Inc. Sponsored by: Klara, Inc. Differential Revision:https://reviews.freebsd.org/D27076 Modified: head/sys/amd64/amd64/machdep.c head/sys/amd64/amd64/mp_machdep.c head/sys/amd64/amd64/pmap.c head/sys/amd64/include/intr_machdep.h Modified: head/sys/amd64/amd64/machdep.c == --- head/sys/amd64/amd64/machdep.c Wed Nov 4 16:30:56 2020 (r367334) +++ head/sys/amd64/amd64/machdep.c Wed Nov 4 16:42:20 2020 (r367335) @@ -670,10 +670,10 @@ cpu_setregs(void) static struct gate_descriptor idt0[NIDT]; struct gate_descriptor *idt = [0];/* interrupt descriptor table */ -static char dblfault_stack[PAGE_SIZE] __aligned(16); -static char mce0_stack[PAGE_SIZE] __aligned(16); -static char nmi0_stack[PAGE_SIZE] __aligned(16); -static char dbg0_stack[PAGE_SIZE] __aligned(16); +static char dblfault_stack[DBLFAULT_STACK_SIZE] __aligned(16); +static char mce0_stack[MCE_STACK_SIZE] __aligned(16); +static char nmi0_stack[NMI_STACK_SIZE] __aligned(16); +static char dbg0_stack[DBG_STACK_SIZE] __aligned(16); CTASSERT(sizeof(struct nmi_pcpu) == 16); /* Modified: head/sys/amd64/amd64/mp_machdep.c == --- head/sys/amd64/amd64/mp_machdep.c Wed Nov 4 16:30:56 2020 (r367334) +++ head/sys/amd64/amd64/mp_machdep.c Wed Nov 4 16:42:20 2020 (r367335) @@ -305,22 +305,22 @@ init_secondary(void) pc->pc_common_tss.tss_rsp0 = 0; /* The doublefault stack runs on IST1. */ - np = ((struct nmi_pcpu *)_stack[PAGE_SIZE]) - 1; + np = ((struct nmi_pcpu *)_stack[DBLFAULT_STACK_SIZE]) - 1; np->np_pcpu = (register_t)pc; pc->pc_common_tss.tss_ist1 = (long)np; /* The NMI stack runs on IST2. */ - np = ((struct nmi_pcpu *) _stack[PAGE_SIZE]) - 1; + np = ((struct nmi_pcpu *)_stack[NMI_STACK_SIZE]) - 1; np->np_pcpu = (register_t)pc; pc->pc_common_tss.tss_ist2 = (long)np; /* The MC# stack runs on IST3. */ - np = ((struct nmi_pcpu *) _stack[PAGE_SIZE]) - 1; + np = ((struct nmi_pcpu *)_stack[MCE_STACK_SIZE]) - 1; np->np_pcpu = (register_t)pc; pc->pc_common_tss.tss_ist3 = (long)np; /* The DB# stack runs on IST4. */ - np = ((struct nmi_pcpu *) _stack[PAGE_SIZE]) - 1; + np = ((struct nmi_pcpu *)_stack[DBG_STACK_SIZE]) - 1; np->np_pcpu = (register_t)pc; pc->pc_common_tss.tss_ist4 = (long)np; @@ -481,13 +481,14 @@ native_start_all_aps(void) /* allocate and set up an idle stack data page */ bootstacks[cpu] = (void *)kmem_malloc(kstack_pages * PAGE_SIZE, M_WAITOK | M_ZERO); - doublefault_stack = (char *)kmem_malloc(PAGE_SIZE, M_WAITOK | - M_ZERO); - mce_stack = (char *)kmem_malloc(PAGE_SIZE, M_WAITOK | M_ZERO); + doublefault_stack = (char *)kmem_malloc(DBLFAULT_STACK_SIZE, + M_WAITOK | M_ZERO); + mce_stack = (char *)kmem_malloc(MCE_STACK_SIZE, + M_WAITOK | M_ZERO); nmi_stack = (char *)kmem_malloc_domainset( - DOMAINSET_PREF(domain), PAGE_SIZE, M_WAITOK | M_ZERO); + DOMAINSET_PREF(domain), NMI_STACK_SIZE, M_WAITOK | M_ZERO); dbg_stack = (char *)kmem_malloc_domainset( - DOMAINSET_PREF(domain), PAGE_SIZE, M_WAITOK | M_ZERO); + DOMAINSET_PREF(domain), DBG_STACK_SIZE, M_WAITOK | M_ZERO); dpcpu = (void *)kmem_malloc_domainset(DOMAINSET_PREF(domain), DPCPU_SIZE, M_WAITOK | M_ZERO); Modified: head/sys/amd64/amd64/pmap.c == --- head/sys/amd64/amd64/pmap.c Wed Nov 4 16:30:56 2020(r367334) +++ head/sys/amd64/amd64/pmap.c Wed Nov 4 16:42:20 2020(r367335) @@ -157,6 +157,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -10481,17 +10482,17 @@ pmap_pti_init(void) CPU_FOREACH(i) { /* Doublefault stack IST 1 */ va = __pcpu[i].pc_common_tss.tss_ist1 + sizeof(struct nmi_pcpu); - pmap_pti_add_kva_locked(va - PAGE_SIZE, va, false); +
svn commit: r367334 - in head/sys: dev/cxgbe/tom kern vm
Author: markj Date: Wed Nov 4 16:30:56 2020 New Revision: 367334 URL: https://svnweb.freebsd.org/changeset/base/367334 Log: vmspace: Convert to refcount(9) This is mostly mechanical except for vmspace_exit(). There, use the new refcount_release_if_last() to avoid switching to vmspace0 unless other processes are sharing the vmspace. In that case, upon switching to vmspace0 we can unconditionally release the reference. Remove the volatile qualifier from vm_refcnt now that accesses are protected using refcount(9) KPIs. Reviewed by: alc, kib, mmel MFC after:1 month Sponsored by: The FreeBSD Foundation Differential Revision:https://reviews.freebsd.org/D27057 Modified: head/sys/dev/cxgbe/tom/t4_ddp.c head/sys/kern/init_main.c head/sys/kern/kern_exec.c head/sys/kern/vfs_aio.c head/sys/vm/vm_glue.c head/sys/vm/vm_map.c head/sys/vm/vm_map.h Modified: head/sys/dev/cxgbe/tom/t4_ddp.c == --- head/sys/dev/cxgbe/tom/t4_ddp.c Wed Nov 4 16:30:30 2020 (r367333) +++ head/sys/dev/cxgbe/tom/t4_ddp.c Wed Nov 4 16:30:56 2020 (r367334) @@ -1347,7 +1347,7 @@ hold_aio(struct toepcb *toep, struct kaiocb *job, stru ps->offset = pgoff; ps->len = job->uaiocb.aio_nbytes; - atomic_add_int(>vm_refcnt, 1); + refcount_acquire(>vm_refcnt); ps->vm = vm; ps->start = start; Modified: head/sys/kern/init_main.c == --- head/sys/kern/init_main.c Wed Nov 4 16:30:30 2020(r367333) +++ head/sys/kern/init_main.c Wed Nov 4 16:30:56 2020(r367334) @@ -591,7 +591,7 @@ proc0_init(void *dummy __unused) /* Allocate a prototype map so we have something to fork. */ p->p_vmspace = - vmspace0.vm_refcnt = 1; + refcount_init(_refcnt, 1); pmap_pinit0(vmspace_pmap()); /* Modified: head/sys/kern/kern_exec.c == --- head/sys/kern/kern_exec.c Wed Nov 4 16:30:30 2020(r367333) +++ head/sys/kern/kern_exec.c Wed Nov 4 16:30:56 2020(r367334) @@ -1060,7 +1060,8 @@ exec_new_vmspace(struct image_params *imgp, struct sys sv_minuser = sv->sv_minuser; else sv_minuser = MAX(sv->sv_minuser, PAGE_SIZE); - if (vmspace->vm_refcnt == 1 && vm_map_min(map) == sv_minuser && + if (refcount_load(>vm_refcnt) == 1 && + vm_map_min(map) == sv_minuser && vm_map_max(map) == sv->sv_maxuser && cpu_exec_vmspace_reuse(p, map)) { shmexit(vmspace); Modified: head/sys/kern/vfs_aio.c == --- head/sys/kern/vfs_aio.c Wed Nov 4 16:30:30 2020(r367333) +++ head/sys/kern/vfs_aio.c Wed Nov 4 16:30:56 2020(r367334) @@ -1159,8 +1159,9 @@ aio_daemon(void *_id) KASSERT(p->p_vmspace == myvm, ("AIOD: bad vmspace for exiting daemon")); - KASSERT(myvm->vm_refcnt > 1, - ("AIOD: bad vm refcnt for exiting daemon: %d", myvm->vm_refcnt)); + KASSERT(refcount_load(>vm_refcnt) > 1, + ("AIOD: bad vm refcnt for exiting daemon: %d", + refcount_load(>vm_refcnt))); kproc_exit(0); } Modified: head/sys/vm/vm_glue.c == --- head/sys/vm/vm_glue.c Wed Nov 4 16:30:30 2020(r367333) +++ head/sys/vm/vm_glue.c Wed Nov 4 16:30:56 2020(r367334) @@ -75,6 +75,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -549,7 +550,7 @@ vm_forkproc(struct thread *td, struct proc *p2, struct * COW locally. */ if ((flags & RFMEM) == 0) { - if (p1->p_vmspace->vm_refcnt > 1) { + if (refcount_load(>p_vmspace->vm_refcnt) > 1) { error = vmspace_unshare(p1); if (error) return (error); @@ -561,7 +562,7 @@ vm_forkproc(struct thread *td, struct proc *p2, struct if (flags & RFMEM) { p2->p_vmspace = p1->p_vmspace; - atomic_add_int(>p_vmspace->vm_refcnt, 1); + refcount_acquire(>p_vmspace->vm_refcnt); } dset = td2->td_domain.dr_policy; while (vm_page_count_severe_set(>ds_mask)) { Modified: head/sys/vm/vm_map.c == --- head/sys/vm/vm_map.cWed Nov 4 16:30:30 2020(r367333) +++ head/sys/vm/vm_map.cWed Nov 4 16:30:56 2020(r367334) @@ -257,7 +257,7 @@ vmspace_alloc(vm_offset_t min, vm_offset_t max, pmap_p
svn commit: r367333 - in head: share/man/man9 sys/sys
Author: markj Date: Wed Nov 4 16:30:30 2020 New Revision: 367333 URL: https://svnweb.freebsd.org/changeset/base/367333 Log: refcount(9): Add refcount_release_if_last() and refcount_load() The former is intended for use in vmspace_exit(). The latter is to encourage use of explicit loads rather than relying on the volatile qualifier. This works better with kernel sanitizers, which can intercept atomic(9) calls, and makes tricky lockless code easier to read by not forcing the reader to remember which variables are declared volatile. Reviewed by: kib, mjg, mmel MFC after:2 weeks Sponsored by: The FreeBSD Foundation Differential Revision:https://reviews.freebsd.org/D27056 Modified: head/share/man/man9/refcount.9 head/sys/sys/refcount.h Modified: head/share/man/man9/refcount.9 == --- head/share/man/man9/refcount.9 Wed Nov 4 15:44:59 2020 (r367332) +++ head/share/man/man9/refcount.9 Wed Nov 4 16:30:30 2020 (r367333) @@ -32,7 +32,7 @@ .\" .\" $FreeBSD$ .\" -.Dd July 23, 2019 +.Dd November 2, 2020 .Dt REFCOUNT 9 .Os .Sh NAME @@ -46,6 +46,8 @@ .In sys/refcount.h .Ft void .Fn refcount_init "volatile u_int *count" "u_int value" +.Ft u_int +.Fn refcount_load "volatile u_int *count" .Ft void .Fn refcount_acquire "volatile u_int *count" .Ft bool @@ -55,6 +57,8 @@ .Ft bool .Fn refcount_release "volatile u_int *count" .Ft bool +.Fn refcount_release_if_last "volatile u_int *count" +.Ft bool .Fn refcount_release_if_not_last "volatile u_int *count" .Sh DESCRIPTION The @@ -75,6 +79,16 @@ function is used to set the initial value of the count It is normally used when creating a reference-counted object. .Pp The +.Fn refcount_load +function returns a snapshot of the counter value. +This value may immediately become out-of-date in the absence of external +synchronization. +.Fn refcount_load +should be used instead of relying on the properties of the +.Vt volatile +qualifier. +.Pp +The .Fn refcount_acquire function is used to acquire a new reference. The caller is responsible for ensuring that it holds a valid reference @@ -119,16 +133,33 @@ the last reference; otherwise, it returns false. .Pp The +.Fn refcount_release_if_last +and .Fn refcount_release_if_not_last -is a variant of +functions are variants of .Fn refcount_release -which only drops the reference when it is not the last reference. -In other words, the function returns +which only drop the reference when it is or is not the last reference, +respectively. +In other words, +.Fn refcount_release_if_last +returns .Dv true when .Fa *count +is equal to one, in which case it is decremented to zero. +Otherwise, +.Fa *count +is not modified and the function returns +.Dv false . +Similarly, +.Fn refcount_release_if_not_last +returns +.Dv true +when +.Fa *count is greater than one, in which case -.Fa *count is decremented. +.Fa *count +is decremented. Otherwise, if .Fa *count is equal to one, the reference is not released and the function returns Modified: head/sys/sys/refcount.h == --- head/sys/sys/refcount.h Wed Nov 4 15:44:59 2020(r367332) +++ head/sys/sys/refcount.h Wed Nov 4 16:30:30 2020(r367333) @@ -67,6 +67,12 @@ refcount_init(volatile u_int *count, u_int value) } static __inline u_int +refcount_load(volatile u_int *count) +{ + return (atomic_load_int(count)); +} + +static __inline u_int refcount_acquire(volatile u_int *count) { u_int old; @@ -168,32 +174,50 @@ refcount_release(volatile u_int *count) return (refcount_releasen(count, 1)); } +#define_refcount_release_if_cond(cond, name) \ +static __inline __result_use_check bool \ +_refcount_release_if_##name(volatile u_int *count, u_int n)\ +{ \ + u_int old; \ + \ + KASSERT(n > 0, ("%s: zero increment", __func__)); \ + old = atomic_load_int(count); \ + for (;;) { \ + if (!(cond))\ + return (false); \ + if (__predict_false(REFCOUNT_SATURATED(old))) \ + return (false); \ + if (atomic_fcmpset_rel_int(count, , old - 1)) \ + return (true); \ + } \ +} +_refcount_release_if_cond(old > n,
svn commit: r367297 - stable/12
Author: markj Date: Tue Nov 3 14:41:49 2020 New Revision: 367297 URL: https://svnweb.freebsd.org/changeset/base/367297 Log: MFC r367081: arm64: Remove a racy KASSERT from pmap_remove_pages() Modified: Directory Properties: stable/12/ (props changed) ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r367272 - stable/12/sys/kern
Author: markj Date: Mon Nov 2 14:30:55 2020 New Revision: 367272 URL: https://svnweb.freebsd.org/changeset/base/367272 Log: MFC r366838: vmem: Allocate btags before looping in vmem_xalloc() Modified: stable/12/sys/kern/subr_vmem.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/kern/subr_vmem.c == --- stable/12/sys/kern/subr_vmem.c Mon Nov 2 14:01:33 2020 (r367271) +++ stable/12/sys/kern/subr_vmem.c Mon Nov 2 14:30:55 2020 (r367272) @@ -359,6 +359,24 @@ bt_free(vmem_t *vm, bt_t *bt) } /* + * Hide MAXALLOC tags before dropping the arena lock to ensure that a + * concurrent allocation attempt does not grab them. + */ +static void +bt_save(vmem_t *vm) +{ + KASSERT(vm->vm_nfreetags >= BT_MAXALLOC, + ("%s: insufficient free tags %d", __func__, vm->vm_nfreetags)); + vm->vm_nfreetags -= BT_MAXALLOC; +} + +static void +bt_restore(vmem_t *vm) +{ + vm->vm_nfreetags += BT_MAXALLOC; +} + +/* * freelist[0] ... [1, 1] * freelist[1] ... [2, 2] * : @@ -886,16 +904,11 @@ vmem_import(vmem_t *vm, vmem_size_t size, vmem_size_t if (vm->vm_limit != 0 && vm->vm_limit < vm->vm_size + size) return (ENOMEM); - /* -* Hide MAXALLOC tags so we're guaranteed to be able to add this -* span and the tag we want to allocate from it. -*/ - MPASS(vm->vm_nfreetags >= BT_MAXALLOC); - vm->vm_nfreetags -= BT_MAXALLOC; + bt_save(vm); VMEM_UNLOCK(vm); error = (vm->vm_importfn)(vm->vm_arg, size, flags, ); VMEM_LOCK(vm); - vm->vm_nfreetags += BT_MAXALLOC; + bt_restore(vm); if (error) return (ENOMEM); @@ -1023,19 +1036,23 @@ vmem_try_fetch(vmem_t *vm, const vmem_size_t size, vme */ if (vm->vm_qcache_max != 0 || vm->vm_reclaimfn != NULL) { avail = vm->vm_size - vm->vm_inuse; + bt_save(vm); VMEM_UNLOCK(vm); if (vm->vm_qcache_max != 0) qc_drain(vm); if (vm->vm_reclaimfn != NULL) vm->vm_reclaimfn(vm, flags); VMEM_LOCK(vm); + bt_restore(vm); /* If we were successful retry even NOWAIT. */ if (vm->vm_size - vm->vm_inuse > avail) return (1); } if ((flags & M_NOWAIT) != 0) return (0); + bt_save(vm); VMEM_CONDVAR_WAIT(vm); + bt_restore(vm); return (1); } @@ -1083,13 +1100,14 @@ vmem_xalloc_nextfit(vmem_t *vm, const vmem_size_t size error = ENOMEM; VMEM_LOCK(vm); -retry: + /* * Make sure we have enough tags to complete the operation. */ if (bt_fill(vm, flags) != 0) goto out; +retry: /* * Find the next free tag meeting our constraints. If one is found, * perform the allocation. @@ -1364,15 +1382,14 @@ vmem_xalloc(vmem_t *vm, const vmem_size_t size0, vmem_ */ first = bt_freehead_toalloc(vm, size, strat); VMEM_LOCK(vm); - for (;;) { - /* -* Make sure we have enough tags to complete the -* operation. -*/ - error = bt_fill(vm, flags); - if (error != 0) - break; + /* +* Make sure we have enough tags to complete the operation. +*/ + error = bt_fill(vm, flags); + if (error != 0) + goto out; + for (;;) { /* * Scan freelists looking for a tag that satisfies the * allocation. If we're doing BESTFIT we may encounter ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r367271 - stable/12/sys/kern
Author: markj Date: Mon Nov 2 14:01:33 2020 New Revision: 367271 URL: https://svnweb.freebsd.org/changeset/base/367271 Log: MFC r366837: vmem: Simplify bt_fill() callers a bit Modified: stable/12/sys/kern/subr_vmem.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/kern/subr_vmem.c == --- stable/12/sys/kern/subr_vmem.c Mon Nov 2 14:00:25 2020 (r367270) +++ stable/12/sys/kern/subr_vmem.c Mon Nov 2 14:01:33 2020 (r367271) @@ -257,8 +257,8 @@ vmem_t *memguard_arena = _arena_storage; * allocation will not fail once bt_fill() passes. To do so we cache * at least the maximum possible tag allocations in the arena. */ -static int -bt_fill(vmem_t *vm, int flags) +static __noinline int +_bt_fill(vmem_t *vm, int flags) { bt_t *bt; @@ -298,6 +298,14 @@ bt_fill(vmem_t *vm, int flags) return 0; } +static inline int +bt_fill(vmem_t *vm, int flags) +{ + if (vm->vm_nfreetags >= BT_MAXALLOC) + return (0); + return (_bt_fill(vm, flags)); +} + /* * Pop a tag off of the freetag stack. */ @@ -1079,7 +1087,7 @@ retry: /* * Make sure we have enough tags to complete the operation. */ - if (vm->vm_nfreetags < BT_MAXALLOC && bt_fill(vm, flags) != 0) + if (bt_fill(vm, flags) != 0) goto out; /* @@ -1361,11 +1369,9 @@ vmem_xalloc(vmem_t *vm, const vmem_size_t size0, vmem_ * Make sure we have enough tags to complete the * operation. */ - if (vm->vm_nfreetags < BT_MAXALLOC && - bt_fill(vm, flags) != 0) { - error = ENOMEM; + error = bt_fill(vm, flags); + if (error != 0) break; - } /* * Scan freelists looking for a tag that satisfies the @@ -1484,13 +1490,12 @@ vmem_add(vmem_t *vm, vmem_addr_t addr, vmem_size_t siz { int error; - error = 0; flags &= VMEM_FLAGS; + VMEM_LOCK(vm); - if (vm->vm_nfreetags >= BT_MAXALLOC || bt_fill(vm, flags) == 0) + error = bt_fill(vm, flags); + if (error == 0) vmem_add1(vm, addr, size, BT_TYPE_SPAN_STATIC); - else - error = ENOMEM; VMEM_UNLOCK(vm); return (error); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r367270 - stable/12/sys/amd64/vmm/intel
Author: markj Date: Mon Nov 2 14:00:25 2020 New Revision: 367270 URL: https://svnweb.freebsd.org/changeset/base/367270 Log: MFC r366834: vmx: Implement pmap (de)activation in C Modified: stable/12/sys/amd64/vmm/intel/vmx.c stable/12/sys/amd64/vmm/intel/vmx.h stable/12/sys/amd64/vmm/intel/vmx_genassym.c stable/12/sys/amd64/vmm/intel/vmx_support.S Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/amd64/vmm/intel/vmx.c == --- stable/12/sys/amd64/vmm/intel/vmx.c Mon Nov 2 10:44:29 2020 (r367269) +++ stable/12/sys/amd64/vmm/intel/vmx.c Mon Nov 2 14:00:25 2020 (r367270) @@ -2822,7 +2822,6 @@ vmx_exit_inst_error(struct vmxctx *vmxctx, int rc, str switch (rc) { case VMX_VMRESUME_ERROR: case VMX_VMLAUNCH_ERROR: - case VMX_INVEPT_ERROR: vmexit->u.vmx.inst_type = rc; break; default: @@ -2927,6 +2926,29 @@ vmx_dr_leave_guest(struct vmxctx *vmxctx) write_rflags(read_rflags() | vmxctx->host_tf); } +static __inline void +vmx_pmap_activate(struct vmx *vmx, pmap_t pmap) +{ + long eptgen; + int cpu; + + cpu = curcpu; + + CPU_SET_ATOMIC(cpu, >pm_active); + eptgen = atomic_load_long(>pm_eptgen); + if (eptgen != vmx->eptgen[cpu]) { + vmx->eptgen[cpu] = eptgen; + invept(INVEPT_TYPE_SINGLE_CONTEXT, + (struct invept_desc){ .eptp = vmx->eptp, ._res = 0 }); + } +} + +static __inline void +vmx_pmap_deactivate(struct vmx *vmx, pmap_t pmap) +{ + CPU_CLR_ATOMIC(curcpu, >pm_active); +} + static int vmx_run(void *arg, int vcpu, register_t rip, pmap_t pmap, struct vm_eventinfo *evinfo) @@ -3075,11 +3097,19 @@ vmx_run(void *arg, int vcpu, register_t rip, pmap_t pm */ vmx_msr_guest_enter_tsc_aux(vmx, vcpu); - vmx_run_trace(vmx, vcpu); vmx_dr_enter_guest(vmxctx); + + /* +* Mark the EPT as active on this host CPU and invalidate +* EPTP-tagged TLB entries if required. +*/ + vmx_pmap_activate(vmx, pmap); + + vmx_run_trace(vmx, vcpu); rc = vmx_enter_guest(vmxctx, vmx, launched); - vmx_dr_leave_guest(vmxctx); + vmx_pmap_deactivate(vmx, pmap); + vmx_dr_leave_guest(vmxctx); vmx_msr_guest_exit_tsc_aux(vmx, vcpu); bare_lgdt(); Modified: stable/12/sys/amd64/vmm/intel/vmx.h == --- stable/12/sys/amd64/vmm/intel/vmx.h Mon Nov 2 10:44:29 2020 (r367269) +++ stable/12/sys/amd64/vmm/intel/vmx.h Mon Nov 2 14:00:25 2020 (r367270) @@ -142,7 +142,6 @@ CTASSERT((offsetof(struct vmx, pir_desc[0]) & 63) == 0 #defineVMX_GUEST_VMEXIT0 #defineVMX_VMRESUME_ERROR 1 #defineVMX_VMLAUNCH_ERROR 2 -#defineVMX_INVEPT_ERROR3 intvmx_enter_guest(struct vmxctx *ctx, struct vmx *vmx, int launched); void vmx_call_isr(uintptr_t entry); Modified: stable/12/sys/amd64/vmm/intel/vmx_genassym.c == --- stable/12/sys/amd64/vmm/intel/vmx_genassym.cMon Nov 2 10:44:29 2020(r367269) +++ stable/12/sys/amd64/vmm/intel/vmx_genassym.cMon Nov 2 14:00:25 2020(r367270) @@ -70,17 +70,12 @@ ASSYM(VMXCTX_HOST_RSP, offsetof(struct vmxctx, host_rs ASSYM(VMXCTX_HOST_RBX, offsetof(struct vmxctx, host_rbx)); ASSYM(VMXCTX_INST_FAIL_STATUS, offsetof(struct vmxctx, inst_fail_status)); -ASSYM(VMXCTX_PMAP, offsetof(struct vmxctx, pmap)); -ASSYM(VMX_EPTGEN, offsetof(struct vmx, eptgen)); -ASSYM(VMX_EPTP, offsetof(struct vmx, eptp)); - ASSYM(VM_FAIL_INVALID, VM_FAIL_INVALID); ASSYM(VM_FAIL_VALID, VM_FAIL_VALID); ASSYM(VMX_GUEST_VMEXIT, VMX_GUEST_VMEXIT); ASSYM(VMX_VMRESUME_ERROR, VMX_VMRESUME_ERROR); ASSYM(VMX_VMLAUNCH_ERROR, VMX_VMLAUNCH_ERROR); -ASSYM(VMX_INVEPT_ERROR, VMX_INVEPT_ERROR); ASSYM(PC_CPUID, offsetof(struct pcpu, pc_cpuid)); Modified: stable/12/sys/amd64/vmm/intel/vmx_support.S == --- stable/12/sys/amd64/vmm/intel/vmx_support.S Mon Nov 2 10:44:29 2020 (r367269) +++ stable/12/sys/amd64/vmm/intel/vmx_support.S Mon Nov 2 14:00:25 2020 (r367270) @@ -148,33 +148,6 @@ ENTRY(vmx_enter_guest) */ VMX_HOST_SAVE - /* -* Activate guest pmap on this cpu. -*/ - movqVMXCTX_PMAP(%rdi), %r11 - movlPCPU(CPUID), %eax - LK btsl %eax, PM_ACTIVE(%r11) - - /* -* If 'vmx->eptgen[curcpu]' is not identical to 'pmap->pm_eptgen' -* then we must invalidate all mappings associated with this EPTP. -
svn commit: r367174 - head/sys/opencrypto
Author: markj Date: Fri Oct 30 17:05:36 2020 New Revision: 367174 URL: https://svnweb.freebsd.org/changeset/base/367174 Log: opencrypto: Annotate hmac_init_(i|o)pad() to make auth_hash const This makes them friendlier to drivers that try to use const pointers whenever possible in their internal structures. Reviewed by: jhb Sponsored by: Rubicon Communications, LLC (Netgate) Differential Revision:https://reviews.freebsd.org/D26901 Modified: head/sys/opencrypto/crypto.c head/sys/opencrypto/cryptodev.h Modified: head/sys/opencrypto/crypto.c == --- head/sys/opencrypto/crypto.cFri Oct 30 15:43:52 2020 (r367173) +++ head/sys/opencrypto/crypto.cFri Oct 30 17:05:36 2020 (r367174) @@ -411,8 +411,8 @@ crypto_terminate(struct proc **pp, void *q) } static void -hmac_init_pad(struct auth_hash *axf, const char *key, int klen, void *auth_ctx, -uint8_t padval) +hmac_init_pad(const struct auth_hash *axf, const char *key, int klen, +void *auth_ctx, uint8_t padval) { uint8_t hmac_key[HMAC_MAX_BLOCK_LEN]; u_int i; @@ -442,7 +442,7 @@ hmac_init_pad(struct auth_hash *axf, const char *key, } void -hmac_init_ipad(struct auth_hash *axf, const char *key, int klen, +hmac_init_ipad(const struct auth_hash *axf, const char *key, int klen, void *auth_ctx) { @@ -450,7 +450,7 @@ hmac_init_ipad(struct auth_hash *axf, const char *key, } void -hmac_init_opad(struct auth_hash *axf, const char *key, int klen, +hmac_init_opad(const struct auth_hash *axf, const char *key, int klen, void *auth_ctx) { Modified: head/sys/opencrypto/cryptodev.h == --- head/sys/opencrypto/cryptodev.h Fri Oct 30 15:43:52 2020 (r367173) +++ head/sys/opencrypto/cryptodev.h Fri Oct 30 17:05:36 2020 (r367174) @@ -683,9 +683,9 @@ SYSCTL_DECL(_kern_crypto); /* Helper routines for drivers to initialize auth contexts for HMAC. */ struct auth_hash; -void hmac_init_ipad(struct auth_hash *axf, const char *key, int klen, +void hmac_init_ipad(const struct auth_hash *axf, const char *key, int klen, void *auth_ctx); -void hmac_init_opad(struct auth_hash *axf, const char *key, int klen, +void hmac_init_opad(const struct auth_hash *axf, const char *key, int klen, void *auth_ctx); /* ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
Re: svn commit: r367165 - head/sys/fs/tmpfs
On Fri, Oct 30, 2020 at 03:08:32PM +0100, Mateusz Guzik wrote: > On 10/30/20, Mateusz Guzik wrote: > > Author: mjg > > Date: Fri Oct 30 14:07:25 2020 > > New Revision: 367165 > > URL: https://svnweb.freebsd.org/changeset/base/367165 > > > > Log: > > tmpfs: change tmpfs dirent zone into a malloc type > > > > It is 64 bytes. > > > > Right now malloc has only power-of-2 zones but I'm looking into > changing that. The allocator itself trivially extends to multiply of > 16, but stat collection needs reworking. Sums of consecutive powers of 2 also works well. That is, 16, 16 + 8, 32, 32 + 16, ... When I last looked I didn't see very many places that would benefit, at least outside of ZFS. Probably the main one is CAM CCBs, and that'll be helped by https://reviews.freebsd.org/D26844 . ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
Re: svn commit: r367165 - head/sys/fs/tmpfs
On Fri, Oct 30, 2020 at 02:07:25PM +, Mateusz Guzik wrote: > Author: mjg > Date: Fri Oct 30 14:07:25 2020 > New Revision: 367165 > URL: https://svnweb.freebsd.org/changeset/base/367165 > > Log: > tmpfs: change tmpfs dirent zone into a malloc type > > It is 64 bytes. That could change though. What's the reason for whacking UMA zones? Is it to reduce fragmentation? If so it would worth trying to change UMA to share kegs among zones with identical item sizes. That would provide a similar benefit automatically. ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r367171 - in stable/12/usr.bin/col: . tests
Author: markj Date: Fri Oct 30 14:41:19 2020 New Revision: 367171 URL: https://svnweb.freebsd.org/changeset/base/367171 Log: MFC r366577: col(1): Fix a couple of bugs PR: 249308 Added: stable/12/usr.bin/col/tests/hlf.in - copied unchanged from r366577, head/usr.bin/col/tests/hlf.in stable/12/usr.bin/col/tests/hlf2.in - copied unchanged from r366577, head/usr.bin/col/tests/hlf2.in stable/12/usr.bin/col/tests/nl.in - copied unchanged from r366577, head/usr.bin/col/tests/nl.in stable/12/usr.bin/col/tests/nl2.in - copied unchanged from r366577, head/usr.bin/col/tests/nl2.in stable/12/usr.bin/col/tests/nl3.in - copied unchanged from r366577, head/usr.bin/col/tests/nl3.in stable/12/usr.bin/col/tests/rlf3.in - copied unchanged from r366577, head/usr.bin/col/tests/rlf3.in Modified: stable/12/usr.bin/col/col.c stable/12/usr.bin/col/tests/Makefile stable/12/usr.bin/col/tests/col_test.sh (contents, props changed) Directory Properties: stable/12/ (props changed) Modified: stable/12/usr.bin/col/col.c == --- stable/12/usr.bin/col/col.c Fri Oct 30 14:40:48 2020(r367170) +++ stable/12/usr.bin/col/col.c Fri Oct 30 14:41:19 2020(r367171) @@ -100,7 +100,7 @@ struct line_str { }; static voidaddto_lineno(int *, int); -static LINE *alloc_line(void); +static LINE*alloc_line(void); static voiddowarn(int); static voidflush_line(LINE *); static voidflush_lines(int); @@ -109,7 +109,7 @@ static void free_line(LINE *); static voidusage(void); static CSETlast_set; /* char_set of last char printed */ -static LINE*lines; +static LINE*lines; static int compress_spaces;/* if doing space -> tab conversion */ static int fine; /* if `fine' resolution (half lines) */ static int max_bufd_lines; /* max # of half lines to keep in memory */ @@ -340,8 +340,16 @@ main(int argc, char **argv) } if (ferror(stdin)) err(1, NULL); - if (extra_lines) + if (extra_lines) { + /* +* Extra lines only exist if no lines have been flushed +* yet. This means that 'lines' must point to line zero +* after we flush the extra lines. +*/ flush_lines(extra_lines); + l = lines; + this_line = 0; + } /* goto the last line that had a character on it */ for (; l->l_next; l = l->l_next) @@ -353,14 +361,22 @@ main(int argc, char **argv) PUTC(SI); /* flush out the last few blank lines */ - if (max_line > this_line) - nblank_lines = max_line - this_line; - if (max_line & 1) - nblank_lines++; + if (max_line >= this_line) + nblank_lines = max_line - this_line + (max_line & 1); + if (nblank_lines == 0) + /* end with a newline even if the source doesn't */ + nblank_lines = 2; flush_blanks(); exit(0); } +/* + * Prints the first 'nflush' lines. Printed lines are freed. + * After this function returns, 'lines' points to the first + * of the remaining lines, and 'nblank_lines' will have the + * number of half line feeds between the final flushed line + * and the first remaining line. + */ static void flush_lines(int nflush) { @@ -372,11 +388,10 @@ flush_lines(int nflush) if (l->l_line) { flush_blanks(); flush_line(l); + free(l->l_line); } - if (l->l_line || l->l_next) + if (l->l_next) nblank_lines++; - if (l->l_line) - (void)free(l->l_line); free_line(l); } if (lines) @@ -384,9 +399,8 @@ flush_lines(int nflush) } /* - * Print a number of newline/half newlines. If fine flag is set, nblank_lines - * is the number of half line feeds, otherwise it is the number of whole line - * feeds. + * Print a number of newline/half newlines. + * nblank_lines is the number of half line feeds. */ static void flush_blanks(void) Modified: stable/12/usr.bin/col/tests/Makefile == --- stable/12/usr.bin/col/tests/MakefileFri Oct 30 14:40:48 2020 (r367170) +++ stable/12/usr.bin/col/tests/MakefileFri Oct 30 14:41:19 2020 (r367171) @@ -4,8 +4,14 @@ PACKAGE= tests ATF_TESTS_SH= col_test -${PACKAGE}FILES+= \ +${PACKAGE}FILES+= \ + hlf.in \ + hlf2.in \ + nl.in \ + nl2.in \ + nl3.in \ rlf.in \ - rlf2.in + rlf2.in \ + rlf3.in .include Modified:
svn commit: r367170 - stable/12/share/man/man9
Author: markj Date: Fri Oct 30 14:40:48 2020 New Revision: 367170 URL: https://svnweb.freebsd.org/changeset/base/367170 Log: MFC r366970: Add some missing nv(9) MLINKS Modified: stable/12/share/man/man9/Makefile Directory Properties: stable/12/ (props changed) Modified: stable/12/share/man/man9/Makefile == --- stable/12/share/man/man9/Makefile Fri Oct 30 14:38:17 2020 (r367169) +++ stable/12/share/man/man9/Makefile Fri Oct 30 14:40:48 2020 (r367170) @@ -1483,6 +1483,11 @@ MLINKS+=nv.9 libnv.9 \ nv.9 nvlist_add_stringf.9 \ nv.9 nvlist_add_stringv.9 \ nv.9 nvlist_add_string_array.9 \ + nv.9 nvlist_append_bool_array.9 \ + nv.9 nvlist_append_descriptor_array.9 \ + nv.9 nvlist_append_nvlist_array.9 \ + nv.9 nvlist_append_number_array.9 \ + nv.9 nvlist_append_string_array.9 \ nv.9 nvlist_clone.9 \ nv.9 nvlist_create.9 \ nv.9 nvlist_destroy.9 \ ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r367168 - stable/12/usr.sbin/rtsold
Author: markj Date: Fri Oct 30 14:37:51 2020 New Revision: 367168 URL: https://svnweb.freebsd.org/changeset/base/367168 Log: MFC r366972: rtsold: Remove an incorrect __unused annotation Modified: stable/12/usr.sbin/rtsold/cap_script.c Directory Properties: stable/12/ (props changed) Modified: stable/12/usr.sbin/rtsold/cap_script.c == --- stable/12/usr.sbin/rtsold/cap_script.c Fri Oct 30 14:34:51 2020 (r367167) +++ stable/12/usr.sbin/rtsold/cap_script.c Fri Oct 30 14:37:51 2020 (r367168) @@ -207,7 +207,7 @@ script_command(const char *cmd, const nvlist_t *limits } static int -script_limit(const nvlist_t *oldlimits, const nvlist_t *newlimits __unused) +script_limit(const nvlist_t *oldlimits, const nvlist_t *newlimits) { const char *name; void *cookie; ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r367169 - stable/12/sys/dev/ntb
Author: markj Date: Fri Oct 30 14:38:17 2020 New Revision: 367169 URL: https://svnweb.freebsd.org/changeset/base/367169 Log: MFC r366968: ntb: Fix an assertion to permit >= 32 doorbells Modified: stable/12/sys/dev/ntb/ntb_transport.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/ntb/ntb_transport.c == --- stable/12/sys/dev/ntb/ntb_transport.c Fri Oct 30 14:37:51 2020 (r367168) +++ stable/12/sys/dev/ntb/ntb_transport.c Fri Oct 30 14:38:17 2020 (r367169) @@ -355,7 +355,7 @@ ntb_transport_attach(device_t dev) spad_count = ntb_spad_count(dev); db_bitmap = ntb_db_valid_mask(dev); db_count = flsll(db_bitmap); - KASSERT(db_bitmap == (1 << db_count) - 1, + KASSERT(db_bitmap == ((uint64_t)1 << db_count) - 1, ("Doorbells are not sequential (%jx).\n", db_bitmap)); if (nt->mw_count == 0) { ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r367081 - head/sys/arm64/arm64
Author: markj Date: Tue Oct 27 13:27:47 2020 New Revision: 367081 URL: https://svnweb.freebsd.org/changeset/base/367081 Log: arm64: Remove a racy KASSERT from pmap_remove_pages() PCPU_GET(curpmap) expands to multiple instructions on arm64, and if the current thread is migrated in between execution of those instructions, a stale value may be used in the assertion condition. Diagnosed by: mmel Reported by: mmel, Bob Prohaska Submitted by: alc MFC after:1 week Modified: head/sys/arm64/arm64/pmap.c Modified: head/sys/arm64/arm64/pmap.c == --- head/sys/arm64/arm64/pmap.c Tue Oct 27 13:13:04 2020(r367080) +++ head/sys/arm64/arm64/pmap.c Tue Oct 27 13:27:47 2020(r367081) @@ -4838,8 +4838,6 @@ pmap_remove_pages(pmap_t pmap) int allfree, field, freed, idx, lvl; vm_paddr_t pa; - KASSERT(pmap == PCPU_GET(curpmap), ("non-current pmap %p", pmap)); - lock = NULL; SLIST_INIT(); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r366973 - head/sys/dev/ntb/ntb_hw
Author: markj Date: Fri Oct 23 15:12:06 2020 New Revision: 366973 URL: https://svnweb.freebsd.org/changeset/base/366973 Log: ntb: Fix the 32-bit build after r366969 Reported by: Jenkins MFC with: r366969 Modified: head/sys/dev/ntb/ntb_hw/ntb_hw_intel.c Modified: head/sys/dev/ntb/ntb_hw/ntb_hw_intel.c == --- head/sys/dev/ntb/ntb_hw/ntb_hw_intel.c Fri Oct 23 14:56:17 2020 (r366972) +++ head/sys/dev/ntb/ntb_hw/ntb_hw_intel.c Fri Oct 23 15:12:06 2020 (r366973) @@ -3353,7 +3353,8 @@ intel_ntb_peer_db_set(device_t dev, uint64_t bits) uint64_t db; if ((bits & ~ntb->db_valid_mask) != 0) { - device_printf(ntb->device, "Invalid doorbell bits %lx\n", bits); + device_printf(ntb->device, "Invalid doorbell bits %#jx\n", + (uintmax_t)bits); return; } ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r366972 - head/usr.sbin/rtsold
Author: markj Date: Fri Oct 23 14:56:17 2020 New Revision: 366972 URL: https://svnweb.freebsd.org/changeset/base/366972 Log: rtsold: Remove an incorrect __unused annotation MFC after:1 week Modified: head/usr.sbin/rtsold/cap_script.c Modified: head/usr.sbin/rtsold/cap_script.c == --- head/usr.sbin/rtsold/cap_script.c Fri Oct 23 14:47:32 2020 (r366971) +++ head/usr.sbin/rtsold/cap_script.c Fri Oct 23 14:56:17 2020 (r366972) @@ -207,7 +207,7 @@ script_command(const char *cmd, const nvlist_t *limits } static int -script_limit(const nvlist_t *oldlimits, const nvlist_t *newlimits __unused) +script_limit(const nvlist_t *oldlimits, const nvlist_t *newlimits) { const char *name; void *cookie; ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r366971 - stable/12/lib/libc/locale
Author: markj Date: Fri Oct 23 14:47:32 2020 New Revision: 366971 URL: https://svnweb.freebsd.org/changeset/base/366971 Log: MFC r366375: newlocale(3): Fix a memory leak. PR: 249416 Modified: stable/12/lib/libc/locale/newlocale.3 stable/12/lib/libc/locale/xlocale.c Directory Properties: stable/12/ (props changed) Modified: stable/12/lib/libc/locale/newlocale.3 == --- stable/12/lib/libc/locale/newlocale.3 Fri Oct 23 14:25:48 2020 (r366970) +++ stable/12/lib/libc/locale/newlocale.3 Fri Oct 23 14:47:32 2020 (r366971) @@ -26,7 +26,7 @@ .\" SUCH DAMAGE. .\" .\" $FreeBSD$ -.Dd September 17, 2011 +.Dd October 2, 2020 .Dt NEWLOCALE 3 .Os .Sh NAME @@ -46,7 +46,20 @@ defines the components that the new locale will have s name specified in the .Fa locale parameter. -Any other components will be inherited from +Any components not specified in +.Fa mask +will be inherited from the locale referenced by +.Fa base , +if +.Fa base +is not +.Dv NULL . +If the call is successful, the state of the locale referenced by +.Fa base +is unspecified, and it must not be accessed. +The special locale +.Dv LC_GLOBAL_LOCALE +may not be specified for .Fa base . The .Fa mask Modified: stable/12/lib/libc/locale/xlocale.c == --- stable/12/lib/libc/locale/xlocale.c Fri Oct 23 14:25:48 2020 (r366970) +++ stable/12/lib/libc/locale/xlocale.c Fri Oct 23 14:47:32 2020 (r366971) @@ -251,6 +251,7 @@ static int dupcomponent(int type, locale_t base, local locale_t newlocale(int mask, const char *locale, locale_t base) { + locale_t orig_base; int type; const char *realLocale = locale; int useenv = 0; @@ -263,6 +264,7 @@ locale_t newlocale(int mask, const char *locale, local return (NULL); } + orig_base = base; FIX_LOCALE(base); copyflags(new, base); @@ -297,6 +299,8 @@ locale_t newlocale(int mask, const char *locale, local if (0 == success) { xlocale_release(new); new = NULL; + } else if (base == orig_base) { + xlocale_release(base); } return (new); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r366970 - head/share/man/man9
Author: markj Date: Fri Oct 23 14:25:48 2020 New Revision: 366970 URL: https://svnweb.freebsd.org/changeset/base/366970 Log: Add some missing nv(9) MLINKS MFC after:1 week Modified: head/share/man/man9/Makefile Modified: head/share/man/man9/Makefile == --- head/share/man/man9/MakefileFri Oct 23 14:16:52 2020 (r366969) +++ head/share/man/man9/MakefileFri Oct 23 14:25:48 2020 (r366970) @@ -1563,6 +1563,11 @@ MLINKS+=nv.9 libnv.9 \ nv.9 nvlist_add_stringf.9 \ nv.9 nvlist_add_stringv.9 \ nv.9 nvlist_add_string_array.9 \ + nv.9 nvlist_append_bool_array.9 \ + nv.9 nvlist_append_descriptor_array.9 \ + nv.9 nvlist_append_nvlist_array.9 \ + nv.9 nvlist_append_number_array.9 \ + nv.9 nvlist_append_string_array.9 \ nv.9 nvlist_clone.9 \ nv.9 nvlist_create.9 \ nv.9 nvlist_destroy.9 \ ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r366969 - in head: share/man/man4 sys/dev/ntb/ntb_hw
Author: markj Date: Fri Oct 23 14:16:52 2020 New Revision: 366969 URL: https://svnweb.freebsd.org/changeset/base/366969 Log: ntb: Add Intel Xeon Gen3 support The NTB hardware starting with Skylake has some changes to the register map and the doorbell interface. Add a new NTB_XEON_GEN3 device type and use it to conditionalize driver logic that differs from the existing Xeon code. Reviewed by: vangyzen Discussed with: cem, Bret Ketchum MFC after:1 month Sponsored by: NetApp, Inc. Sponsored by: Klara, Inc. Differential Revision:https://reviews.freebsd.org/D26683 Modified: head/share/man/man4/ntb_hw_intel.4 head/sys/dev/ntb/ntb_hw/ntb_hw_intel.c head/sys/dev/ntb/ntb_hw/ntb_hw_intel.h Modified: head/share/man/man4/ntb_hw_intel.4 == --- head/share/man/man4/ntb_hw_intel.4 Fri Oct 23 14:15:58 2020 (r366968) +++ head/share/man/man4/ntb_hw_intel.4 Fri Oct 23 14:16:52 2020 (r366969) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd August 30, 2017 +.Dd October 11, 2020 .Dt NTB_HW_INTEL 4 .Os .Sh NAME @@ -50,16 +50,18 @@ The driver provides support for the Non-Transparent Bridge (NTB) hardware in Intel Xeon E3/E5 and S1200 processor families, which allow one of their PCIe ports to be switched from transparent to non-transparent bridge mode. -In this mode bridge looks not as a PCI bridge, but as PCI endpoint device. +In this mode the bridge looks not like a PCI bridge, but like a PCI endpoint +device. The driver hides hardware details, exposing memory windows, scratchpads -and doorbells of the other side via hardware independent KPI to +and doorbells of the other side via a hardware independent KPI to the .Xr ntb 4 subsystem. .Pp The hardware provides 2 or 3 memory windows to the other system's memory, -16 scratchpad registers and 14 or 34 doorbells to interrupt the other system. -On Xeon processors one of memory windows is typically consumed by the driver -itself to workaround multiple hardware erratas. +16 scratchpad registers and 14, 31 or 34 doorbells to interrupt the other +system, depending on the platform. +On Xeon processors one of the memory windows is typically consumed by the driver +itself to work around multiple hardware errata. .Sh CONFIGURATION The NTB configuration should be set by BIOS. It includes enabling NTB, choosing between NTB-to-NTB (back-to-back) or @@ -67,9 +69,10 @@ NTB-to-Root Port mode, enabling split BAR mode (one of two 64-bit BARs can be split into two 32-bit ones) and configuring BAR sizes in bits (from 12 to 29/39) for both NTB sides. .Pp -The recommended configuration is NTB-to-NTB mode, split bar is enabled and -all BAR sizes are set to 20 (1 MiB). +The recommended configuration is NTB-to-NTB mode, split bar enabled and +all BAR sizes set to 20 (1 MiB). This needs to be done on both systems. +Note, on Xeon SkyLake and newer platforms, split bar mode is not available. .Sh SEE ALSO .Xr if_ntb 4 , .Xr ntb_transport 4 , Modified: head/sys/dev/ntb/ntb_hw/ntb_hw_intel.c == --- head/sys/dev/ntb/ntb_hw/ntb_hw_intel.c Fri Oct 23 14:15:58 2020 (r366968) +++ head/sys/dev/ntb/ntb_hw/ntb_hw_intel.c Fri Oct 23 14:16:52 2020 (r366969) @@ -68,7 +68,8 @@ __FBSDID("$FreeBSD$"); #include "ntb_hw_intel.h" #include "../ntb.h" -#define MAX_MSIX_INTERRUPTS MAX(XEON_DB_COUNT, ATOM_DB_COUNT) +#define MAX_MSIX_INTERRUPTS\ + MAX(MAX(XEON_DB_COUNT, ATOM_DB_COUNT), XEON_GEN3_DB_COUNT) #define NTB_HB_TIMEOUT 1 /* second */ #define ATOM_LINK_RECOVERY_TIME500 /* ms */ @@ -87,7 +88,8 @@ __FBSDID("$FreeBSD$"); #definePCI_MSIX_ENTRY_DATA 8 enum ntb_device_type { - NTB_XEON, + NTB_XEON_GEN1, + NTB_XEON_GEN3, NTB_ATOM }; @@ -338,6 +340,7 @@ static int map_memory_window_bar(struct ntb_softc *ntb static void intel_ntb_unmap_pci_bar(struct ntb_softc *ntb); static int intel_ntb_remap_msix(device_t, uint32_t desired, uint32_t avail); static int intel_ntb_init_isr(struct ntb_softc *ntb); +static int intel_ntb_xeon_gen3_init_isr(struct ntb_softc *ntb); static int intel_ntb_setup_legacy_interrupt(struct ntb_softc *ntb); static int intel_ntb_setup_msix(struct ntb_softc *ntb, uint32_t num_vectors); static void intel_ntb_teardown_interrupts(struct ntb_softc *ntb); @@ -355,8 +358,10 @@ static void intel_ntb_exchange_msix(void *); static struct ntb_hw_info *intel_ntb_get_device_info(uint32_t device_id); static void intel_ntb_detect_max_mw(struct ntb_softc *ntb); static int intel_ntb_detect_xeon(struct ntb_softc *ntb); +static int intel_ntb_detect_xeon_gen3(struct ntb_softc *ntb); static int intel_ntb_detect_atom(struct ntb_softc *ntb); static int intel_ntb_xeon_init_dev(struct ntb_softc *ntb); +static int intel_ntb_xeon_gen3_init_dev(struct ntb_softc *ntb); static
svn commit: r366968 - head/sys/dev/ntb
Author: markj Date: Fri Oct 23 14:15:58 2020 New Revision: 366968 URL: https://svnweb.freebsd.org/changeset/base/366968 Log: ntb: Fix an assertion to permit >= 32 doorbells MFC after:1 week Sponsored by: NetApp, Inc. Sponsored by: Klara, Inc. Modified: head/sys/dev/ntb/ntb_transport.c Modified: head/sys/dev/ntb/ntb_transport.c == --- head/sys/dev/ntb/ntb_transport.cFri Oct 23 12:00:30 2020 (r366967) +++ head/sys/dev/ntb/ntb_transport.cFri Oct 23 14:15:58 2020 (r366968) @@ -357,7 +357,7 @@ ntb_transport_attach(device_t dev) spad_count = ntb_spad_count(dev); db_bitmap = ntb_db_valid_mask(dev); db_count = flsll(db_bitmap); - KASSERT(db_bitmap == (1 << db_count) - 1, + KASSERT(db_bitmap == ((uint64_t)1 << db_count) - 1, ("Doorbells are not sequential (%jx).\n", db_bitmap)); if (nt->mw_count == 0) { ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r366842 - in head: sys/netinet sys/netinet6 usr.bin/netstat
Author: markj Date: Mon Oct 19 17:07:19 2020 New Revision: 366842 URL: https://svnweb.freebsd.org/changeset/base/366842 Log: icmp6: Count packets dropped due to an invalid hop limit Pad the icmp6stat structure so that we can add more counters in the future without breaking compatibility again, last done in r358620. Annotate the rarely executed error paths with __predict_false while here. Reviewed by: bz, melifaro Sponsored by: NetApp, Inc. Sponsored by: Klara, Inc. Differential Revision:https://reviews.freebsd.org/D26578 Modified: head/sys/netinet/icmp6.h head/sys/netinet6/icmp6.c head/sys/netinet6/nd6_nbr.c head/sys/netinet6/nd6_rtr.c head/usr.bin/netstat/inet6.c Modified: head/sys/netinet/icmp6.h == --- head/sys/netinet/icmp6.hMon Oct 19 16:57:59 2020(r366841) +++ head/sys/netinet/icmp6.hMon Oct 19 17:07:19 2020(r366842) @@ -639,6 +639,8 @@ struct icmp6stat { uint64_t icp6s_overflowprfx;/* Too many prefixes. */ uint64_t icp6s_overflownndp;/* Too many neighbour entries. */ uint64_t icp6s_overflowredirect;/* Too many redirects. */ + uint64_t icp6s_invlhlim;/* Invalid hop limit. */ + uint64_t icp6s_spare[32]; }; #ifdef _KERNEL Modified: head/sys/netinet6/icmp6.c == --- head/sys/netinet6/icmp6.c Mon Oct 19 16:57:59 2020(r366841) +++ head/sys/netinet6/icmp6.c Mon Oct 19 17:07:19 2020(r366842) @@ -2261,7 +2261,8 @@ icmp6_redirect_input(struct mbuf *m, int off) ip6_sprintf(ip6buf, ))); goto bad; } - if (ip6->ip6_hlim != 255) { + if (__predict_false(ip6->ip6_hlim != 255)) { + ICMP6STAT_INC(icp6s_invlhlim); nd6log((LOG_ERR, "ICMP6 redirect sent from %s rejected; " "hlim=%d (must be 255)\n", Modified: head/sys/netinet6/nd6_nbr.c == --- head/sys/netinet6/nd6_nbr.c Mon Oct 19 16:57:59 2020(r366841) +++ head/sys/netinet6/nd6_nbr.c Mon Oct 19 17:07:19 2020(r366842) @@ -136,7 +136,8 @@ nd6_ns_input(struct mbuf *m, int off, int icmp6len) ifp = m->m_pkthdr.rcvif; ip6 = mtod(m, struct ip6_hdr *); - if (ip6->ip6_hlim != 255) { + if (__predict_false(ip6->ip6_hlim != 255)) { + ICMP6STAT_INC(icp6s_invlhlim); nd6log((LOG_ERR, "nd6_ns_input: invalid hlim (%d) from %s to %s on %s\n", ip6->ip6_hlim, ip6_sprintf(ip6bufs, >ip6_src), @@ -641,7 +642,8 @@ nd6_na_input(struct mbuf *m, int off, int icmp6len) ifp = m->m_pkthdr.rcvif; ip6 = mtod(m, struct ip6_hdr *); - if (ip6->ip6_hlim != 255) { + if (__predict_false(ip6->ip6_hlim != 255)) { + ICMP6STAT_INC(icp6s_invlhlim); nd6log((LOG_ERR, "nd6_na_input: invalid hlim (%d) from %s to %s on %s\n", ip6->ip6_hlim, ip6_sprintf(ip6bufs, >ip6_src), Modified: head/sys/netinet6/nd6_rtr.c == --- head/sys/netinet6/nd6_rtr.c Mon Oct 19 16:57:59 2020(r366841) +++ head/sys/netinet6/nd6_rtr.c Mon Oct 19 17:07:19 2020(r366842) @@ -177,7 +177,8 @@ nd6_rs_input(struct mbuf *m, int off, int icmp6len) /* Sanity checks */ ip6 = mtod(m, struct ip6_hdr *); - if (ip6->ip6_hlim != 255) { + if (__predict_false(ip6->ip6_hlim != 255)) { + ICMP6STAT_INC(icp6s_invlhlim); nd6log((LOG_ERR, "%s: invalid hlim (%d) from %s to %s on %s\n", __func__, ip6->ip6_hlim, ip6_sprintf(ip6bufs, >ip6_src), @@ -376,7 +377,8 @@ nd6_ra_input(struct mbuf *m, int off, int icmp6len) goto freeit; ip6 = mtod(m, struct ip6_hdr *); - if (ip6->ip6_hlim != 255) { + if (__predict_false(ip6->ip6_hlim != 255)) { + ICMP6STAT_INC(icp6s_invlhlim); nd6log((LOG_ERR, "%s: invalid hlim (%d) from %s to %s on %s\n", __func__, ip6->ip6_hlim, ip6_sprintf(ip6bufs, >ip6_src), Modified: head/usr.bin/netstat/inet6.c == --- head/usr.bin/netstat/inet6.cMon Oct 19 16:57:59 2020 (r366841) +++ head/usr.bin/netstat/inet6.cMon Oct 19 17:07:19 2020 (r366842) @@ -1063,6 +1063,8 @@ icmp6_stats(u_long off, const char *name, int af1 __un "{N:/neighbour entries overflow%s}\n"); p(icp6s_overflowredirect, "\t{:redirect-overflows/%ju} " "{N:/redirect overflow%s}\n"); + p(icp6s_invlhlim, "\t{:dropped-invalid-hop-limit/%ju} " +
svn commit: r366841 - head/sys/kern
Author: markj Date: Mon Oct 19 16:57:59 2020 New Revision: 366841 URL: https://svnweb.freebsd.org/changeset/base/366841 Log: link_elf_obj: Colour VM objects This will cause the VM to back sufficiently large .text sections, such as those in zfs.ko or amdgpu.ko on amd64, with superpage mappings when possible. Reviewed by: alc, kib MFC after:1 week Sponsored by: The FreeBSD Foundation Differential Revision:https://reviews.freebsd.org/D26802 Modified: head/sys/kern/link_elf_obj.c Modified: head/sys/kern/link_elf_obj.c == --- head/sys/kern/link_elf_obj.cMon Oct 19 16:57:40 2020 (r366840) +++ head/sys/kern/link_elf_obj.cMon Oct 19 16:57:59 2020 (r366841) @@ -914,6 +914,9 @@ link_elf_load_file(linker_class_t cls, const char *fil error = ENOMEM; goto out; } +#if VM_NRESERVLEVEL > 0 + vm_object_color(ef->object, 0); +#endif /* * In order to satisfy amd64's architectural requirements on the ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r366840 - head/sys/vm
Author: markj Date: Mon Oct 19 16:57:40 2020 New Revision: 366840 URL: https://svnweb.freebsd.org/changeset/base/366840 Log: uma: Respect uk_reserve in keg_drain() When a reserve of free items is configured for a zone, the reserve must not be reclaimed under memory pressure. Modify keg_drain() to simply respect the reserved pool. While here remove an always-false uk_freef == NULL check (kegs that shouldn't be drained should set _NOFREE instead), and make sure that the keg_drain() KTR statement does not reference an uninitialized variable. Reviewed by: alc, rlibby Sponsored by: The FreeBSD Foundation Differential Revision:https://reviews.freebsd.org/D26772 Modified: head/sys/vm/uma_core.c Modified: head/sys/vm/uma_core.c == --- head/sys/vm/uma_core.c Mon Oct 19 16:55:03 2020(r366839) +++ head/sys/vm/uma_core.c Mon Oct 19 16:57:40 2020(r366840) @@ -1415,47 +1415,81 @@ keg_free_slab(uma_keg_t keg, uma_slab_t slab, int star uma_total_dec(PAGE_SIZE * keg->uk_ppera); } -/* - * Frees pages from a keg back to the system. This is done on demand from - * the pageout daemon. - * - * Returns nothing. - */ static void -keg_drain(uma_keg_t keg) +keg_drain_domain(uma_keg_t keg, int domain) { struct slabhead freeslabs; uma_domain_t dom; uma_slab_t slab, tmp; - int i, n; + uint32_t i, stofree, stokeep, partial; - if (keg->uk_flags & UMA_ZONE_NOFREE || keg->uk_freef == NULL) - return; + dom = >uk_domain[domain]; + LIST_INIT(); - for (i = 0; i < vm_ndomains; i++) { - CTR4(KTR_UMA, "keg_drain %s(%p) domain %d free items: %u", - keg->uk_name, keg, i, dom->ud_free_items); - dom = >uk_domain[i]; - LIST_INIT(); + CTR4(KTR_UMA, "keg_drain %s(%p) domain %d free items: %u", + keg->uk_name, keg, i, dom->ud_free_items); - KEG_LOCK(keg, i); - if ((keg->uk_flags & UMA_ZFLAG_HASH) != 0) { - LIST_FOREACH(slab, >ud_free_slab, us_link) - UMA_HASH_REMOVE(>uk_hash, slab); - } - n = dom->ud_free_slabs; + KEG_LOCK(keg, domain); + + /* +* Are the free items in partially allocated slabs sufficient to meet +* the reserve? If not, compute the number of fully free slabs that must +* be kept. +*/ + partial = dom->ud_free_items - dom->ud_free_slabs * keg->uk_ipers; + if (partial < keg->uk_reserve) { + stokeep = min(dom->ud_free_slabs, + howmany(keg->uk_reserve - partial, keg->uk_ipers)); + } else { + stokeep = 0; + } + stofree = dom->ud_free_slabs - stokeep; + + /* +* Partition the free slabs into two sets: those that must be kept in +* order to maintain the reserve, and those that may be released back to +* the system. Since one set may be much larger than the other, +* populate the smaller of the two sets and swap them if necessary. +*/ + for (i = min(stofree, stokeep); i > 0; i--) { + slab = LIST_FIRST(>ud_free_slab); + LIST_REMOVE(slab, us_link); + LIST_INSERT_HEAD(, slab, us_link); + } + if (stofree > stokeep) LIST_SWAP(, >ud_free_slab, uma_slab, us_link); - dom->ud_free_slabs = 0; - dom->ud_free_items -= n * keg->uk_ipers; - dom->ud_pages -= n * keg->uk_ppera; - KEG_UNLOCK(keg, i); - LIST_FOREACH_SAFE(slab, , us_link, tmp) - keg_free_slab(keg, slab, keg->uk_ipers); + if ((keg->uk_flags & UMA_ZFLAG_HASH) != 0) { + LIST_FOREACH(slab, , us_link) + UMA_HASH_REMOVE(>uk_hash, slab); } + dom->ud_free_items -= stofree * keg->uk_ipers; + dom->ud_free_slabs -= stofree; + dom->ud_pages -= stofree * keg->uk_ppera; + KEG_UNLOCK(keg, domain); + + LIST_FOREACH_SAFE(slab, , us_link, tmp) + keg_free_slab(keg, slab, keg->uk_ipers); } +/* + * Frees pages from a keg back to the system. This is done on demand from + * the pageout daemon. + * + * Returns nothing. + */ static void +keg_drain(uma_keg_t keg) +{ + int i; + + if ((keg->uk_flags & UMA_ZONE_NOFREE) != 0) + return; + for (i = 0; i < vm_ndomains; i++) + keg_drain_domain(keg, i); +} + +static void zone_reclaim(uma_zone_t zone, int waitok, bool drain) { @@ -2411,6 +2445,9 @@ zone_alloc_sysctl(uma_zone_t zone, void *unused) SYSCTL_ADD_U32(NULL, SYSCTL_CHILDREN(oid), OID_AUTO, "align", CTLFLAG_RD, >uk_align, 0, "item alignment mask"); +
svn commit: r366839 - head/sys/vm
Author: markj Date: Mon Oct 19 16:55:03 2020 New Revision: 366839 URL: https://svnweb.freebsd.org/changeset/base/366839 Log: uma: Avoid depleting keg reserves when filling a bucket zone_import() fetches a free or partially free slab from the keg and then uses its items to populate an array, typically filling a bucket. If a single allocation causes the keg to drop below its minimum reserve, the inner loop ends. However, if the bucket is still not full and M_USE_RESERVE is specified, the outer loop will continue to fetch items from the keg. If M_USE_RESERVE is specified and the number of free items is below the reserved limit, we should return only a single item. Otherwise, if the bucket size is larger than the reserve, all of the reserved items may end up in a single per-CPU bucket, invisible to other CPUs. Reviewed by: rlibby MFC after:2 weeks Sponsored by: The FreeBSD Foundation Differential Revision:https://reviews.freebsd.org/D26771 Modified: head/sys/vm/uma_core.c Modified: head/sys/vm/uma_core.c == --- head/sys/vm/uma_core.c Mon Oct 19 16:54:06 2020(r366838) +++ head/sys/vm/uma_core.c Mon Oct 19 16:55:03 2020(r366839) @@ -3734,10 +3734,17 @@ zone_import(void *arg, void **bucket, int max, int dom stripe = howmany(max, vm_ndomains); #endif dom = >uk_domain[slab->us_domain]; - while (slab->us_freecount && i < max) { + do { bucket[i++] = slab_alloc_item(keg, slab); - if (dom->ud_free_items <= keg->uk_reserve) - break; + if (dom->ud_free_items <= keg->uk_reserve) { + /* +* Avoid depleting the reserve after a +* successful item allocation, even if +* M_USE_RESERVE is specified. +*/ + KEG_UNLOCK(keg, slab->us_domain); + goto out; + } #ifdef NUMA /* * If the zone is striped we pick a new slab for every @@ -3751,13 +3758,14 @@ zone_import(void *arg, void **bucket, int max, int dom vm_ndomains > 1 && --stripe == 0) break; #endif - } + } while (slab->us_freecount != 0 && i < max); KEG_UNLOCK(keg, slab->us_domain); + /* Don't block if we allocated any successfully. */ flags &= ~M_WAITOK; flags |= M_NOWAIT; } - +out: return i; } ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r366838 - head/sys/kern
Author: markj Date: Mon Oct 19 16:54:06 2020 New Revision: 366838 URL: https://svnweb.freebsd.org/changeset/base/366838 Log: vmem: Allocate btags before looping in vmem_xalloc() BT_MAXALLOC (4) is the number of boundary tags required to complete an allocation in the worst case: two to clip a free segment, and two to import from a parent arena. vmem_xalloc() preallocates four boundary tags before attempting a search to simplify the segment allocation code. It implements a loop that: 1) ensures that BT_MAXALLOC boundary tags are available, 2) attempts to find and clip a free segment satisfying the allocation constraints, and failing that, 3) attempts to import a segment. On !UMA_MD_SMALL_ALLOC platforms the btag zone has to handle recusion: it needs boundary tags to allocate boundary tags. Thus we reserve 2 * BT_MAXALLOC * mp_ncpus tags for use when recursing: the factor of 2 is because there are two layers of vmem arenas, the per-domain arena and global arena. For a single thread, 2 * BT_MAXALLOC tags should be sufficient. Because of the way the loop is structured, BT_MAXALLOC tags are not sufficient. The first bt_fill() call may allocate BT_MAXALLOC tags, then import a segment (consuming two tags), then attempt to top up the preallocation before carving into the imported free segment, thus requiring up to six tags in the worst case. Because we don't preallocate that many, this bug can cause deadlocks in rare scenarios. Fix the problem by moving the preallocation out the loop. This assumes that only a single import is ever required to satisfy an allocation request. Thanks to manu, emaste and lwhsu for helping test debug patches. Reported by: Jenkins (hardware CI lab) Reviewed by: alc, kib, rlibby MFC after:2 weeks Sponsored by: The FreeBSD Foundation Differential Revision:https://reviews.freebsd.org/D26770 Modified: head/sys/kern/subr_vmem.c Modified: head/sys/kern/subr_vmem.c == --- head/sys/kern/subr_vmem.c Mon Oct 19 16:52:27 2020(r366837) +++ head/sys/kern/subr_vmem.c Mon Oct 19 16:54:06 2020(r366838) @@ -368,6 +368,24 @@ bt_free(vmem_t *vm, bt_t *bt) } /* + * Hide MAXALLOC tags before dropping the arena lock to ensure that a + * concurrent allocation attempt does not grab them. + */ +static void +bt_save(vmem_t *vm) +{ + KASSERT(vm->vm_nfreetags >= BT_MAXALLOC, + ("%s: insufficient free tags %d", __func__, vm->vm_nfreetags)); + vm->vm_nfreetags -= BT_MAXALLOC; +} + +static void +bt_restore(vmem_t *vm) +{ + vm->vm_nfreetags += BT_MAXALLOC; +} + +/* * freelist[0] ... [1, 1] * freelist[1] ... [2, 2] * : @@ -911,16 +929,11 @@ vmem_import(vmem_t *vm, vmem_size_t size, vmem_size_t if (vm->vm_limit != 0 && vm->vm_limit < vm->vm_size + size) return (ENOMEM); - /* -* Hide MAXALLOC tags so we're guaranteed to be able to add this -* span and the tag we want to allocate from it. -*/ - MPASS(vm->vm_nfreetags >= BT_MAXALLOC); - vm->vm_nfreetags -= BT_MAXALLOC; + bt_save(vm); VMEM_UNLOCK(vm); error = (vm->vm_importfn)(vm->vm_arg, size, flags, ); VMEM_LOCK(vm); - vm->vm_nfreetags += BT_MAXALLOC; + bt_restore(vm); if (error) return (ENOMEM); @@ -1048,19 +1061,23 @@ vmem_try_fetch(vmem_t *vm, const vmem_size_t size, vme */ if (vm->vm_qcache_max != 0 || vm->vm_reclaimfn != NULL) { avail = vm->vm_size - vm->vm_inuse; + bt_save(vm); VMEM_UNLOCK(vm); if (vm->vm_qcache_max != 0) qc_drain(vm); if (vm->vm_reclaimfn != NULL) vm->vm_reclaimfn(vm, flags); VMEM_LOCK(vm); + bt_restore(vm); /* If we were successful retry even NOWAIT. */ if (vm->vm_size - vm->vm_inuse > avail) return (1); } if ((flags & M_NOWAIT) != 0) return (0); + bt_save(vm); VMEM_CONDVAR_WAIT(vm); + bt_restore(vm); return (1); } @@ -1108,13 +1125,14 @@ vmem_xalloc_nextfit(vmem_t *vm, const vmem_size_t size error = ENOMEM; VMEM_LOCK(vm); -retry: + /* * Make sure we have enough tags to complete the operation. */ if (bt_fill(vm, flags) != 0) goto out; +retry: /* * Find the next free tag meeting our constraints. If one is found, * perform the allocation. @@ -1390,15 +1408,14 @@ vmem_xalloc(vmem_t *vm, const vmem_size_t size0, vmem_ */ first = bt_freehead_toalloc(vm, size, strat); VMEM_LOCK(vm); - for (;;) { - /* -* Make sure we have enough tags to