svn commit: r349638 - head/sys/arm64/rockchip
Author: ganbold Date: Wed Jul 3 03:42:51 2019 New Revision: 349638 URL: https://svnweb.freebsd.org/changeset/base/349638 Log: Subclass Rockchip's General Register Files driver from Simple MFD driver. Modified: head/sys/arm64/rockchip/rk_grf.c Modified: head/sys/arm64/rockchip/rk_grf.c == --- head/sys/arm64/rockchip/rk_grf.cWed Jul 3 01:40:29 2019 (r349637) +++ head/sys/arm64/rockchip/rk_grf.cWed Jul 3 03:42:51 2019 (r349638) @@ -42,7 +42,7 @@ __FBSDID("$FreeBSD$"); #include #include -#include +#include #include "opt_soc.h" @@ -77,7 +77,7 @@ static device_method_t rk_grf_methods[] = { }; DEFINE_CLASS_1(rk_grf, rk_grf_driver, rk_grf_methods, -sizeof(struct syscon_generic_softc), syscon_generic_driver); +sizeof(struct simple_mfd_softc), simple_mfd_driver); static devclass_t rk_grf_devclass; EARLY_DRIVER_MODULE(rk_grf, simplebus, rk_grf_driver, rk_grf_devclass, ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r349637 - head/sys/conf
Author: ganbold Date: Wed Jul 3 01:40:29 2019 New Revision: 349637 URL: https://svnweb.freebsd.org/changeset/base/349637 Log: Fix build error introduced by r349596. Modified: head/sys/conf/files Modified: head/sys/conf/files == --- head/sys/conf/files Wed Jul 3 01:04:11 2019(r349636) +++ head/sys/conf/files Wed Jul 3 01:40:29 2019(r349637) @@ -1712,7 +1712,7 @@ dev/fdt/fdt_slicer.c optional fdt cfi | fdt mx25l | f dev/fdt/fdt_static_dtb.S optional fdt fdt_dtb_static \ dependency "${FDT_DTS_FILE:T:R}.dtb" dev/fdt/simplebus.coptional fdt -dev/fdt/simple_mfd.c optional fdt +dev/fdt/simple_mfd.c optional syscon fdt dev/filemon/filemon.c optional filemon dev/firewire/firewire.coptional firewire dev/firewire/fwcrom.c optional firewire ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r349627 - in head/sys: cam/scsi compat/linux sys
Author: markj Date: Wed Jul 3 00:10:01 2019 New Revision: 349627 URL: https://svnweb.freebsd.org/changeset/base/349627 Log: Remove the CDIOCREADSUBCHANNEL_SYSSPACE ioctl. This was added for emulation of Linux's CDROMSUBCHNL, but allows users with read access to a cd(4) device to overwrite kernel memory provided that the driver detects some media present. Reimplement CDROMSUBCHNL by bouncing the data from CDIOCREADSUBCHANNEL through the linux_cdrom_subchnl structure passed from userspace. admbugs: 768 Reported by: Alex Fortune Security: CVE-2019-5602 Security: FreeBSD-SA-19:11.cd_ioctl Modified: head/sys/cam/scsi/scsi_cd.c head/sys/compat/linux/linux_ioctl.c head/sys/sys/cdio.h Modified: head/sys/cam/scsi/scsi_cd.c == --- head/sys/cam/scsi/scsi_cd.c Wed Jul 3 00:04:50 2019(r349626) +++ head/sys/cam/scsi/scsi_cd.c Wed Jul 3 00:10:01 2019(r349627) @@ -1314,7 +1314,7 @@ cdioctl(struct disk *dp, u_long cmd, void *addr, int f struct cam_periph *periph; struct cd_softc *softc; - int nocopyout, error = 0; + int error = 0; periph = (struct cam_periph *)dp->d_drv1; cam_periph_lock(periph); @@ -1356,7 +1356,6 @@ cdioctl(struct disk *dp, u_long cmd, void *addr, int f */ cam_periph_unlock(periph); - nocopyout = 0; switch (cmd) { case CDIOCPLAYTRACKS: @@ -1532,9 +1531,6 @@ cdioctl(struct disk *dp, u_long cmd, void *addr, int f cam_periph_unlock(periph); } break; - case CDIOCREADSUBCHANNEL_SYSSPACE: - nocopyout = 1; - /* Fallthrough */ case CDIOCREADSUBCHANNEL: { struct ioc_read_subchannel *args @@ -1579,13 +1575,7 @@ cdioctl(struct disk *dp, u_long cmd, void *addr, int f data->header.data_len[1] + sizeof(struct cd_sub_channel_header))); cam_periph_unlock(periph); - if (nocopyout == 0) { - if (copyout(data, args->data, len) != 0) { - error = EFAULT; - } - } else { - bcopy(data, args->data, len); - } + error = copyout(data, args->data, len); free(data, M_SCSICD); } break; Modified: head/sys/compat/linux/linux_ioctl.c == --- head/sys/compat/linux/linux_ioctl.c Wed Jul 3 00:04:50 2019 (r349626) +++ head/sys/compat/linux/linux_ioctl.c Wed Jul 3 00:10:01 2019 (r349627) @@ -1489,16 +1489,26 @@ linux_ioctl_cdrom(struct thread *td, struct linux_ioct struct ioc_read_subchannel bsdsc; struct cd_sub_channel_info bsdinfo; + error = copyin((void *)args->arg, &sc, sizeof(sc)); + if (error) + break; + + /* +* Invoke the native ioctl and bounce the returned data through +* the userspace buffer. This works because the Linux structure +* is the same size as our structures for the subchannel header +* and position data. +*/ bsdsc.address_format = CD_LBA_FORMAT; bsdsc.data_format = CD_CURRENT_POSITION; bsdsc.track = 0; - bsdsc.data_len = sizeof(bsdinfo); - bsdsc.data = &bsdinfo; - error = fo_ioctl(fp, CDIOCREADSUBCHANNEL_SYSSPACE, - (caddr_t)&bsdsc, td->td_ucred, td); + bsdsc.data_len = sizeof(sc); + bsdsc.data = (void *)args->arg; + error = fo_ioctl(fp, CDIOCREADSUBCHANNEL, (caddr_t)&bsdsc, + td->td_ucred, td); if (error) break; - error = copyin((void *)args->arg, &sc, sizeof(sc)); + error = copyin((void *)args->arg, &bsdinfo, sizeof(bsdinfo)); if (error) break; sc.cdsc_audiostatus = bsdinfo.header.audio_status; Modified: head/sys/sys/cdio.h == --- head/sys/sys/cdio.h Wed Jul 3 00:04:50 2019(r349626) +++ head/sys/sys/cdio.h Wed Jul 3 00:10:01 2019(r349627) @@ -274,11 +274,4 @@ struct ioc_capability {/*<2>*/ #defineCDIOCCAPABILITY _IOR('c',30,struct ioc_capability) /*<2>*/ -/* - * Special version of CDIOCREADSUBCHANNEL which assumes that - * ioc_read_subchannel->data points to the kernel memory. For - * use in compatibility
svn commit: r349619 - head/lib/libc/iconv
Author: emaste Date: Tue Jul 2 23:56:37 2019 New Revision: 349619 URL: https://svnweb.freebsd.org/changeset/base/349619 Log: libc: correct iconv buffer overflow admbugs: 920 Submitted by: Andrea Venturoli, gabor Reported by: Andrea Venturoli , NetFence Security: CVE-2019-5600 Security: FreeBSD-SA-19:09.iconv Modified: head/lib/libc/iconv/citrus_none.c Modified: head/lib/libc/iconv/citrus_none.c == --- head/lib/libc/iconv/citrus_none.c Tue Jul 2 23:02:52 2019 (r349618) +++ head/lib/libc/iconv/citrus_none.c Tue Jul 2 23:56:37 2019 (r349619) @@ -144,7 +144,7 @@ _citrus_NONE_stdenc_cstomb(struct _citrus_stdenc * __r s[2] = (char)(idx >> 16); *nresult = 3; } else { - if (n < 3) { + if (n < 4) { *nresult = (size_t)-1; return (E2BIG); } ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r349618 - head/sys/arm64/arm64
Author: alc Date: Tue Jul 2 23:02:52 2019 New Revision: 349618 URL: https://svnweb.freebsd.org/changeset/base/349618 Log: Implement pmap_copy(). (This includes the changes applied to the amd64 pmap_copy() in r349585.) Reviewed by: kib, markj Differential Revision:https://reviews.freebsd.org/D20790 Modified: head/sys/arm64/arm64/pmap.c Modified: head/sys/arm64/arm64/pmap.c == --- head/sys/arm64/arm64/pmap.c Tue Jul 2 22:58:21 2019(r349617) +++ head/sys/arm64/arm64/pmap.c Tue Jul 2 23:02:52 2019(r349618) @@ -3875,12 +3875,153 @@ pmap_unwire(pmap_t pmap, vm_offset_t sva, vm_offset_t * in the destination map. * * This routine is only advisory and need not do anything. + * + * Because the executable mappings created by this routine are copied, + * it should not have to flush the instruction cache. */ - void pmap_copy(pmap_t dst_pmap, pmap_t src_pmap, vm_offset_t dst_addr, vm_size_t len, vm_offset_t src_addr) { + struct rwlock *lock; + struct spglist free; + pd_entry_t *l0, *l1, *l2, srcptepaddr; + pt_entry_t *dst_pte, ptetemp, *src_pte; + vm_offset_t addr, end_addr, va_next; + vm_page_t dst_l2pg, dstmpte, srcmpte; + + if (dst_addr != src_addr) + return; + end_addr = src_addr + len; + lock = NULL; + if (dst_pmap < src_pmap) { + PMAP_LOCK(dst_pmap); + PMAP_LOCK(src_pmap); + } else { + PMAP_LOCK(src_pmap); + PMAP_LOCK(dst_pmap); + } + for (addr = src_addr; addr < end_addr; addr = va_next) { + l0 = pmap_l0(src_pmap, addr); + if (pmap_load(l0) == 0) { + va_next = (addr + L0_SIZE) & ~L0_OFFSET; + if (va_next < addr) + va_next = end_addr; + continue; + } + l1 = pmap_l0_to_l1(l0, addr); + if (pmap_load(l1) == 0) { + va_next = (addr + L1_SIZE) & ~L1_OFFSET; + if (va_next < addr) + va_next = end_addr; + continue; + } + va_next = (addr + L2_SIZE) & ~L2_OFFSET; + if (va_next < addr) + va_next = end_addr; + l2 = pmap_l1_to_l2(l1, addr); + srcptepaddr = pmap_load(l2); + if (srcptepaddr == 0) + continue; + if ((srcptepaddr & ATTR_DESCR_MASK) == L2_BLOCK) { + if ((addr & L2_OFFSET) != 0 || + addr + L2_SIZE > end_addr) + continue; + dst_l2pg = pmap_alloc_l2(dst_pmap, addr, NULL); + if (dst_l2pg == NULL) + break; + l2 = (pd_entry_t *) + PHYS_TO_DMAP(VM_PAGE_TO_PHYS(dst_l2pg)); + l2 = &l2[pmap_l2_index(addr)]; + if (pmap_load(l2) == 0 && + ((srcptepaddr & ATTR_SW_MANAGED) == 0 || + pmap_pv_insert_l2(dst_pmap, addr, srcptepaddr, + PMAP_ENTER_NORECLAIM, &lock))) { + (void)pmap_load_store(l2, srcptepaddr & + ~ATTR_SW_WIRED); + pmap_resident_count_inc(dst_pmap, L2_SIZE / + PAGE_SIZE); + atomic_add_long(&pmap_l2_mappings, 1); + } else + dst_l2pg->wire_count--; + continue; + } + KASSERT((srcptepaddr & ATTR_DESCR_MASK) == L2_TABLE, + ("pmap_copy: invalid L2 entry")); + srcptepaddr &= ~ATTR_MASK; + srcmpte = PHYS_TO_VM_PAGE(srcptepaddr); + KASSERT(srcmpte->wire_count > 0, + ("pmap_copy: source page table page is unused")); + if (va_next > end_addr) + va_next = end_addr; + src_pte = (pt_entry_t *)PHYS_TO_DMAP(srcptepaddr); + src_pte = &src_pte[pmap_l3_index(addr)]; + dstmpte = NULL; + for (; addr < va_next; addr += PAGE_SIZE, src_pte++) { + ptetemp = pmap_load(src_pte); + + /* +* We only virtual copy managed pages. +*/ + if ((ptetemp & ATTR_SW_MANAGED) == 0) + continue; + + if (dstmpte != NULL) { + KASSERT(dstmpte->pindex == pmap_l2_pindex(addr), + ("dstmpte pindex/addr mismatch"));
svn commit: r349617 - head/sys/kern
Author: jhb Date: Tue Jul 2 22:58:21 2019 New Revision: 349617 URL: https://svnweb.freebsd.org/changeset/base/349617 Log: Invoke ext_free function when freeing an unmapped mbuf. Fix a mis-merge when extracting the unmapped mbuf changes from Netflix's in-kernel TLS changes where the call to the function that freed the backing pages from an unmapped mbuf was missed. Sponsored by: Chelsio Communications Modified: head/sys/kern/kern_mbuf.c Modified: head/sys/kern/kern_mbuf.c == --- head/sys/kern/kern_mbuf.c Tue Jul 2 22:57:24 2019(r349616) +++ head/sys/kern/kern_mbuf.c Tue Jul 2 22:58:21 2019(r349617) @@ -1282,6 +1282,9 @@ mb_free_ext(struct mbuf *m) uma_zfree(zone_mbuf, mref); break; case EXT_PGS: + KASSERT(mref->m_ext.ext_free != NULL, + ("%s: ext_free not set", __func__)); + mref->m_ext.ext_free(mref); uma_zfree(zone_extpgs, mref->m_ext.ext_pgs); uma_zfree(zone_mbuf, mref); break; ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r349616 - head/sys/kern
Author: jhb Date: Tue Jul 2 22:57:24 2019 New Revision: 349616 URL: https://svnweb.freebsd.org/changeset/base/349616 Log: Fix description of debug.obsolete_panic. MFC after:1 week Modified: head/sys/kern/subr_bus.c Modified: head/sys/kern/subr_bus.c == --- head/sys/kern/subr_bus.cTue Jul 2 22:11:07 2019(r349615) +++ head/sys/kern/subr_bus.cTue Jul 2 22:57:24 2019(r349616) @@ -5922,8 +5922,9 @@ devctl2_init(void) */ static int obsolete_panic = 0; SYSCTL_INT(_debug, OID_AUTO, obsolete_panic, CTLFLAG_RWTUN, &obsolete_panic, 0, -"Bus debug level"); -/* 0 - don't panic, 1 - panic if already obsolete, 2 - panic if deprecated */ +"Panic when obsolete features are used (0 = never, 1 = if osbolete, " +"2 = if deprecated)"); + static void gone_panic(int major, int running, const char *msg) { ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r349615 - head/libexec/rtld-elf/rtld-libc
Author: arichardson Date: Tue Jul 2 22:11:07 2019 New Revision: 349615 URL: https://svnweb.freebsd.org/changeset/base/349615 Log: Fix build race when building rtld I found this on one of the CheriBSD Jenkins builders. Using beforelinking instead of ${PROG} should fix the dependency for the DEBUG_FILES case. Reviewed by: brooks Modified: head/libexec/rtld-elf/rtld-libc/Makefile.inc Modified: head/libexec/rtld-elf/rtld-libc/Makefile.inc == --- head/libexec/rtld-elf/rtld-libc/Makefile.incTue Jul 2 21:03:06 2019(r349614) +++ head/libexec/rtld-elf/rtld-libc/Makefile.incTue Jul 2 22:11:07 2019(r349615) @@ -98,4 +98,4 @@ rtld_libc.a: ${LIBC_NOSSP_PIC} ${SRCTOP}/libexec/rtld- ${AR} cr ${.OBJDIR}/${.TARGET} ${_rtld_libc_objs} CLEANFILES+=rtld_libc.a LDADD+=${.OBJDIR}/rtld_libc.a -${PROG}: rtld_libc.a +beforelinking: rtld_libc.a ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r349614 - head/sys/kern
Author: kib Date: Tue Jul 2 21:03:06 2019 New Revision: 349614 URL: https://svnweb.freebsd.org/changeset/base/349614 Log: More style. Re-wrap long lines, reformat comments, remove excessive blank line. Sponsored by: The FreeBSD Foundation MFC after:3 days Modified: head/sys/kern/kern_umtx.c Modified: head/sys/kern/kern_umtx.c == --- head/sys/kern/kern_umtx.c Tue Jul 2 20:32:35 2019(r349613) +++ head/sys/kern/kern_umtx.c Tue Jul 2 21:03:06 2019(r349614) @@ -1059,7 +1059,6 @@ do_lock_normal(struct thread *td, struct umutex *m, ui if (owner == UMUTEX_RB_NOTRECOV) return (ENOTRECOVERABLE); - /* * Try the uncontested case. This should be * done in userland. @@ -2658,7 +2657,8 @@ do_rw_rdlock(struct thread *td, struct urwlock *rwlock /* try to lock it */ while (!(state & wrflags)) { - if (__predict_false(URWLOCK_READER_COUNT(state) == URWLOCK_MAX_READERS)) { + if (__predict_false(URWLOCK_READER_COUNT(state) == + URWLOCK_MAX_READERS)) { umtx_key_release(&uq->uq_key); return (EAGAIN); } @@ -2725,7 +2725,10 @@ do_rw_rdlock(struct thread *td, struct urwlock *rwlock } sleep: - /* contention bit is set, before sleeping, increase read waiter count */ + /* +* Contention bit is set, before sleeping, increase +* read waiter count. +*/ rv = fueword32(&rwlock->rw_blocked_readers, &blocked_readers); if (rv == -1) { @@ -2829,7 +2832,8 @@ do_rw_wrlock(struct thread *td, struct urwlock *rwlock umtx_key_release(&uq->uq_key); return (EFAULT); } - while (!(state & URWLOCK_WRITE_OWNER) && URWLOCK_READER_COUNT(state) == 0) { + while ((state & URWLOCK_WRITE_OWNER) == 0 && + URWLOCK_READER_COUNT(state) == 0) { rv = casueword32(&rwlock->rw_state, state, &oldstate, state | URWLOCK_WRITE_OWNER); if (rv == -1) { @@ -2865,8 +2869,8 @@ do_rw_wrlock(struct thread *td, struct urwlock *rwlock umtxq_unlock(&uq->uq_key); /* -* re-read the state, in case it changed between the try-lock above -* and the check below +* Re-read the state, in case it changed between the +* try-lock above and the check below. */ rv = fueword32(&rwlock->rw_state, &state); if (rv == -1) ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r349613 - head/stand/efi/libefi
Author: tsoome Date: Tue Jul 2 20:32:35 2019 New Revision: 349613 URL: https://svnweb.freebsd.org/changeset/base/349613 Log: efihttp: mac and err can be used uninitialized While there, also check if mac != NULL, and use pointer compare for ipv4 and dns. Modified: head/stand/efi/libefi/efihttp.c Modified: head/stand/efi/libefi/efihttp.c == --- head/stand/efi/libefi/efihttp.c Tue Jul 2 19:51:40 2019 (r349612) +++ head/stand/efi/libefi/efihttp.c Tue Jul 2 20:32:35 2019 (r349613) @@ -127,9 +127,11 @@ setup_ipv4_config2(EFI_HANDLE handle, MAC_ADDR_DEVICE_ (void **)&ip4config2, IH, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL); if (EFI_ERROR(status)) return (efi_status_to_errno(status)); - if (ipv4) { - setenv("boot.netif.hwaddr", - ether_sprintf((u_char *)mac->MacAddress.Addr), 1); + if (ipv4 != NULL) { + if (mac != NULL) { + setenv("boot.netif.hwaddr", + ether_sprintf((u_char *)mac->MacAddress.Addr), 1); + } setenv("boot.netif.ip", inet_ntoa(*(struct in_addr *)ipv4->LocalIpAddress.Addr), 1); setenv("boot.netif.netmask", @@ -160,7 +162,7 @@ setup_ipv4_config2(EFI_HANDLE handle, MAC_ADDR_DEVICE_ return (efi_status_to_errno(status)); } - if (dns) { + if (dns != NULL) { status = ip4config2->SetData(ip4config2, Ip4Config2DataTypeDnsServer, sizeof(EFI_IPv4_ADDRESS), &dns->DnsServerIp); @@ -252,6 +254,7 @@ efihttp_dev_open(struct open_file *f, ...) status = BS->LocateDevicePath(&httpsb_guid, &devpath, &handle); if (EFI_ERROR(status)) return (efi_status_to_errno(status)); + mac = NULL; ipv4 = NULL; dns = NULL; uri = NULL; @@ -662,7 +665,7 @@ static int efihttp_fs_read(struct open_file *f, void *buf, size_t size, size_t *resid) { size_t res; - int err; + int err = 0; while (size > 0) { err = _efihttp_fs_read(f, buf, size, &res); ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r349612 - head/sys/vm
Author: markj Date: Tue Jul 2 19:51:40 2019 New Revision: 349612 URL: https://svnweb.freebsd.org/changeset/base/349612 Log: Mark pages allocated from the per-CPU cache. Only free pages to the cache when they were allocated from that cache. This mitigates rapid fragmentation of physical memory seen during poudriere's dependency calculation phase. In particular, pages belonging to broken reservations are no longer freed to the per-CPU cache, so they get a chance to coalesce with freed pages during the break. Otherwise, the optimized CoW handler may create object chains in which multiple objects contain pages from the same reservation, and the order in which we do object termination means that the reservation is broken before all of those pages are freed, so some of them end up in the per-CPU cache and thus permanently fragment physical memory. The flag may also be useful for eliding calls to vm_reserv_free_page(), thus avoiding memory accesses for data that is likely not present in the CPU caches. Reviewed by: alc Discussed with: jeff MFC after:1 week Sponsored by: The FreeBSD Foundation Differential Revision:https://reviews.freebsd.org/D20763 Modified: head/sys/vm/vm_page.c head/sys/vm/vm_page.h Modified: head/sys/vm/vm_page.c == --- head/sys/vm/vm_page.c Tue Jul 2 19:32:48 2019(r349611) +++ head/sys/vm/vm_page.c Tue Jul 2 19:51:40 2019(r349612) @@ -1812,8 +1812,9 @@ vm_page_alloc_domain_after(vm_object_t object, vm_pind if (object != NULL) VM_OBJECT_ASSERT_WLOCKED(object); -again: + flags = 0; m = NULL; +again: #if VM_NRESERVLEVEL > 0 /* * Can we allocate the page from a reservation? @@ -1829,8 +1830,10 @@ again: vmd = VM_DOMAIN(domain); if (object != NULL && vmd->vmd_pgcache != NULL) { m = uma_zalloc(vmd->vmd_pgcache, M_NOWAIT); - if (m != NULL) + if (m != NULL) { + flags |= PG_PCPU_CACHE; goto found; + } } if (vm_domain_allocate(vmd, req, 1)) { /* @@ -1858,10 +1861,8 @@ again: } /* -* At this point we had better have found a good page. +* At this point we had better have found a good page. */ - KASSERT(m != NULL, ("missing page")); - found: vm_page_dequeue(m); vm_page_alloc_check(m); @@ -1869,10 +1870,8 @@ found: /* * Initialize the page. Only the PG_ZERO flag is inherited. */ - flags = 0; if ((req & VM_ALLOC_ZERO) != 0) - flags = PG_ZERO; - flags &= m->flags; + flags |= (m->flags & PG_ZERO); if ((req & VM_ALLOC_NODUMP) != 0) flags |= PG_NODUMP; m->flags = flags; @@ -2018,6 +2017,7 @@ vm_page_alloc_contig_domain(vm_object_t object, vm_pin * Can we allocate the pages without the number of free pages falling * below the lower bound for the allocation class? */ + m_ret = NULL; again: #if VM_NRESERVLEVEL > 0 /* @@ -2031,7 +2031,6 @@ again: goto found; } #endif - m_ret = NULL; vmd = VM_DOMAIN(domain); if (vm_domain_allocate(vmd, req, npages)) { /* @@ -3506,7 +3505,7 @@ vm_page_free_toq(vm_page_t m) return; vmd = vm_pagequeue_domain(m); - if (m->pool == VM_FREEPOOL_DEFAULT && vmd->vmd_pgcache != NULL) { + if ((m->flags & PG_PCPU_CACHE) != 0 && vmd->vmd_pgcache != NULL) { uma_zfree(vmd->vmd_pgcache, m); return; } Modified: head/sys/vm/vm_page.h == --- head/sys/vm/vm_page.h Tue Jul 2 19:32:48 2019(r349611) +++ head/sys/vm/vm_page.h Tue Jul 2 19:51:40 2019(r349612) @@ -379,6 +379,7 @@ extern struct mtx_padalign pa_lock[]; * Page flags. If changed at any other time than page allocation or * freeing, the modification must be protected by the vm_page lock. */ +#definePG_PCPU_CACHE 0x0001 /* was allocated from per-CPU caches */ #definePG_FICTITIOUS 0x0004 /* physical page doesn't exist */ #definePG_ZERO 0x0008 /* page is zeroed */ #definePG_MARKER 0x0010 /* special queue marker page */ ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r349611 - head/sys/kern
Author: kib Date: Tue Jul 2 19:32:48 2019 New Revision: 349611 URL: https://svnweb.freebsd.org/changeset/base/349611 Log: Style. Sponsored by: The FreeBSD Foundation MFC after:3 days Modified: head/sys/kern/kern_umtx.c Modified: head/sys/kern/kern_umtx.c == --- head/sys/kern/kern_umtx.c Tue Jul 2 19:12:02 2019(r349610) +++ head/sys/kern/kern_umtx.c Tue Jul 2 19:32:48 2019(r349611) @@ -2893,7 +2893,8 @@ do_rw_wrlock(struct thread *td, struct urwlock *rwlock break; } - if (!(state & URWLOCK_WRITE_OWNER) && URWLOCK_READER_COUNT(state) == 0) { + if ((state & URWLOCK_WRITE_OWNER) == 0 && + URWLOCK_READER_COUNT(state) == 0) { umtxq_unbusy_unlocked(&uq->uq_key); error = umtxq_check_susp(td); if (error != 0) @@ -2908,9 +2909,10 @@ sleep: error = EFAULT; break; } - suword32(&rwlock->rw_blocked_writers, blocked_writers+1); + suword32(&rwlock->rw_blocked_writers, blocked_writers + 1); - while ((state & URWLOCK_WRITE_OWNER) || URWLOCK_READER_COUNT(state) != 0) { + while ((state & URWLOCK_WRITE_OWNER) || + URWLOCK_READER_COUNT(state) != 0) { umtxq_lock(&uq->uq_key); umtxq_insert_queue(uq, UMTX_EXCLUSIVE_QUEUE); umtxq_unbusy(&uq->uq_key); ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r349610 - head/usr.bin/proccontrol
Author: kib Date: Tue Jul 2 19:12:02 2019 New Revision: 349610 URL: https://svnweb.freebsd.org/changeset/base/349610 Log: Add implicit PROT_MAX() knob to proccontrol(1). Reviewed by: emaste, markj (previous version) Discussed with: brooks Sponsored by: The FreeBSD Foundation Differential revision:https://reviews.freebsd.org/D20795 Modified: head/usr.bin/proccontrol/proccontrol.1 head/usr.bin/proccontrol/proccontrol.c Modified: head/usr.bin/proccontrol/proccontrol.1 == --- head/usr.bin/proccontrol/proccontrol.1 Tue Jul 2 19:07:17 2019 (r349609) +++ head/usr.bin/proccontrol/proccontrol.1 Tue Jul 2 19:12:02 2019 (r349610) @@ -66,6 +66,9 @@ Note that process is only allowed to enable tracing fo not for any other process. .It Ar trapcap Controls the signalling of capability mode access violations. +.It Ar protmax +Controls the implicit PROT_MAX application for +.Xr mmap 2 . .It Ar kpti Controls the KPTI enable, AMD64 only. .El Modified: head/usr.bin/proccontrol/proccontrol.c == --- head/usr.bin/proccontrol/proccontrol.c Tue Jul 2 19:07:17 2019 (r349609) +++ head/usr.bin/proccontrol/proccontrol.c Tue Jul 2 19:12:02 2019 (r349610) @@ -43,6 +43,7 @@ enum { MODE_INVALID, MODE_TRACE, MODE_TRAPCAP, + MODE_PROTMAX, #ifdef PROC_KPTI_CTL MODE_KPTI, #endif @@ -72,7 +73,7 @@ static void __dead2 usage(void) { - fprintf(stderr, "Usage: proccontrol -m (aslr|trace|trapcap" + fprintf(stderr, "Usage: proccontrol -m (aslr|protmax|trace|trapcap" KPTI_USAGE") [-q] " "[-s (enable|disable)] [-p pid | command]\n"); exit(1); @@ -94,6 +95,8 @@ main(int argc, char *argv[]) case 'm': if (strcmp(optarg, "aslr") == 0) mode = MODE_ASLR; + else if (strcmp(optarg, "protmax") == 0) + mode = MODE_PROTMAX; else if (strcmp(optarg, "trace") == 0) mode = MODE_TRACE; else if (strcmp(optarg, "trapcap") == 0) @@ -147,6 +150,9 @@ main(int argc, char *argv[]) case MODE_TRAPCAP: error = procctl(P_PID, pid, PROC_TRAPCAP_STATUS, &arg); break; + case MODE_PROTMAX: + error = procctl(P_PID, pid, PROC_PROTMAX_STATUS, &arg); + break; #ifdef PROC_KPTI_CTL case MODE_KPTI: error = procctl(P_PID, pid, PROC_KPTI_STATUS, &arg); @@ -194,6 +200,23 @@ main(int argc, char *argv[]) break; } break; + case MODE_PROTMAX: + switch (arg & ~PROC_PROTMAX_ACTIVE) { + case PROC_PROTMAX_FORCE_ENABLE: + printf("force enabled"); + break; + case PROC_PROTMAX_FORCE_DISABLE: + printf("force disabled"); + break; + case PROC_PROTMAX_NOFORCE: + printf("not forced"); + break; + } + if ((arg & PROC_PROTMAX_ACTIVE) != 0) + printf(", active\n"); + else + printf(", not active\n"); + break; #ifdef PROC_KPTI_CTL case MODE_KPTI: switch (arg & ~PROC_KPTI_STATUS_ACTIVE) { @@ -227,6 +250,11 @@ main(int argc, char *argv[]) arg = enable ? PROC_TRAPCAP_CTL_ENABLE : PROC_TRAPCAP_CTL_DISABLE; error = procctl(P_PID, pid, PROC_TRAPCAP_CTL, &arg); + break; + case MODE_PROTMAX: + arg = enable ? PROC_PROTMAX_FORCE_ENABLE : + PROC_PROTMAX_FORCE_DISABLE; + error = procctl(P_PID, pid, PROC_PROTMAX_CTL, &arg); break; #ifdef PROC_KPTI_CTL case MODE_KPTI: ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r349609 - in head: lib/libc/sys sys/compat/freebsd32 sys/kern sys/sys sys/vm
Author: kib Date: Tue Jul 2 19:07:17 2019 New Revision: 349609 URL: https://svnweb.freebsd.org/changeset/base/349609 Log: Control implicit PROT_MAX() using procctl(2) and the FreeBSD note feature bit. In particular, allocate the bit to opt-out the image from implicit PROTMAX enablement. Provide procctl(2) verbs to set and query implicit PROTMAX handling. The knobs mimic the same per-image flag and per-process controls for ASLR. Reviewed by: emaste, markj (previous version) Discussed with: brooks Sponsored by: The FreeBSD Foundation Differential revision:https://reviews.freebsd.org/D20795 Modified: head/lib/libc/sys/procctl.2 head/sys/compat/freebsd32/freebsd32_misc.c head/sys/kern/kern_procctl.c head/sys/sys/elf_common.h head/sys/sys/proc.h head/sys/sys/procctl.h head/sys/sys/syscallsubr.h head/sys/vm/vm_mmap.c Modified: head/lib/libc/sys/procctl.2 == --- head/lib/libc/sys/procctl.2 Tue Jul 2 19:01:14 2019(r349608) +++ head/lib/libc/sys/procctl.2 Tue Jul 2 19:07:17 2019(r349609) @@ -94,7 +94,7 @@ Same notes as for .Dv PROC_ASLR_FORCE_ENABLE apply. .It Dv PROC_ASLR_NOFORCE -Use system-wide configured policy for ASLR. +Use the system-wide configured policy for ASLR. .El .It Dv PROC_ASLR_STATUS Returns the current status of ASLR enablement for the target process. @@ -112,6 +112,47 @@ If the currently executed image in the process itself the .Dv PROC_ASLR_ACTIVE flag is or-ed with the value listed above. +.It Dv PROC_PROTMAX_CTL +Controls implicit application of PROT_MAX protection equal to the +.Fa prot +argument of the +.Xr mmap 2 +syscall, in the target process. +The +.Va arg +parameter must point to the integer variable holding one of the following +values: +.Bl -tag -width PROC_PROTMAX_FORCE_DISABLE +.It Dv PROC_PROTMAX_FORCE_ENABLE +Enables implicit PROT_MAX application, +even if it is disabled system-wide by the sysctl +.Va vm.imply_prot_max . +The image flag might still prevent the enablement. +.It Dv PROC_ASLR_FORCE_DISABLE +Request that implicit application of PROT_MAX be disabled. +Same notes as for +.Dv PROC_PROTMAX_FORCE_ENABLE +apply. +.It Dv PROC_PROTMAX_NOFORCE +Use the system-wide configured policy for PROT_MAX. +.El +.It Dv PROC_PROTMAX_STATUS +Returns the current status of implicit PROT_MAX enablement for the +target process. +The +.Va arg +parameter must point to the integer variable, where one of the +following values is written: +.Bl -tag -width PROC_PROTMAX_FORCE_DISABLE +.It Dv PROC_PROTMAX_FORCE_ENABLE +.It Dv PROC_PROTMAX_FORCE_DISABLE +.It Dv PROC_PROTMAX_NOFORCE +.El +.Pp +If the currently executed image in the process itself has implicit PROT_MAX +application enabled, the +.Dv PROC_PROTMAX_ACTIVE +flag is or-ed with the value listed above. .It Dv PROC_SPROTECT Set process protection state. This is used to mark a process as protected from being killed if the system @@ -575,6 +616,8 @@ or invalid signal number. .Xr cap_enter 2, .Xr kill 2 , .Xr ktrace 2 , +.Xr mmap 2 , +.Xr mprotect 2 , .Xr ptrace 2 , .Xr wait 2 , .Xr capsicum 4 , Modified: head/sys/compat/freebsd32/freebsd32_misc.c == --- head/sys/compat/freebsd32/freebsd32_misc.c Tue Jul 2 19:01:14 2019 (r349608) +++ head/sys/compat/freebsd32/freebsd32_misc.c Tue Jul 2 19:07:17 2019 (r349609) @@ -,6 +,7 @@ freebsd32_procctl(struct thread *td, struct freebsd32_ switch (uap->com) { case PROC_ASLR_CTL: + case PROC_PROTMAX_CTL: case PROC_SPROTECT: case PROC_TRACE_CTL: case PROC_TRAPCAP_CTL: @@ -3365,6 +3366,7 @@ freebsd32_procctl(struct thread *td, struct freebsd32_ data = &x.rk; break; case PROC_ASLR_STATUS: + case PROC_PROTMAX_STATUS: case PROC_TRACE_STATUS: case PROC_TRAPCAP_STATUS: data = &flags; @@ -3394,6 +3396,7 @@ freebsd32_procctl(struct thread *td, struct freebsd32_ error = error1; break; case PROC_ASLR_STATUS: + case PROC_PROTMAX_STATUS: case PROC_TRACE_STATUS: case PROC_TRAPCAP_STATUS: if (error == 0) Modified: head/sys/kern/kern_procctl.c == --- head/sys/kern/kern_procctl.cTue Jul 2 19:01:14 2019 (r349608) +++ head/sys/kern/kern_procctl.cTue Jul 2 19:07:17 2019 (r349609) @@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -419,6 +420,51 @@ trapcap_status(struct thread *td, struct proc *p, int } static int +protmax_ctl(struct thread *td, struct proc *p, int state) +{ + PROC_LOCK_ASSERT(p, MA_OWNED); + + switch (state) { + case PROC_PROTMAX_F
svn commit: r349608 - head/sys/vm
Author: kib Date: Tue Jul 2 19:01:14 2019 New Revision: 349608 URL: https://svnweb.freebsd.org/changeset/base/349608 Log: Use traditional 'p' local to designate td->td_proc in kern_mmap. Reviewed by: emaste, markj Sponsored by: The FreeBSD Foundation MFC after:3 days Differential revision:https://reviews.freebsd.org/D20795 Modified: head/sys/vm/vm_mmap.c Modified: head/sys/vm/vm_mmap.c == --- head/sys/vm/vm_mmap.c Tue Jul 2 17:48:27 2019(r349607) +++ head/sys/vm/vm_mmap.c Tue Jul 2 19:01:14 2019(r349608) @@ -187,6 +187,7 @@ kern_mmap(struct thread *td, uintptr_t addr0, size_t l { struct vmspace *vms; struct file *fp; + struct proc *p; vm_offset_t addr; vm_size_t pageoff, size; vm_prot_t cap_maxprot; @@ -199,6 +200,9 @@ kern_mmap(struct thread *td, uintptr_t addr0, size_t l prot = PROT_EXTRACT(prot); if (max_prot != 0 && (max_prot & prot) != prot) return (EINVAL); + + p = td->td_proc; + /* * Always honor PROT_MAX if set. If not, default to all * permissions unless we're implying maximum permissions. @@ -209,7 +213,7 @@ kern_mmap(struct thread *td, uintptr_t addr0, size_t l max_prot = (imply_prot_max && prot != PROT_NONE) ? prot : _PROT_ALL; - vms = td->td_proc->p_vmspace; + vms = p->p_vmspace; fp = NULL; AUDIT_ARG_FD(fd); addr = addr0; @@ -229,7 +233,7 @@ kern_mmap(struct thread *td, uintptr_t addr0, size_t l * pos. */ if (!SV_CURPROC_FLAG(SV_AOUT)) { - if ((len == 0 && curproc->p_osrel >= P_OSREL_MAP_ANON) || + if ((len == 0 && p->p_osrel >= P_OSREL_MAP_ANON) || ((flags & MAP_ANON) != 0 && (fd != -1 || pos != 0))) return (EINVAL); } else { @@ -375,7 +379,7 @@ kern_mmap(struct thread *td, uintptr_t addr0, size_t l if (error != 0) goto done; if ((flags & (MAP_SHARED | MAP_PRIVATE)) == 0 && - td->td_proc->p_osrel >= P_OSREL_MAP_FSTRICT) { + p->p_osrel >= P_OSREL_MAP_FSTRICT) { error = EINVAL; goto done; } ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r349607 - head/share/man/man4
Author: zeising (doc,ports committer) Date: Tue Jul 2 17:48:27 2019 New Revision: 349607 URL: https://svnweb.freebsd.org/changeset/base/349607 Log: pci(4): Use plural configuration registers Change to use registers instead of register, as it is customary to use plural when talking about PCI registers. This was missed in r349150. MFC after:3 days Modified: head/share/man/man4/pci.4 Modified: head/share/man/man4/pci.4 == --- head/share/man/man4/pci.4 Tue Jul 2 17:24:25 2019(r349606) +++ head/share/man/man4/pci.4 Tue Jul 2 17:48:27 2019(r349607) @@ -290,7 +290,7 @@ This .Xr ioctl 2 reads the .Tn PCI -configuration register specified by the passed-in +configuration registers specified by the passed-in .Va pci_io structure. The ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r349602 - head/sys/dev/usb/net
Author: emaste Date: Tue Jul 2 16:44:04 2019 New Revision: 349602 URL: https://svnweb.freebsd.org/changeset/base/349602 Log: if_muge: set IFCAP_VLAN_MTU to maintain 1500 MTU with vlan use PR: 238665 Submitted by: Ralf MFC after:1 week Modified: head/sys/dev/usb/net/if_muge.c Modified: head/sys/dev/usb/net/if_muge.c == --- head/sys/dev/usb/net/if_muge.c Tue Jul 2 15:01:54 2019 (r349601) +++ head/sys/dev/usb/net/if_muge.c Tue Jul 2 16:44:04 2019 (r349602) @@ -1610,6 +1610,7 @@ muge_attach_post_sub(struct usb_ether *ue) * however currently only RX checksum is supported in the driver * (see top of file). */ + ifp->if_capabilities |= IFCAP_VLAN_MTU; ifp->if_hwassist = 0; if (MUGE_DEFAULT_RX_CSUM_ENABLE) ifp->if_capabilities |= IFCAP_RXCSUM; ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r349601 - head/sys/dev/ntb/ntb_hw
Author: mav Date: Tue Jul 2 15:01:54 2019 New Revision: 349601 URL: https://svnweb.freebsd.org/changeset/base/349601 Log: Include sys/lock.h, as told by man page. MFC after:1 week Modified: head/sys/dev/ntb/ntb_hw/ntb_hw_amd.c Modified: head/sys/dev/ntb/ntb_hw/ntb_hw_amd.c == --- head/sys/dev/ntb/ntb_hw/ntb_hw_amd.cTue Jul 2 14:53:51 2019 (r349600) +++ head/sys/dev/ntb/ntb_hw/ntb_hw_amd.cTue Jul 2 15:01:54 2019 (r349601) @@ -59,6 +59,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r349600 - head/usr.sbin/bhyve
Author: wblock (doc committer) Date: Tue Jul 2 14:53:51 2019 New Revision: 349600 URL: https://svnweb.freebsd.org/changeset/base/349600 Log: Correct name of vmm(4) pptdevs variable. Reported by: nwo...@ixsystems.com Modified: head/usr.sbin/bhyve/bhyve.8 Modified: head/usr.sbin/bhyve/bhyve.8 == --- head/usr.sbin/bhyve/bhyve.8 Tue Jul 2 14:24:42 2019(r349599) +++ head/usr.sbin/bhyve/bhyve.8 Tue Jul 2 14:53:51 2019(r349600) @@ -347,7 +347,7 @@ Guest memory must be wired using the option when a pass-through device is configured. .Pp The host device must have been reserved at boot-time using the -.Va pptdev +.Va pptdevs loader variable as described in .Xr vmm 4 . .Pp ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r349599 - head/sys/kern
Author: markj Date: Tue Jul 2 14:24:42 2019 New Revision: 349599 URL: https://svnweb.freebsd.org/changeset/base/349599 Log: Fix handling of errors from sblock() in soreceive_stream(). Previously we would attempt to unlock the socket buffer despite having failed to lock it. Simply return an error instead: no resources need to be released at this point, and doing so is consistent with soreceive_generic(). PR: 238789 Submitted by: Greg Becker MFC after:1 week Modified: head/sys/kern/uipc_socket.c Modified: head/sys/kern/uipc_socket.c == --- head/sys/kern/uipc_socket.c Tue Jul 2 12:22:54 2019(r349598) +++ head/sys/kern/uipc_socket.c Tue Jul 2 14:24:42 2019(r349599) @@ -2200,7 +2200,7 @@ soreceive_stream(struct socket *so, struct sockaddr ** /* Prevent other readers from entering the socket. */ error = sblock(sb, SBLOCKWAIT(flags)); if (error) - goto out; + return (error); SOCKBUF_LOCK(sb); /* Easy one, no space to copyout anything. */ ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
Re: svn commit: r349596 - head/sys/dev/fdt
On 2019-07-02 10:48, Ganbold Tsagaankhuu wrote: On Tue, Jul 2, 2019 at 4:47 PM Ganbold Tsagaankhuu wrote: Author: ganbold Date: Tue Jul 2 08:47:18 2019 New Revision: 349596 URL: https://svnweb.freebsd.org/changeset/base/349596 Log: Extend simple_mfd driver to expose a syscon interface if that node is also compatible with syscon. For instance, Rockchip RK3399's GRF (General Register Files) is compatible with simple-mfd as well as syscon and has devices like usb2-phy, emmc-phy and pcie-phy etc. under it. Forgot to include: https://reviews.freebsd.org/D20647 08:55:21 /usr/src/sys/dev/fdt/simple_mfd.c:54:23: error: syscon_if.h: No such file or directory See: https://ci.freebsd.org/tinderbox/ --HPS ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
Re: svn commit: r349596 - head/sys/dev/fdt
On Tue, Jul 2, 2019 at 4:47 PM Ganbold Tsagaankhuu wrote: > Author: ganbold > Date: Tue Jul 2 08:47:18 2019 > New Revision: 349596 > URL: https://svnweb.freebsd.org/changeset/base/349596 > > Log: > Extend simple_mfd driver to expose a syscon interface if > that node is also compatible with syscon. For instance, > Rockchip RK3399's GRF (General Register Files) is compatible > with simple-mfd as well as syscon and has devices like > usb2-phy, emmc-phy and pcie-phy etc. under it. > Forgot to include: https://reviews.freebsd.org/D20647 thanks, Ganbold > > Reviewed by: manu > > Added: > head/sys/dev/fdt/simple_mfd.h (contents, props changed) > Modified: > head/sys/dev/fdt/simple_mfd.c > > Modified: head/sys/dev/fdt/simple_mfd.c > > == > --- head/sys/dev/fdt/simple_mfd.c Tue Jul 2 07:47:11 2019 > (r349595) > +++ head/sys/dev/fdt/simple_mfd.c Tue Jul 2 08:47:18 2019 > (r349596) > @@ -33,7 +33,10 @@ __FBSDID("$FreeBSD$"); > #include > #include > #include > +#include > #include > +#include > +#include > > #include > > @@ -42,15 +45,88 @@ __FBSDID("$FreeBSD$"); > #include > #include > > -struct simple_mfd_softc { > - struct simplebus_softc sc; > -}; > +#include > > device_t simple_mfd_add_device(device_t dev, phandle_t node, u_int order, > const char *name, int unit, struct simplebus_devinfo *di); > struct simplebus_devinfo *simple_mfd_setup_dinfo(device_t dev, phandle_t > node, struct simplebus_devinfo *di); > > +#include "syscon_if.h" > +#include > + > +MALLOC_DECLARE(M_SYSCON); > + > +static uint32_t simple_mfd_syscon_read_4(struct syscon *syscon, > bus_size_t offset); > +static int simple_mfd_syscon_write_4(struct syscon *syscon, bus_size_t > offset, > +uint32_t val); > +static int simple_mfd_syscon_modify_4(struct syscon *syscon, bus_size_t > offset, > +uint32_t clear_bits, uint32_t set_bits); > + > +#defineSYSCON_LOCK(_sc)mtx_lock_spin(&(_sc)->mtx) > +#defineSYSCON_UNLOCK(_sc) > mtx_unlock_spin(&(_sc)->mtx) > +#defineSYSCON_LOCK_INIT(_sc) mtx_init(&(_sc)->mtx, \ > +device_get_nameunit((_sc)->dev), "syscon", MTX_SPIN) > +#defineSYSCON_LOCK_DESTROY(_sc)mtx_destroy(&(_sc)->mtx); > +#defineSYSCON_ASSERT_LOCKED(_sc) mtx_assert(&(_sc)->mtx, > MA_OWNED); > +#defineSYSCON_ASSERT_UNLOCKED(_sc) mtx_assert(&(_sc)->mtx, > MA_NOTOWNED); > + > +static syscon_method_t simple_mfd_syscon_methods[] = { > + SYSCONMETHOD(syscon_read_4, simple_mfd_syscon_read_4), > + SYSCONMETHOD(syscon_write_4,simple_mfd_syscon_write_4), > + SYSCONMETHOD(syscon_modify_4, simple_mfd_syscon_modify_4), > + > + SYSCONMETHOD_END > +}; > +DEFINE_CLASS_1(simple_mfd_syscon, simple_mfd_syscon_class, > +simple_mfd_syscon_methods, 0, syscon_class); > + > +static uint32_t > +simple_mfd_syscon_read_4(struct syscon *syscon, bus_size_t offset) > +{ > + struct simple_mfd_softc *sc; > + uint32_t val; > + > + sc = device_get_softc(syscon->pdev); > + > + SYSCON_LOCK(sc); > + val = bus_read_4(sc->mem_res, offset); > + SYSCON_UNLOCK(sc); > + return (val); > +} > + > static int > +simple_mfd_syscon_write_4(struct syscon *syscon, bus_size_t offset, > +uint32_t val) > +{ > + struct simple_mfd_softc *sc; > + > + sc = device_get_softc(syscon->pdev); > + > + SYSCON_LOCK(sc); > + bus_write_4(sc->mem_res, offset, val); > + SYSCON_UNLOCK(sc); > + return (0); > +} > + > +static int > +simple_mfd_syscon_modify_4(struct syscon *syscon, bus_size_t offset, > +uint32_t clear_bits, uint32_t set_bits) > +{ > + struct simple_mfd_softc *sc; > + uint32_t val; > + > + sc = device_get_softc(syscon->pdev); > + > + SYSCON_LOCK(sc); > + val = bus_read_4(sc->mem_res, offset); > + val &= ~clear_bits; > + val |= set_bits; > + bus_write_4(sc->mem_res, offset, val); > + SYSCON_UNLOCK(sc); > + return (0); > +} > + > +static int > simple_mfd_probe(device_t dev) > { > > @@ -70,10 +146,14 @@ simple_mfd_attach(device_t dev) > struct simple_mfd_softc *sc; > phandle_t node, child; > device_t cdev; > + int rid; > > sc = device_get_softc(dev); > node = ofw_bus_get_node(dev); > > + sc->dev = dev; > + rid = 0; > + > /* Parse address-cells and size-cells from the parent node as a > fallback */ > if (OF_getencprop(node, "#address-cells", &sc->sc.acells, > sizeof(sc->sc.acells)) == -1) { > @@ -105,9 +185,48 @@ simple_mfd_attach(device_t dev) > device_probe_and_attach(cdev); > } > > + if (ofw_bus_is_compatible(dev, "syscon")) { > + sc->mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, > &rid, > + RF_ACTIVE); > +
svn commit: r349596 - head/sys/dev/fdt
Author: ganbold Date: Tue Jul 2 08:47:18 2019 New Revision: 349596 URL: https://svnweb.freebsd.org/changeset/base/349596 Log: Extend simple_mfd driver to expose a syscon interface if that node is also compatible with syscon. For instance, Rockchip RK3399's GRF (General Register Files) is compatible with simple-mfd as well as syscon and has devices like usb2-phy, emmc-phy and pcie-phy etc. under it. Reviewed by: manu Added: head/sys/dev/fdt/simple_mfd.h (contents, props changed) Modified: head/sys/dev/fdt/simple_mfd.c Modified: head/sys/dev/fdt/simple_mfd.c == --- head/sys/dev/fdt/simple_mfd.c Tue Jul 2 07:47:11 2019 (r349595) +++ head/sys/dev/fdt/simple_mfd.c Tue Jul 2 08:47:18 2019 (r349596) @@ -33,7 +33,10 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include +#include +#include #include @@ -42,15 +45,88 @@ __FBSDID("$FreeBSD$"); #include #include -struct simple_mfd_softc { - struct simplebus_softc sc; -}; +#include device_t simple_mfd_add_device(device_t dev, phandle_t node, u_int order, const char *name, int unit, struct simplebus_devinfo *di); struct simplebus_devinfo *simple_mfd_setup_dinfo(device_t dev, phandle_t node, struct simplebus_devinfo *di); +#include "syscon_if.h" +#include + +MALLOC_DECLARE(M_SYSCON); + +static uint32_t simple_mfd_syscon_read_4(struct syscon *syscon, bus_size_t offset); +static int simple_mfd_syscon_write_4(struct syscon *syscon, bus_size_t offset, +uint32_t val); +static int simple_mfd_syscon_modify_4(struct syscon *syscon, bus_size_t offset, +uint32_t clear_bits, uint32_t set_bits); + +#defineSYSCON_LOCK(_sc)mtx_lock_spin(&(_sc)->mtx) +#defineSYSCON_UNLOCK(_sc) mtx_unlock_spin(&(_sc)->mtx) +#defineSYSCON_LOCK_INIT(_sc) mtx_init(&(_sc)->mtx, \ +device_get_nameunit((_sc)->dev), "syscon", MTX_SPIN) +#defineSYSCON_LOCK_DESTROY(_sc)mtx_destroy(&(_sc)->mtx); +#defineSYSCON_ASSERT_LOCKED(_sc) mtx_assert(&(_sc)->mtx, MA_OWNED); +#defineSYSCON_ASSERT_UNLOCKED(_sc) mtx_assert(&(_sc)->mtx, MA_NOTOWNED); + +static syscon_method_t simple_mfd_syscon_methods[] = { + SYSCONMETHOD(syscon_read_4, simple_mfd_syscon_read_4), + SYSCONMETHOD(syscon_write_4,simple_mfd_syscon_write_4), + SYSCONMETHOD(syscon_modify_4, simple_mfd_syscon_modify_4), + + SYSCONMETHOD_END +}; +DEFINE_CLASS_1(simple_mfd_syscon, simple_mfd_syscon_class, +simple_mfd_syscon_methods, 0, syscon_class); + +static uint32_t +simple_mfd_syscon_read_4(struct syscon *syscon, bus_size_t offset) +{ + struct simple_mfd_softc *sc; + uint32_t val; + + sc = device_get_softc(syscon->pdev); + + SYSCON_LOCK(sc); + val = bus_read_4(sc->mem_res, offset); + SYSCON_UNLOCK(sc); + return (val); +} + static int +simple_mfd_syscon_write_4(struct syscon *syscon, bus_size_t offset, +uint32_t val) +{ + struct simple_mfd_softc *sc; + + sc = device_get_softc(syscon->pdev); + + SYSCON_LOCK(sc); + bus_write_4(sc->mem_res, offset, val); + SYSCON_UNLOCK(sc); + return (0); +} + +static int +simple_mfd_syscon_modify_4(struct syscon *syscon, bus_size_t offset, +uint32_t clear_bits, uint32_t set_bits) +{ + struct simple_mfd_softc *sc; + uint32_t val; + + sc = device_get_softc(syscon->pdev); + + SYSCON_LOCK(sc); + val = bus_read_4(sc->mem_res, offset); + val &= ~clear_bits; + val |= set_bits; + bus_write_4(sc->mem_res, offset, val); + SYSCON_UNLOCK(sc); + return (0); +} + +static int simple_mfd_probe(device_t dev) { @@ -70,10 +146,14 @@ simple_mfd_attach(device_t dev) struct simple_mfd_softc *sc; phandle_t node, child; device_t cdev; + int rid; sc = device_get_softc(dev); node = ofw_bus_get_node(dev); + sc->dev = dev; + rid = 0; + /* Parse address-cells and size-cells from the parent node as a fallback */ if (OF_getencprop(node, "#address-cells", &sc->sc.acells, sizeof(sc->sc.acells)) == -1) { @@ -105,9 +185,48 @@ simple_mfd_attach(device_t dev) device_probe_and_attach(cdev); } + if (ofw_bus_is_compatible(dev, "syscon")) { + sc->mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, + RF_ACTIVE); + if (sc->mem_res == NULL) { + device_printf(dev, + "Cannot allocate memory resource\n"); + return (ENXIO); + } + + SYSCON_LOCK_INIT(sc); + sc->syscon = syscon_create_ofw_node(dev, + &simple_mfd_syscon_class, ofw_bus_get_node(dev)); + if (sc->syscon ==
svn commit: r349595 - head/sys/dev/ntb/ntb_hw
Author: mav Date: Tue Jul 2 07:47:11 2019 New Revision: 349595 URL: https://svnweb.freebsd.org/changeset/base/349595 Log: Fix i386 LINT after r349594. MFC after:1 month Modified: head/sys/dev/ntb/ntb_hw/ntb_hw_amd.c Modified: head/sys/dev/ntb/ntb_hw/ntb_hw_amd.c == --- head/sys/dev/ntb/ntb_hw/ntb_hw_amd.cTue Jul 2 05:25:18 2019 (r349594) +++ head/sys/dev/ntb/ntb_hw/ntb_hw_amd.cTue Jul 2 07:47:11 2019 (r349595) @@ -93,6 +93,26 @@ SYSCTL_UINT(_hw_ntb, OID_AUTO, debug_level, CTLFLAG_RW device_printf(ntb->device, __VA_ARGS__); \ } while (0) +#ifdef __i386__ +static __inline uint64_t +bus_space_read_8(bus_space_tag_t tag, bus_space_handle_t handle, +bus_size_t offset) +{ + + return (bus_space_read_4(tag, handle, offset) | + ((uint64_t)bus_space_read_4(tag, handle, offset + 4)) << 32); +} + +static __inline void +bus_space_write_8(bus_space_tag_t tag, bus_space_handle_t handle, +bus_size_t offset, uint64_t val) +{ + + bus_space_write_4(tag, handle, offset, val); + bus_space_write_4(tag, handle, offset + 4, val >> 32); +} +#endif + /* * AMD NTB INTERFACE ROUTINES */ @@ -316,11 +336,6 @@ amd_ntb_mw_get_range(device_t dev, unsigned mw_idx, vm *plimit = BUS_SPACE_MAXADDR_32BIT; } - amd_ntb_printf(1, "%s: mw %d padd %p vadd %p psize 0x%lx " - "align 0x%lx asize 0x%lx alimit %p\n", __func__, mw_idx, - (void *)*base, (void *)*vbase, (uint64_t)*size, (uint64_t)*align, - (uint64_t)*align_size, (void *)*plimit); - return (0); } @@ -353,14 +368,14 @@ amd_ntb_mw_set_trans(device_t dev, unsigned mw_idx, bu * set and verify setting the translation address */ amd_ntb_peer_reg_write(8, bar_info->xlat_off, (uint64_t)addr); - amd_ntb_printf(0, "%s: mw %d xlat_off 0x%x cur_val 0x%lx addr %p\n", + amd_ntb_printf(0, "%s: mw %d xlat_off 0x%x cur_val 0x%jx addr %p\n", __func__, mw_idx, bar_info->xlat_off, amd_ntb_peer_reg_read(8, bar_info->xlat_off), (void *)addr); /* set and verify setting the limit */ if (mw_idx != 0) { amd_ntb_reg_write(8, bar_info->limit_off, (uint64_t)size); - amd_ntb_printf(1, "%s: limit_off 0x%x cur_val 0x%lx limit 0x%x\n", + amd_ntb_printf(1, "%s: limit_off 0x%x cur_val 0x%jx limit 0x%x\n", __func__, bar_info->limit_off, amd_ntb_peer_reg_read(8, bar_info->limit_off), (uint32_t)size); } else { @@ -470,7 +485,7 @@ amd_ntb_db_read(device_t dev) dbstat_off = (uint64_t)amd_ntb_reg_read(2, AMD_DBSTAT_OFFSET); - amd_ntb_printf(1, "%s: dbstat_off 0x%lx\n", __func__, dbstat_off); + amd_ntb_printf(1, "%s: dbstat_off 0x%jx\n", __func__, dbstat_off); return (dbstat_off); } @@ -480,7 +495,7 @@ amd_ntb_db_clear(device_t dev, uint64_t db_bits) { struct amd_ntb_softc *ntb = device_get_softc(dev); - amd_ntb_printf(1, "%s: db_bits 0x%lx\n", __func__, db_bits); + amd_ntb_printf(1, "%s: db_bits 0x%jx\n", __func__, db_bits); amd_ntb_reg_write(2, AMD_DBSTAT_OFFSET, (uint16_t)db_bits); } @@ -490,7 +505,7 @@ amd_ntb_db_set_mask(device_t dev, uint64_t db_bits) struct amd_ntb_softc *ntb = device_get_softc(dev); DB_MASK_LOCK(ntb); - amd_ntb_printf(1, "%s: db_mask 0x%x db_bits 0x%lx\n", + amd_ntb_printf(1, "%s: db_mask 0x%x db_bits 0x%jx\n", __func__, ntb->db_mask, db_bits); ntb->db_mask |= db_bits; @@ -504,7 +519,7 @@ amd_ntb_db_clear_mask(device_t dev, uint64_t db_bits) struct amd_ntb_softc *ntb = device_get_softc(dev); DB_MASK_LOCK(ntb); - amd_ntb_printf(1, "%s: db_mask 0x%x db_bits 0x%lx\n", + amd_ntb_printf(1, "%s: db_mask 0x%x db_bits 0x%jx\n", __func__, ntb->db_mask, db_bits); ntb->db_mask &= ~db_bits; @@ -517,7 +532,7 @@ amd_ntb_peer_db_set(device_t dev, uint64_t db_bits) { struct amd_ntb_softc *ntb = device_get_softc(dev); - amd_ntb_printf(1, "%s: db_bits 0x%lx\n", __func__, db_bits); + amd_ntb_printf(1, "%s: db_bits 0x%jx\n", __func__, db_bits); amd_ntb_reg_write(2, AMD_DBREQ_OFFSET, (uint16_t)db_bits); } @@ -660,17 +675,17 @@ amd_ntb_hw_info_handler(SYSCTL_HANDLER_ARGS) sbuf_printf(sb, "AMD Doorbell: 0x%x\n", amd_ntb_reg_read(4, AMD_DBSTAT_OFFSET)); sbuf_printf(sb, "AMD NTB Incoming XLAT: \n"); - sbuf_printf(sb, "AMD XLAT1: 0x%lx\n", + sbuf_printf(sb, "AMD XLAT1: 0x%jx\n", amd_ntb_peer_reg_read(8, AMD_BAR1XLAT_OFFSET)); - sbuf_printf(sb, "AMD XLAT23: 0x%lx\n", + sbuf_printf(sb, "AMD XLAT23: 0x%jx\n", amd_ntb_peer_reg_read(8, AMD_BAR23XLAT_OFFSET)); - sbuf_printf(sb, "AMD XLAT45: 0x%lx\n", + sbuf_
Re: svn commit: r349589 - in head: sbin/mount sys/sys sys/ufs/ffs
On Mon, Jul 1, 2019 at 8:33 PM Kirk McKusick via svn-src-all < svn-src-...@freebsd.org> wrote: > Author: mckusick > Date: Mon Jul 1 23:22:26 2019 > New Revision: 349589 > URL: https://svnweb.freebsd.org/changeset/base/349589 > > Log: > Add a new "untrusted" option to the mount command. Its purpose > is to notify the kernel that the file system is untrusted and it > should use more extensive checks on the file-system's metadata > before using it. This option is intended to be used when mounting > file systems from untrusted media such as USB memory sticks or other > externally-provided media. > > Are these additional extensive checks supposed to be computationally expensive in some regard, that we would not want to just always perform them? Thanks, Ben ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"