CVS commit: src/usr.bin/rlogin
Module Name:src Committed By: chs Date: Tue Aug 3 23:21:07 UTC 2021 Modified Files: src/usr.bin/rlogin: rlogin.c Log Message: revert rev 1.45: "PR/54435: Adjust for new kernel behavior of soreceive(9) clearing MSG_OOB" That change was trying to make rlogin work again after the SIOCATMARK ioctl was broken, but that kernel bug has now been fixed, so the original rlogin code now works again. Further, the changed rlogin code actually did the wrong thing, by treating reception of the MSG_OOB byte as meaning that we are now "at the mark", but that is not true... we are "at the mark" only when we have reached the point in the stream where the MSG_OOB byte was originally, as indicated by SIOCATMARK. So going back to the previous code seems best all around. ok'd by christos. To generate a diff of this commit: cvs rdiff -u -r1.47 -r1.48 src/usr.bin/rlogin/rlogin.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/rlogin/rlogin.c diff -u src/usr.bin/rlogin/rlogin.c:1.47 src/usr.bin/rlogin/rlogin.c:1.48 --- src/usr.bin/rlogin/rlogin.c:1.47 Sun May 3 16:32:16 2020 +++ src/usr.bin/rlogin/rlogin.c Tue Aug 3 23:21:07 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: rlogin.c,v 1.47 2020/05/03 16:32:16 christos Exp $ */ +/* $NetBSD: rlogin.c,v 1.48 2021/08/03 23:21:07 chs Exp $ */ /* * Copyright (c) 1983, 1990, 1993 @@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 19 #if 0 static char sccsid[] = "@(#)rlogin.c 8.4 (Berkeley) 4/29/95"; #else -__RCSID("$NetBSD: rlogin.c,v 1.47 2020/05/03 16:32:16 christos Exp $"); +__RCSID("$NetBSD: rlogin.c,v 1.48 2021/08/03 23:21:07 chs Exp $"); #endif #endif /* not lint */ @@ -577,34 +577,16 @@ static pid_t ppid; static ssize_t rcvcnt, rcvstate; static char rcvbuf[8 * 1024]; -static int -recvx(int fd, void *buf, size_t len, int flags, int *msgflags) -{ - struct msghdr msg; - struct iovec iov; - int error; - - memset(, 0, sizeof(msg)); - msg.msg_iov = - iov.iov_base = buf; - iov.iov_len = len; - error = recvmsg(fd, , flags); - if (error) - return error; - *msgflags = msg.msg_flags; - return 0; -} - static void oob(int signo) { struct termios tty; - int atmark = 0; + int atmark; ssize_t n, rcvd; char waste[BUFSIZ], mark; rcvd = 0; - while (recvx(rem, , 1, MSG_OOB, ) == -1) { + while (recv(rem, , 1, MSG_OOB) == -1) { switch (errno) { case EWOULDBLOCK: /* @@ -628,7 +610,6 @@ oob(int signo) return; } } - atmark &= MSG_OOB; if (mark & TIOCPKT_WINDOW) { /* Let server know about window size changes */ (void)kill(ppid, SIGUSR1); @@ -645,8 +626,17 @@ oob(int signo) } if (mark & TIOCPKT_FLUSHWRITE) { (void)tcflush(1, TCIOFLUSH); - if (!atmark) + for (;;) { + if (ioctl(rem, SIOCATMARK, ) < 0) { +warn("ioctl SIOCATMARK (ignored)"); +break; + } + if (atmark) +break; n = read(rem, waste, sizeof (waste)); + if (n <= 0) +break; + } /* * Don't want any pending data to be output, so clear the recv * buffer. If we were hanging on a write when interrupted,
CVS commit: src/sys/kern
Module Name:src Committed By: chs Date: Tue Aug 3 20:27:08 UTC 2021 Modified Files: src/sys/kern: uipc_socket.c Log Message: in sbsavetimestamp(), initialize struct timeval to 0 with memset() so that the implicit padding is initialized. this avoids later copying uninitialized memory out to user space. detected by KMSAN. To generate a diff of this commit: cvs rdiff -u -r1.294 -r1.295 src/sys/kern/uipc_socket.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/uipc_socket.c diff -u src/sys/kern/uipc_socket.c:1.294 src/sys/kern/uipc_socket.c:1.295 --- src/sys/kern/uipc_socket.c:1.294 Fri Dec 11 03:00:09 2020 +++ src/sys/kern/uipc_socket.c Tue Aug 3 20:27:08 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: uipc_socket.c,v 1.294 2020/12/11 03:00:09 thorpej Exp $ */ +/* $NetBSD: uipc_socket.c,v 1.295 2021/08/03 20:27:08 chs Exp $ */ /* * Copyright (c) 2002, 2007, 2008, 2009 The NetBSD Foundation, Inc. @@ -71,7 +71,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.294 2020/12/11 03:00:09 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.295 2021/08/03 20:27:08 chs Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd.h" @@ -2432,6 +2432,7 @@ sbsavetimestamp(int opt, struct mbuf **m struct timeval tv; int error; + memset(, 0, sizeof(tv)); microtime(); MODULE_HOOK_CALL(uipc_socket_50_sbts_hook, (opt, ), enosys(), error);
CVS commit: src/sys/kern
Module Name:src Committed By: chs Date: Tue Aug 3 20:25:43 UTC 2021 Modified Files: src/sys/kern: vfs_wapbl.c Log Message: initialize wc_unused to 0, to avoid writing uninitialized memory to disk. detected by KMSAN. To generate a diff of this commit: cvs rdiff -u -r1.108 -r1.109 src/sys/kern/vfs_wapbl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vfs_wapbl.c diff -u src/sys/kern/vfs_wapbl.c:1.108 src/sys/kern/vfs_wapbl.c:1.109 --- src/sys/kern/vfs_wapbl.c:1.108 Sun Apr 12 17:02:52 2020 +++ src/sys/kern/vfs_wapbl.c Tue Aug 3 20:25:43 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_wapbl.c,v 1.108 2020/04/12 17:02:52 jdolecek Exp $ */ +/* $NetBSD: vfs_wapbl.c,v 1.109 2021/08/03 20:25:43 chs Exp $ */ /*- * Copyright (c) 2003, 2008, 2009 The NetBSD Foundation, Inc. @@ -36,7 +36,7 @@ #define WAPBL_INTERNAL #include -__KERNEL_RCSID(0, "$NetBSD: vfs_wapbl.c,v 1.108 2020/04/12 17:02:52 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_wapbl.c,v 1.109 2021/08/03 20:25:43 chs Exp $"); #include #include @@ -2559,6 +2559,7 @@ wapbl_write_blocks(struct wapbl *wl, off wc->wc_type = WAPBL_WC_BLOCKS; wc->wc_len = blocklen; wc->wc_blkcount = 0; + wc->wc_unused = 0; while (bp && (wc->wc_blkcount < wl->wl_brperjblock)) { /* * Make sure all the physical block numbers are up to @@ -2647,6 +2648,7 @@ wapbl_write_revocations(struct wapbl *wl wc->wc_type = WAPBL_WC_REVOCATIONS; wc->wc_len = blocklen; wc->wc_blkcount = 0; + wc->wc_unused = 0; while (wd && (wc->wc_blkcount < wl->wl_brperjblock)) { wc->wc_blocks[wc->wc_blkcount].wc_daddr = wd->wd_blkno;
CVS commit: src/external/gpl2/gettext/dist/gettext-runtime
Module Name:src Committed By: chs Date: Tue Aug 3 20:22:15 UTC 2021 Modified Files: src/external/gpl2/gettext/dist/gettext-runtime: Makefile.in Log Message: do not descend into the man or tests directory. this avoids a problem where git sets the file timestamps differently than CVS does and accidentally causes make to try to rebuild various targets that don't work during the tools build. this matches the change that was made to Makefile.am in our tree. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 \ src/external/gpl2/gettext/dist/gettext-runtime/Makefile.in Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/gpl2/gettext/dist/gettext-runtime/Makefile.in diff -u src/external/gpl2/gettext/dist/gettext-runtime/Makefile.in:1.2 src/external/gpl2/gettext/dist/gettext-runtime/Makefile.in:1.3 --- src/external/gpl2/gettext/dist/gettext-runtime/Makefile.in:1.2 Tue Jan 12 22:58:02 2016 +++ src/external/gpl2/gettext/dist/gettext-runtime/Makefile.in Tue Aug 3 20:22:15 2021 @@ -347,7 +347,7 @@ ACLOCAL_AMFLAGS = -I m4 -I ../autoconf-l # The list of subdirectories depends on whether --disable-libasprintf was # specified. @ENABLE_LIBASPRINTF_TRUE@SUBDIR_libasprintf = libasprintf -SUBDIRS = doc intl intl-java intl-csharp gnulib-lib $(SUBDIR_libasprintf) src po man m4 tests +SUBDIRS = doc intl intl-java intl-csharp gnulib-lib $(SUBDIR_libasprintf) src po m4 # Allow users to use "gnulib-tool --update".
CVS commit: src/sys/arch/powerpc/oea
Module Name:src Committed By: chs Date: Mon Jul 19 14:49:45 UTC 2021 Modified Files: src/sys/arch/powerpc/oea: pmap.c Log Message: there is no need to keep pvos for unmanaged mappings on a hidden p/v list, since "unmanaged" means that we don't want to find such pvos on any p/v list. instead, just don't put such pvos on any p/v list at all and remove the two hidden p/v lists for unmanaged mappings. code mostly from martin, to implement rin's suggestion of unifying the two hidden lists. To generate a diff of this commit: cvs rdiff -u -r1.106 -r1.107 src/sys/arch/powerpc/oea/pmap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/powerpc/oea/pmap.c diff -u src/sys/arch/powerpc/oea/pmap.c:1.106 src/sys/arch/powerpc/oea/pmap.c:1.107 --- src/sys/arch/powerpc/oea/pmap.c:1.106 Sun Jun 27 12:26:33 2021 +++ src/sys/arch/powerpc/oea/pmap.c Mon Jul 19 14:49:45 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.106 2021/06/27 12:26:33 martin Exp $ */ +/* $NetBSD: pmap.c,v 1.107 2021/07/19 14:49:45 chs Exp $ */ /*- * Copyright (c) 2001 The NetBSD Foundation, Inc. * All rights reserved. @@ -63,7 +63,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.106 2021/06/27 12:26:33 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.107 2021/07/19 14:49:45 chs Exp $"); #define PMAP_NOOPNAMES @@ -328,8 +328,6 @@ struct pvo_entry { TAILQ_HEAD(pvo_tqhead, pvo_entry); struct pvo_tqhead *pmap_pvo_table; /* pvo entries by ptegroup index */ -static struct pvo_head pmap_pvo_kunmanaged = LIST_HEAD_INITIALIZER(pmap_pvo_kunmanaged); /* list of unmanaged pages */ -static struct pvo_head pmap_pvo_unmanaged = LIST_HEAD_INITIALIZER(pmap_pvo_unmanaged); /* list of unmanaged pages */ struct pool pmap_pool; /* pool for pmap structures */ struct pool pmap_pvo_pool; /* pool for pvo entries */ @@ -652,7 +650,7 @@ pa_to_pvoh(paddr_t pa, struct vm_page ** if (pg_p != NULL) *pg_p = pg; if (pg == NULL) - return _pvo_unmanaged; + return NULL; md = VM_PAGE_TO_MD(pg); return >mdpg_pvoh; } @@ -1410,22 +1408,19 @@ pmap_pvo_check(const struct pvo_entry *p if (PVO_MANAGED_P(pvo)) { pvo_head = pa_to_pvoh(pvo->pvo_pte.pte_lo & PTE_RPGN, NULL); - } else { - if (pvo->pvo_vaddr < VM_MIN_KERNEL_ADDRESS) { - printf("pmap_pvo_check: pvo %p: non kernel address " - "on kernel unmanaged list\n", pvo); + LIST_FOREACH(pvo0, pvo_head, pvo_vlink) { + if (pvo0 == pvo) +break; + } + if (pvo0 == NULL) { + printf("pmap_pvo_check: pvo %p: not present " + "on its vlist head %p\n", pvo, pvo_head); failed = 1; } - pvo_head = _pvo_kunmanaged; - } - LIST_FOREACH(pvo0, pvo_head, pvo_vlink) { - if (pvo0 == pvo) - break; - } - if (pvo0 == NULL) { - printf("pmap_pvo_check: pvo %p: not present " - "on its vlist head %p\n", pvo, pvo_head); - failed = 1; + } else { + KASSERT(pvo->pvo_vaddr >= VM_MIN_KERNEL_ADDRESS); + if (__predict_false(pvo->pvo_vaddr < VM_MIN_KERNEL_ADDRESS)) + failed = 1; } if (pvo != pmap_pvo_find_va(pvo->pvo_pmap, pvo->pvo_vaddr, NULL)) { printf("pmap_pvo_check: pvo %p: not present " @@ -1620,7 +1615,7 @@ pmap_pvo_enter(pmap_t pm, struct pool *p } if (flags & PMAP_WIRED) pvo->pvo_vaddr |= PVO_WIRED; - if (pvo_head != _pvo_kunmanaged) { + if (pvo_head != NULL) { pvo->pvo_vaddr |= PVO_MANAGED; PMAPCOUNT(mappings); } else { @@ -1628,7 +1623,8 @@ pmap_pvo_enter(pmap_t pm, struct pool *p } pmap_pte_create(>pvo_pte, pm, va, pa | pte_lo); - LIST_INSERT_HEAD(pvo_head, pvo, pvo_vlink); + if (pvo_head != NULL) + LIST_INSERT_HEAD(pvo_head, pvo, pvo_vlink); if (PVO_WIRED_P(pvo)) pvo->pvo_pmap->pm_stats.wired_count++; pvo->pvo_pmap->pm_stats.resident_count++; @@ -1728,7 +1724,9 @@ pmap_pvo_remove(struct pvo_entry *pvo, i pvo->pvo_pmap->pm_stats.wired_count--; /* - * Save the REF/CHG bits into their cache if the page is managed. + * If the page is managed: + * Save the REF/CHG bits into their cache. + * Remove the PVO from the P/V list. */ if (PVO_MANAGED_P(pvo)) { register_t ptelo = pvo->pvo_pte.pte_lo; @@ -1760,15 +1758,15 @@ pmap_pvo_remove(struct pvo_entry *pvo, i pmap_attr_save(pg, ptelo & (PTE_REF|PTE_CHG)); } + LIST_REMOVE(pvo, pvo_vlink); PMAPCOUNT(unmappings); } else { PMAPCOUNT(kernel_unmappings); } /* - * Remove the PVO from its lists and return it to the pool. + * Remove the PVO from its list and return it to the pool. */ - LIST_REMOVE(pvo, pvo_vlink); TAILQ_REMOVE(_pvo_table[ptegidx], pvo, pvo_olink); if (pvol) { LIST_INSERT_HEAD(pvol, pvo, pvo_vlink); @@ -1861,9 +1859,10 @@ pmap_enter(pmap_t pm, vaddr_t va, paddr_ PMAP_LOCK(); if (__predict_false(!pmap_initialized)) { - pvo_head = _pvo_kunmanaged; + pvo_head = NULL; pg = NULL; was_exec = PTE_EXEC; + } else { pvo_head = pa_to_pvoh(pa, ); } @@ -1952,7 +1951,6 @@ pmap_enter(pmap_t pm,
CVS commit: src/sys/uvm
Module Name:src Committed By: chs Date: Thu Jul 1 15:06:01 UTC 2021 Modified Files: src/sys/uvm: uvm_map.c Log Message: in uvm_mapent_forkzero(), if the old entry was an object mapping, appease a debug check by setting the new entry offset to zero along with setting the new entry object pointer to NULL. Reported-by: syzbot+de8e4b223a3838c73...@syzkaller.appspotmail.com Reported-by: syzbot+efaea991addfdcc5a...@syzkaller.appspotmail.com Reported-by: syzbot+15d1e19dff9209c2e...@syzkaller.appspotmail.com To generate a diff of this commit: cvs rdiff -u -r1.389 -r1.390 src/sys/uvm/uvm_map.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/uvm/uvm_map.c diff -u src/sys/uvm/uvm_map.c:1.389 src/sys/uvm/uvm_map.c:1.390 --- src/sys/uvm/uvm_map.c:1.389 Sun Jun 20 07:11:38 2021 +++ src/sys/uvm/uvm_map.c Thu Jul 1 15:06:01 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: uvm_map.c,v 1.389 2021/06/20 07:11:38 mrg Exp $ */ +/* $NetBSD: uvm_map.c,v 1.390 2021/07/01 15:06:01 chs Exp $ */ /* * Copyright (c) 1997 Charles D. Cranor and Washington University. @@ -66,7 +66,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uvm_map.c,v 1.389 2021/06/20 07:11:38 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uvm_map.c,v 1.390 2021/07/01 15:06:01 chs Exp $"); #include "opt_ddb.h" #include "opt_pax.h" @@ -4451,6 +4451,7 @@ uvm_mapent_forkzero(struct vm_map *new_m new_entry->object.uvm_obj->pgops->pgo_detach( new_entry->object.uvm_obj); new_entry->object.uvm_obj = NULL; + new_entry->offset = 0; new_entry->etype &= ~UVM_ET_OBJ; } }
CVS commit: src/sys
Module Name:src Committed By: chs Date: Mon Jun 28 17:52:13 UTC 2021 Modified Files: src/sys/fs/ptyfs: ptyfs_vnops.c src/sys/miscfs/fdesc: fdesc_vnops.c src/sys/miscfs/kernfs: kernfs_vnops.c src/sys/miscfs/procfs: procfs_vnops.c Log Message: VOP_BMAP() may be called via ioctl(FIOGETBMAP) on any vnode that applications can open. change various pseudo-fs *_bmap methods return an error instead of panic. Reported-by: syzbot+8289a3eaf2ba60958...@syzkaller.appspotmail.com To generate a diff of this commit: cvs rdiff -u -r1.62 -r1.63 src/sys/fs/ptyfs/ptyfs_vnops.c cvs rdiff -u -r1.135 -r1.136 src/sys/miscfs/fdesc/fdesc_vnops.c cvs rdiff -u -r1.166 -r1.167 src/sys/miscfs/kernfs/kernfs_vnops.c cvs rdiff -u -r1.215 -r1.216 src/sys/miscfs/procfs/procfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/ptyfs/ptyfs_vnops.c diff -u src/sys/fs/ptyfs/ptyfs_vnops.c:1.62 src/sys/fs/ptyfs/ptyfs_vnops.c:1.63 --- src/sys/fs/ptyfs/ptyfs_vnops.c:1.62 Fri Nov 27 14:43:57 2020 +++ src/sys/fs/ptyfs/ptyfs_vnops.c Mon Jun 28 17:52:12 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: ptyfs_vnops.c,v 1.62 2020/11/27 14:43:57 christos Exp $ */ +/* $NetBSD: ptyfs_vnops.c,v 1.63 2021/06/28 17:52:12 chs Exp $ */ /* * Copyright (c) 1993, 1995 @@ -76,7 +76,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ptyfs_vnops.c,v 1.62 2020/11/27 14:43:57 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ptyfs_vnops.c,v 1.63 2021/06/28 17:52:12 chs Exp $"); #include #include @@ -144,7 +144,7 @@ int ptyfs_reclaim (void *); int ptyfs_inactive (void *); #define ptyfs_lock genfs_lock #define ptyfs_unlock genfs_unlock -#define ptyfs_bmap genfs_badop +#define ptyfs_bmap genfs_eopnotsupp #define ptyfs_strategy genfs_badop int ptyfs_print (void *); int ptyfs_pathconf (void *); Index: src/sys/miscfs/fdesc/fdesc_vnops.c diff -u src/sys/miscfs/fdesc/fdesc_vnops.c:1.135 src/sys/miscfs/fdesc/fdesc_vnops.c:1.136 --- src/sys/miscfs/fdesc/fdesc_vnops.c:1.135 Sat May 1 15:08:14 2021 +++ src/sys/miscfs/fdesc/fdesc_vnops.c Mon Jun 28 17:52:13 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: fdesc_vnops.c,v 1.135 2021/05/01 15:08:14 hannken Exp $ */ +/* $NetBSD: fdesc_vnops.c,v 1.136 2021/06/28 17:52:13 chs Exp $ */ /* * Copyright (c) 1992, 1993 @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: fdesc_vnops.c,v 1.135 2021/05/01 15:08:14 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fdesc_vnops.c,v 1.136 2021/06/28 17:52:13 chs Exp $"); #include #include @@ -104,7 +104,7 @@ int fdesc_inactive(void *); int fdesc_reclaim(void *); #define fdesc_lock genfs_lock #define fdesc_unlock genfs_unlock -#define fdesc_bmap genfs_badop +#define fdesc_bmap genfs_eopnotsupp #define fdesc_strategy genfs_badop int fdesc_print(void *); int fdesc_pathconf(void *); Index: src/sys/miscfs/kernfs/kernfs_vnops.c diff -u src/sys/miscfs/kernfs/kernfs_vnops.c:1.166 src/sys/miscfs/kernfs/kernfs_vnops.c:1.167 --- src/sys/miscfs/kernfs/kernfs_vnops.c:1.166 Sat Jun 27 17:29:19 2020 +++ src/sys/miscfs/kernfs/kernfs_vnops.c Mon Jun 28 17:52:13 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: kernfs_vnops.c,v 1.166 2020/06/27 17:29:19 christos Exp $ */ +/* $NetBSD: kernfs_vnops.c,v 1.167 2021/06/28 17:52:13 chs Exp $ */ /* * Copyright (c) 1992, 1993 @@ -39,7 +39,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kernfs_vnops.c,v 1.166 2020/06/27 17:29:19 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kernfs_vnops.c,v 1.167 2021/06/28 17:52:13 chs Exp $"); #include #include @@ -166,7 +166,7 @@ int kernfs_reclaim(void *); #define kernfs_lock genfs_lock #define kernfs_unlock genfs_unlock #define kernfs_bmap genfs_badop -#define kernfs_strategy genfs_badop +#define kernfs_strategy genfs_eopnotsupp int kernfs_print(void *); #define kernfs_islocked genfs_islocked int kernfs_pathconf(void *); Index: src/sys/miscfs/procfs/procfs_vnops.c diff -u src/sys/miscfs/procfs/procfs_vnops.c:1.215 src/sys/miscfs/procfs/procfs_vnops.c:1.216 --- src/sys/miscfs/procfs/procfs_vnops.c:1.215 Sat Jun 27 17:29:19 2020 +++ src/sys/miscfs/procfs/procfs_vnops.c Mon Jun 28 17:52:13 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: procfs_vnops.c,v 1.215 2020/06/27 17:29:19 christos Exp $ */ +/* $NetBSD: procfs_vnops.c,v 1.216 2021/06/28 17:52:13 chs Exp $ */ /*- * Copyright (c) 2006, 2007, 2008, 2020 The NetBSD Foundation, Inc. @@ -105,7 +105,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: procfs_vnops.c,v 1.215 2020/06/27 17:29:19 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: procfs_vnops.c,v 1.216 2021/06/28 17:52:13 chs Exp $"); #include #include @@ -237,7 +237,7 @@ int procfs_inactive(void *); int procfs_reclaim(void *); #define procfs_lock genfs_lock #define procfs_unlock genfs_unlock -#define procfs_bmap genfs_badop +#define procfs_bmap genfs_eopnotsupp #define procfs_strategy genfs_badop int procfs_print(void *); int procfs_pathconf(void *);
CVS commit: src/usr.bin/kdump
Module Name:src Committed By: chs Date: Sun Jun 20 00:25:29 UTC 2021 Modified Files: src/usr.bin/kdump: kdump.c Log Message: fix printf format string for xattr names (the length of the xattr name needs to be a precision rather than a width). To generate a diff of this commit: cvs rdiff -u -r1.139 -r1.140 src/usr.bin/kdump/kdump.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/kdump/kdump.c diff -u src/usr.bin/kdump/kdump.c:1.139 src/usr.bin/kdump/kdump.c:1.140 --- src/usr.bin/kdump/kdump.c:1.139 Thu Apr 30 15:12:25 2020 +++ src/usr.bin/kdump/kdump.c Sun Jun 20 00:25:29 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: kdump.c,v 1.139 2020/04/30 15:12:25 martin Exp $ */ +/* $NetBSD: kdump.c,v 1.140 2021/06/20 00:25:29 chs Exp $ */ /*- * Copyright (c) 1988, 1993 @@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 19 #if 0 static char sccsid[] = "@(#)kdump.c 8.4 (Berkeley) 4/28/95"; #else -__RCSID("$NetBSD: kdump.c,v 1.139 2020/04/30 15:12:25 martin Exp $"); +__RCSID("$NetBSD: kdump.c,v 1.140 2021/06/20 00:25:29 chs Exp $"); #endif #endif /* not lint */ @@ -1288,7 +1288,7 @@ ktruser_soname(const char *name, const v static void ktruser_xattr_name(const char *name, const void *buf, size_t len) { - printf("%.*s: [%*s]\n", KTR_USER_MAXIDLEN, name, (int)len, + printf("%.*s: [%.*s]\n", KTR_USER_MAXIDLEN, name, (int)len, (const char *)buf); }
CVS commit: src/sys/external/bsd/acpica/dist/namespace
Module Name:src Committed By: chs Date: Sun May 30 16:25:35 UTC 2021 Modified Files: src/sys/external/bsd/acpica/dist/namespace: nsaccess.c Log Message: avoid dereferencing a constant string address as a UINT32 pointer, KUBSAN complains about bad alignment. Reported-by: syzbot+91187f4e33436ce83...@syzkaller.appspotmail.com To generate a diff of this commit: cvs rdiff -u -r1.20 -r1.21 \ src/sys/external/bsd/acpica/dist/namespace/nsaccess.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/external/bsd/acpica/dist/namespace/nsaccess.c diff -u src/sys/external/bsd/acpica/dist/namespace/nsaccess.c:1.20 src/sys/external/bsd/acpica/dist/namespace/nsaccess.c:1.21 --- src/sys/external/bsd/acpica/dist/namespace/nsaccess.c:1.20 Sat Apr 3 17:45:03 2021 +++ src/sys/external/bsd/acpica/dist/namespace/nsaccess.c Sun May 30 16:25:35 2021 @@ -79,6 +79,7 @@ AcpiNsRootInitialize ( ACPI_NAMESPACE_NODE *PrevNode = NULL; ACPI_OPERAND_OBJECT *ObjDesc; ACPI_STRING Val = NULL; +UINT32 Name; ACPI_FUNCTION_TRACE (NsRootInitialize); @@ -143,7 +144,8 @@ AcpiNsRootInitialize ( * predefined names are at the root level. It is much easier to * just create and link the new node(s) here. */ -NewNode = AcpiNsCreateNode (*ACPI_CAST_PTR (UINT32, InitVal->Name)); +memcpy(, InitVal->Name, sizeof(Name)); +NewNode = AcpiNsCreateNode (Name); if (!NewNode) { Status = AE_NO_MEMORY;
CVS commit: src/sys/uvm
Module Name:src Committed By: chs Date: Fri Mar 26 09:35:18 UTC 2021 Modified Files: src/sys/uvm: uvm_pglist.c Log Message: in uvm_pglistalloc_contig_aggressive(), avoid looking forward past the end of the target range of the physseg. fixes PR 56074. To generate a diff of this commit: cvs rdiff -u -r1.87 -r1.88 src/sys/uvm/uvm_pglist.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/uvm/uvm_pglist.c diff -u src/sys/uvm/uvm_pglist.c:1.87 src/sys/uvm/uvm_pglist.c:1.88 --- src/sys/uvm/uvm_pglist.c:1.87 Wed Mar 24 06:37:27 2021 +++ src/sys/uvm/uvm_pglist.c Fri Mar 26 09:35:18 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: uvm_pglist.c,v 1.87 2021/03/24 06:37:27 skrll Exp $ */ +/* $NetBSD: uvm_pglist.c,v 1.88 2021/03/26 09:35:18 chs Exp $ */ /*- * Copyright (c) 1997, 2019 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uvm_pglist.c,v 1.87 2021/03/24 06:37:27 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uvm_pglist.c,v 1.88 2021/03/26 09:35:18 chs Exp $"); #include #include @@ -401,6 +401,9 @@ uvm_pglistalloc_contig_aggressive(int nu * Look forward for any remaining pages. */ + if (spa + ptoa(num) > rhi) { + continue; + } for (; run < num; run++) { pg = PHYS_TO_VM_PAGE(spa + ptoa(run)); if ((pg->flags & PG_PGLCA) == 0) {
CVS commit: src/tests/rump/rumpkern
Module Name:src Committed By: chs Date: Fri Jan 22 22:03:01 UTC 2021 Modified Files: src/tests/rump/rumpkern: t_vm.c Log Message: for the busypage test, replace atf_tc_expect_fail() with atf_tc_skip() because atf apparently has no way to expect a test program to crash. fixes PR 55945. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/tests/rump/rumpkern/t_vm.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/rump/rumpkern/t_vm.c diff -u src/tests/rump/rumpkern/t_vm.c:1.5 src/tests/rump/rumpkern/t_vm.c:1.6 --- src/tests/rump/rumpkern/t_vm.c:1.5 Tue Dec 8 17:52:11 2020 +++ src/tests/rump/rumpkern/t_vm.c Fri Jan 22 22:03:01 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: t_vm.c,v 1.5 2020/12/08 17:52:11 chs Exp $ */ +/* $NetBSD: t_vm.c,v 1.6 2021/01/22 22:03:01 chs Exp $ */ /*- * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -50,7 +50,10 @@ ATF_TC_HEAD(busypage, tc) ATF_TC_BODY(busypage, tc) { +#if 0 atf_tc_expect_fail("test bug: unbusies an uninitialized page"); +#endif + atf_tc_skip("this test is buggy and hits an assertion, but atf doesn't provide any way to expect that a test program crashes, this all we can do is skip"); rump_init(); rump_schedule();
CVS commit: src/sys/rump/librump/rumpkern
Module Name:src Committed By: chs Date: Sun Jan 17 22:32:25 UTC 2021 Modified Files: src/sys/rump/librump/rumpkern: rump.c Log Message: rump_component_init() is called recursively, so LIST_FOREACH_SAFE is not actually safe, since the recursive calls can result in elements other than the current element being removed from the list. instead use an explicit marker element to do safe list traversal. To generate a diff of this commit: cvs rdiff -u -r1.352 -r1.353 src/sys/rump/librump/rumpkern/rump.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/rump/librump/rumpkern/rump.c diff -u src/sys/rump/librump/rumpkern/rump.c:1.352 src/sys/rump/librump/rumpkern/rump.c:1.353 --- src/sys/rump/librump/rumpkern/rump.c:1.352 Sat Jan 16 23:50:49 2021 +++ src/sys/rump/librump/rumpkern/rump.c Sun Jan 17 22:32:25 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: rump.c,v 1.352 2021/01/16 23:50:49 chs Exp $ */ +/* $NetBSD: rump.c,v 1.353 2021/01/17 22:32:25 chs Exp $ */ /* * Copyright (c) 2007-2011 Antti Kantee. All Rights Reserved. @@ -26,7 +26,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: rump.c,v 1.352 2021/01/16 23:50:49 chs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rump.c,v 1.353 2021/01/17 22:32:25 chs Exp $"); #include #define ELFSIZE ARCH_ELFSIZE @@ -605,14 +605,22 @@ rump_component_count(enum rump_component void rump_component_init(enum rump_component_type type) { - struct rump_component *rc, *rc_safe; + struct rump_component *rc, *rc_next, rc_marker; KASSERT(curlwp == bootlwp); KASSERT(!compinited[type]); - LIST_FOREACH_SAFE(rc, , rc_entries, rc_safe) { + + rc_marker.rc_type = RUMP_COMPONENT_MAX; + rc_marker.rc_init = NULL; + for (rc = LIST_FIRST(); rc != NULL; rc = rc_next) { if (rc->rc_type == type) { + LIST_INSERT_AFTER(rc, _marker, rc_entries); rc->rc_init(); LIST_REMOVE(rc, rc_entries); + rc_next = LIST_NEXT(_marker, rc_entries); + LIST_REMOVE(_marker, rc_entries); + } else { + rc_next = LIST_NEXT(rc, rc_entries); } } compinited[type] = 1;
CVS commit: src/sys
Module Name:src Committed By: chs Date: Sat Jan 16 23:51:51 UTC 2021 Modified Files: src/sys/arch/arm/arm: psci.c src/sys/conf: files src/sys/lib/libkern: libkern.h src/sys/lib/libkern/arch/hppa: bcopy.S src/sys/sys: cdefs.h queue.h Log Message: remove unused "_DIAGNOSTIC" option and opt_diagnostic.h. note that this is unrelated to the widely used "DIAGNOSTIC" option. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/arm/psci.c cvs rdiff -u -r1.1277 -r1.1278 src/sys/conf/files cvs rdiff -u -r1.140 -r1.141 src/sys/lib/libkern/libkern.h cvs rdiff -u -r1.15 -r1.16 src/sys/lib/libkern/arch/hppa/bcopy.S cvs rdiff -u -r1.155 -r1.156 src/sys/sys/cdefs.h cvs rdiff -u -r1.75 -r1.76 src/sys/sys/queue.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/arm/psci.c diff -u src/sys/arch/arm/arm/psci.c:1.4 src/sys/arch/arm/arm/psci.c:1.5 --- src/sys/arch/arm/arm/psci.c:1.4 Fri Dec 4 08:00:53 2020 +++ src/sys/arch/arm/arm/psci.c Sat Jan 16 23:51:50 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: psci.c,v 1.4 2020/12/04 08:00:53 skrll Exp $ */ +/* $NetBSD: psci.c,v 1.5 2021/01/16 23:51:50 chs Exp $ */ /*- * Copyright (c) 2017 Jared McNeill @@ -26,10 +26,8 @@ * SUCH DAMAGE. */ -#include "opt_diagnostic.h" - #include -__KERNEL_RCSID(0, "$NetBSD: psci.c,v 1.4 2020/12/04 08:00:53 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: psci.c,v 1.5 2021/01/16 23:51:50 chs Exp $"); #include #include Index: src/sys/conf/files diff -u src/sys/conf/files:1.1277 src/sys/conf/files:1.1278 --- src/sys/conf/files:1.1277 Tue Oct 27 08:57:11 2020 +++ src/sys/conf/files Sat Jan 16 23:51:50 2021 @@ -1,4 +1,4 @@ -# $NetBSD: files,v 1.1277 2020/10/27 08:57:11 ryo Exp $ +# $NetBSD: files,v 1.1278 2021/01/16 23:51:50 chs Exp $ # @(#)files.newconf 7.5 (Berkeley) 5/10/93 version 20171118 @@ -27,7 +27,6 @@ defflag opt_modular.h MODULAR defflag opt_modular.h MODULAR_DEFAULT_AUTOLOAD defflagKEYLOCK defparam opt_syslimits.h CHILD_MAX OPEN_MAX -defflag opt_diagnostic.h _DIAGNOSTIC defflagGPROF defflagKASAN defflag opt_kasan.h KASAN_PANIC Index: src/sys/lib/libkern/libkern.h diff -u src/sys/lib/libkern/libkern.h:1.140 src/sys/lib/libkern/libkern.h:1.141 --- src/sys/lib/libkern/libkern.h:1.140 Fri Apr 17 17:24:46 2020 +++ src/sys/lib/libkern/libkern.h Sat Jan 16 23:51:51 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: libkern.h,v 1.140 2020/04/17 17:24:46 maxv Exp $ */ +/* $NetBSD: libkern.h,v 1.141 2021/01/16 23:51:51 chs Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -35,7 +35,6 @@ #define _LIB_LIBKERN_LIBKERN_H_ #ifdef _KERNEL_OPT -#include "opt_diagnostic.h" #include "opt_kasan.h" #include "opt_kcsan.h" #include "opt_kmsan.h" Index: src/sys/lib/libkern/arch/hppa/bcopy.S diff -u src/sys/lib/libkern/arch/hppa/bcopy.S:1.15 src/sys/lib/libkern/arch/hppa/bcopy.S:1.16 --- src/sys/lib/libkern/arch/hppa/bcopy.S:1.15 Sun Aug 30 07:55:45 2015 +++ src/sys/lib/libkern/arch/hppa/bcopy.S Sat Jan 16 23:51:51 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: bcopy.S,v 1.15 2015/08/30 07:55:45 uebayasi Exp $ */ +/* $NetBSD: bcopy.S,v 1.16 2021/01/16 23:51:51 chs Exp $ */ /* * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -38,7 +38,6 @@ #if defined(SPCOPY) && !defined(_STANDALONE) -#include "opt_diagnostic.h" #include "opt_multiprocessor.h" #include @@ -50,7 +49,7 @@ #include #if defined(LIBC_SCCS) && !defined(lint) -RCSID("$NetBSD: bcopy.S,v 1.15 2015/08/30 07:55:45 uebayasi Exp $") +RCSID("$NetBSD: bcopy.S,v 1.16 2021/01/16 23:51:51 chs Exp $") #endif /* LIBC_SCCS and not lint */ /* Index: src/sys/sys/cdefs.h diff -u src/sys/sys/cdefs.h:1.155 src/sys/sys/cdefs.h:1.156 --- src/sys/sys/cdefs.h:1.155 Fri Dec 4 20:38:44 2020 +++ src/sys/sys/cdefs.h Sat Jan 16 23:51:51 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: cdefs.h,v 1.155 2020/12/04 20:38:44 christos Exp $ */ +/* $NetBSD: cdefs.h,v 1.156 2021/01/16 23:51:51 chs Exp $ */ /* * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. @@ -36,10 +36,6 @@ #ifndef _SYS_CDEFS_H_ #define _SYS_CDEFS_H_ -#ifdef _KERNEL_OPT -#include "opt_diagnostic.h" -#endif - /* * Macro to test if we're using a GNU C compiler of a specific vintage * or later, for e.g. features that appeared in a particular version Index: src/sys/sys/queue.h diff -u src/sys/sys/queue.h:1.75 src/sys/sys/queue.h:1.76 --- src/sys/sys/queue.h:1.75 Tue Oct 20 23:27:58 2020 +++ src/sys/sys/queue.h Sat Jan 16 23:51:51 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: queue.h,v 1.75 2020/10/20 23:27:58 kamil Exp $ */ +/* $NetBSD: queue.h,v 1.76 2021/01/16 23:51:51 chs Exp $ */ /* * Copyright (c) 1991, 1993 @@ -83,12 +83,9 @@ #include #endif -#if defined(_KERNEL) && defined(_KERNEL_OPT) -#include "opt_diagnostic.h" -#ifdef DIAGNOSTIC +#if defined(_KERNEL) && defined(DIAGNOSTIC) #define QUEUEDEBUG 1 #endif
CVS commit: src/sys/rump/librump/rumpkern
Module Name:src Committed By: chs Date: Sat Jan 16 23:50:49 UTC 2021 Modified Files: src/sys/rump/librump/rumpkern: rump.c Log Message: remove a const to allow building with QUEUEDEBUG. To generate a diff of this commit: cvs rdiff -u -r1.351 -r1.352 src/sys/rump/librump/rumpkern/rump.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/rump/librump/rumpkern/rump.c diff -u src/sys/rump/librump/rumpkern/rump.c:1.351 src/sys/rump/librump/rumpkern/rump.c:1.352 --- src/sys/rump/librump/rumpkern/rump.c:1.351 Sun Dec 6 09:03:29 2020 +++ src/sys/rump/librump/rumpkern/rump.c Sat Jan 16 23:50:49 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: rump.c,v 1.351 2020/12/06 09:03:29 skrll Exp $ */ +/* $NetBSD: rump.c,v 1.352 2021/01/16 23:50:49 chs Exp $ */ /* * Copyright (c) 2007-2011 Antti Kantee. All Rights Reserved. @@ -26,7 +26,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: rump.c,v 1.351 2020/12/06 09:03:29 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rump.c,v 1.352 2021/01/16 23:50:49 chs Exp $"); #include #define ELFSIZE ARCH_ELFSIZE @@ -605,7 +605,7 @@ rump_component_count(enum rump_component void rump_component_init(enum rump_component_type type) { - const struct rump_component *rc, *rc_safe; + struct rump_component *rc, *rc_safe; KASSERT(curlwp == bootlwp); KASSERT(!compinited[type]);
CVS commit: src/sys/arch/sparc/sparc
Module Name:src Committed By: chs Date: Wed Jan 13 16:42:17 UTC 2021 Modified Files: src/sys/arch/sparc/sparc: pmap.c Log Message: in pmap_writetext(), restore the context also when we return early. To generate a diff of this commit: cvs rdiff -u -r1.370 -r1.371 src/sys/arch/sparc/sparc/pmap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/sparc/sparc/pmap.c diff -u src/sys/arch/sparc/sparc/pmap.c:1.370 src/sys/arch/sparc/sparc/pmap.c:1.371 --- src/sys/arch/sparc/sparc/pmap.c:1.370 Mon Jan 11 06:12:43 2021 +++ src/sys/arch/sparc/sparc/pmap.c Wed Jan 13 16:42:17 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.370 2021/01/11 06:12:43 chs Exp $ */ +/* $NetBSD: pmap.c,v 1.371 2021/01/13 16:42:17 chs Exp $ */ /* * Copyright (c) 1996 @@ -56,7 +56,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.370 2021/01/11 06:12:43 chs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.371 2021/01/13 16:42:17 chs Exp $"); #include "opt_ddb.h" #include "opt_kgdb.h" @@ -7868,8 +7868,7 @@ pmap_writetext(unsigned char *dst, int c if (CPU_HAS_SRMMU) { pte0 = getpte4m(va); if ((pte0 & SRMMU_TETYPE) != SRMMU_TEPTE) { - splx(s); - return; + goto out; } pte = pte0 | PPROT_WRITE; setpte4m(va, pte); @@ -7882,8 +7881,7 @@ pmap_writetext(unsigned char *dst, int c if (CPU_ISSUN4C || CPU_ISSUN4) { pte0 = getpte4(va); if ((pte0 & PG_V) == 0) { - splx(s); - return; + goto out; } pte = pte0 | PG_W; setpte4(va, pte); @@ -7892,6 +7890,8 @@ pmap_writetext(unsigned char *dst, int c } #endif cache_flush(dst, 1); + +out: setcontext(ctx); splx(s); }
CVS commit: src/sys/arch/sparc/sparc
Module Name:src Committed By: chs Date: Mon Jan 11 06:12:43 UTC 2021 Modified Files: src/sys/arch/sparc/sparc: pmap.c Log Message: in pgt_page_alloc(), wait and retry the page allocation if PR_WAITOK. fixes PR 55895. To generate a diff of this commit: cvs rdiff -u -r1.369 -r1.370 src/sys/arch/sparc/sparc/pmap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/sparc/sparc/pmap.c diff -u src/sys/arch/sparc/sparc/pmap.c:1.369 src/sys/arch/sparc/sparc/pmap.c:1.370 --- src/sys/arch/sparc/sparc/pmap.c:1.369 Wed Dec 9 11:35:44 2020 +++ src/sys/arch/sparc/sparc/pmap.c Mon Jan 11 06:12:43 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.369 2020/12/09 11:35:44 uwe Exp $ */ +/* $NetBSD: pmap.c,v 1.370 2021/01/11 06:12:43 chs Exp $ */ /* * Copyright (c) 1996 @@ -56,7 +56,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.369 2020/12/09 11:35:44 uwe Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.370 2021/01/11 06:12:43 chs Exp $"); #include "opt_ddb.h" #include "opt_kgdb.h" @@ -907,13 +907,20 @@ pgt_page_alloc(struct pool *pp, int flag paddr_t pa; /* Allocate a page of physical memory */ - if ((pg = uvm_pagealloc(NULL, 0, NULL, 0)) == NULL) - return (NULL); + while ((pg = uvm_pagealloc(NULL, 0, NULL, 0)) == NULL && + (flags & PR_WAITOK) != 0) { + uvm_wait("pgtpg"); + } + if (pg == NULL) { + KASSERT((flags & PR_WAITOK) == 0); + return NULL; + } /* Allocate virtual memory */ va = uvm_km_alloc(kernel_map, PAGE_SIZE, 0, UVM_KMF_VAONLY | ((flags & PR_WAITOK) ? 0 : UVM_KMF_NOWAIT | UVM_KMF_TRYLOCK)); if (va == 0) { + KASSERT((flags & PR_WAITOK) == 0); uvm_pagefree(pg); return (NULL); }
CVS commit: src/sys/kern
Module Name:src Committed By: chs Date: Tue Dec 29 22:13:40 UTC 2020 Modified Files: src/sys/kern: vfs_lookup.c Log Message: Honor LOCKPARENT for ".." of the root directory. Reported-by: syzbot+f40b9f241b818fd12...@syzkaller.appspotmail.com To generate a diff of this commit: cvs rdiff -u -r1.224 -r1.225 src/sys/kern/vfs_lookup.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vfs_lookup.c diff -u src/sys/kern/vfs_lookup.c:1.224 src/sys/kern/vfs_lookup.c:1.225 --- src/sys/kern/vfs_lookup.c:1.224 Mon Jun 15 18:44:10 2020 +++ src/sys/kern/vfs_lookup.c Tue Dec 29 22:13:40 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_lookup.c,v 1.224 2020/06/15 18:44:10 ad Exp $ */ +/* $NetBSD: vfs_lookup.c,v 1.225 2020/12/29 22:13:40 chs Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_lookup.c,v 1.224 2020/06/15 18:44:10 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_lookup.c,v 1.225 2020/12/29 22:13:40 chs Exp $"); #ifdef _KERNEL_OPT #include "opt_magiclinks.h" @@ -1047,6 +1047,28 @@ lookup_crossmount(struct namei_state *st } /* + * Determine the desired locking mode for the directory of a lookup. + */ +static int +lookup_lktype(struct vnode *searchdir, struct componentname *cnp) +{ + + /* + * If the file system supports VOP_LOOKUP() with a shared lock, and + * we are not making any modifications (nameiop LOOKUP) or this is + * not the last component then get a shared lock. Where we can't do + * fast-forwarded lookups (for example with layered file systems) + * then this is the fallback for reducing lock contention. + */ + if ((searchdir->v_mount->mnt_iflag & IMNT_SHRLOOKUP) != 0 && + (cnp->cn_nameiop == LOOKUP || (cnp->cn_flags & ISLASTCN) == 0)) { + return LK_SHARED; + } else { + return LK_EXCLUSIVE; + } +} + +/* * Call VOP_LOOKUP for a single lookup; return a new search directory * (used when crossing mountpoints up or searching union mounts down) and * the found object, which for create operations may be NULL on success. @@ -1100,6 +1122,11 @@ lookup_once(struct namei_state *state, foundobj = searchdir; vref(foundobj); *foundobj_ret = foundobj; +if (cnp->cn_flags & LOCKPARENT) { + lktype = lookup_lktype(searchdir, cnp); + vn_lock(searchdir, lktype | LK_RETRY); + searchdir_locked = true; +} error = 0; goto done; } @@ -1137,19 +1164,7 @@ lookup_once(struct namei_state *state, } } - /* - * If the file system supports VOP_LOOKUP() with a shared lock, and - * we are not making any modifications (nameiop LOOKUP) or this is - * not the last component then get a shared lock. Where we can't do - * fast-forwarded lookups (for example with layered file systems) - * then this is the fallback for reducing lock contention. - */ - if ((searchdir->v_mount->mnt_iflag & IMNT_SHRLOOKUP) != 0 && - (cnp->cn_nameiop == LOOKUP || (cnp->cn_flags & ISLASTCN) == 0)) { - lktype = LK_SHARED; - } else { - lktype = LK_EXCLUSIVE; - } + lktype = lookup_lktype(searchdir, cnp); /* * We now have a segment name to search for, and a directory to search.
CVS commit: src/sys/kern
Module Name:src Committed By: chs Date: Mon Dec 14 23:12:12 UTC 2020 Modified Files: src/sys/kern: uipc_sem.c Log Message: when updating the per-uid "semcnt", decrement the counter for the uid that created the ksem, not the uid of the process freeing the ksem. fixes PR 55509. Reported-by: syzbot+9d04b3ef2ca180ef9...@syzkaller.appspotmail.com To generate a diff of this commit: cvs rdiff -u -r1.59 -r1.60 src/sys/kern/uipc_sem.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/uipc_sem.c diff -u src/sys/kern/uipc_sem.c:1.59 src/sys/kern/uipc_sem.c:1.60 --- src/sys/kern/uipc_sem.c:1.59 Mon May 4 13:58:48 2020 +++ src/sys/kern/uipc_sem.c Mon Dec 14 23:12:12 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: uipc_sem.c,v 1.59 2020/05/04 13:58:48 riastradh Exp $ */ +/* $NetBSD: uipc_sem.c,v 1.60 2020/12/14 23:12:12 chs Exp $ */ /*- * Copyright (c) 2011, 2019 The NetBSD Foundation, Inc. @@ -60,7 +60,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uipc_sem.c,v 1.59 2020/05/04 13:58:48 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uipc_sem.c,v 1.60 2020/12/14 23:12:12 chs Exp $"); #include #include @@ -469,8 +469,6 @@ ksem_create(lwp_t *l, const char *name, len = 0; } - chgsemcnt(kauth_cred_getuid(l->l_cred), 1); - ks = kmem_zalloc(sizeof(ksem_t), KM_SLEEP); mutex_init(>ks_lock, MUTEX_DEFAULT, IPL_NONE); cv_init(>ks_cv, "psem"); @@ -483,8 +481,9 @@ ksem_create(lwp_t *l, const char *name, uc = l->l_cred; ks->ks_uid = kauth_cred_geteuid(uc); ks->ks_gid = kauth_cred_getegid(uc); - + chgsemcnt(ks->ks_uid, 1); atomic_inc_uint(_total); + *ksret = ks; return 0; } @@ -495,6 +494,9 @@ ksem_free(ksem_t *ks) KASSERT(!cv_has_waiters(>ks_cv)); + chgsemcnt(ks->ks_uid, -1); + atomic_dec_uint(_total); + if (ks->ks_pshared_id) { KASSERT(ks->ks_pshared_proc == NULL); ksem_remove_pshared(ks); @@ -506,9 +508,6 @@ ksem_free(ksem_t *ks) mutex_destroy(>ks_lock); cv_destroy(>ks_cv); kmem_free(ks, sizeof(ksem_t)); - - atomic_dec_uint(_total); - chgsemcnt(kauth_cred_getuid(curproc->p_cred), -1); } #define KSEM_ID_IS_PSHARED(id) \
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: chs Date: Sun Dec 13 19:22:02 UTC 2020 Modified Files: src/sys/fs/tmpfs: tmpfs_vnops.c Log Message: Disable use of UBC_FAULTBUSY in tmpfs_write() for now, which brings back zeroing of all new tmpfs data pages. The existing code that enables this optimization skips the zeroing in numerous cases where it is needed, resulting in corrupted files and data leaks from the page's previous identity. To generate a diff of this commit: cvs rdiff -u -r1.144 -r1.145 src/sys/fs/tmpfs/tmpfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/tmpfs/tmpfs_vnops.c diff -u src/sys/fs/tmpfs/tmpfs_vnops.c:1.144 src/sys/fs/tmpfs/tmpfs_vnops.c:1.145 --- src/sys/fs/tmpfs/tmpfs_vnops.c:1.144 Sat Sep 5 16:30:12 2020 +++ src/sys/fs/tmpfs/tmpfs_vnops.c Sun Dec 13 19:22:02 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_vnops.c,v 1.144 2020/09/05 16:30:12 riastradh Exp $ */ +/* $NetBSD: tmpfs_vnops.c,v 1.145 2020/12/13 19:22:02 chs Exp $ */ /* * Copyright (c) 2005, 2006, 2007, 2020 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.144 2020/09/05 16:30:12 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.145 2020/12/13 19:22:02 chs Exp $"); #include #include @@ -616,12 +616,19 @@ tmpfs_write(void *v) * of PG_BUSY and the vnode lock). */ ubc_flags = UBC_WRITE | UBC_VNODE_FLAGS(vp); +#if 0 + /* + * XXX disable use of UBC_FAULTBUSY for now, this check is insufficient + * because it does not zero uninitialized parts of pages in all of + * the cases where zeroing is needed. + */ if (uio->uio_offset >= oldsize && ((uio->uio_offset & (PAGE_SIZE - 1)) == 0 || ((vp->v_vflag & VV_MAPPED) == 0 && trunc_page(uio->uio_offset) == trunc_page(oldsize { ubc_flags |= UBC_FAULTBUSY; } +#endif uobj = node->tn_spec.tn_reg.tn_aobj; error = 0;
CVS commit: src/sys/rump/librump/rumpvfs
Module Name:src Committed By: chs Date: Wed Dec 9 00:03:32 UTC 2020 Modified Files: src/sys/rump/librump/rumpvfs: vm_vfs.c Log Message: make rump's uvm_aio_aiodone_pages() look more like the kernel version. fixes some more rumpy assertions. To generate a diff of this commit: cvs rdiff -u -r1.40 -r1.41 src/sys/rump/librump/rumpvfs/vm_vfs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/rump/librump/rumpvfs/vm_vfs.c diff -u src/sys/rump/librump/rumpvfs/vm_vfs.c:1.40 src/sys/rump/librump/rumpvfs/vm_vfs.c:1.41 --- src/sys/rump/librump/rumpvfs/vm_vfs.c:1.40 Thu Oct 22 03:05:17 2020 +++ src/sys/rump/librump/rumpvfs/vm_vfs.c Wed Dec 9 00:03:32 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: vm_vfs.c,v 1.40 2020/10/22 03:05:17 chs Exp $ */ +/* $NetBSD: vm_vfs.c,v 1.41 2020/12/09 00:03:32 chs Exp $ */ /* * Copyright (c) 2008-2011 Antti Kantee. All Rights Reserved. @@ -26,7 +26,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vm_vfs.c,v 1.40 2020/10/22 03:05:17 chs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vm_vfs.c,v 1.41 2020/12/09 00:03:32 chs Exp $"); #include @@ -48,6 +48,16 @@ uvm_aio_aiodone_pages(struct vm_page **p pg = pgs[i]; KASSERT((pg->flags & PG_PAGEOUT) == 0 || (pg->flags & PG_FAKE) == 0); + + if (pg->flags & PG_FAKE) { + KASSERT(!write); + pg->flags &= ~PG_FAKE; + KASSERT(uvm_pagegetdirty(pg) == UVM_PAGE_STATUS_CLEAN); + uvm_pagelock(pg); + uvm_pageenqueue(pg); + uvm_pageunlock(pg); + } + } uvm_page_unbusy(pgs, npages); rw_exit(uobj->vmobjlock);
CVS commit: src/tests/rump/rumpkern
Module Name:src Committed By: chs Date: Tue Dec 8 17:52:11 UTC 2020 Modified Files: src/tests/rump/rumpkern: t_vm.c Log Message: the busypage test is buggy, expect it to fail. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/tests/rump/rumpkern/t_vm.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/rump/rumpkern/t_vm.c diff -u src/tests/rump/rumpkern/t_vm.c:1.4 src/tests/rump/rumpkern/t_vm.c:1.5 --- src/tests/rump/rumpkern/t_vm.c:1.4 Fri Jan 13 21:30:43 2017 +++ src/tests/rump/rumpkern/t_vm.c Tue Dec 8 17:52:11 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: t_vm.c,v 1.4 2017/01/13 21:30:43 christos Exp $ */ +/* $NetBSD: t_vm.c,v 1.5 2020/12/08 17:52:11 chs Exp $ */ /*- * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -50,6 +50,7 @@ ATF_TC_HEAD(busypage, tc) ATF_TC_BODY(busypage, tc) { + atf_tc_expect_fail("test bug: unbusies an uninitialized page"); rump_init(); rump_schedule();
CVS commit: src/sys/rump/librump/rumpkern
Module Name:src Committed By: chs Date: Sat Dec 5 19:08:50 UTC 2020 Modified Files: src/sys/rump/librump/rumpkern: vm.c Log Message: update the rump copy of uvm_page_unbusy() to match the real version, in particular handle PG_PAGEOUT. fixes a few atf tests. To generate a diff of this commit: cvs rdiff -u -r1.190 -r1.191 src/sys/rump/librump/rumpkern/vm.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/rump/librump/rumpkern/vm.c diff -u src/sys/rump/librump/rumpkern/vm.c:1.190 src/sys/rump/librump/rumpkern/vm.c:1.191 --- src/sys/rump/librump/rumpkern/vm.c:1.190 Thu Jun 11 19:20:46 2020 +++ src/sys/rump/librump/rumpkern/vm.c Sat Dec 5 19:08:50 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: vm.c,v 1.190 2020/06/11 19:20:46 ad Exp $ */ +/* $NetBSD: vm.c,v 1.191 2020/12/05 19:08:50 chs Exp $ */ /* * Copyright (c) 2007-2011 Antti Kantee. All Rights Reserved. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vm.c,v 1.190 2020/06/11 19:20:46 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vm.c,v 1.191 2020/12/05 19:08:50 chs Exp $"); #include #include @@ -673,26 +673,51 @@ void uvm_page_unbusy(struct vm_page **pgs, int npgs) { struct vm_page *pg; - int i; + int i, pageout_done; KASSERT(npgs > 0); - KASSERT(rw_write_held(pgs[0]->uobject->vmobjlock)); + pageout_done = 0; for (i = 0; i < npgs; i++) { pg = pgs[i]; - if (pg == NULL) + if (pg == NULL || pg == PGO_DONTCARE) { continue; + } +#if 0 + KASSERT(uvm_page_owner_locked_p(pg, true)); +#else + /* + * uvm_page_owner_locked_p() is not available in rump, + * and rump doesn't support amaps anyway. + */ + KASSERT(rw_write_held(pg->uobject->vmobjlock)); +#endif KASSERT(pg->flags & PG_BUSY); + + if (pg->flags & PG_PAGEOUT) { + pg->flags &= ~PG_PAGEOUT; + pg->flags |= PG_RELEASED; + pageout_done++; + atomic_inc_uint(); + } if (pg->flags & PG_RELEASED) { + KASSERT(pg->uobject != NULL || + (pg->uanon != NULL && pg->uanon->an_ref > 0)); + pg->flags &= ~PG_RELEASED; uvm_pagefree(pg); } else { + KASSERT((pg->flags & PG_FAKE) == 0); pg->flags &= ~PG_BUSY; uvm_pagelock(pg); uvm_pagewakeup(pg); uvm_pageunlock(pg); + UVM_PAGE_OWN(pg, NULL); } } + if (pageout_done != 0) { + uvm_pageout_done(pageout_done); + } } void
CVS commit: src/sys
Module Name:src Committed By: chs Date: Mon Nov 23 00:52:53 UTC 2020 Modified Files: src/sys/kern: uipc_socket.c src/sys/netinet: tcp_usrreq.c src/sys/sys: socketvar.h Log Message: Restore correct functioning of SIOCATMARK by removing the previous change that was done to fix poll(POLLPRI | POLLRDBAND) and instead add a separate flag to track when poll() should indicate that a MSG_OOB byte is available. Re-fixes PR 54435 properly. To generate a diff of this commit: cvs rdiff -u -r1.292 -r1.293 src/sys/kern/uipc_socket.c cvs rdiff -u -r1.227 -r1.228 src/sys/netinet/tcp_usrreq.c cvs rdiff -u -r1.162 -r1.163 src/sys/sys/socketvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/uipc_socket.c diff -u src/sys/kern/uipc_socket.c:1.292 src/sys/kern/uipc_socket.c:1.293 --- src/sys/kern/uipc_socket.c:1.292 Sat Oct 17 09:06:15 2020 +++ src/sys/kern/uipc_socket.c Mon Nov 23 00:52:53 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: uipc_socket.c,v 1.292 2020/10/17 09:06:15 mlelstv Exp $ */ +/* $NetBSD: uipc_socket.c,v 1.293 2020/11/23 00:52:53 chs Exp $ */ /* * Copyright (c) 2002, 2007, 2008, 2009 The NetBSD Foundation, Inc. @@ -71,7 +71,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.292 2020/10/17 09:06:15 mlelstv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.293 2020/11/23 00:52:53 chs Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd.h" @@ -1186,9 +1186,6 @@ soreceive(struct socket *so, struct mbuf MIN(uio->uio_resid, m->m_len), uio); m = m_free(m); } while (uio->uio_resid > 0 && error == 0 && m); - /* We consumed the oob data, no more oobmark. */ - so->so_oobmark = 0; - so->so_state &= ~SS_RCVATMARK; bad: if (m != NULL) m_freem(m); @@ -1565,6 +1562,8 @@ dontblock: if (offset == so->so_oobmark) break; } + } else { + so->so_state &= ~SS_POLLRDBAND; } if (flags & MSG_EOR) break; @@ -2214,6 +2213,7 @@ void sohasoutofband(struct socket *so) { + so->so_state |= SS_POLLRDBAND; fownsignal(so->so_pgid, SIGURG, POLL_PRI, POLLPRI|POLLRDBAND, so); selnotify(>so_rcv.sb_sel, POLLPRI | POLLRDBAND, NOTE_SUBMIT); } @@ -2388,7 +2388,7 @@ sodopoll(struct socket *so, int events) revents |= events & (POLLOUT | POLLWRNORM); if (events & (POLLPRI | POLLRDBAND)) - if (so->so_oobmark || (so->so_state & SS_RCVATMARK)) + if (so->so_state & SS_POLLRDBAND) revents |= events & (POLLPRI | POLLRDBAND); return revents; Index: src/sys/netinet/tcp_usrreq.c diff -u src/sys/netinet/tcp_usrreq.c:1.227 src/sys/netinet/tcp_usrreq.c:1.228 --- src/sys/netinet/tcp_usrreq.c:1.227 Sat Oct 17 08:50:38 2020 +++ src/sys/netinet/tcp_usrreq.c Mon Nov 23 00:52:53 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: tcp_usrreq.c,v 1.227 2020/10/17 08:50:38 mlelstv Exp $ */ +/* $NetBSD: tcp_usrreq.c,v 1.228 2020/11/23 00:52:53 chs Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -99,7 +99,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tcp_usrreq.c,v 1.227 2020/10/17 08:50:38 mlelstv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tcp_usrreq.c,v 1.228 2020/11/23 00:52:53 chs Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -1095,8 +1095,10 @@ tcp_recvoob(struct socket *so, struct mb m->m_len = 1; *mtod(m, char *) = tp->t_iobc; - if ((flags & MSG_PEEK) == 0) + if ((flags & MSG_PEEK) == 0) { tp->t_oobflags ^= (TCPOOB_HAVEDATA | TCPOOB_HADDATA); + so->so_state &= ~SS_POLLRDBAND; + } tcp_debug_trace(so, tp, ostate, PRU_RCVOOB); splx(s); Index: src/sys/sys/socketvar.h diff -u src/sys/sys/socketvar.h:1.162 src/sys/sys/socketvar.h:1.163 --- src/sys/sys/socketvar.h:1.162 Tue Nov 17 03:22:33 2020 +++ src/sys/sys/socketvar.h Mon Nov 23 00:52:53 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: socketvar.h,v 1.162 2020/11/17 03:22:33 chs Exp $ */ +/* $NetBSD: socketvar.h,v 1.163 2020/11/23 00:52:53 chs Exp $ */ /*- * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. @@ -197,12 +197,12 @@ struct socket { #define SS_RCVATMARK 0x040 /* at mark on input */ #define SS_ISABORTING 0x080 /* aborting fd references - close() */ #define SS_RESTARTSYS 0x100 /* restart blocked system calls */ -#define SS_ISDISCONNECTED 0x800 /* socket disconnected from peer */ - +#define SS_POLLRDBAND 0x200 /* poll should return POLLRDBAND */ #define SS_MORETOCOME 0x400 /* * hint from sosend to lower layer; * more data coming */ +#define SS_ISDISCONNECTED 0x800 /* socket disconnected from peer */ #define SS_ISAPIPE 0x1000 /* socket is implementing a pipe */ #define SS_NBIO 0x2000 /* socket is in non blocking I/O */
CVS commit: src/sys
Module Name:src Committed By: chs Date: Tue Nov 17 03:22:33 UTC 2020 Modified Files: src/sys/kern: sys_socket.c src/sys/sys: socketvar.h Log Message: When SS_RESTARTSYS was added, it was accidentally given the same value as the existing SS_ASYNC. SS_ASYNC was already vestigial at that point, having been superceded by SB_ASYNC, however the SS_ASYNC flag is still set and cleared, unlessly because it is never checked. Fix this conflict by removing SS_ASYNC and its vestigial uses. To generate a diff of this commit: cvs rdiff -u -r1.78 -r1.79 src/sys/kern/sys_socket.c cvs rdiff -u -r1.161 -r1.162 src/sys/sys/socketvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/sys_socket.c diff -u src/sys/kern/sys_socket.c:1.78 src/sys/kern/sys_socket.c:1.79 --- src/sys/kern/sys_socket.c:1.78 Tue Dec 4 00:18:05 2018 +++ src/sys/kern/sys_socket.c Tue Nov 17 03:22:33 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: sys_socket.c,v 1.78 2018/12/04 00:18:05 maya Exp $ */ +/* $NetBSD: sys_socket.c,v 1.79 2020/11/17 03:22:33 chs Exp $ */ /*- * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. @@ -61,7 +61,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sys_socket.c,v 1.78 2018/12/04 00:18:05 maya Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sys_socket.c,v 1.79 2020/11/17 03:22:33 chs Exp $"); #include #include @@ -141,11 +141,9 @@ soo_ioctl(file_t *fp, u_long cmd, void * case FIOASYNC: solock(so); if (*(int *)data) { - so->so_state |= SS_ASYNC; so->so_rcv.sb_flags |= SB_ASYNC; so->so_snd.sb_flags |= SB_ASYNC; } else { - so->so_state &= ~SS_ASYNC; so->so_rcv.sb_flags &= ~SB_ASYNC; so->so_snd.sb_flags &= ~SB_ASYNC; } Index: src/sys/sys/socketvar.h diff -u src/sys/sys/socketvar.h:1.161 src/sys/sys/socketvar.h:1.162 --- src/sys/sys/socketvar.h:1.161 Mon Oct 5 08:38:17 2020 +++ src/sys/sys/socketvar.h Tue Nov 17 03:22:33 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: socketvar.h,v 1.161 2020/10/05 08:38:17 roy Exp $ */ +/* $NetBSD: socketvar.h,v 1.162 2020/11/17 03:22:33 chs Exp $ */ /*- * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. @@ -199,7 +199,6 @@ struct socket { #define SS_RESTARTSYS 0x100 /* restart blocked system calls */ #define SS_ISDISCONNECTED 0x800 /* socket disconnected from peer */ -#define SS_ASYNC 0x100 /* async i/o notify */ #define SS_MORETOCOME 0x400 /* * hint from sosend to lower layer; * more data coming
CVS commit: src/external/cddl/osnet/dist/uts/common/dtrace
Module Name:src Committed By: chs Date: Tue Nov 17 03:20:33 UTC 2020 Modified Files: src/external/cddl/osnet/dist/uts/common/dtrace: dtrace.c Log Message: Remove a pointless printf. To generate a diff of this commit: cvs rdiff -u -r1.40 -r1.41 \ src/external/cddl/osnet/dist/uts/common/dtrace/dtrace.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/cddl/osnet/dist/uts/common/dtrace/dtrace.c diff -u src/external/cddl/osnet/dist/uts/common/dtrace/dtrace.c:1.40 src/external/cddl/osnet/dist/uts/common/dtrace/dtrace.c:1.41 --- src/external/cddl/osnet/dist/uts/common/dtrace/dtrace.c:1.40 Sat May 23 23:42:41 2020 +++ src/external/cddl/osnet/dist/uts/common/dtrace/dtrace.c Tue Nov 17 03:20:33 2020 @@ -13840,7 +13840,6 @@ doferr: return (NULL); #endif /* __FreeBSD__ */ #ifdef __NetBSD__ - printf("dtrace: XXX %s not implemented (name=%s)\n", __func__, name); return (NULL); #endif /* __NetBSD__ */ }
CVS commit: src/external/cddl/osnet/dist/uts/common/fs/zfs
Module Name:src Committed By: chs Date: Sun Nov 15 00:54:13 UTC 2020 Modified Files: src/external/cddl/osnet/dist/uts/common/fs/zfs: zfs_vnops.c Log Message: Commit the ZFS file that I forgot in this previous commit: Move the handling of PG_PAGEOUT from uvm_aio_aiodone_pages() to uvm_page_unbusy() so that all callers of uvm_page_unbusy() don't need to handle this flag separately. Split out the pages part of uvm_aio_aiodone() into uvm_aio_aiodone_pages() in rump just like in the real kernel. In ZFS functions that can fail to copy data between the ARC and VM pages, use uvm_aio_aiodone_pages() rather than uvm_page_unbusy() so that we can handle these "I/O" errors. Fixes PR 55702. To generate a diff of this commit: cvs rdiff -u -r1.70 -r1.71 \ src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c diff -u src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c:1.70 src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c:1.71 --- src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c:1.70 Thu Aug 27 09:57:33 2020 +++ src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c Sun Nov 15 00:54:13 2020 @@ -6049,20 +6049,13 @@ zfs_netbsd_getpages(void *v) PAGE_SIZE, va, DMU_READ_PREFETCH); zfs_unmap_page(pg, va); - rw_enter(rw, RW_WRITER); if (err != 0) { -for (i = 0; i < npages; i++) { - pg = ap->a_m[i]; - if ((pg->flags & PG_FAKE) != 0) { - uvm_pagefree(pg); - } else { - uvm_page_unbusy(, 1); - } -} +uvm_aio_aiodone_pages(ap->a_m, npages, false, err); memset(ap->a_m, 0, sizeof(ap->a_m[0]) * npages); break; } + rw_enter(rw, RW_WRITER); pg->flags &= ~(PG_FAKE); } @@ -6089,14 +6082,13 @@ zfs_putapage(vnode_t *vp, page_t **pp, i voff_t len, klen; int err; - bool async = (flags & PGO_SYNCIO) == 0; bool *cleanedp; struct uvm_object *uobj = >v_uobj; krwlock_t *rw = uobj->vmobjlock; if (zp->z_sa_hdl == NULL) { err = 0; - goto out_unbusy; + goto out; } /* @@ -6170,12 +6162,8 @@ zfs_putapage(vnode_t *vp, page_t **pp, i } dmu_tx_commit(tx); -out_unbusy: - rw_enter(rw, RW_WRITER); - uvm_page_unbusy(pp, count); - rw_exit(rw); - out: + uvm_aio_aiodone_pages(pp, count, true, err); return (err); }
CVS commit: src/external/cddl/osnet/sys/kern
Module Name:src Committed By: chs Date: Wed Nov 11 03:31:04 UTC 2020 Modified Files: src/external/cddl/osnet/sys/kern: kmem.c Log Message: kmem_cache_create()'s "name" parameter can be on the stack, so make a copy of it rather than keeping a pointer to it. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/external/cddl/osnet/sys/kern/kmem.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/cddl/osnet/sys/kern/kmem.c diff -u src/external/cddl/osnet/sys/kern/kmem.c:1.2 src/external/cddl/osnet/sys/kern/kmem.c:1.3 --- src/external/cddl/osnet/sys/kern/kmem.c:1.2 Thu May 23 08:32:30 2019 +++ src/external/cddl/osnet/sys/kern/kmem.c Wed Nov 11 03:31:04 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: kmem.c,v 1.2 2019/05/23 08:32:30 hannken Exp $ */ +/* $NetBSD: kmem.c,v 1.3 2020/11/11 03:31:04 chs Exp $ */ /*- * Copyright (c) 2017 The NetBSD Foundation, Inc. @@ -30,6 +30,7 @@ struct kmem_cache { pool_cache_t km_pool; + char km_name[32]; void *km_private; int (*km_constructor)(void *, void *, int); void (*km_destructor)(void *, void *); @@ -78,11 +79,12 @@ kmem_cache_create(char *name, size_t buf KASSERT(vmp == NULL); km = kmem_zalloc(sizeof(*km), KM_SLEEP); + strlcpy(km->km_name, name, sizeof(km->km_name)); km->km_private = private; km->km_constructor = constructor; km->km_destructor = destructor; km->km_reclaim = reclaim; - km->km_pool = pool_cache_init(bufsize, align, 0, 0, name, NULL, + km->km_pool = pool_cache_init(bufsize, align, 0, 0, km->km_name, NULL, IPL_NONE, solaris_constructor, solaris_destructor, km); if (km->km_pool == NULL) { kmem_free(km, sizeof(*km));
CVS commit: src/sys/uvm
Module Name:src Committed By: chs Date: Tue Nov 10 04:27:22 UTC 2020 Modified Files: src/sys/uvm: uvm_bio.c Log Message: remove someone's leftover debug printfs. To generate a diff of this commit: cvs rdiff -u -r1.123 -r1.124 src/sys/uvm/uvm_bio.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/uvm/uvm_bio.c diff -u src/sys/uvm/uvm_bio.c:1.123 src/sys/uvm/uvm_bio.c:1.124 --- src/sys/uvm/uvm_bio.c:1.123 Sun Oct 18 08:52:15 2020 +++ src/sys/uvm/uvm_bio.c Tue Nov 10 04:27:22 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: uvm_bio.c,v 1.123 2020/10/18 08:52:15 rin Exp $ */ +/* $NetBSD: uvm_bio.c,v 1.124 2020/11/10 04:27:22 chs Exp $ */ /* * Copyright (c) 1998 Chuck Silvers. @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uvm_bio.c,v 1.123 2020/10/18 08:52:15 rin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uvm_bio.c,v 1.124 2020/11/10 04:27:22 chs Exp $"); #include "opt_uvmhist.h" #include "opt_ubc.h" @@ -780,7 +780,6 @@ ubc_uiomove(struct uvm_object *uobj, str * do it now. it's safe to use memset here * because we just mapped the pages above. */ - printf("%s: error=%d\n", __func__, error); memset(win, 0, bytelen); } ubc_release(win, flags, pgs, npages); @@ -1009,7 +1008,6 @@ ubc_uiomove_direct(struct uvm_object *uo * error above, do it now. */ if (error != 0) { -printf("%s: error=%d\n", __func__, error); (void) uvm_direct_process(pgs, npages, off, bytelen, ubc_zerorange_process, NULL); }
CVS commit: src/sys/kern
Module Name:src Committed By: chs Date: Mon Nov 9 18:09:02 UTC 2020 Modified Files: src/sys/kern: vfs_vnops.c Log Message: Lock the vnode while calling VOP_BMAP() for FIOGETBMAP. Reported-by: syzbot+cfa1b773be7337250...@syzkaller.appspotmail.com To generate a diff of this commit: cvs rdiff -u -r1.213 -r1.214 src/sys/kern/vfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vfs_vnops.c diff -u src/sys/kern/vfs_vnops.c:1.213 src/sys/kern/vfs_vnops.c:1.214 --- src/sys/kern/vfs_vnops.c:1.213 Thu Jun 11 22:21:05 2020 +++ src/sys/kern/vfs_vnops.c Mon Nov 9 18:09:02 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_vnops.c,v 1.213 2020/06/11 22:21:05 ad Exp $ */ +/* $NetBSD: vfs_vnops.c,v 1.214 2020/11/09 18:09:02 chs Exp $ */ /*- * Copyright (c) 2009 The NetBSD Foundation, Inc. @@ -66,7 +66,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_vnops.c,v 1.213 2020/06/11 22:21:05 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_vnops.c,v 1.214 2020/11/09 18:09:02 chs Exp $"); #include "veriexec.h" @@ -757,7 +757,10 @@ vn_ioctl(file_t *fp, u_long com, void *d if (*(daddr_t *)data < 0) return (EINVAL); block = (daddr_t *)data; - return (VOP_BMAP(vp, *block, NULL, block, NULL)); + vn_lock(vp, LK_SHARED | LK_RETRY); + error = VOP_BMAP(vp, *block, NULL, block, NULL); + VOP_UNLOCK(vp); + return error; } if (com == OFIOGETBMAP) { daddr_t ibn, obn; @@ -765,7 +768,9 @@ vn_ioctl(file_t *fp, u_long com, void *d if (*(int32_t *)data < 0) return (EINVAL); ibn = (daddr_t)*(int32_t *)data; + vn_lock(vp, LK_SHARED | LK_RETRY); error = VOP_BMAP(vp, ibn, NULL, , NULL); + VOP_UNLOCK(vp); *(int32_t *)data = (int32_t)obn; return error; }
CVS commit: src/usr.bin/pmap
Module Name:src Committed By: chs Date: Wed Nov 4 01:37:55 UTC 2020 Modified Files: src/usr.bin/pmap: main.c pmap.c pmap.h Log Message: Restrict to root any command option that prints kernel addresses. To generate a diff of this commit: cvs rdiff -u -r1.28 -r1.29 src/usr.bin/pmap/main.c cvs rdiff -u -r1.55 -r1.56 src/usr.bin/pmap/pmap.c cvs rdiff -u -r1.12 -r1.13 src/usr.bin/pmap/pmap.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/pmap/main.c diff -u src/usr.bin/pmap/main.c:1.28 src/usr.bin/pmap/main.c:1.29 --- src/usr.bin/pmap/main.c:1.28 Sun Mar 22 14:41:32 2020 +++ src/usr.bin/pmap/main.c Wed Nov 4 01:37:55 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.28 2020/03/22 14:41:32 ad Exp $ */ +/* $NetBSD: main.c,v 1.29 2020/11/04 01:37:55 chs Exp $ */ /* * Copyright (c) 2002, 2003, 2020 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include #ifndef lint -__RCSID("$NetBSD: main.c,v 1.28 2020/03/22 14:41:32 ad Exp $"); +__RCSID("$NetBSD: main.c,v 1.29 2020/11/04 01:37:55 chs Exp $"); #endif #include @@ -121,6 +121,7 @@ main(int argc, char *argv[]) struct kbit kbit, *vmspace; u_long address; + uid = getuid(); egid = getegid(); if (setegid(getgid()) == -1) err(1, "failed to reset privileges"); @@ -231,11 +232,12 @@ main(int argc, char *argv[]) print_ddb == 0) print_solaris = 1; - /* get privs back if it appears to be safe, otherwise toss them */ - if (kernel == NULL && kmem == NULL && address == 0) - rc = setegid(egid); - else - rc = setgid(getgid()); + if ((kernel != NULL || kmem != NULL || address != 0 || + print_ddb || debug) && uid != 0) + errx(1, "one or more options specified is restricted to root"); + + /* get privs back since it appears to be safe. */ + rc = setegid(egid); if (rc == -1) err(1, "failed to reset privileges"); @@ -283,8 +285,6 @@ main(int argc, char *argv[]) exit(0); } - uid = getuid(); - do { if (pid == -1) { if (argc == 0) Index: src/usr.bin/pmap/pmap.c diff -u src/usr.bin/pmap/pmap.c:1.55 src/usr.bin/pmap/pmap.c:1.56 --- src/usr.bin/pmap/pmap.c:1.55 Sun Mar 22 14:41:32 2020 +++ src/usr.bin/pmap/pmap.c Wed Nov 4 01:37:55 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.55 2020/03/22 14:41:32 ad Exp $ */ +/* $NetBSD: pmap.c,v 1.56 2020/11/04 01:37:55 chs Exp $ */ /* * Copyright (c) 2002, 2003, 2020 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include #ifndef lint -__RCSID("$NetBSD: pmap.c,v 1.55 2020/03/22 14:41:32 ad Exp $"); +__RCSID("$NetBSD: pmap.c,v 1.56 2020/11/04 01:37:55 chs Exp $"); #endif #include @@ -483,9 +483,7 @@ dump_vm_map_entry(kvm_t *kd, struct kinf if (print_all) { sz = (size_t)((vme->end - vme->start) / 1024); - printf(A(vp) ? - "%*s%0*"PRIxVADDR"-%0*"PRIxVADDR" %7luk %0*" PRIx64 " %c%c%c%c%c (%c%c%c) %d/%d/%d %02llu:%02llu %7llu - %s [%p]\n" : - "%*s%0*"PRIxVADDR"-%0*"PRIxVADDR" %7luk %0*" PRIx64 " %c%c%c%c%c (%c%c%c) %d/%d/%d %02llu:%02llu %7llu - %s\n", + printf("%*s%0*"PRIxVADDR"-%0*"PRIxVADDR" %7luk %0*" PRIx64 " %c%c%c%c%c (%c%c%c) %d/%d/%d %02llu:%02llu %7llu - %s\n", indent(2), "", (int)sizeof(void *) * 2, vme->start, @@ -508,7 +506,7 @@ dump_vm_map_entry(kvm_t *kd, struct kinf (unsigned long long)major(dev), (unsigned long long)minor(dev), (unsigned long long)inode, - name, P(vp)); + name); } /* no access allowed, don't count space */ Index: src/usr.bin/pmap/pmap.h diff -u src/usr.bin/pmap/pmap.h:1.12 src/usr.bin/pmap/pmap.h:1.13 --- src/usr.bin/pmap/pmap.h:1.12 Sun Mar 22 14:41:32 2020 +++ src/usr.bin/pmap/pmap.h Wed Nov 4 01:37:55 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.h,v 1.12 2020/03/22 14:41:32 ad Exp $ */ +/* $NetBSD: pmap.h,v 1.13 2020/11/04 01:37:55 chs Exp $ */ /* * Copyright (c) 2002, 2003, 2020 The NetBSD Foundation, Inc. @@ -98,8 +98,7 @@ ((size_t)kvm_read((kd), (addr), (dst), (sz)) == (size_t)(sz)) #define _KDEREF(kd, addr, dst, sz) do { \ if (!_KDEREFOK((kd), (addr), (dst), (sz))) \ - errx(1, "trying to read %lu (%s) bytes from %lx: %s", \ - (unsigned long)(sz), #sz, (addr), kvm_geterr(kd)); \ + errx(1, "reading from kmem failed: %s", kvm_geterr(kd)); \ } while (0/*CONSTCOND*/) /* suck the data using the structure */
CVS commit: src/sys
Module Name:src Committed By: chs Date: Wed Nov 4 01:30:19 UTC 2020 Modified Files: src/sys/kern: init_main.c src/sys/uvm: uvm_aobj.c uvm_init.c uvm_pdaemon.c Log Message: In uvmpd_tryownerlock(), if the initial try-lock of the owner lock fails then rather than do more try-locks and eventually sleep for a tick, take a hold on the current owner's lock, drop the page interlock, and acquire the lock that we took the hold on in a blocking fashion. After we get the lock, check if the lock that we acquired is still the lock for the owner of the page that we're interested in. If the owner hasn't changed then can proceed with this page, otherwise we will skip this page and move on to a different page. This dramatically reduces the amount of time that the pagedaemon sleeps trying to get locks, since even 1 tick is an eternity to sleep in this context and it was easy to trigger that case in practice, and with this new method the pagedaemon only very rarely actually blocks to acquire the lock that it wants since the object locks are adaptive, and when the pagedaemon does block then the amount of time it spends sleeping will be generally be much less than 1 tick. To generate a diff of this commit: cvs rdiff -u -r1.531 -r1.532 src/sys/kern/init_main.c cvs rdiff -u -r1.151 -r1.152 src/sys/uvm/uvm_aobj.c cvs rdiff -u -r1.54 -r1.55 src/sys/uvm/uvm_init.c cvs rdiff -u -r1.130 -r1.131 src/sys/uvm/uvm_pdaemon.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/init_main.c diff -u src/sys/kern/init_main.c:1.531 src/sys/kern/init_main.c:1.532 --- src/sys/kern/init_main.c:1.531 Tue Sep 8 16:00:35 2020 +++ src/sys/kern/init_main.c Wed Nov 4 01:30:19 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: init_main.c,v 1.531 2020/09/08 16:00:35 riastradh Exp $ */ +/* $NetBSD: init_main.c,v 1.532 2020/11/04 01:30:19 chs Exp $ */ /*- * Copyright (c) 2008, 2009, 2019 The NetBSD Foundation, Inc. @@ -97,7 +97,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.531 2020/09/08 16:00:35 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.532 2020/11/04 01:30:19 chs Exp $"); #include "opt_cnmagic.h" #include "opt_ddb.h" @@ -329,7 +329,6 @@ main(void) /* Initialize lock caches. */ mutex_obj_init(); - rw_obj_init(); /* Initialize radix trees (used by numerous subsystems). */ radix_tree_init(); Index: src/sys/uvm/uvm_aobj.c diff -u src/sys/uvm/uvm_aobj.c:1.151 src/sys/uvm/uvm_aobj.c:1.152 --- src/sys/uvm/uvm_aobj.c:1.151 Wed Aug 19 15:36:41 2020 +++ src/sys/uvm/uvm_aobj.c Wed Nov 4 01:30:19 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: uvm_aobj.c,v 1.151 2020/08/19 15:36:41 chs Exp $ */ +/* $NetBSD: uvm_aobj.c,v 1.152 2020/11/04 01:30:19 chs Exp $ */ /* * Copyright (c) 1998 Chuck Silvers, Charles D. Cranor and @@ -38,7 +38,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uvm_aobj.c,v 1.151 2020/08/19 15:36:41 chs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uvm_aobj.c,v 1.152 2020/11/04 01:30:19 chs Exp $"); #ifdef _KERNEL_OPT #include "opt_uvmhist.h" @@ -416,7 +416,7 @@ struct uvm_object * uao_create(voff_t size, int flags) { static struct uvm_aobj kernel_object_store; - static krwlock_t kernel_object_lock __cacheline_aligned; + static krwlock_t bootstrap_kernel_object_lock; static int kobj_alloced __diagused = 0; pgoff_t pages = round_page((uint64_t)size) >> PAGE_SHIFT; struct uvm_aobj *aobj; @@ -458,25 +458,30 @@ uao_create(voff_t size, int flags) * we are still booting we should be the only thread around. */ - if (flags == 0 || (flags & UAO_FLAG_KERNSWAP) != 0) { + const int kernswap = (flags & UAO_FLAG_KERNSWAP) != 0; + if (flags == 0 || kernswap) { #if defined(VMSWAP) - const int kernswap = (flags & UAO_FLAG_KERNSWAP) != 0; /* allocate hash table or array depending on object size */ if (UAO_USES_SWHASH(aobj)) { aobj->u_swhash = hashinit(UAO_SWHASH_BUCKETS(aobj), - HASH_LIST, kernswap ? false : true, - >u_swhashmask); - if (aobj->u_swhash == NULL) -panic("uao_create: hashinit swhash failed"); + HASH_LIST, true, >u_swhashmask); } else { aobj->u_swslots = kmem_zalloc(pages * sizeof(int), - kernswap ? KM_NOSLEEP : KM_SLEEP); - if (aobj->u_swslots == NULL) -panic("uao_create: swslots allocation failed"); + KM_SLEEP); } #endif /* defined(VMSWAP) */ + /* + * Replace kernel_object's temporary static lock with + * a regular rw_obj. We cannot use uvm_obj_setlock() + * because that would try to free the old lock. + */ + + if (kernswap) { + aobj->u_obj.vmobjlock = rw_obj_alloc(); + rw_destroy(_kernel_object_lock); + } if (flags) { aobj->u_flags &= ~UAO_FLAG_NOSWAP; /* clear noswap */ return >u_obj; @@ -490,9 +495,9
CVS commit: src/sys/uvm
Module Name:src Committed By: chs Date: Sun Oct 25 00:05:26 UTC 2020 Modified Files: src/sys/uvm: uvm_anon.c Log Message: Handle PG_PAGEOUT in uvm_anon_release() too. To generate a diff of this commit: cvs rdiff -u -r1.79 -r1.80 src/sys/uvm/uvm_anon.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/uvm/uvm_anon.c diff -u src/sys/uvm/uvm_anon.c:1.79 src/sys/uvm/uvm_anon.c:1.80 --- src/sys/uvm/uvm_anon.c:1.79 Thu Jul 9 05:57:15 2020 +++ src/sys/uvm/uvm_anon.c Sun Oct 25 00:05:26 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: uvm_anon.c,v 1.79 2020/07/09 05:57:15 skrll Exp $ */ +/* $NetBSD: uvm_anon.c,v 1.80 2020/10/25 00:05:26 chs Exp $ */ /* * Copyright (c) 1997 Charles D. Cranor and Washington University. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uvm_anon.c,v 1.79 2020/07/09 05:57:15 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uvm_anon.c,v 1.80 2020/10/25 00:05:26 chs Exp $"); #include "opt_uvmhist.h" @@ -371,6 +371,11 @@ uvm_anon_release(struct vm_anon *anon) KASSERT(pg->loan_count == 0); KASSERT(anon->an_ref == 0); + if ((pg->flags & PG_PAGEOUT) != 0) { + pg->flags &= ~PG_PAGEOUT; + uvm_pageout_done(1); + } + uvm_pagefree(pg); KASSERT(anon->an_page == NULL); lock = anon->an_lock;
CVS commit: src/sys/rump/librump/rumpvfs
Module Name:src Committed By: chs Date: Thu Oct 22 03:05:17 UTC 2020 Modified Files: src/sys/rump/librump/rumpvfs: vm_vfs.c Log Message: fix an incorrect assertion in the previous commit. To generate a diff of this commit: cvs rdiff -u -r1.39 -r1.40 src/sys/rump/librump/rumpvfs/vm_vfs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/rump/librump/rumpvfs/vm_vfs.c diff -u src/sys/rump/librump/rumpvfs/vm_vfs.c:1.39 src/sys/rump/librump/rumpvfs/vm_vfs.c:1.40 --- src/sys/rump/librump/rumpvfs/vm_vfs.c:1.39 Sun Oct 18 18:22:29 2020 +++ src/sys/rump/librump/rumpvfs/vm_vfs.c Thu Oct 22 03:05:17 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: vm_vfs.c,v 1.39 2020/10/18 18:22:29 chs Exp $ */ +/* $NetBSD: vm_vfs.c,v 1.40 2020/10/22 03:05:17 chs Exp $ */ /* * Copyright (c) 2008-2011 Antti Kantee. All Rights Reserved. @@ -26,7 +26,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vm_vfs.c,v 1.39 2020/10/18 18:22:29 chs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vm_vfs.c,v 1.40 2020/10/22 03:05:17 chs Exp $"); #include @@ -46,7 +46,8 @@ uvm_aio_aiodone_pages(struct vm_page **p rw_enter(uobj->vmobjlock, RW_WRITER); for (i = 0; i < npages; i++) { pg = pgs[i]; - KASSERT((pg->flags & PG_FAKE) == 0); + KASSERT((pg->flags & PG_PAGEOUT) == 0 || + (pg->flags & PG_FAKE) == 0); } uvm_page_unbusy(pgs, npages); rw_exit(uobj->vmobjlock);
CVS commit: src/sys/uvm
Module Name:src Committed By: chs Date: Sun Oct 18 18:31:31 UTC 2020 Modified Files: src/sys/uvm: uvm_page.c uvm_pgflcache.c Log Message: In the current code, CPU_COUNT_FREEPAGES counts pages in the global freelists AND the per-CPU pgflcache free pages caches, and that is the number of pages that the pagedaemon considers to be available. However, most pages in the pgflcache per-CPU free page caches are NOT actually available for any particular allocation, and thus allocating a page can fail even though the pagedaemon thinks enough pages are available. This change makes CPU_COUNT_FREEPAGES only count pages in the global freelists and not pages in the pgflcache per-CPU free page caches, thus better aligning the pagedaemon's view of how many pages are available with the number of pages that can actually be allocated by any particular request. This fixes a hang that Christos was hitting. To generate a diff of this commit: cvs rdiff -u -r1.248 -r1.249 src/sys/uvm/uvm_page.c cvs rdiff -u -r1.5 -r1.6 src/sys/uvm/uvm_pgflcache.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/uvm/uvm_page.c diff -u src/sys/uvm/uvm_page.c:1.248 src/sys/uvm/uvm_page.c:1.249 --- src/sys/uvm/uvm_page.c:1.248 Sun Oct 18 18:22:29 2020 +++ src/sys/uvm/uvm_page.c Sun Oct 18 18:31:31 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: uvm_page.c,v 1.248 2020/10/18 18:22:29 chs Exp $ */ +/* $NetBSD: uvm_page.c,v 1.249 2020/10/18 18:31:31 chs Exp $ */ /*- * Copyright (c) 2019, 2020 The NetBSD Foundation, Inc. @@ -95,7 +95,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uvm_page.c,v 1.248 2020/10/18 18:22:29 chs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uvm_page.c,v 1.249 2020/10/18 18:31:31 chs Exp $"); #include "opt_ddb.h" #include "opt_uvm.h" @@ -1069,6 +1069,7 @@ uvm_pagealloc_pgb(struct uvm_cpu *ucpu, KASSERT(pg->flags == PG_FREE); pg->flags = PG_BUSY | PG_CLEAN | PG_FAKE; pgb->pgb_nfree--; + CPU_COUNT(CPU_COUNT_FREEPAGES, -1); /* * While we have the bucket locked and our data @@ -1270,7 +1271,6 @@ uvm_pagealloc_strat(struct uvm_object *o * while still at IPL_VM, update allocation statistics. */ - CPU_COUNT(CPU_COUNT_FREEPAGES, -1); if (anon) { CPU_COUNT(CPU_COUNT_ANONCLEAN, 1); } @@ -1567,7 +1567,6 @@ uvm_pagefree(struct vm_page *pg) /* Try to send the page to the per-CPU cache. */ s = splvm(); - CPU_COUNT(CPU_COUNT_FREEPAGES, 1); ucpu = curcpu()->ci_data.cpu_uvm; bucket = uvm_page_get_bucket(pg); if (bucket == ucpu->pgflbucket && uvm_pgflcache_free(ucpu, pg)) { @@ -1585,6 +1584,7 @@ uvm_pagefree(struct vm_page *pg) pg->flags = PG_FREE; LIST_INSERT_HEAD(>pgb_colors[VM_PGCOLOR(pg)], pg, pageq.list); pgb->pgb_nfree++; + CPU_COUNT(CPU_COUNT_FREEPAGES, 1); mutex_spin_exit(lock); splx(s); } Index: src/sys/uvm/uvm_pgflcache.c diff -u src/sys/uvm/uvm_pgflcache.c:1.5 src/sys/uvm/uvm_pgflcache.c:1.6 --- src/sys/uvm/uvm_pgflcache.c:1.5 Sun Jun 14 21:41:42 2020 +++ src/sys/uvm/uvm_pgflcache.c Sun Oct 18 18:31:31 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: uvm_pgflcache.c,v 1.5 2020/06/14 21:41:42 ad Exp $ */ +/* $NetBSD: uvm_pgflcache.c,v 1.6 2020/10/18 18:31:31 chs Exp $ */ /*- * Copyright (c) 2019 The NetBSD Foundation, Inc. @@ -43,7 +43,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uvm_pgflcache.c,v 1.5 2020/06/14 21:41:42 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uvm_pgflcache.c,v 1.6 2020/10/18 18:31:31 chs Exp $"); #include "opt_uvm.h" #include "opt_multiprocessor.h" @@ -151,6 +151,7 @@ uvm_pgflcache_fill(struct uvm_cpu *ucpu, pg->pageq.list.le_prev = >lh_first; } pgb->pgb_nfree -= (count - pcc->count); + CPU_COUNT(CPU_COUNT_FREEPAGES, -(count - pcc->count)); pcc->count = count; } @@ -188,6 +189,7 @@ uvm_pgflcache_spill(struct uvm_cpu *ucpu LIST_INSERT_HEAD(head, pcc->pages[pcc->count], pageq.list); } pgb->pgb_nfree += adj; + CPU_COUNT(CPU_COUNT_FREEPAGES, adj); mutex_spin_exit(lock); }
CVS commit: src/sys
Module Name:src Committed By: chs Date: Sun Oct 18 18:22:29 UTC 2020 Modified Files: src/sys/rump/librump/rumpvfs: vm_vfs.c src/sys/uvm: uvm_page.c uvm_pager.c Log Message: Move the handling of PG_PAGEOUT from uvm_aio_aiodone_pages() to uvm_page_unbusy() so that all callers of uvm_page_unbusy() don't need to handle this flag separately. Split out the pages part of uvm_aio_aiodone() into uvm_aio_aiodone_pages() in rump just like in the real kernel. In ZFS functions that can fail to copy data between the ARC and VM pages, use uvm_aio_aiodone_pages() rather than uvm_page_unbusy() so that we can handle these "I/O" errors. Fixes PR 55702. To generate a diff of this commit: cvs rdiff -u -r1.38 -r1.39 src/sys/rump/librump/rumpvfs/vm_vfs.c cvs rdiff -u -r1.247 -r1.248 src/sys/uvm/uvm_page.c cvs rdiff -u -r1.129 -r1.130 src/sys/uvm/uvm_pager.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/rump/librump/rumpvfs/vm_vfs.c diff -u src/sys/rump/librump/rumpvfs/vm_vfs.c:1.38 src/sys/rump/librump/rumpvfs/vm_vfs.c:1.39 --- src/sys/rump/librump/rumpvfs/vm_vfs.c:1.38 Sun Feb 23 15:46:42 2020 +++ src/sys/rump/librump/rumpvfs/vm_vfs.c Sun Oct 18 18:22:29 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: vm_vfs.c,v 1.38 2020/02/23 15:46:42 ad Exp $ */ +/* $NetBSD: vm_vfs.c,v 1.39 2020/10/18 18:22:29 chs Exp $ */ /* * Copyright (c) 2008-2011 Antti Kantee. All Rights Reserved. @@ -26,7 +26,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vm_vfs.c,v 1.38 2020/02/23 15:46:42 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vm_vfs.c,v 1.39 2020/10/18 18:22:29 chs Exp $"); #include @@ -36,19 +36,37 @@ __KERNEL_RCSID(0, "$NetBSD: vm_vfs.c,v 1 #include #include +void +uvm_aio_aiodone_pages(struct vm_page **pgs, int npages, bool write, int error) +{ + struct uvm_object *uobj = pgs[0]->uobject; + struct vm_page *pg; + int i; + + rw_enter(uobj->vmobjlock, RW_WRITER); + for (i = 0; i < npages; i++) { + pg = pgs[i]; + KASSERT((pg->flags & PG_FAKE) == 0); + } + uvm_page_unbusy(pgs, npages); + rw_exit(uobj->vmobjlock); +} + /* - * release resources held during async io. this is almost the - * same as uvm_aio_aiodone() from uvm_pager.c and only lacks the - * call to uvm_aio_aiodone_pages(): unbusies pages directly here. + * Release resources held during async io. */ void uvm_aio_aiodone(struct buf *bp) { struct uvm_object *uobj = NULL; - int i, npages = bp->b_bufsize >> PAGE_SHIFT; + int npages = bp->b_bufsize >> PAGE_SHIFT; struct vm_page **pgs; vaddr_t va; - int pageout = 0; + int i, error; + bool write; + + error = bp->b_error; + write = BUF_ISWRITE(bp); KASSERT(npages > 0); pgs = kmem_alloc(npages * sizeof(*pgs), KM_SLEEP); @@ -59,27 +77,15 @@ uvm_aio_aiodone(struct buf *bp) if (uobj == NULL) { uobj = pgs[i]->uobject; KASSERT(uobj != NULL); - rw_enter(uobj->vmobjlock, RW_WRITER); } else { KASSERT(uobj == pgs[i]->uobject); } - - if (pgs[i]->flags & PG_PAGEOUT) { - KASSERT((pgs[i]->flags & PG_FAKE) == 0); - pageout++; - pgs[i]->flags &= ~PG_PAGEOUT; - pgs[i]->flags |= PG_RELEASED; - } } - KASSERT(rw_write_held(uobj->vmobjlock)); - - uvm_page_unbusy(pgs, npages); - rw_exit(uobj->vmobjlock); - uvm_pagermapout((vaddr_t)bp->b_data, npages); - uvm_pageout_done(pageout); - if (BUF_ISWRITE(bp) && (bp->b_cflags & BC_AGE) != 0) { + uvm_aio_aiodone_pages(pgs, npages, write, error); + + if (write && (bp->b_cflags & BC_AGE) != 0) { mutex_enter(bp->b_objlock); vwakeup(bp); mutex_exit(bp->b_objlock); Index: src/sys/uvm/uvm_page.c diff -u src/sys/uvm/uvm_page.c:1.247 src/sys/uvm/uvm_page.c:1.248 --- src/sys/uvm/uvm_page.c:1.247 Sun Sep 20 10:30:05 2020 +++ src/sys/uvm/uvm_page.c Sun Oct 18 18:22:29 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: uvm_page.c,v 1.247 2020/09/20 10:30:05 skrll Exp $ */ +/* $NetBSD: uvm_page.c,v 1.248 2020/10/18 18:22:29 chs Exp $ */ /*- * Copyright (c) 2019, 2020 The NetBSD Foundation, Inc. @@ -95,7 +95,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uvm_page.c,v 1.247 2020/09/20 10:30:05 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uvm_page.c,v 1.248 2020/10/18 18:22:29 chs Exp $"); #include "opt_ddb.h" #include "opt_uvm.h" @@ -1602,9 +1602,10 @@ void uvm_page_unbusy(struct vm_page **pgs, int npgs) { struct vm_page *pg; - int i; + int i, pageout_done; UVMHIST_FUNC(__func__); UVMHIST_CALLED(ubchist); + pageout_done = 0; for (i = 0; i < npgs; i++) { pg = pgs[i]; if (pg == NULL || pg == PGO_DONTCARE) { @@ -1613,7 +1614,13 @@ uvm_page_unbusy(struct vm_page **pgs, in KASSERT(uvm_page_owner_locked_p(pg, true)); KASSERT(pg->flags & PG_BUSY); - KASSERT((pg->flags & PG_PAGEOUT) == 0); + + if (pg->flags & PG_PAGEOUT) { + pg->flags &= ~PG_PAGEOUT; + pg->flags |= PG_RELEASED; + pageout_done++; + atomic_inc_uint(); + } if (pg->flags & PG_RELEASED) { UVMHIST_LOG(ubchist, "releasing pg %#jx",
CVS commit: src/sys/uvm
Module Name:src Committed By: chs Date: Wed Oct 7 17:51:50 UTC 2020 Modified Files: src/sys/uvm: uvm_init.c uvm_page.h uvm_pglist.c uvm_swap.c Log Message: Add a new, more aggressive allocator for uvm_pglistalloc() to allocate contiguous physical pages, and try this new allocator if the existing one fails. The existing contig allocator only tries to allocate pages that are already free, which works fine shortly after boot but rarely works after the system has been up for a while. The new allocator uses the pagedaemon to evict pages from memory in the hope that this will free up a range of pages that satisfies the constraits of the request. This should help with things like plugging in a USB device, which often fails for some USB controllers because they can't get contigous memory. To generate a diff of this commit: cvs rdiff -u -r1.53 -r1.54 src/sys/uvm/uvm_init.c cvs rdiff -u -r1.106 -r1.107 src/sys/uvm/uvm_page.h cvs rdiff -u -r1.85 -r1.86 src/sys/uvm/uvm_pglist.c cvs rdiff -u -r1.199 -r1.200 src/sys/uvm/uvm_swap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/uvm/uvm_init.c diff -u src/sys/uvm/uvm_init.c:1.53 src/sys/uvm/uvm_init.c:1.54 --- src/sys/uvm/uvm_init.c:1.53 Fri Mar 6 20:46:12 2020 +++ src/sys/uvm/uvm_init.c Wed Oct 7 17:51:50 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: uvm_init.c,v 1.53 2020/03/06 20:46:12 ad Exp $ */ +/* $NetBSD: uvm_init.c,v 1.54 2020/10/07 17:51:50 chs Exp $ */ /* * Copyright (c) 1997 Charles D. Cranor and Washington University. @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uvm_init.c,v 1.53 2020/03/06 20:46:12 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uvm_init.c,v 1.54 2020/10/07 17:51:50 chs Exp $"); #include #include @@ -107,6 +107,7 @@ uvm_init(void) */ uvm_page_init(_start, _end); + uvm_pglistalloc_init(); /* * Init the map sub-system. Index: src/sys/uvm/uvm_page.h diff -u src/sys/uvm/uvm_page.h:1.106 src/sys/uvm/uvm_page.h:1.107 --- src/sys/uvm/uvm_page.h:1.106 Sun Sep 20 10:30:05 2020 +++ src/sys/uvm/uvm_page.h Wed Oct 7 17:51:50 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: uvm_page.h,v 1.106 2020/09/20 10:30:05 skrll Exp $ */ +/* $NetBSD: uvm_page.h,v 1.107 2020/10/07 17:51:50 chs Exp $ */ /* * Copyright (c) 1997 Charles D. Cranor and Washington University. @@ -259,6 +259,7 @@ struct vm_page { #define PG_FREE 0x4000 /* page is on free list */ #define PG_MARKER 0x8000 /* dummy marker page */ #define PG_PAGER1 0x0001 /* pager-specific flag */ +#define PG_PGLCA 0x0002 /* allocated by uvm_pglistalloc_contig */ #define PG_STAT (PG_ANON|PG_AOBJ|PG_FILE) #define PG_SWAPBACKED (PG_ANON|PG_AOBJ) @@ -268,7 +269,7 @@ struct vm_page { "\5PAGEOUT\6RELEASED\7FAKE\10RDONLY" \ "\11ZERO\12TABLED\13AOBJ\14ANON" \ "\15FILE\16READAHEAD\17FREE\20MARKER" \ - "\21PAGER1" + "\21PAGER1\22PGLCA" /* * Flags stored in pg->pqflags, which is protected by pg->interlock. @@ -330,6 +331,7 @@ struct vm_page { */ void uvm_page_init(vaddr_t *, vaddr_t *); +void uvm_pglistalloc_init(void); #if defined(UVM_PAGE_TRKOWN) void uvm_page_own(struct vm_page *, const char *); #endif Index: src/sys/uvm/uvm_pglist.c diff -u src/sys/uvm/uvm_pglist.c:1.85 src/sys/uvm/uvm_pglist.c:1.86 --- src/sys/uvm/uvm_pglist.c:1.85 Sun Jun 14 21:41:42 2020 +++ src/sys/uvm/uvm_pglist.c Wed Oct 7 17:51:50 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: uvm_pglist.c,v 1.85 2020/06/14 21:41:42 ad Exp $ */ +/* $NetBSD: uvm_pglist.c,v 1.86 2020/10/07 17:51:50 chs Exp $ */ /*- * Copyright (c) 1997, 2019 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uvm_pglist.c,v 1.85 2020/06/14 21:41:42 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uvm_pglist.c,v 1.86 2020/10/07 17:51:50 chs Exp $"); #include #include @@ -59,6 +59,8 @@ u_long uvm_pglistalloc_npages; #define STAT_DECR(v) #endif +kmutex_t uvm_pglistalloc_contig_lock; + /* * uvm_pglistalloc: allocate a list of pages * @@ -293,13 +295,161 @@ uvm_pglistalloc_c_ps(uvm_physseg_t psi, } static int +uvm_pglistalloc_contig_aggressive(int num, paddr_t low, paddr_t high, +paddr_t alignment, paddr_t boundary, struct pglist *rlist) +{ + struct vm_page *pg; + struct pglist tmp; + paddr_t pa, off, spa, amask, bmask, rlo, rhi; + uvm_physseg_t upm; + int error, i, run, acnt; + + /* + * Allocate pages the normal way and for each new page, check if + * the page completes a range satisfying the request. + * The pagedaemon will evict pages as we go and we are very likely + * to get compatible pages eventually. + */ + + error = ENOMEM; + TAILQ_INIT(); + acnt = atop(alignment); + amask = ~(alignment - 1); + bmask = ~(boundary - 1); + KASSERT(bmask <= amask); + mutex_enter(_pglistalloc_contig_lock); + while (uvm_reclaimable()) { + pg = uvm_pagealloc(NULL, 0, NULL, 0); + if (pg == NULL) { + uvm_wait("pglac2"); + continue; + } +
CVS commit: src/sys/uvm
Module Name:src Committed By: chs Date: Mon Sep 21 18:41:59 UTC 2020 Modified Files: src/sys/uvm: uvm_amap.c uvm_io.c Log Message: the previous fix for PR 55366 in uvm_amap.c 1.124 was incomplete: - amap_adjref_anons() must also ignore AMAP_REFALL when updating the ppref, not just when deciding whether or not to initialize ppref. - UVM_EXTRACT_QREF relies on AMAP_REFALL to work properly, and since we can't use AMAP_REFALL then we can't use QREF either. To generate a diff of this commit: cvs rdiff -u -r1.124 -r1.125 src/sys/uvm/uvm_amap.c cvs rdiff -u -r1.28 -r1.29 src/sys/uvm/uvm_io.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/uvm/uvm_amap.c diff -u src/sys/uvm/uvm_amap.c:1.124 src/sys/uvm/uvm_amap.c:1.125 --- src/sys/uvm/uvm_amap.c:1.124 Sun Sep 20 23:03:01 2020 +++ src/sys/uvm/uvm_amap.c Mon Sep 21 18:41:59 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: uvm_amap.c,v 1.124 2020/09/20 23:03:01 chs Exp $ */ +/* $NetBSD: uvm_amap.c,v 1.125 2020/09/21 18:41:59 chs Exp $ */ /* * Copyright (c) 1997 Charles D. Cranor and Washington University. @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uvm_amap.c,v 1.124 2020/09/20 23:03:01 chs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uvm_amap.c,v 1.125 2020/09/21 18:41:59 chs Exp $"); #include "opt_uvmhist.h" @@ -1602,11 +1602,7 @@ amap_adjref_anons(struct vm_amap *amap, #ifdef UVM_AMAP_PPREF if (amap->am_ppref && amap->am_ppref != PPREF_NONE) { - if (all) { - amap_pp_adjref(amap, 0, amap->am_nslot, refv); - } else { - amap_pp_adjref(amap, offset, len, refv); - } + amap_pp_adjref(amap, offset, len, refv); } #endif amap_unlock(amap); Index: src/sys/uvm/uvm_io.c diff -u src/sys/uvm/uvm_io.c:1.28 src/sys/uvm/uvm_io.c:1.29 --- src/sys/uvm/uvm_io.c:1.28 Wed May 25 17:43:58 2016 +++ src/sys/uvm/uvm_io.c Mon Sep 21 18:41:59 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: uvm_io.c,v 1.28 2016/05/25 17:43:58 christos Exp $ */ +/* $NetBSD: uvm_io.c,v 1.29 2020/09/21 18:41:59 chs Exp $ */ /* * Copyright (c) 1997 Charles D. Cranor and Washington University. @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uvm_io.c,v 1.28 2016/05/25 17:43:58 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uvm_io.c,v 1.29 2020/09/21 18:41:59 chs Exp $"); #include #include @@ -87,6 +87,10 @@ uvm_io(struct vm_map *map, struct uio *u error = 0; flags |= UVM_EXTRACT_QREF | UVM_EXTRACT_CONTIG | UVM_EXTRACT_FIXPROT; + + /* XXX cannot use QREF with without AMAP_REFALL, and REFALL is unsafe */ + flags &= ~UVM_EXTRACT_QREF; + /* * step 1: main loop... while we've got data to move */
CVS commit: src/sys/uvm
Module Name:src Committed By: chs Date: Sun Sep 20 23:03:01 UTC 2020 Modified Files: src/sys/uvm: uvm_amap.c Log Message: Effectively disable the AMAP_REFALL flag because it is unsafe. This flag tells the amap code that it does not need to allocate ppref as part of adding or removing a reference, but that is only correct if the range of the reference being added or removed is the same as the range of all other references to the amap, and the point of this flag is exactly to try to optimize the case where the range is different and thus this flag would not be correct to use. Fixes PR 55366. To generate a diff of this commit: cvs rdiff -u -r1.123 -r1.124 src/sys/uvm/uvm_amap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/uvm/uvm_amap.c diff -u src/sys/uvm/uvm_amap.c:1.123 src/sys/uvm/uvm_amap.c:1.124 --- src/sys/uvm/uvm_amap.c:1.123 Tue Aug 18 10:40:20 2020 +++ src/sys/uvm/uvm_amap.c Sun Sep 20 23:03:01 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: uvm_amap.c,v 1.123 2020/08/18 10:40:20 chs Exp $ */ +/* $NetBSD: uvm_amap.c,v 1.124 2020/09/20 23:03:01 chs Exp $ */ /* * Copyright (c) 1997 Charles D. Cranor and Washington University. @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uvm_amap.c,v 1.123 2020/08/18 10:40:20 chs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uvm_amap.c,v 1.124 2020/09/20 23:03:01 chs Exp $"); #include "opt_uvmhist.h" @@ -1593,7 +1593,7 @@ amap_adjref_anons(struct vm_amap *amap, * so that the ppref values match the current amap refcount. */ - if (amap->am_ppref == NULL && !all && len != amap->am_nslot) { + if (amap->am_ppref == NULL) { amap_pp_establish(amap, offset); } #endif
CVS commit: src/sys/uvm
Module Name:src Committed By: chs Date: Wed Aug 19 15:36:41 UTC 2020 Modified Files: src/sys/uvm: uvm_aobj.c Log Message: in uao_get(), if we unlock the uobj to read a page from swap, we must clear the cached page array because it is now stale. also add a missing call to uvm_page_array_fini() if the I/O fails. fixes PR 55493. To generate a diff of this commit: cvs rdiff -u -r1.150 -r1.151 src/sys/uvm/uvm_aobj.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/uvm/uvm_aobj.c diff -u src/sys/uvm/uvm_aobj.c:1.150 src/sys/uvm/uvm_aobj.c:1.151 --- src/sys/uvm/uvm_aobj.c:1.150 Wed Aug 19 07:29:00 2020 +++ src/sys/uvm/uvm_aobj.c Wed Aug 19 15:36:41 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: uvm_aobj.c,v 1.150 2020/08/19 07:29:00 simonb Exp $ */ +/* $NetBSD: uvm_aobj.c,v 1.151 2020/08/19 15:36:41 chs Exp $ */ /* * Copyright (c) 1998 Chuck Silvers, Charles D. Cranor and @@ -38,7 +38,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uvm_aobj.c,v 1.150 2020/08/19 07:29:00 simonb Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uvm_aobj.c,v 1.151 2020/08/19 15:36:41 chs Exp $"); #ifdef _KERNEL_OPT #include "opt_uvmhist.h" @@ -982,6 +982,7 @@ uao_get(struct uvm_object *uobj, voff_t * unlock object for i/o, relock when done. */ + uvm_page_array_clear(); rw_exit(uobj->vmobjlock); error = uvm_swap_get(ptmp, swslot, PGO_SYNCIO); rw_enter(uobj->vmobjlock, RW_WRITER); @@ -1015,6 +1016,7 @@ uao_get(struct uvm_object *uobj, voff_t uvm_page_unbusy(pps, lcv); } memset(pps, 0, maxpages * sizeof(pps[0])); +uvm_page_array_fini(); return error; } #else /* defined(VMSWAP) */
CVS commit: src/sys/uvm
Module Name:src Committed By: chs Date: Tue Aug 18 10:40:20 UTC 2020 Modified Files: src/sys/uvm: uvm_amap.c Log Message: fix amap_extend() to handle amaps where we previously failed to allocate the ppref memory. To generate a diff of this commit: cvs rdiff -u -r1.122 -r1.123 src/sys/uvm/uvm_amap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/uvm/uvm_amap.c diff -u src/sys/uvm/uvm_amap.c:1.122 src/sys/uvm/uvm_amap.c:1.123 --- src/sys/uvm/uvm_amap.c:1.122 Thu Jul 9 05:57:15 2020 +++ src/sys/uvm/uvm_amap.c Tue Aug 18 10:40:20 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: uvm_amap.c,v 1.122 2020/07/09 05:57:15 skrll Exp $ */ +/* $NetBSD: uvm_amap.c,v 1.123 2020/08/18 10:40:20 chs Exp $ */ /* * Copyright (c) 1997 Charles D. Cranor and Washington University. @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uvm_amap.c,v 1.122 2020/07/09 05:57:15 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uvm_amap.c,v 1.123 2020/08/18 10:40:20 chs Exp $"); #include "opt_uvmhist.h" @@ -353,7 +353,7 @@ amap_extend(struct vm_map_entry *entry, struct vm_amap *amap = entry->aref.ar_amap; int slotoff = entry->aref.ar_pageoff; int slotmapped, slotadd, slotneed, slotadded, slotalloc; - int slotadj, slotarea; + int slotadj, slotarea, slotendoff; int oldnslots; #ifdef UVM_AMAP_PPREF int *newppref, *oldppref; @@ -388,6 +388,36 @@ amap_extend(struct vm_map_entry *entry, } /* + * Because this amap only has 1 ref, we know that there is + * only one vm_map_entry pointing to it, and the one entry is + * using slots between slotoff and slotoff + slotmapped. If + * we have been using ppref then we know that only slots in + * the one map entry's range can have anons, since ppref + * allowed us to free any anons outside that range as other map + * entries which used this amap were removed. But without ppref, + * we couldn't know which slots were still needed by other map + * entries, so we couldn't free any anons as we removed map + * entries, and so any slot from 0 to am_nslot can have an + * anon. But now that we know there is only one map entry + * left and we know its range, we can free up any anons + * outside that range. This is necessary because the rest of + * this function assumes that there are no anons in the amap + * outside of the one map entry's range. + */ + + slotendoff = slotoff + slotmapped; + if (amap->am_ppref == PPREF_NONE) { + amap_wiperange(amap, 0, slotoff); + amap_wiperange(amap, slotendoff, amap->am_nslot - slotendoff); + } + for (i = 0; i < slotoff; i++) { + KASSERT(amap->am_anon[i] == NULL); + } + for (i = slotendoff; i < amap->am_nslot - slotendoff; i++) { + KASSERT(amap->am_anon[i] == NULL); + } + + /* * case 1: we already have enough slots in the map and thus * only need to bump the reference counts on the slots we are * adding.
CVS commit: src/sys/uvm
Module Name:src Committed By: chs Date: Sun Aug 16 00:24:41 UTC 2020 Modified Files: src/sys/uvm: uvm_vnode.c Log Message: in uvm_findpage(), when uvm_page_array_fill_and_peek() returns a page that is not the one we want and we make an assertion about dirtiness, check the dirty status of the page we wanted rather than the page we got. To generate a diff of this commit: cvs rdiff -u -r1.116 -r1.117 src/sys/uvm/uvm_vnode.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/uvm/uvm_vnode.c diff -u src/sys/uvm/uvm_vnode.c:1.116 src/sys/uvm/uvm_vnode.c:1.117 --- src/sys/uvm/uvm_vnode.c:1.116 Fri Aug 14 09:06:15 2020 +++ src/sys/uvm/uvm_vnode.c Sun Aug 16 00:24:41 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: uvm_vnode.c,v 1.116 2020/08/14 09:06:15 chs Exp $ */ +/* $NetBSD: uvm_vnode.c,v 1.117 2020/08/16 00:24:41 chs Exp $ */ /* * Copyright (c) 1997 Charles D. Cranor and Washington University. @@ -45,7 +45,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uvm_vnode.c,v 1.116 2020/08/14 09:06:15 chs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uvm_vnode.c,v 1.117 2020/08/16 00:24:41 chs Exp $"); #ifdef _KERNEL_OPT #include "opt_uvmhist.h" @@ -313,12 +313,13 @@ uvn_findpage(struct uvm_object *uobj, vo */ pg = uvm_page_array_fill_and_peek(a, offset, nleft); if (pg != NULL && pg->offset != offset) { + struct vm_page __diagused *tpg; KASSERT( ((a->ar_flags & UVM_PAGE_ARRAY_FILL_BACKWARD) != 0) == (pg->offset < offset)); - KASSERT(uvm_pagelookup(uobj, offset) == NULL || + KASSERT((tpg = uvm_pagelookup(uobj, offset)) == NULL || ((a->ar_flags & UVM_PAGE_ARRAY_FILL_DIRTY) != 0 && - !uvm_obj_page_dirty_p(pg))); + !uvm_obj_page_dirty_p(tpg))); pg = NULL; if ((a->ar_flags & UVM_PAGE_ARRAY_FILL_DENSE) != 0) { UVMHIST_LOG(ubchist, "dense", 0,0,0,0);
CVS commit: src/sys/uvm
Module Name:src Committed By: chs Date: Sat Aug 15 07:24:10 UTC 2020 Modified Files: src/sys/uvm: uvm_object.c Log Message: use uint64_t rather than int for storing the index of a page within an object. To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/sys/uvm/uvm_object.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/uvm/uvm_object.c diff -u src/sys/uvm/uvm_object.c:1.24 src/sys/uvm/uvm_object.c:1.25 --- src/sys/uvm/uvm_object.c:1.24 Fri Aug 14 09:06:15 2020 +++ src/sys/uvm/uvm_object.c Sat Aug 15 07:24:09 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: uvm_object.c,v 1.24 2020/08/14 09:06:15 chs Exp $ */ +/* $NetBSD: uvm_object.c,v 1.25 2020/08/15 07:24:09 chs Exp $ */ /* * Copyright (c) 2006, 2010, 2019 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uvm_object.c,v 1.24 2020/08/14 09:06:15 chs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uvm_object.c,v 1.25 2020/08/15 07:24:09 chs Exp $"); #ifdef _KERNEL_OPT #include "opt_ddb.h" @@ -259,7 +259,7 @@ static inline bool uvm_obj_page_tag_p(struct vm_page *pg, int tag) { struct uvm_object *uobj = pg->uobject; - int pgidx = pg->offset >> PAGE_SHIFT; + uint64_t pgidx = pg->offset >> PAGE_SHIFT; KASSERT(uobj != NULL); KASSERT(rw_lock_held(uobj->vmobjlock)); @@ -270,7 +270,7 @@ static inline void uvm_obj_page_set_tag(struct vm_page *pg, int tag) { struct uvm_object *uobj = pg->uobject; - int pgidx = pg->offset >> PAGE_SHIFT; + uint64_t pgidx = pg->offset >> PAGE_SHIFT; KASSERT(uobj != NULL); KASSERT(rw_write_held(uobj->vmobjlock)); @@ -281,7 +281,7 @@ static inline void uvm_obj_page_clear_tag(struct vm_page *pg, int tag) { struct uvm_object *uobj = pg->uobject; - int pgidx = pg->offset >> PAGE_SHIFT; + uint64_t pgidx = pg->offset >> PAGE_SHIFT; KASSERT(uobj != NULL); KASSERT(rw_write_held(uobj->vmobjlock));
CVS commit: src/sys/dev/ic
Module Name:src Committed By: chs Date: Fri Aug 14 09:28:29 UTC 2020 Modified Files: src/sys/dev/ic: ld_icp.c Log Message: fix a bit that I missed in the device_t/softc split 8 years ago. To generate a diff of this commit: cvs rdiff -u -r1.31 -r1.32 src/sys/dev/ic/ld_icp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/ic/ld_icp.c diff -u src/sys/dev/ic/ld_icp.c:1.31 src/sys/dev/ic/ld_icp.c:1.32 --- src/sys/dev/ic/ld_icp.c:1.31 Mon Feb 27 21:32:33 2017 +++ src/sys/dev/ic/ld_icp.c Fri Aug 14 09:28:29 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ld_icp.c,v 1.31 2017/02/27 21:32:33 jdolecek Exp $ */ +/* $NetBSD: ld_icp.c,v 1.32 2020/08/14 09:28:29 chs Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ld_icp.c,v 1.31 2017/02/27 21:32:33 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ld_icp.c,v 1.32 2020/08/14 09:28:29 chs Exp $"); #include #include @@ -167,11 +167,12 @@ ld_icp_attach(device_t parent, device_t static int ld_icp_detach(device_t dv, int flags) { + struct ld_softc *ldsc = device_private(dv); int rv; - if ((rv = ldbegindetach((struct ld_softc *)dv, flags)) != 0) + if ((rv = ldbegindetach(ldsc, flags)) != 0) return (rv); - ldenddetach((struct ld_softc *) dv); + ldenddetach(ldsc); return (0); } @@ -345,7 +346,7 @@ static void ld_icp_adjqparam(device_t dv, int openings) { - ldadjqparam((struct ld_softc *) dv, openings); + ldadjqparam(device_private(dv), openings); } MODULE(MODULE_CLASS_DRIVER, ld_icp, "ld"); /* no icp module yet */
CVS commit: src/sys/dev/ic
Module Name:src Committed By: chs Date: Fri Aug 14 09:26:40 UTC 2020 Modified Files: src/sys/dev/ic: icp.c Log Message: restore the initialization of icp->icp_ccbs that I removed by mistake. To generate a diff of this commit: cvs rdiff -u -r1.33 -r1.34 src/sys/dev/ic/icp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/ic/icp.c diff -u src/sys/dev/ic/icp.c:1.33 src/sys/dev/ic/icp.c:1.34 --- src/sys/dev/ic/icp.c:1.33 Sun Nov 10 21:16:35 2019 +++ src/sys/dev/ic/icp.c Fri Aug 14 09:26:40 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: icp.c,v 1.33 2019/11/10 21:16:35 chs Exp $ */ +/* $NetBSD: icp.c,v 1.34 2020/08/14 09:26:40 chs Exp $ */ /*- * Copyright (c) 2002, 2003 The NetBSD Foundation, Inc. @@ -76,7 +76,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: icp.c,v 1.33 2019/11/10 21:16:35 chs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: icp.c,v 1.34 2020/08/14 09:26:40 chs Exp $"); #include #include @@ -179,6 +179,7 @@ icp_init(struct icp_softc *icp, const ch * Allocate and initialize the command control blocks. */ ic = malloc(sizeof(*ic) * ICP_NCCBS, M_DEVBUF, M_WAITOK | M_ZERO); + icp->icp_ccbs = ic; state++; for (i = 0; i < ICP_NCCBS; i++, ic++) {
CVS commit: src/sys
Module Name:src Committed By: chs Date: Fri Aug 14 09:06:15 UTC 2020 Modified Files: src/sys/miscfs/genfs: genfs_io.c src/sys/uvm: uvm_extern.h uvm_object.c uvm_object.h uvm_page.c uvm_page_status.c uvm_pager.c uvm_vnode.c Log Message: centralize calls from UVM to radixtree into a few functions. in those functions, assert that the object lock is held in the correct mode. To generate a diff of this commit: cvs rdiff -u -r1.99 -r1.100 src/sys/miscfs/genfs/genfs_io.c cvs rdiff -u -r1.230 -r1.231 src/sys/uvm/uvm_extern.h cvs rdiff -u -r1.23 -r1.24 src/sys/uvm/uvm_object.c cvs rdiff -u -r1.38 -r1.39 src/sys/uvm/uvm_object.h cvs rdiff -u -r1.244 -r1.245 src/sys/uvm/uvm_page.c cvs rdiff -u -r1.5 -r1.6 src/sys/uvm/uvm_page_status.c cvs rdiff -u -r1.128 -r1.129 src/sys/uvm/uvm_pager.c cvs rdiff -u -r1.115 -r1.116 src/sys/uvm/uvm_vnode.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/miscfs/genfs/genfs_io.c diff -u src/sys/miscfs/genfs/genfs_io.c:1.99 src/sys/miscfs/genfs/genfs_io.c:1.100 --- src/sys/miscfs/genfs/genfs_io.c:1.99 Mon Aug 10 11:09:15 2020 +++ src/sys/miscfs/genfs/genfs_io.c Fri Aug 14 09:06:14 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_io.c,v 1.99 2020/08/10 11:09:15 rin Exp $ */ +/* $NetBSD: genfs_io.c,v 1.100 2020/08/14 09:06:14 chs Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.99 2020/08/10 11:09:15 rin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.100 2020/08/14 09:06:14 chs Exp $"); #include #include @@ -913,8 +913,7 @@ retry: * shortcut if we have no pages to process. */ - nodirty = radix_tree_empty_tagged_tree_p(>uo_pages, -UVM_PAGE_DIRTY_TAG); + nodirty = uvm_obj_clean_p(uobj); #ifdef DIAGNOSTIC mutex_enter(vp->v_interlock); KASSERT((vp->v_iflag & VI_ONWORKLST) != 0 || nodirty); @@ -922,9 +921,8 @@ retry: #endif if (uobj->uo_npages == 0 || (dirtyonly && nodirty)) { mutex_enter(vp->v_interlock); - if (vp->v_iflag & VI_ONWORKLST) { - if (LIST_FIRST(>v_dirtyblkhd) == NULL) -vn_syncer_remove_from_worklist(vp); + if (vp->v_iflag & VI_ONWORKLST && LIST_EMPTY(>v_dirtyblkhd)) { + vn_syncer_remove_from_worklist(vp); } mutex_exit(vp->v_interlock); if (trans_mp) { @@ -978,8 +976,7 @@ retry: } error = 0; - wasclean = radix_tree_empty_tagged_tree_p(>uo_pages, -UVM_PAGE_WRITEBACK_TAG); + wasclean = uvm_obj_nowriteback_p(uobj); nextoff = startoff; if (endoff == 0 || flags & PGO_ALLPAGES) { endoff = trunc_page(LLONG_MAX); @@ -1030,8 +1027,7 @@ retry: KASSERT(pg->offset >= nextoff); KASSERT(!dirtyonly || uvm_pagegetdirty(pg) != UVM_PAGE_STATUS_CLEAN || - radix_tree_get_tag(>uo_pages, - pg->offset >> PAGE_SHIFT, UVM_PAGE_WRITEBACK_TAG)); + uvm_obj_page_writeback_p(pg)); if (pg->offset >= endoff) { break; @@ -1245,9 +1241,7 @@ retry: * mark pages as WRITEBACK so that concurrent * fsync can find and wait for our activities. */ -radix_tree_set_tag(>uo_pages, -pgs[i]->offset >> PAGE_SHIFT, -UVM_PAGE_WRITEBACK_TAG); +uvm_obj_page_set_writeback(pgs[i]); } if (tpg->offset < startoff || tpg->offset >= endoff) continue; @@ -1332,11 +1326,9 @@ retry: * syncer list. */ - if ((vp->v_iflag & VI_ONWORKLST) != 0 && - radix_tree_empty_tagged_tree_p(>uo_pages, - UVM_PAGE_DIRTY_TAG)) { - if (LIST_FIRST(>v_dirtyblkhd) == NULL) - vn_syncer_remove_from_worklist(vp); + if ((vp->v_iflag & VI_ONWORKLST) != 0 && uvm_obj_clean_p(uobj) && + LIST_EMPTY(>v_dirtyblkhd)) { + vn_syncer_remove_from_worklist(vp); } #if !defined(DEBUG) Index: src/sys/uvm/uvm_extern.h diff -u src/sys/uvm/uvm_extern.h:1.230 src/sys/uvm/uvm_extern.h:1.231 --- src/sys/uvm/uvm_extern.h:1.230 Sun Jun 14 22:25:15 2020 +++ src/sys/uvm/uvm_extern.h Fri Aug 14 09:06:15 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: uvm_extern.h,v 1.230 2020/06/14 22:25:15 ad Exp $ */ +/* $NetBSD: uvm_extern.h,v 1.231 2020/08/14 09:06:15 chs Exp $ */ /* * Copyright (c) 1997 Charles D. Cranor and Washington University. @@ -776,6 +776,14 @@ void uvm_obj_destroy(struct uvm_object int uvm_obj_wirepages(struct uvm_object *, off_t, off_t, struct pglist *); void uvm_obj_unwirepages(struct uvm_object *, off_t, off_t); +bool uvm_obj_clean_p(struct uvm_object *); +bool uvm_obj_nowriteback_p(struct uvm_object *); +bool uvm_obj_page_dirty_p(struct vm_page *); +void uvm_obj_page_set_dirty(struct vm_page *); +void uvm_obj_page_clear_dirty(struct vm_page *); +bool uvm_obj_page_writeback_p(struct vm_page *); +void uvm_obj_page_set_writeback(struct vm_page *); +void uvm_obj_page_clear_writeback(struct vm_page *); /* uvm_page.c */ int uvm_availmem(bool); @@ -826,7 +834,6 @@ int uvn_findpages(struct uvm_object *, unsigned int *, struct
CVS commit: src/sys
Module Name:src Committed By: chs Date: Fri Jul 31 04:07:30 UTC 2020 Modified Files: src/sys/kern: vfs_bio.c src/sys/sys: buf.h src/sys/ufs/ffs: ffs_inode.c Log Message: fix the UFS2 extattr truncate code to play nice with wapbl. also, rather than pull in the FreeBSD V_NORMAL/V_ALT flags to vinvalbuf() and the buf b_xflags field and BX_ALTDATA flag, add a binvalbuf() function to invalid a specific buffer and use that to invalidate the two possible exattr bufs during IO_EXT truncations. To generate a diff of this commit: cvs rdiff -u -r1.296 -r1.297 src/sys/kern/vfs_bio.c cvs rdiff -u -r1.133 -r1.134 src/sys/sys/buf.h cvs rdiff -u -r1.130 -r1.131 src/sys/ufs/ffs/ffs_inode.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vfs_bio.c diff -u src/sys/kern/vfs_bio.c:1.296 src/sys/kern/vfs_bio.c:1.297 --- src/sys/kern/vfs_bio.c:1.296 Thu Jun 11 19:20:46 2020 +++ src/sys/kern/vfs_bio.c Fri Jul 31 04:07:30 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_bio.c,v 1.296 2020/06/11 19:20:46 ad Exp $ */ +/* $NetBSD: vfs_bio.c,v 1.297 2020/07/31 04:07:30 chs Exp $ */ /*- * Copyright (c) 2007, 2008, 2009, 2019, 2020 The NetBSD Foundation, Inc. @@ -123,7 +123,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_bio.c,v 1.296 2020/06/11 19:20:46 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_bio.c,v 1.297 2020/07/31 04:07:30 chs Exp $"); #ifdef _KERNEL_OPT #include "opt_bufcache.h" @@ -1516,6 +1516,36 @@ getnewbuf(int slpflag, int slptimeo, int } /* + * Invalidate the specified buffer if it exists. + */ +void +binvalbuf(struct vnode *vp, daddr_t blkno) +{ + buf_t *bp; + int err; + + mutex_enter(_lock); + + loop: + bp = incore(vp, blkno); + if (bp != NULL) { + err = bbusy(bp, 0, 0, NULL); + if (err == EPASSTHROUGH) + goto loop; + bremfree(bp); + if (ISSET(bp->b_oflags, BO_DELWRI)) { + SET(bp->b_cflags, BC_NOCACHE); + mutex_exit(_lock); + bwrite(bp); + } else { + brelsel(bp, BC_INVAL); + mutex_exit(_lock); + } + } else + mutex_exit(_lock); +} + +/* * Attempt to free an aged buffer off the queues. * Called with queue lock held. * Returns the amount of buffer memory freed. Index: src/sys/sys/buf.h diff -u src/sys/sys/buf.h:1.133 src/sys/sys/buf.h:1.134 --- src/sys/sys/buf.h:1.133 Mon Apr 20 21:39:05 2020 +++ src/sys/sys/buf.h Fri Jul 31 04:07:30 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: buf.h,v 1.133 2020/04/20 21:39:05 ad Exp $ */ +/* $NetBSD: buf.h,v 1.134 2020/07/31 04:07:30 chs Exp $ */ /*- * Copyright (c) 1999, 2000, 2007, 2008 The NetBSD Foundation, Inc. @@ -287,6 +287,7 @@ buf_t *incore(struct vnode *, daddr_t); int allocbuf(buf_t *, int, int); void brelsel(buf_t *, int); void brelse(buf_t *, int); +void binvalbuf(struct vnode *, daddr_t); /* * So-far indeterminate ops that might belong to either Index: src/sys/ufs/ffs/ffs_inode.c diff -u src/sys/ufs/ffs/ffs_inode.c:1.130 src/sys/ufs/ffs/ffs_inode.c:1.131 --- src/sys/ufs/ffs/ffs_inode.c:1.130 Sun Jul 26 00:21:24 2020 +++ src/sys/ufs/ffs/ffs_inode.c Fri Jul 31 04:07:30 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ffs_inode.c,v 1.130 2020/07/26 00:21:24 chs Exp $ */ +/* $NetBSD: ffs_inode.c,v 1.131 2020/07/31 04:07:30 chs Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -61,7 +61,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ffs_inode.c,v 1.130 2020/07/26 00:21:24 chs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ffs_inode.c,v 1.131 2020/07/31 04:07:30 chs Exp $"); #if defined(_KERNEL_OPT) #include "opt_ffs.h" @@ -208,6 +208,7 @@ ffs_truncate(struct vnode *ovp, off_t le { daddr_t lastblock; struct inode *oip = VTOI(ovp); + struct mount *omp = ovp->v_mount; daddr_t bn, lastiblock[UFS_NIADDR], indir_lbn[UFS_NIADDR]; daddr_t blks[UFS_NDADDR + UFS_NIADDR], oldblks[UFS_NDADDR + UFS_NIADDR]; struct fs *fs; @@ -220,6 +221,8 @@ ffs_truncate(struct vnode *ovp, off_t le int sync; struct ufsmount *ump = oip->i_ump; void *dcookie; + long bsize; + bool wapbl = omp->mnt_wapbl != NULL; UFS_WAPBL_JLOCK_ASSERT(ump->um_mountp); @@ -255,11 +258,11 @@ ffs_truncate(struct vnode *ovp, off_t le #ifdef QUOTA (void) chkdq(oip, -extblocks, NOCRED, FORCE); #endif - vinvalbuf(ovp, 0, cred, curlwp, 0, 0); osize = oip->i_din2->di_extsize; oip->i_din2->di_blocks -= extblocks; oip->i_din2->di_extsize = 0; for (i = 0; i < UFS_NXADDR; i++) { +binvalbuf(ovp, -1 - i); oldblks[i] = oip->i_din2->di_extb[i]; oip->i_din2->di_extb[i] = 0; } @@ -269,8 +272,15 @@ ffs_truncate(struct vnode *ovp, off_t le for (i = 0; i < UFS_NXADDR; i++) { if (oldblks[i] == 0) continue; -ffs_blkfree(fs, oip->i_devvp, oldblks[i], -ffs_sblksize(fs, osize, i), oip->i_number); +bsize = ffs_sblksize(fs, osize, i); +if (wapbl) { + error = UFS_WAPBL_REGISTER_DEALLOCATION(omp, + FFS_FSBTODB(fs, oldblks[i]), bsize, NULL); + if
CVS commit: src/sys/ufs
Module Name:src Committed By: chs Date: Sun Jul 26 00:21:24 UTC 2020 Modified Files: src/sys/ufs/ffs: ffs_inode.c src/sys/ufs/ufs: ufs_inode.c Log Message: pull in a bit more FreeBSD code to allow specifying truncation of the regular bmap (IO_NORMAL) independently of the extattr bmap (IO_EXT). fixes fs corruption when removing extattrs in UFS2. To generate a diff of this commit: cvs rdiff -u -r1.129 -r1.130 src/sys/ufs/ffs/ffs_inode.c cvs rdiff -u -r1.110 -r1.111 src/sys/ufs/ufs/ufs_inode.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ffs/ffs_inode.c diff -u src/sys/ufs/ffs/ffs_inode.c:1.129 src/sys/ufs/ffs/ffs_inode.c:1.130 --- src/sys/ufs/ffs/ffs_inode.c:1.129 Sat May 2 22:11:16 2020 +++ src/sys/ufs/ffs/ffs_inode.c Sun Jul 26 00:21:24 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ffs_inode.c,v 1.129 2020/05/02 22:11:16 christos Exp $ */ +/* $NetBSD: ffs_inode.c,v 1.130 2020/07/26 00:21:24 chs Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -61,7 +61,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ffs_inode.c,v 1.129 2020/05/02 22:11:16 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ffs_inode.c,v 1.130 2020/07/26 00:21:24 chs Exp $"); #if defined(_KERNEL_OPT) #include "opt_ffs.h" @@ -232,6 +232,14 @@ ffs_truncate(struct vnode *ovp, off_t le if (length < 0) return (EINVAL); + /* + * Historically clients did not have to specify which data + * they were truncating. So, if not specified, we assume + * traditional behavior, e.g., just the normal data. + */ + if ((ioflag & (IO_EXT | IO_NORMAL)) == 0) + ioflag |= IO_NORMAL; + fs = oip->i_fs; #define i_din2 i_din.ffs2_din extblocks = 0; @@ -267,6 +275,8 @@ ffs_truncate(struct vnode *ovp, off_t le extblocks = 0; } } + if ((ioflag & IO_NORMAL) == 0) + return (0); if (ovp->v_type == VLNK && (oip->i_size < ump->um_maxsymlinklen || (ump->um_maxsymlinklen == 0 && datablocks == 0))) { @@ -376,8 +386,7 @@ ffs_truncate(struct vnode *ovp, off_t le } } - if (!(ioflag & IO_EXT)) - genfs_node_wrlock(ovp); + genfs_node_wrlock(ovp); oip->i_size = length; DIP_ASSIGN(oip, size, length); uvm_vnp_setsize(ovp, length); @@ -586,8 +595,7 @@ out: oip->i_size = length; DIP_ASSIGN(oip, size, length); DIP_ADD(oip, blocks, -blocksreleased); - if (!(ioflag & IO_EXT)) - genfs_node_unlock(ovp); + genfs_node_unlock(ovp); oip->i_flag |= IN_CHANGE; UFS_WAPBL_UPDATE(ovp, NULL, NULL, 0); #if defined(QUOTA) || defined(QUOTA2) Index: src/sys/ufs/ufs/ufs_inode.c diff -u src/sys/ufs/ufs/ufs_inode.c:1.110 src/sys/ufs/ufs/ufs_inode.c:1.111 --- src/sys/ufs/ufs/ufs_inode.c:1.110 Sat Apr 18 19:18:34 2020 +++ src/sys/ufs/ufs/ufs_inode.c Sun Jul 26 00:21:24 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_inode.c,v 1.110 2020/04/18 19:18:34 christos Exp $ */ +/* $NetBSD: ufs_inode.c,v 1.111 2020/07/26 00:21:24 chs Exp $ */ /* * Copyright (c) 1991, 1993 @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ufs_inode.c,v 1.110 2020/04/18 19:18:34 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ufs_inode.c,v 1.111 2020/07/26 00:21:24 chs Exp $"); #if defined(_KERNEL_OPT) #include "opt_ffs.h" @@ -327,5 +327,5 @@ ufs_truncate_all(struct vnode *vp) if (isize == 0) return 0; - return ufs_truncate_retry(vp, IO_EXT, 0, NOCRED); + return ufs_truncate_retry(vp, IO_NORMAL | IO_EXT, 0, NOCRED); }
CVS commit: src/sys/ufs/ffs
Module Name:src Committed By: chs Date: Sun Jul 26 00:20:14 UTC 2020 Modified Files: src/sys/ufs/ffs: ffs_alloc.c Log Message: skip the assertions about page-locking when allocating to the extattr bmap, since extattrs do not use the page cache. To generate a diff of this commit: cvs rdiff -u -r1.167 -r1.168 src/sys/ufs/ffs/ffs_alloc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ffs/ffs_alloc.c diff -u src/sys/ufs/ffs/ffs_alloc.c:1.167 src/sys/ufs/ffs/ffs_alloc.c:1.168 --- src/sys/ufs/ffs/ffs_alloc.c:1.167 Sat Apr 18 19:18:34 2020 +++ src/sys/ufs/ffs/ffs_alloc.c Sun Jul 26 00:20:13 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ffs_alloc.c,v 1.167 2020/04/18 19:18:34 christos Exp $ */ +/* $NetBSD: ffs_alloc.c,v 1.168 2020/07/26 00:20:13 chs Exp $ */ /*- * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. @@ -70,7 +70,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ffs_alloc.c,v 1.167 2020/04/18 19:18:34 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ffs_alloc.c,v 1.168 2020/07/26 00:20:13 chs Exp $"); #if defined(_KERNEL_OPT) #include "opt_ffs.h" @@ -204,7 +204,7 @@ ffs_alloc(struct inode *ip, daddr_t lbn, */ struct vnode *vp = ITOV(ip); - if (vp->v_type == VREG && + if (vp->v_type == VREG && (flags & IO_EXT) == 0 && ffs_lblktosize(fs, (voff_t)lbn) < round_page(vp->v_size) && ((vp->v_vflag & VV_MAPPED) != 0 || (size & PAGE_MASK) != 0 || ffs_blkoff(fs, size) != 0)) {
CVS commit: src/doc
Module Name:src Committed By: chs Date: Sat Jul 4 21:03:50 UTC 2020 Modified Files: src/doc: CHANGES Log Message: note x86 Xen kernel module change. To generate a diff of this commit: cvs rdiff -u -r1.2708 -r1.2709 src/doc/CHANGES Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/doc/CHANGES diff -u src/doc/CHANGES:1.2708 src/doc/CHANGES:1.2709 --- src/doc/CHANGES:1.2708 Fri Jul 3 10:47:29 2020 +++ src/doc/CHANGES Sat Jul 4 21:03:50 2020 @@ -1,4 +1,4 @@ -# LIST OF CHANGES FROM LAST RELEASE: <$Revision: 1.2708 $> +# LIST OF CHANGES FROM LAST RELEASE: <$Revision: 1.2709 $> # # # [Note: This file does not mention every change made to the NetBSD source tree. @@ -241,3 +241,5 @@ Changes from NetBSD 9.0 to NetBSD 10.0: cgd(4): Add support for Adiantum cipher, providing much better software performance than AES-CBC or AES-XTS. [riastradh 20200629] dhcpcd: Import version 9.1.4 [roy 20200703] + x86: Xen kernels now use the same kernel modules as native kernels. + [chs 20200704]
CVS commit: src
Module Name:src Committed By: chs Date: Sat Jul 4 21:02:16 UTC 2020 Modified Files: src/distrib/sets/lists/modules: md.amd64 md.i386 src/share/mk: bsd.own.mk src/sys/arch/x86/x86: x86_machdep.c src/sys/modules/arch: archdirs.mk Removed Files: src/sys/modules/arch/x86/amd64-xen: Makefile bsd.amd64-xen.mk src/sys/modules/arch/x86/i386pae-xen: Makefile bsd.i386pae-xen.mk Log Message: the x86 xen and non-xen modules are identical, so remove the unneeded extra copies. Xen kernels now use the same modules as native kernels. To generate a diff of this commit: cvs rdiff -u -r1.86 -r1.87 src/distrib/sets/lists/modules/md.amd64 \ src/distrib/sets/lists/modules/md.i386 cvs rdiff -u -r1.1199 -r1.1200 src/share/mk/bsd.own.mk cvs rdiff -u -r1.143 -r1.144 src/sys/arch/x86/x86/x86_machdep.c cvs rdiff -u -r1.5 -r1.6 src/sys/modules/arch/archdirs.mk cvs rdiff -u -r1.1 -r0 src/sys/modules/arch/x86/amd64-xen/Makefile cvs rdiff -u -r1.2 -r0 src/sys/modules/arch/x86/amd64-xen/bsd.amd64-xen.mk cvs rdiff -u -r1.1 -r0 src/sys/modules/arch/x86/i386pae-xen/Makefile cvs rdiff -u -r1.2 -r0 \ src/sys/modules/arch/x86/i386pae-xen/bsd.i386pae-xen.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/distrib/sets/lists/modules/md.amd64 diff -u src/distrib/sets/lists/modules/md.amd64:1.86 src/distrib/sets/lists/modules/md.amd64:1.87 --- src/distrib/sets/lists/modules/md.amd64:1.86 Thu Mar 12 15:04:13 2020 +++ src/distrib/sets/lists/modules/md.amd64 Sat Jul 4 21:02:16 2020 @@ -1,7 +1,4 @@ -# $NetBSD: md.amd64,v 1.86 2020/03/12 15:04:13 pgoyette Exp $ -# -# NOTE that there are two sets of files here: -# @MODULEDIR@ and amd64-xen +# $NetBSD: md.amd64,v 1.87 2020/07/04 21:02:16 chs Exp $ # ./@MODULEDIR@/acpiacadmodules-base-kernel kmod ./@MODULEDIR@/acpiacad/acpiacad.kmod modules-base-kernel kmod Index: src/distrib/sets/lists/modules/md.i386 diff -u src/distrib/sets/lists/modules/md.i386:1.86 src/distrib/sets/lists/modules/md.i386:1.87 --- src/distrib/sets/lists/modules/md.i386:1.86 Sat Feb 29 18:46:12 2020 +++ src/distrib/sets/lists/modules/md.i386 Sat Jul 4 21:02:16 2020 @@ -1,8 +1,5 @@ -# $NetBSD: md.i386,v 1.86 2020/02/29 18:46:12 skrll Exp $ +# $NetBSD: md.i386,v 1.87 2020/07/04 21:02:16 chs Exp $ # -# NOTE that there are two sets of files here: @MODULEDIR@ and i386pae-xen -# - ./@MODULEDIR@/acpiacadmodules-base-kernel kmod ./@MODULEDIR@/acpiacad/acpiacad.kmod modules-base-kernel kmod ./@MODULEDIR@/acpibatmodules-base-kernel kmod Index: src/share/mk/bsd.own.mk diff -u src/share/mk/bsd.own.mk:1.1199 src/share/mk/bsd.own.mk:1.1200 --- src/share/mk/bsd.own.mk:1.1199 Sat Jun 6 22:06:42 2020 +++ src/share/mk/bsd.own.mk Sat Jul 4 21:02:16 2020 @@ -1,4 +1,4 @@ -# $NetBSD: bsd.own.mk,v 1.1199 2020/06/06 22:06:42 joerg Exp $ +# $NetBSD: bsd.own.mk,v 1.1200 2020/07/04 21:02:16 chs Exp $ # This needs to be before bsd.init.mk .if defined(BSD_MK_COMPAT_FILE) @@ -1006,8 +1006,7 @@ MKCOMPATTESTS:= no MKCOMPATX11:= no .endif -.if ${MACHINE_ARCH} == "x86_64" || ${MACHINE_ARCH} == "i386" \ -|| ${MACHINE_ARCH} == "mips64eb" || ${MACHINE_ARCH} == "mips64el" \ +.if ${MACHINE_ARCH} == "mips64eb" || ${MACHINE_ARCH} == "mips64el" \ || (${MACHINE} == "evbppc" && ${MACHINE_ARCH} == "powerpc") MKCOMPATMODULES?= yes .else Index: src/sys/arch/x86/x86/x86_machdep.c diff -u src/sys/arch/x86/x86/x86_machdep.c:1.143 src/sys/arch/x86/x86/x86_machdep.c:1.144 --- src/sys/arch/x86/x86/x86_machdep.c:1.143 Thu May 21 21:12:30 2020 +++ src/sys/arch/x86/x86/x86_machdep.c Sat Jul 4 21:02:16 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: x86_machdep.c,v 1.143 2020/05/21 21:12:30 ad Exp $ */ +/* $NetBSD: x86_machdep.c,v 1.144 2020/07/04 21:02:16 chs Exp $ */ /*- * Copyright (c) 2002, 2006, 2007 YAMAMOTO Takashi, @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: x86_machdep.c,v 1.143 2020/05/21 21:12:30 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: x86_machdep.c,v 1.144 2020/07/04 21:02:16 chs Exp $"); #include "opt_modular.h" #include "opt_physmem.h" @@ -100,10 +100,6 @@ static char x86_cpu_idle_text[16]; #include #include #endif -#ifdef XENPV -char module_machine_amd64_xen[] = "amd64-xen"; -char module_machine_i386pae_xen[] = "i386pae-xen"; -#endif #ifndef XENPV void (*delay_func)(unsigned int) = i8254_delay; @@ -224,15 +220,6 @@ module_init_md(void) struct btinfo_modulelist *biml; struct bi_modulelist_entry *bi, *bimax; - /* setup module path for XEN kernels */ -#ifdef XENPV -#ifdef __x86_64__ - module_machine = module_machine_amd64_xen; -#else - module_machine = module_machine_i386pae_xen; -#endif -#endif - biml = lookup_bootinfo(BTINFO_MODULELIST); if (biml == NULL) { aprint_debug("No module info at boot\n"); Index: src/sys/modules/arch/archdirs.mk diff -u src/sys/modules/arch/archdirs.mk:1.5 src/sys/modules/arch/archdirs.mk:1.6 ---
CVS commit: src/sys/dev/iscsi
Module Name:src Committed By: chs Date: Sun Jun 21 23:08:16 UTC 2020 Modified Files: src/sys/dev/iscsi: iscsi_globals.h iscsi_ioctl.c Log Message: avoid the use of UVM internals in the iscsi ioctl code. copyin/out are fine in this context. To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 src/sys/dev/iscsi/iscsi_globals.h cvs rdiff -u -r1.31 -r1.32 src/sys/dev/iscsi/iscsi_ioctl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/iscsi/iscsi_globals.h diff -u src/sys/dev/iscsi/iscsi_globals.h:1.25 src/sys/dev/iscsi/iscsi_globals.h:1.26 --- src/sys/dev/iscsi/iscsi_globals.h:1.25 Sun Apr 21 11:45:08 2019 +++ src/sys/dev/iscsi/iscsi_globals.h Sun Jun 21 23:08:16 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: iscsi_globals.h,v 1.25 2019/04/21 11:45:08 maya Exp $ */ +/* $NetBSD: iscsi_globals.h,v 1.26 2020/06/21 23:08:16 chs Exp $ */ /*- * Copyright (c) 2004,2005,2006,2011 The NetBSD Foundation, Inc. @@ -651,10 +651,6 @@ int kill_all_sessions(void); void handle_connection_error(connection_t *, uint32_t, int); void add_connection_cleanup(connection_t *); -#ifndef ISCSI_MINIMAL -uint32_t map_databuf(struct proc *, void **, uint32_t); -void unmap_databuf(struct proc *, void *, uint32_t); -#endif int iscsiioctl(struct file *, u_long, void *); session_t *find_session(uint32_t); Index: src/sys/dev/iscsi/iscsi_ioctl.c diff -u src/sys/dev/iscsi/iscsi_ioctl.c:1.31 src/sys/dev/iscsi/iscsi_ioctl.c:1.32 --- src/sys/dev/iscsi/iscsi_ioctl.c:1.31 Tue May 26 00:50:54 2020 +++ src/sys/dev/iscsi/iscsi_ioctl.c Sun Jun 21 23:08:16 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: iscsi_ioctl.c,v 1.31 2020/05/26 00:50:54 kamil Exp $ */ +/* $NetBSD: iscsi_ioctl.c,v 1.32 2020/06/21 23:08:16 chs Exp $ */ /*- * Copyright (c) 2004,2005,2006,2011 The NetBSD Foundation, Inc. @@ -34,11 +34,7 @@ #include #include #include - -#ifndef ISCSI_MINIMAL -#include -#include -#endif +#include static kmutex_t iscsi_cleanup_mtx; static kcondvar_t iscsi_cleanup_cv; @@ -1278,92 +1274,6 @@ restore_connection(iscsi_login_parameter #ifndef ISCSI_MINIMAL /* - * map_databuf: - *Map user-supplied data buffer into kernel space. - * - *Parameter: - * pIN: The proc pointer of the caller - * buf IN/OUT: The virtual address of the buffer, modified - * on exit to reflect kernel VA. - * datalen IN: The size of the data buffer - * - *Returns: - * An ISCSI status code on error, else 0. - */ - -uint32_t -map_databuf(struct proc *p, void **buf, uint32_t datalen) -{ - vaddr_t kva, databuf, offs; - int error; - - /* page align address */ - databuf = (vaddr_t) * buf & ~PAGE_MASK; - /* offset of VA into page */ - offs = (vaddr_t) * buf & PAGE_MASK; - /* round to full page including offset */ - datalen = (datalen + offs + PAGE_MASK) & ~PAGE_MASK; - - /* Do some magic to the vm space reference count (copied from "copyin_proc") */ - if ((p->p_sflag & PS_WEXIT) || (p->p_vmspace->vm_refcnt < 1)) { - return ISCSI_STATUS_NO_RESOURCES; - } - uvmspace_addref(p->p_vmspace); - - /* this is lifted from uvm_io */ - error = uvm_map_extract(>p_vmspace->vm_map, databuf, datalen, - kernel_map, , - UVM_EXTRACT_QREF | UVM_EXTRACT_CONTIG | -UVM_EXTRACT_FIXPROT); - if (error) { - DEBOUT(("uvm_map_extract failed, error = %d\n", error)); - return ISCSI_STATUS_NO_RESOURCES; - } - /* add offset back into kernel VA */ - *buf = (void *) (kva + offs); - - return 0; -} - - -/* - * unmap_databuf: - *Remove kernel space mapping of data buffer. - * - *Parameter: - * pIN: The proc pointer of the caller - * buf IN: The kernel virtual address of the buffer - * datalen IN: The size of the data buffer - * - *Returns: - * An ISCSI status code on error, else 0. - */ - -void -unmap_databuf(struct proc *p, void *buf, uint32_t datalen) -{ - struct vm_map_entry *dead_entries; - vaddr_t databuf; - - /* round to full page */ - datalen = (datalen + ((uintptr_t) buf & PAGE_MASK) + PAGE_MASK) & ~PAGE_MASK; - /* page align address */ - databuf = (vaddr_t) buf & ~PAGE_MASK; - - /* following code lifted almost verbatim from uvm_io.c */ - vm_map_lock(kernel_map); - uvm_unmap_remove(kernel_map, databuf, databuf + datalen, _entries, - 0); - vm_map_unlock(kernel_map); - if (dead_entries != NULL) { - uvm_unmap_detach(dead_entries, AMAP_REFALL); - } - /* this apparently reverses the magic to the vm ref count, from copyin_proc */ - uvmspace_free(p->p_vmspace); -} - - -/* * io_command: *Handle the io_command ioctl. * @@ -1376,8 +1286,9 @@ static void io_command(iscsi_iocommand_parameters_t *par, struct lwp *l) { uint32_t datalen = par->req.datalen; - void *databuf = par->req.databuf; session_t *session; + void *kbuf = NULL; + int error; DEB(9, ("ISCSI: io_command, SID=%d, lun=%" PRIu64 "\n", par->session_id,
CVS commit: src/sys
Module Name:src Committed By: chs Date: Sun Jun 14 01:40:06 UTC 2020 Modified Files: src/sys/arch/algor/dev: mainbus.c src/sys/arch/amiga/pci: em4k.c empb.c mppb.c p5pb.c src/sys/arch/arc/pci: necpb.c src/sys/arch/arm/broadcom: bcm53xx_pax.c src/sys/arch/arm/fdt: pcihost_fdt.c src/sys/arch/arm/gemini: gemini_pci.c src/sys/arch/arm/imx: imx6_pcie.c src/sys/arch/arm/imx/fdt: imx6_pcie.c src/sys/arch/arm/ixp12x0: ixp12x0_pci.c src/sys/arch/arm/nvidia: tegra_pcie.c src/sys/arch/arm/s3c2xx0: s3c2800_pci.c src/sys/arch/arm/xscale: becc_pci.c i80312_pci.c i80321_pci.c ixp425_pci.c src/sys/arch/bebox/bebox: mainbus.c src/sys/arch/cobalt/dev: gt.c src/sys/arch/evbarm/ifpga: ifpga.c src/sys/arch/evbmips/gdium: mainbus.c src/sys/arch/evbmips/loongson: mainbus.c src/sys/arch/evbmips/malta/dev: mainbus.c src/sys/arch/evbppc/walnut/pci: pchb.c src/sys/arch/hppa/dev: astro.c dino.c uturn.c src/sys/arch/ibmnws/ibmnws: mainbus.c src/sys/arch/mvmeppc/mvmeppc: mainbus.c src/sys/arch/ofppc/pci: ofwpci.c src/sys/arch/powerpc/ibm4xx/pci: pchb.c src/sys/arch/prep/prep: mainbus.c src/sys/arch/sandpoint/sandpoint: mainbus.c src/sys/arch/sgimips/gio: pci_gio.c src/sys/arch/sgimips/mace: pci_mace.c src/sys/arch/sh3/dev: shpcic.c src/sys/arch/sparc/dev: vme_machdep.c src/sys/arch/sparc/sparc: iommu.c src/sys/arch/sparc64/dev: sbus.c src/sys/arch/vax/uba: qv.c src/sys/arch/x68k/dev: intio.c src/sys/dev/ic: cpc700.c src/sys/dev/marvell: gtpci.c mvpex.c Log Message: replace EX_NOWAIT with EX_WAITOK in device attach methods. remove checks for failures that can no longer occur. To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/sys/arch/algor/dev/mainbus.c cvs rdiff -u -r1.4 -r1.5 src/sys/arch/amiga/pci/em4k.c cvs rdiff -u -r1.11 -r1.12 src/sys/arch/amiga/pci/empb.c cvs rdiff -u -r1.8 -r1.9 src/sys/arch/amiga/pci/mppb.c cvs rdiff -u -r1.15 -r1.16 src/sys/arch/amiga/pci/p5pb.c cvs rdiff -u -r1.43 -r1.44 src/sys/arch/arc/pci/necpb.c cvs rdiff -u -r1.17 -r1.18 src/sys/arch/arm/broadcom/bcm53xx_pax.c cvs rdiff -u -r1.15 -r1.16 src/sys/arch/arm/fdt/pcihost_fdt.c cvs rdiff -u -r1.20 -r1.21 src/sys/arch/arm/gemini/gemini_pci.c cvs rdiff -u -r1.15 -r1.16 src/sys/arch/arm/imx/imx6_pcie.c cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/imx/fdt/imx6_pcie.c cvs rdiff -u -r1.15 -r1.16 src/sys/arch/arm/ixp12x0/ixp12x0_pci.c cvs rdiff -u -r1.29 -r1.30 src/sys/arch/arm/nvidia/tegra_pcie.c cvs rdiff -u -r1.27 -r1.28 src/sys/arch/arm/s3c2xx0/s3c2800_pci.c cvs rdiff -u -r1.19 -r1.20 src/sys/arch/arm/xscale/becc_pci.c cvs rdiff -u -r1.17 -r1.18 src/sys/arch/arm/xscale/i80312_pci.c cvs rdiff -u -r1.16 -r1.17 src/sys/arch/arm/xscale/i80321_pci.c cvs rdiff -u -r1.12 -r1.13 src/sys/arch/arm/xscale/ixp425_pci.c cvs rdiff -u -r1.30 -r1.31 src/sys/arch/bebox/bebox/mainbus.c cvs rdiff -u -r1.30 -r1.31 src/sys/arch/cobalt/dev/gt.c cvs rdiff -u -r1.26 -r1.27 src/sys/arch/evbarm/ifpga/ifpga.c cvs rdiff -u -r1.5 -r1.6 src/sys/arch/evbmips/gdium/mainbus.c cvs rdiff -u -r1.2 -r1.3 src/sys/arch/evbmips/loongson/mainbus.c cvs rdiff -u -r1.13 -r1.14 src/sys/arch/evbmips/malta/dev/mainbus.c cvs rdiff -u -r1.13 -r1.14 src/sys/arch/evbppc/walnut/pci/pchb.c cvs rdiff -u -r1.1 -r1.2 src/sys/arch/hppa/dev/astro.c cvs rdiff -u -r1.5 -r1.6 src/sys/arch/hppa/dev/dino.c cvs rdiff -u -r1.2 -r1.3 src/sys/arch/hppa/dev/uturn.c cvs rdiff -u -r1.12 -r1.13 src/sys/arch/ibmnws/ibmnws/mainbus.c cvs rdiff -u -r1.17 -r1.18 src/sys/arch/mvmeppc/mvmeppc/mainbus.c cvs rdiff -u -r1.15 -r1.16 src/sys/arch/ofppc/pci/ofwpci.c cvs rdiff -u -r1.11 -r1.12 src/sys/arch/powerpc/ibm4xx/pci/pchb.c cvs rdiff -u -r1.35 -r1.36 src/sys/arch/prep/prep/mainbus.c cvs rdiff -u -r1.30 -r1.31 src/sys/arch/sandpoint/sandpoint/mainbus.c cvs rdiff -u -r1.15 -r1.16 src/sys/arch/sgimips/gio/pci_gio.c cvs rdiff -u -r1.21 -r1.22 src/sys/arch/sgimips/mace/pci_mace.c cvs rdiff -u -r1.18 -r1.19 src/sys/arch/sh3/dev/shpcic.c cvs rdiff -u -r1.69 -r1.70 src/sys/arch/sparc/dev/vme_machdep.c cvs rdiff -u -r1.95 -r1.96 src/sys/arch/sparc/sparc/iommu.c cvs rdiff -u -r1.98 -r1.99 src/sys/arch/sparc64/dev/sbus.c cvs rdiff -u -r1.34 -r1.35 src/sys/arch/vax/uba/qv.c cvs rdiff -u -r1.46 -r1.47 src/sys/arch/x68k/dev/intio.c cvs rdiff -u -r1.19 -r1.20 src/sys/dev/ic/cpc700.c cvs rdiff -u -r1.32 -r1.33 src/sys/dev/marvell/gtpci.c cvs rdiff -u -r1.18 -r1.19 src/sys/dev/marvell/mvpex.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/algor/dev/mainbus.c diff -u src/sys/arch/algor/dev/mainbus.c:1.26 src/sys/arch/algor/dev/mainbus.c:1.27 --- src/sys/arch/algor/dev/mainbus.c:1.26 Fri Jan 27 18:52:47 2012 +++
CVS commit: src/sys/dev/ic
Module Name:src Committed By: chs Date: Sun May 17 21:50:47 UTC 2020 Modified Files: src/sys/dev/ic: dwc_gmac.c dwc_gmac_reg.h Log Message: Mask all the MMC counter interrupts if the MMC module is present. To generate a diff of this commit: cvs rdiff -u -r1.69 -r1.70 src/sys/dev/ic/dwc_gmac.c cvs rdiff -u -r1.19 -r1.20 src/sys/dev/ic/dwc_gmac_reg.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/ic/dwc_gmac.c diff -u src/sys/dev/ic/dwc_gmac.c:1.69 src/sys/dev/ic/dwc_gmac.c:1.70 --- src/sys/dev/ic/dwc_gmac.c:1.69 Wed Jan 29 14:14:55 2020 +++ src/sys/dev/ic/dwc_gmac.c Sun May 17 21:50:47 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: dwc_gmac.c,v 1.69 2020/01/29 14:14:55 thorpej Exp $ */ +/* $NetBSD: dwc_gmac.c,v 1.70 2020/05/17 21:50:47 chs Exp $ */ /*- * Copyright (c) 2013, 2014 The NetBSD Foundation, Inc. @@ -41,7 +41,7 @@ #include -__KERNEL_RCSID(1, "$NetBSD: dwc_gmac.c,v 1.69 2020/01/29 14:14:55 thorpej Exp $"); +__KERNEL_RCSID(1, "$NetBSD: dwc_gmac.c,v 1.70 2020/05/17 21:50:47 chs Exp $"); /* #define DWC_GMAC_DEBUG 1 */ @@ -254,6 +254,16 @@ dwc_gmac_attach(struct dwc_gmac_softc *s } else { sc->sc_descm = _methods_standard; } + if (hwft & GMAC_DMA_FEAT_RMON) { + uint32_t val; + + /* Mask all MMC interrupts */ + val = 0x; + bus_space_write_4(sc->sc_bst, sc->sc_bsh, + GMAC_MMC_RX_INT_MSK, val); + bus_space_write_4(sc->sc_bst, sc->sc_bsh, + GMAC_MMC_TX_INT_MSK, val); + } /* * Allocate Tx and Rx rings Index: src/sys/dev/ic/dwc_gmac_reg.h diff -u src/sys/dev/ic/dwc_gmac_reg.h:1.19 src/sys/dev/ic/dwc_gmac_reg.h:1.20 --- src/sys/dev/ic/dwc_gmac_reg.h:1.19 Mon Oct 8 17:09:31 2018 +++ src/sys/dev/ic/dwc_gmac_reg.h Sun May 17 21:50:47 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: dwc_gmac_reg.h,v 1.19 2018/10/08 17:09:31 martin Exp $ */ +/* $NetBSD: dwc_gmac_reg.h,v 1.20 2020/05/17 21:50:47 chs Exp $ */ /*- * Copyright (c) 2013, 2014 The NetBSD Foundation, Inc. @@ -79,6 +79,46 @@ #define AWIN_GMAC_MAC_FLOWCTRL_TFE __BIT(1) #define AWIN_GMAC_MAC_FLOWCTRL_BUSY __BIT(0) +#define GMAC_MMC_CTRL 0x0100 /* MMC control */ +#define GMAC_MMC_RX_INTR 0x0104 /* MMC RX interrupt */ +#define GMAC_MMC_TX_INTR 0x0108 /* MMC TX interrupt */ +#define GMAC_MMC_RX_INT_MSK 0x010c /* MMC RX interrupt mask */ +#define GMAC_MMC_TX_INT_MSK 0x0110 /* MMC TX interrupt mask */ +#define GMAC_MMC_TXOCTETCNT_GB 0x0114 /* TX octet good+bad */ +#define GMAC_MMC_TXFRMCNT_GB 0x0118 /* TX frame good+bad */ +#define GMAC_MMC_TXUNDFLWERR 0x0148 /* TX underflow */ +#define GMAC_MMC_TXCARERR 0x0160 /* TX carrier error */ +#define GMAC_MMC_TXOCTETCNT_G 0x0164 /* TX octet good */ +#define GMAC_MMC_TXFRMCNT_G 0x0168 /* TX frame good */ +#define GMAC_MMC_RXFRMCNT_GB 0x0180 /* RX frame good+bad */ +#define GMAC_MMC_RXOCTETCNT_GB 0x0184 /* RX octet good+bad */ +#define GMAC_MMC_RXOCTETCNT_G 0x0188 /* RX octet good */ +#define GMAC_MMC_RXMCFRMCNT_G 0x0190 /* RX mcast frame good */ +#define GMAC_MMC_RXCRCERR 0x0194 /* RX CRC error */ +#define GMAC_MMC_RXLENERR 0x01c8 /* RX length error */ +#define GMAC_MMC_RXFIFOOVRFLW 0x01d4 /* RX FIFO overflow */ +#define GMAC_MMC_IPC_INT_MSK 0x0200 /* RX csum offload intr mask */ +#define GMAC_MMC_IPC_INTR 0x0208 /* RX csum offload interrupt */ +#define GMAC_MMC_RXIPV4GFRM 0x0210 /* RX IPv4 good frame */ +#define GMAC_MMC_RXIPV4HDERRFRM 0x0214 /* RX IPv4 header error */ +#define GMAC_MMC_RXIPV6GFRM 0x0224 /* RX IPv6 good frame */ +#define GMAC_MMC_RXIPV6HDERRFRM 0x0228 /* RX IPv6 header error */ +#define GMAC_MMC_RXUDPERRFRM 0x0234 /* RX UDP csum error frame */ +#define GMAC_MMC_RXTCPERRFRM 0x023c /* RX TCP csum error frame */ +#define GMAC_MMC_RXICMPERRFRM 0x0244 /* RX ICMP csum error frame */ +#define GMAC_MMC_RXIPV4HDERROCT 0x0254 /* RX IPv4 header error octets */ +#define GMAC_MMC_RXIPV6HDERROCT 0x0268 /* RX IPv6 header error octets */ +#define GMAC_MMC_RXUDPERROCT 0x0274 /* RX UDP error octets */ +#define GMAC_MMC_RXTCPERROCT 0x027c /* RX TCP error octets */ +#define GMAC_MMC_RXICMPERROCT 0x0280 /* RX ICMP error octets */ + +#define GMAC_MMC_CTRL_FHP __BIT(5) /* Full-Half preset */ +#define GMAC_MMC_CTRL_CP __BIT(4) /* Counters preset */ +#define GMAC_MMC_CTRL_MCF __BIT(3) /* MMC counter freeze */ +#define GMAC_MMC_CTRL_ROR __BIT(2) /* reset on read */ +#define GMAC_MMC_CTRL_CSR __BIT(1) /* Counter stop rollover */ +#define GMAC_MMC_CTRL_CR __BIT(0) /* Counters reset */ + #define AWIN_GMAC_DMA_BUSMODE 0x1000 #define AWIN_GMAC_DMA_TXPOLL 0x1004 #define AWIN_GMAC_DMA_RXPOLL 0x1008 @@ -128,7 +168,12 @@ burst len */ #define GMAC_BUSMODE_RESET __BIT(0) -#define AWIN_GMAC_MII_IRQ __BIT(0) +#define AWIN_GMAC_MRCOIS __BIT(7) /* MMC RX csum offload intr */ +#define AWIN_GMAC_MTIS __BIT(6) /* MMC TX interrupt */ +#define AWIN_GMAC_MRIS __BIT(3) /* MMC RX interrupt */ +#define AWIN_GMAC_MIS
CVS commit: src/external/cddl/osnet/dist/uts/common/fs/zfs
Module Name:src Committed By: chs Date: Wed May 13 05:52:54 UTC 2020 Modified Files: src/external/cddl/osnet/dist/uts/common/fs/zfs: zfs_vnops.c Log Message: fix the handling in putpage of the page containing EOF. To generate a diff of this commit: cvs rdiff -u -r1.65 -r1.66 \ src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c diff -u src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c:1.65 src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c:1.66 --- src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c:1.65 Thu May 7 09:12:03 2020 +++ src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c Wed May 13 05:52:54 2020 @@ -6066,9 +6066,29 @@ zfs_putapage(vnode_t *vp, page_t **pp, i goto out_unbusy; } + /* + * Calculate the length and assert that no whole pages are past EOF. + * This check is equivalent to "off + len <= round_page(zp->z_size)", + * with gyrations to avoid signed integer overflow. + */ + off = pp[0]->offset; len = count * PAGESIZE; - KASSERT(off + len <= round_page(zp->z_size)); + KASSERT(off <= zp->z_size); + KASSERT(len <= round_page(zp->z_size)); + KASSERT(off <= round_page(zp->z_size) - len); + + /* + * If EOF is within the last page, reduce len to avoid writing past + * the file size in the ZFS buffer. Assert that + * "off + len <= zp->z_size", again avoiding signed integer overflow. + */ + + if (len > zp->z_size - off) { + len = zp->z_size - off; + } + KASSERT(len <= zp->z_size); + KASSERT(off <= zp->z_size - len); if (zfs_owner_overquota(zfsvfs, zp, B_FALSE) || zfs_owner_overquota(zfsvfs, zp, B_TRUE)) {
CVS commit: src/sys/arch/aarch64/aarch64
Module Name:src Committed By: chs Date: Wed May 13 05:37:16 UTC 2020 Modified Files: src/sys/arch/aarch64/aarch64: db_machdep.c Log Message: for "mach cpuinfo", print ci_biglock_count too. To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/sys/arch/aarch64/aarch64/db_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/aarch64/aarch64/db_machdep.c diff -u src/sys/arch/aarch64/aarch64/db_machdep.c:1.21 src/sys/arch/aarch64/aarch64/db_machdep.c:1.22 --- src/sys/arch/aarch64/aarch64/db_machdep.c:1.21 Thu Apr 16 08:03:30 2020 +++ src/sys/arch/aarch64/aarch64/db_machdep.c Wed May 13 05:37:16 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: db_machdep.c,v 1.21 2020/04/16 08:03:30 ryo Exp $ */ +/* $NetBSD: db_machdep.c,v 1.22 2020/05/13 05:37:16 chs Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: db_machdep.c,v 1.21 2020/04/16 08:03:30 ryo Exp $"); +__KERNEL_RCSID(0, "$NetBSD: db_machdep.c,v 1.22 2020/05/13 05:37:16 chs Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd32.h" @@ -291,6 +291,8 @@ show_cpuinfo(struct cpu_info *ci) >ci_astpending, cpuid, cpuinfobuf.ci_astpending); db_printf("%p cpu[%lu].ci_intr_depth = %u\n", >ci_intr_depth, cpuid, cpuinfobuf.ci_intr_depth); + db_printf("%p cpu[%lu].ci_biglock_count = %u\n", + >ci_biglock_count, cpuid, cpuinfobuf.ci_biglock_count); } void
CVS commit: src
Module Name:src Committed By: chs Date: Mon Apr 13 00:27:17 UTC 2020 Modified Files: src/share/man/man9: pool.9 pool_cache.9 src/sys/arch/arm/arm32: pmap.c src/sys/arch/xen/x86: xen_shm_machdep.c src/sys/arch/xen/xen: xbdback_xenbus.c src/sys/dev/ic: ncr53c9x.c src/sys/dev/raidframe: rf_netbsdkintf.c rf_reconmap.c src/sys/dev/scsipi: scsipi_base.c src/sys/kern: subr_pool.c src/sys/opencrypto: cryptodev.c src/sys/sys: pool.h Log Message: slightly change and fix the semantics of pool_set*wat(), pool_sethardlimit() and pool_prime() (and their pool_cache_* counterparts): - the pool_set*wat() APIs are supposed to specify thresholds for the count of free items in the pool before pool pages are automatically allocated or freed during pool_get() / pool_put(), whereas pool_sethardlimit() and pool_prime() are supposed to specify minimum and maximum numbers of total items in the pool (both free and allocated). these were somewhat conflated in the existing code, so separate them as they were intended. - change pool_prime() to take an absolute number of items to preallocate rather than an increment over whatever was done before, and wait for any memory allocations to succeed. since pool_prime() can no longer fail after this, change its return value to void and adjust all callers. - pool_setlowat() is documented as not immediately attempting to allocate any memory, but it was changed some time ago to immediately try to allocate up to the lowat level, so just fix the manpage to describe the current behaviour. - add a pool_cache_prime() to complete the API set. To generate a diff of this commit: cvs rdiff -u -r1.47 -r1.48 src/share/man/man9/pool.9 cvs rdiff -u -r1.20 -r1.21 src/share/man/man9/pool_cache.9 cvs rdiff -u -r1.402 -r1.403 src/sys/arch/arm/arm32/pmap.c cvs rdiff -u -r1.13 -r1.14 src/sys/arch/xen/x86/xen_shm_machdep.c cvs rdiff -u -r1.77 -r1.78 src/sys/arch/xen/xen/xbdback_xenbus.c cvs rdiff -u -r1.152 -r1.153 src/sys/dev/ic/ncr53c9x.c cvs rdiff -u -r1.381 -r1.382 src/sys/dev/raidframe/rf_netbsdkintf.c cvs rdiff -u -r1.37 -r1.38 src/sys/dev/raidframe/rf_reconmap.c cvs rdiff -u -r1.185 -r1.186 src/sys/dev/scsipi/scsipi_base.c cvs rdiff -u -r1.266 -r1.267 src/sys/kern/subr_pool.c cvs rdiff -u -r1.104 -r1.105 src/sys/opencrypto/cryptodev.c cvs rdiff -u -r1.89 -r1.90 src/sys/sys/pool.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/share/man/man9/pool.9 diff -u src/share/man/man9/pool.9:1.47 src/share/man/man9/pool.9:1.48 --- src/share/man/man9/pool.9:1.47 Sun Feb 10 17:15:45 2019 +++ src/share/man/man9/pool.9 Mon Apr 13 00:27:16 2020 @@ -1,4 +1,4 @@ -.\" $NetBSD: pool.9,v 1.47 2019/02/10 17:15:45 christos Exp $ +.\" $NetBSD: pool.9,v 1.48 2020/04/13 00:27:16 chs Exp $ .\" .\" Copyright (c) 1997, 1998, 2007 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -27,7 +27,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd February 10, 2019 +.Dd April 12, 2020 .Dt POOL 9 .Os .Sh NAME @@ -59,8 +59,8 @@ .Fn pool_get "struct pool *pp" "int flags" .Ft void .Fn pool_put "struct pool *pp" "void *item" -.Ft int -.Fn pool_prime "struct pool *pp" "int nitems" +.Ft void +.Fn pool_prime "struct pool *pp" "int n" .Ft void .Fn pool_sethiwat "struct pool *pp" "int n" .Ft void @@ -193,28 +193,7 @@ The handle identifying the pool resource A pointer to a pool item previously obtained by .Fn pool_get . .El -.Ss PRIMING A POOL -.Fn pool_prime -adds items to the pool. -Storage space for the items is allocated by using the page allocation -routine specified to -.Fn pool_create . -.Pp -The arguments to -.Fn pool_prime -are: -.Bl -tag -offset indent -width "storage" -.It Fa pp -The handle identifying the pool resource instance. -.It Fa nitems -The number of items to add to the pool. -.El .Pp -This function may return -.Dv ENOMEM -in case the requested number of items could not be allocated. -Otherwise, -the return value is 0. .Ss SETTING POOL RESOURCE WATERMARKS AND LIMITS A pool will attempt to increase its resource usage to keep up with the demand for its items. @@ -222,8 +201,8 @@ Conversely, it will return unused memory to the system should the number of accumulated unused items in the pool exceed a programmable limit. .Pp -The limits for the minimum and maximum number of items which a pool should keep -at hand are known as the high and low +The targets for the minimum and maximum number of free items which a pool should +try to keep available are known as the high and low .Sy watermarks . The functions .Fn pool_sethiwat @@ -231,20 +210,27 @@ and .Fn pool_setlowat set a pool's high and low watermarks, respectively. .Pp -The hard limit represents the maximum number of items a pool is allowed -to
CVS commit: src/sys/dev/acpi
Module Name:src Committed By: chs Date: Mon Mar 23 00:37:19 UTC 2020 Modified Files: src/sys/dev/acpi: acpi_debug.c Log Message: in acpi_debug_init(), the string we extract from the dictionary is a normal C string, so use strlcpy() rather than memcpy() to copy it. found by KASAN. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/dev/acpi/acpi_debug.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/acpi/acpi_debug.c diff -u src/sys/dev/acpi/acpi_debug.c:1.6 src/sys/dev/acpi/acpi_debug.c:1.7 --- src/sys/dev/acpi/acpi_debug.c:1.6 Sat Jan 5 20:40:26 2019 +++ src/sys/dev/acpi/acpi_debug.c Mon Mar 23 00:37:19 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_debug.c,v 1.6 2019/01/05 20:40:26 christos Exp $ */ +/* $NetBSD: acpi_debug.c,v 1.7 2020/03/23 00:37:19 chs Exp $ */ /*- * Copyright (c) 2010 Jukka Ruohonen @@ -27,7 +27,7 @@ * SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_debug.c,v 1.6 2019/01/05 20:40:26 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_debug.c,v 1.7 2020/03/23 00:37:19 chs Exp $"); #include #include @@ -124,8 +124,8 @@ acpi_debug_init(void) layer = acpi_debug_getkey(acpi_debug_layer_d, AcpiDbgLayer); level = acpi_debug_getkey(acpi_debug_level_d, AcpiDbgLevel); - (void)memcpy(acpi_debug_layer_s, layer, ACPI_DEBUG_MAX); - (void)memcpy(acpi_debug_level_s, level, ACPI_DEBUG_MAX); + strlcpy(acpi_debug_layer_s, layer, ACPI_DEBUG_MAX); + strlcpy(acpi_debug_level_s, level, ACPI_DEBUG_MAX); return;
CVS commit: src/sys/kern
Module Name:src Committed By: chs Date: Sun Mar 8 00:26:06 UTC 2020 Modified Files: src/sys/kern: kern_mutex.c Log Message: split an "a && b" assertion into two so it's clear in the dump which condition was not true even if both are true by the time the dump is written. To generate a diff of this commit: cvs rdiff -u -r1.89 -r1.90 src/sys/kern/kern_mutex.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/kern_mutex.c diff -u src/sys/kern/kern_mutex.c:1.89 src/sys/kern/kern_mutex.c:1.90 --- src/sys/kern/kern_mutex.c:1.89 Thu Jan 23 12:35:23 2020 +++ src/sys/kern/kern_mutex.c Sun Mar 8 00:26:06 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_mutex.c,v 1.89 2020/01/23 12:35:23 ad Exp $ */ +/* $NetBSD: kern_mutex.c,v 1.90 2020/03/08 00:26:06 chs Exp $ */ /*- * Copyright (c) 2002, 2006, 2007, 2008, 2019 The NetBSD Foundation, Inc. @@ -40,7 +40,7 @@ #define __MUTEX_PRIVATE #include -__KERNEL_RCSID(0, "$NetBSD: kern_mutex.c,v 1.89 2020/01/23 12:35:23 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_mutex.c,v 1.90 2020/03/08 00:26:06 chs Exp $"); #include #include @@ -384,8 +384,8 @@ mutex_destroy(kmutex_t *mtx) uintptr_t owner = mtx->mtx_owner; if (MUTEX_ADAPTIVE_P(owner)) { - MUTEX_ASSERT(mtx, !MUTEX_OWNED(owner) && - !MUTEX_HAS_WAITERS(mtx)); + MUTEX_ASSERT(mtx, !MUTEX_OWNED(owner)); + MUTEX_ASSERT(mtx, !MUTEX_HAS_WAITERS(mtx)); } else { MUTEX_ASSERT(mtx, !MUTEX_SPINBIT_LOCKED_P(mtx)); }
CVS commit: src/sys/ufs/ufs
Module Name:src Committed By: chs Date: Sun Mar 8 00:23:59 UTC 2020 Modified Files: src/sys/ufs/ufs: ufs_dirhash.c Log Message: in ufsdirhash_free(), only examine dh->dh_onlist after taking the dirhashlist lock. if we skip the lock then we might see that dh_onlist is zero while ufsdirhash_recycle() is still working on the dirhash. the symptom I saw was that ufsdirhash_free() would try to destroy the dh_lock mutex while it was still held. To generate a diff of this commit: cvs rdiff -u -r1.37 -r1.38 src/sys/ufs/ufs/ufs_dirhash.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ufs/ufs_dirhash.c diff -u src/sys/ufs/ufs/ufs_dirhash.c:1.37 src/sys/ufs/ufs/ufs_dirhash.c:1.38 --- src/sys/ufs/ufs/ufs_dirhash.c:1.37 Sat Dec 20 00:28:05 2014 +++ src/sys/ufs/ufs/ufs_dirhash.c Sun Mar 8 00:23:59 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_dirhash.c,v 1.37 2014/12/20 00:28:05 christos Exp $ */ +/* $NetBSD: ufs_dirhash.c,v 1.38 2020/03/08 00:23:59 chs Exp $ */ /* * Copyright (c) 2001, 2002 Ian Dowse. All rights reserved. @@ -28,7 +28,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ufs_dirhash.c,v 1.37 2014/12/20 00:28:05 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ufs_dirhash.c,v 1.38 2020/03/08 00:23:59 chs Exp $"); /* * This implements a hash-based lookup scheme for UFS directories. @@ -285,12 +285,10 @@ ufsdirhash_free(struct inode *ip) ip->i_dirhash = NULL; - if (dh->dh_onlist) { - DIRHASHLIST_LOCK(); - if (dh->dh_onlist) - TAILQ_REMOVE(_list, dh, dh_list); - DIRHASHLIST_UNLOCK(); - } + DIRHASHLIST_LOCK(); + if (dh->dh_onlist) + TAILQ_REMOVE(_list, dh, dh_list); + DIRHASHLIST_UNLOCK(); /* The dirhash pointed to by 'dh' is exclusively ours now. */ mem = sizeof(*dh);
CVS commit: src/lib/libkvm
Module Name:src Committed By: chs Date: Sun Mar 8 00:14:18 UTC 2020 Modified Files: src/lib/libkvm: kvm_x86_64.c Log Message: use a binary search in _kvm_pa2off(). this helps a lot for sparse dumps, which can have millions of memory segments. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/lib/libkvm/kvm_x86_64.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libkvm/kvm_x86_64.c diff -u src/lib/libkvm/kvm_x86_64.c:1.10 src/lib/libkvm/kvm_x86_64.c:1.11 --- src/lib/libkvm/kvm_x86_64.c:1.10 Wed Feb 19 20:21:22 2014 +++ src/lib/libkvm/kvm_x86_64.c Sun Mar 8 00:14:18 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: kvm_x86_64.c,v 1.10 2014/02/19 20:21:22 dsl Exp $ */ +/* $NetBSD: kvm_x86_64.c,v 1.11 2020/03/08 00:14:18 chs Exp $ */ /*- * Copyright (c) 1989, 1992, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)kvm_hp300.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: kvm_x86_64.c,v 1.10 2014/02/19 20:21:22 dsl Exp $"); +__RCSID("$NetBSD: kvm_x86_64.c,v 1.11 2020/03/08 00:14:18 chs Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -186,6 +186,36 @@ _kvm_kvatop(kvm_t *kd, vaddr_t va, paddr return (0); } +struct p2o { + paddr_t pa; + psize_t sz; + off_t off; +}; + +static int +cmp_p2o(const void *a, const void *b) +{ + const struct p2o *p1 = a; + const struct p2o *p2 = b; + + /* If one range contains the start of the other, it's a match. */ + if (p1->pa >= p2->pa && p1->pa < p2->pa + p2->sz) { + return 0; + } + if (p2->pa >= p1->pa && p2->pa < p1->pa + p1->sz) { + return 0; + } + + /* Otherwise sort by pa. */ + if (p1->pa < p2->pa) + return -1; + else if (p1->pa > p2->pa) + return 1; + else + return 0; +} + + /* * Translate a physical address to a file-offset in the crash dump. */ @@ -197,19 +227,36 @@ _kvm_pa2off(kvm_t *kd, paddr_t pa) off_t off; int i; + static struct p2o *map; + struct p2o key, *val; + cpu_kh = kd->cpu_data; ramsegs = (void *)((char *)(void *)cpu_kh + ALIGN(sizeof *cpu_kh)); - off = 0; - for (i = 0; i < cpu_kh->nmemsegs; i++) { - if (pa >= ramsegs[i].start && - (pa - ramsegs[i].start) < ramsegs[i].size) { - off += (pa - ramsegs[i].start); - break; + if (map == NULL) { + map = calloc(sizeof *map, cpu_kh->nmemsegs); + off = 0; + for (i = 0; i < cpu_kh->nmemsegs; i++) { + map[i].pa = ramsegs[i].start; + map[i].sz = ramsegs[i].size; + map[i].off = off; + off += ramsegs[i].size; } - off += ramsegs[i].size; +#if 0 + /* The array appears to be sorted already */ + qsort(map, cpu_kh->nmemsegs, sizeof(*map), cmp_p2o); +#endif } + key.pa = pa; + key.sz = 1; + key.off = -1; + val = bsearch(, map, cpu_kh->nmemsegs, sizeof (key), cmp_p2o); + if (val) + off = val->off + pa - val->pa; + else + off = 0; + return (kd->dump_off + off); }
CVS commit: src/lib/libkvm
Module Name:src Committed By: chs Date: Sun Mar 8 00:06:42 UTC 2020 Modified Files: src/lib/libkvm: kvm.c Log Message: only do bounce buffering for character devices. To generate a diff of this commit: cvs rdiff -u -r1.104 -r1.105 src/lib/libkvm/kvm.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libkvm/kvm.c diff -u src/lib/libkvm/kvm.c:1.104 src/lib/libkvm/kvm.c:1.105 --- src/lib/libkvm/kvm.c:1.104 Mon Nov 5 00:43:30 2018 +++ src/lib/libkvm/kvm.c Sun Mar 8 00:06:42 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: kvm.c,v 1.104 2018/11/05 00:43:30 mrg Exp $ */ +/* $NetBSD: kvm.c,v 1.105 2020/03/08 00:06:42 chs Exp $ */ /*- * Copyright (c) 1989, 1992, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)kvm.c 8.2 (Berkeley) 2/13/94"; #else -__RCSID("$NetBSD: kvm.c,v 1.104 2018/11/05 00:43:30 mrg Exp $"); +__RCSID("$NetBSD: kvm.c,v 1.105 2020/03/08 00:06:42 chs Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -352,7 +352,12 @@ _kvm_open(kvm_t *kd, const char *uf, con /* swap is not configured? not fatal */ } } else { - kd->fdalign = DEV_BSIZE; /* XXX */ + if (S_ISCHR(st.st_mode)) { + kd->fdalign = DEV_BSIZE; + } else { + kd->fdalign = 1; + } + /* * This is a crash dump. * Initialize the virtual address translation machinery.
CVS commit: src/sys/kern
Module Name:src Committed By: chs Date: Sat Feb 22 21:59:31 UTC 2020 Modified Files: src/sys/kern: subr_copy.c Log Message: check for errors from proc_vmspace_getref(). To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/sys/kern/subr_copy.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/subr_copy.c diff -u src/sys/kern/subr_copy.c:1.11 src/sys/kern/subr_copy.c:1.12 --- src/sys/kern/subr_copy.c:1.11 Sun Apr 7 16:27:41 2019 +++ src/sys/kern/subr_copy.c Sat Feb 22 21:59:30 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: subr_copy.c,v 1.11 2019/04/07 16:27:41 thorpej Exp $ */ +/* $NetBSD: subr_copy.c,v 1.12 2020/02/22 21:59:30 chs Exp $ */ /*- * Copyright (c) 1997, 1998, 1999, 2002, 2007, 2008, 2019 @@ -80,7 +80,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: subr_copy.c,v 1.11 2019/04/07 16:27:41 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: subr_copy.c,v 1.12 2020/02/22 21:59:30 chs Exp $"); #define __UFETCHSTORE_PRIVATE #define __UCAS_PRIVATE @@ -321,13 +321,14 @@ copyin_pid(pid_t pid, const void *uaddr, return ESRCH; } mutex_enter(p->p_lock); - proc_vmspace_getref(p, ); + error = proc_vmspace_getref(p, ); mutex_exit(p->p_lock); mutex_exit(proc_lock); - error = copyin_vmspace(vm, uaddr, kaddr, len); - - uvmspace_free(vm); + if (error == 0) { + error = copyin_vmspace(vm, uaddr, kaddr, len); + uvmspace_free(vm); + } return error; }
CVS commit: src/sys
Module Name:src Committed By: chs Date: Sat Feb 22 19:49:11 UTC 2020 Modified Files: src/sys/arch/arm/arm: fiq.c src/sys/arch/x86/acpi: acpi_wakeup.c src/sys/arch/x86/include: bus_private.h src/sys/dev/audio: audio.c Log Message: remove some unnecessary includes of internal UVM headers. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/arch/arm/arm/fiq.c cvs rdiff -u -r1.51 -r1.52 src/sys/arch/x86/acpi/acpi_wakeup.c cvs rdiff -u -r1.14 -r1.15 src/sys/arch/x86/include/bus_private.h cvs rdiff -u -r1.52 -r1.53 src/sys/dev/audio/audio.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/arm/fiq.c diff -u src/sys/arch/arm/arm/fiq.c:1.8 src/sys/arch/arm/arm/fiq.c:1.9 --- src/sys/arch/arm/arm/fiq.c:1.8 Wed Jan 24 09:04:44 2018 +++ src/sys/arch/arm/arm/fiq.c Sat Feb 22 19:49:11 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: fiq.c,v 1.8 2018/01/24 09:04:44 skrll Exp $ */ +/* $NetBSD: fiq.c,v 1.9 2020/02/22 19:49:11 chs Exp $ */ /* * Copyright (c) 2001, 2002 Wasabi Systems, Inc. @@ -36,7 +36,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: fiq.c,v 1.8 2018/01/24 09:04:44 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fiq.c,v 1.9 2020/02/22 19:49:11 chs Exp $"); #include #include @@ -44,8 +44,6 @@ __KERNEL_RCSID(0, "$NetBSD: fiq.c,v 1.8 #include #include -#include - TAILQ_HEAD(, fiqhandler) fiqhandler_stack = TAILQ_HEAD_INITIALIZER(fiqhandler_stack); Index: src/sys/arch/x86/acpi/acpi_wakeup.c diff -u src/sys/arch/x86/acpi/acpi_wakeup.c:1.51 src/sys/arch/x86/acpi/acpi_wakeup.c:1.52 --- src/sys/arch/x86/acpi/acpi_wakeup.c:1.51 Sat Oct 12 06:31:03 2019 +++ src/sys/arch/x86/acpi/acpi_wakeup.c Sat Feb 22 19:49:11 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_wakeup.c,v 1.51 2019/10/12 06:31:03 maxv Exp $ */ +/* $NetBSD: acpi_wakeup.c,v 1.52 2020/02/22 19:49:11 chs Exp $ */ /*- * Copyright (c) 2002, 2011 The NetBSD Foundation, Inc. @@ -59,7 +59,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_wakeup.c,v 1.51 2019/10/12 06:31:03 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_wakeup.c,v 1.52 2020/02/22 19:49:11 chs Exp $"); #include #include @@ -70,7 +70,6 @@ __KERNEL_RCSID(0, "$NetBSD: acpi_wakeup. #include #include -#include #ifdef __i386__ #include "opt_mtrr.h" Index: src/sys/arch/x86/include/bus_private.h diff -u src/sys/arch/x86/include/bus_private.h:1.14 src/sys/arch/x86/include/bus_private.h:1.15 --- src/sys/arch/x86/include/bus_private.h:1.14 Thu Sep 1 15:10:31 2011 +++ src/sys/arch/x86/include/bus_private.h Sat Feb 22 19:49:11 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: bus_private.h,v 1.14 2011/09/01 15:10:31 christos Exp $ */ +/* $NetBSD: bus_private.h,v 1.15 2020/02/22 19:49:11 chs Exp $ */ /* NetBSD: bus.h,v 1.8 2005/03/09 19:04:46 matt Exp */ /*- @@ -128,7 +128,7 @@ struct x86_bus_dma_cookie { #endif /* _BUS_PMAP_ENTER */ #if !defined(_BUS_VIRT_TO_BUS) -#include +#include static __inline bus_addr_t _bus_virt_to_bus(struct pmap *, vaddr_t); #define _BUS_VIRT_TO_BUS(pm, va) _bus_virt_to_bus((pm), (va)) Index: src/sys/dev/audio/audio.c diff -u src/sys/dev/audio/audio.c:1.52 src/sys/dev/audio/audio.c:1.53 --- src/sys/dev/audio/audio.c:1.52 Sat Feb 22 08:15:09 2020 +++ src/sys/dev/audio/audio.c Sat Feb 22 19:49:11 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: audio.c,v 1.52 2020/02/22 08:15:09 isaki Exp $ */ +/* $NetBSD: audio.c,v 1.53 2020/02/22 19:49:11 chs Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -142,7 +142,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.52 2020/02/22 08:15:09 isaki Exp $"); +__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.53 2020/02/22 19:49:11 chs Exp $"); #ifdef _KERNEL_OPT #include "audio.h" @@ -188,7 +188,7 @@ __KERNEL_RCSID(0, "$NetBSD: audio.c,v 1. #include -#include +#include #include "ioconf.h"
CVS commit: src/sys
Module Name:src Committed By: chs Date: Sat Feb 22 19:46:49 UTC 2020 Modified Files: src/sys/arch/xen/xen: privcmd.c src/sys/external/bsd/drm2/dist/drm/i915: i915_gem.c src/sys/external/bsd/drm2/drm: drm_gem_cma_helper.c src/sys/uvm: uvm_device.c Log Message: do not wait for memory in pgo_fault methods, just return ENOMEM and let the uvm_fault code wait if it is appropriate. To generate a diff of this commit: cvs rdiff -u -r1.51 -r1.52 src/sys/arch/xen/xen/privcmd.c cvs rdiff -u -r1.59 -r1.60 src/sys/external/bsd/drm2/dist/drm/i915/i915_gem.c cvs rdiff -u -r1.9 -r1.10 src/sys/external/bsd/drm2/drm/drm_gem_cma_helper.c cvs rdiff -u -r1.67 -r1.68 src/sys/uvm/uvm_device.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/xen/xen/privcmd.c diff -u src/sys/arch/xen/xen/privcmd.c:1.51 src/sys/arch/xen/xen/privcmd.c:1.52 --- src/sys/arch/xen/xen/privcmd.c:1.51 Thu Jun 22 22:36:50 2017 +++ src/sys/arch/xen/xen/privcmd.c Sat Feb 22 19:46:48 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: privcmd.c,v 1.51 2017/06/22 22:36:50 chs Exp $ */ +/* $NetBSD: privcmd.c,v 1.52 2020/02/22 19:46:48 chs Exp $ */ /*- * Copyright (c) 2004 Christian Limpach. @@ -27,7 +27,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: privcmd.c,v 1.51 2017/06/22 22:36:50 chs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: privcmd.c,v 1.52 2020/02/22 19:46:48 chs Exp $"); #include #include @@ -502,7 +502,6 @@ privpgop_fault(struct uvm_faultinfo *ufi PMAP_CANFAIL | ufi->entry->protection, pobj->domid); if (error == ENOMEM) { - error = ERESTART; break; } if (error) { @@ -513,10 +512,6 @@ privpgop_fault(struct uvm_faultinfo *ufi } pmap_update(ufi->orig_map->pmap); uvmfault_unlockall(ufi, ufi->entry->aref.ar_amap, uobj); - - if (error == ERESTART) { - uvm_wait("privpgop_fault"); - } return error; } Index: src/sys/external/bsd/drm2/dist/drm/i915/i915_gem.c diff -u src/sys/external/bsd/drm2/dist/drm/i915/i915_gem.c:1.59 src/sys/external/bsd/drm2/dist/drm/i915/i915_gem.c:1.60 --- src/sys/external/bsd/drm2/dist/drm/i915/i915_gem.c:1.59 Fri Feb 14 14:34:58 2020 +++ src/sys/external/bsd/drm2/dist/drm/i915/i915_gem.c Sat Feb 22 19:46:48 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: i915_gem.c,v 1.59 2020/02/14 14:34:58 maya Exp $ */ +/* $NetBSD: i915_gem.c,v 1.60 2020/02/22 19:46:48 chs Exp $ */ /* * Copyright © 2008-2015 Intel Corporation @@ -28,7 +28,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: i915_gem.c,v 1.59 2020/02/14 14:34:58 maya Exp $"); +__KERNEL_RCSID(0, "$NetBSD: i915_gem.c,v 1.60 2020/02/22 19:46:48 chs Exp $"); #ifdef __NetBSD__ #if 0/* XXX uvmhist option? */ @@ -2052,8 +2052,6 @@ unlock: out: mutex_enter(uobj->vmobjlock); uvmfault_unlockall(ufi, ufi->entry->aref.ar_amap, uobj); - if (ret == -ERESTART) - uvm_wait("i915flt"); /* * Remap EINTR to success, so that we return to userland. @@ -2087,7 +2085,7 @@ i915_udv_fault(struct uvm_faultinfo *ufi off_t curr_offset; paddr_t paddr; u_int mmapflags; - int lcv, retval; + int lcv; vm_prot_t mapprot; UVMHIST_FUNC("i915_udv_fault"); UVMHIST_CALLED(maphist); UVMHIST_LOG(maphist," flags=%jd", flags,0,0,0); @@ -2119,7 +2117,6 @@ i915_udv_fault(struct uvm_faultinfo *ufi * loop over the page range entering in as needed */ - retval = 0; for (lcv = 0 ; lcv < npages ; lcv++, curr_offset += PAGE_SIZE, curr_va += PAGE_SIZE) { if ((flags & PGO_ALLPAGES) == 0 && lcv != centeridx) @@ -2147,12 +2144,12 @@ i915_udv_fault(struct uvm_faultinfo *ufi * XXX case. */ pmap_update(ufi->orig_map->pmap); /* sync what we have so far */ - return (ERESTART); + return ENOMEM; } } pmap_update(ufi->orig_map->pmap); - return (retval); + return 0; } #else /** Index: src/sys/external/bsd/drm2/drm/drm_gem_cma_helper.c diff -u src/sys/external/bsd/drm2/drm/drm_gem_cma_helper.c:1.9 src/sys/external/bsd/drm2/drm/drm_gem_cma_helper.c:1.10 --- src/sys/external/bsd/drm2/drm/drm_gem_cma_helper.c:1.9 Tue Nov 5 23:29:28 2019 +++ src/sys/external/bsd/drm2/drm/drm_gem_cma_helper.c Sat Feb 22 19:46:48 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: drm_gem_cma_helper.c,v 1.9 2019/11/05 23:29:28 jmcneill Exp $ */ +/* $NetBSD: drm_gem_cma_helper.c,v 1.10 2020/02/22 19:46:48 chs Exp $ */ /*- * Copyright (c) 2015-2017 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: drm_gem_cma_helper.c,v 1.9 2019/11/05 23:29:28 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: drm_gem_cma_helper.c,v 1.10 2020/02/22 19:46:48 chs Exp $"); #include #include @@ -246,8 +246,7 @@ drm_gem_cma_fault(struct uvm_faultinfo * PMAP_CANFAIL | mapprot | mmapflags) != 0) { pmap_update(ufi->orig_map->pmap); uvmfault_unlockall(ufi, ufi->entry->aref.ar_amap, uobj); - uvm_wait("drm_gem_cma_fault"); - return ERESTART; + return ENOMEM; } } Index: src/sys/uvm/uvm_device.c
CVS commit: src/sys
Module Name:src Committed By: chs Date: Tue Feb 18 20:23:18 UTC 2020 Modified Files: src/sys/kern: init_main.c src/sys/miscfs/genfs: genfs_io.c src/sys/rump/librump/rumpkern: rump.c src/sys/rump/librump/rumpvfs: vm_vfs.c src/sys/ufs/lfs: lfs_bio.c lfs_extern.h lfs_inode.h lfs_segment.c lfs_syscalls.c lfs_vfsops.c src/sys/uvm: uvm.h uvm_extern.h uvm_pager.c uvm_pdaemon.c uvm_swap.c Log Message: remove the aiodoned thread. I originally added this to provide a thread context for doing page cache iodone work, but since then biodone() has changed to hand off all iodone work to a softint thread, so we no longer need the special-purpose aiodoned thread. To generate a diff of this commit: cvs rdiff -u -r1.520 -r1.521 src/sys/kern/init_main.c cvs rdiff -u -r1.84 -r1.85 src/sys/miscfs/genfs/genfs_io.c cvs rdiff -u -r1.340 -r1.341 src/sys/rump/librump/rumpkern/rump.c cvs rdiff -u -r1.36 -r1.37 src/sys/rump/librump/rumpvfs/vm_vfs.c cvs rdiff -u -r1.144 -r1.145 src/sys/ufs/lfs/lfs_bio.c cvs rdiff -u -r1.114 -r1.115 src/sys/ufs/lfs/lfs_extern.h cvs rdiff -u -r1.23 -r1.24 src/sys/ufs/lfs/lfs_inode.h cvs rdiff -u -r1.281 -r1.282 src/sys/ufs/lfs/lfs_segment.c cvs rdiff -u -r1.175 -r1.176 src/sys/ufs/lfs/lfs_syscalls.c cvs rdiff -u -r1.369 -r1.370 src/sys/ufs/lfs/lfs_vfsops.c cvs rdiff -u -r1.73 -r1.74 src/sys/uvm/uvm.h cvs rdiff -u -r1.219 -r1.220 src/sys/uvm/uvm_extern.h cvs rdiff -u -r1.120 -r1.121 src/sys/uvm/uvm_pager.c cvs rdiff -u -r1.123 -r1.124 src/sys/uvm/uvm_pdaemon.c cvs rdiff -u -r1.185 -r1.186 src/sys/uvm/uvm_swap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/init_main.c diff -u src/sys/kern/init_main.c:1.520 src/sys/kern/init_main.c:1.521 --- src/sys/kern/init_main.c:1.520 Sat Feb 15 18:12:15 2020 +++ src/sys/kern/init_main.c Tue Feb 18 20:23:17 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: init_main.c,v 1.520 2020/02/15 18:12:15 ad Exp $ */ +/* $NetBSD: init_main.c,v 1.521 2020/02/18 20:23:17 chs Exp $ */ /*- * Copyright (c) 2008, 2009, 2019 The NetBSD Foundation, Inc. @@ -97,7 +97,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.520 2020/02/15 18:12:15 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.521 2020/02/18 20:23:17 chs Exp $"); #include "opt_ddb.h" #include "opt_inet.h" @@ -720,11 +720,6 @@ main(void) NULL, NULL, "ioflush")) panic("fork syncer"); - /* Create the aiodone daemon kernel thread. */ - if (workqueue_create(_queue, "aiodoned", - uvm_aiodone_worker, NULL, PRI_VM, IPL_NONE, WQ_MPSAFE)) - panic("fork aiodoned"); - /* Wait for final configure threads to complete. */ config_finalize_mountroot(); Index: src/sys/miscfs/genfs/genfs_io.c diff -u src/sys/miscfs/genfs/genfs_io.c:1.84 src/sys/miscfs/genfs/genfs_io.c:1.85 --- src/sys/miscfs/genfs/genfs_io.c:1.84 Wed Jan 15 17:55:44 2020 +++ src/sys/miscfs/genfs/genfs_io.c Tue Feb 18 20:23:17 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_io.c,v 1.84 2020/01/15 17:55:44 ad Exp $ */ +/* $NetBSD: genfs_io.c,v 1.85 2020/02/18 20:23:17 chs Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.84 2020/01/15 17:55:44 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.85 2020/02/18 20:23:17 chs Exp $"); #include #include @@ -606,9 +606,6 @@ genfs_getpages_read(struct vnode *vp, st if (kva == 0) return EBUSY; - if (uvm.aiodone_queue == NULL) - async = 0; - mbp = getiobuf(vp, true); mbp->b_bufsize = totalbytes; mbp->b_data = (void *)kva; @@ -616,7 +613,7 @@ genfs_getpages_read(struct vnode *vp, st mbp->b_cflags = BC_BUSY; if (async) { mbp->b_flags = B_READ | B_ASYNC; - mbp->b_iodone = uvm_aio_biodone; + mbp->b_iodone = uvm_aio_aiodone; } else { mbp->b_flags = B_READ; mbp->b_iodone = NULL; @@ -1396,9 +1393,8 @@ genfs_gop_write(struct vnode *vp, struct UVMPAGER_MAPIN_WRITE | UVMPAGER_MAPIN_WAITOK); len = npages << PAGE_SHIFT; - KASSERT(uvm.aiodone_queue != NULL); error = genfs_do_io(vp, off, kva, len, flags, UIO_WRITE, - uvm_aio_biodone); + uvm_aio_aiodone); return error; } @@ -1429,9 +1425,8 @@ genfs_gop_write_rwmap(struct vnode *vp, UVMPAGER_MAPIN_READ | UVMPAGER_MAPIN_WAITOK); len = npages << PAGE_SHIFT; - KASSERT(uvm.aiodone_queue != NULL); error = genfs_do_io(vp, off, kva, len, flags, UIO_WRITE, - uvm_aio_biodone); + uvm_aio_aiodone); return error; } Index: src/sys/rump/librump/rumpkern/rump.c diff -u src/sys/rump/librump/rumpkern/rump.c:1.340 src/sys/rump/librump/rumpkern/rump.c:1.341 --- src/sys/rump/librump/rumpkern/rump.c:1.340 Mon Feb 10 03:23:29 2020 +++ src/sys/rump/librump/rumpkern/rump.c Tue Feb 18 20:23:17 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: rump.c,v 1.340 2020/02/10 03:23:29 riastradh Exp $ */ +/* $NetBSD: rump.c,v 1.341 2020/02/18 20:23:17 chs
CVS commit: src/sys/dev/scsipi
Module Name:src Committed By: chs Date: Wed Feb 12 00:19:07 UTC 2020 Modified Files: src/sys/dev/scsipi: atapi_wdc.c Log Message: the number of possible ATAPI devices on an ATA bus is not always 2, it is however many devices the underlying ATA bus can have (eg. 1 for SATA), so initialize the scsipi chan_ntargets from the ATA ch_ndrives. this fixes a memory read overrun detected by KASAN. discussed with mlelstv@ and jdolecek@ To generate a diff of this commit: cvs rdiff -u -r1.134 -r1.135 src/sys/dev/scsipi/atapi_wdc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/scsipi/atapi_wdc.c diff -u src/sys/dev/scsipi/atapi_wdc.c:1.134 src/sys/dev/scsipi/atapi_wdc.c:1.135 --- src/sys/dev/scsipi/atapi_wdc.c:1.134 Sun Nov 10 21:16:37 2019 +++ src/sys/dev/scsipi/atapi_wdc.c Wed Feb 12 00:19:07 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: atapi_wdc.c,v 1.134 2019/11/10 21:16:37 chs Exp $ */ +/* $NetBSD: atapi_wdc.c,v 1.135 2020/02/12 00:19:07 chs Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. @@ -25,7 +25,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: atapi_wdc.c,v 1.134 2019/11/10 21:16:37 chs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: atapi_wdc.c,v 1.135 2020/02/12 00:19:07 chs Exp $"); #ifndef ATADEBUG #define ATADEBUG @@ -138,7 +138,7 @@ wdc_atapibus_attach(struct atabus_softc chan->chan_flags = SCSIPI_CHAN_OPENINGS; chan->chan_openings = 1; chan->chan_max_periph = 1; - chan->chan_ntargets = 2; + chan->chan_ntargets = chp->ch_ndrives; chan->chan_nluns = 1; chp->atapibus = config_found_ia(ata_sc->sc_dev, "atapi", chan,
CVS commit: src/sys/kern
Module Name:src Committed By: chs Date: Sun Jan 19 23:49:32 UTC 2020 Modified Files: src/sys/kern: subr_pool.c Log Message: fix assertions about when it is ok for pool_get() to return NULL. To generate a diff of this commit: cvs rdiff -u -r1.264 -r1.265 src/sys/kern/subr_pool.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/subr_pool.c diff -u src/sys/kern/subr_pool.c:1.264 src/sys/kern/subr_pool.c:1.265 --- src/sys/kern/subr_pool.c:1.264 Fri Dec 27 15:49:20 2019 +++ src/sys/kern/subr_pool.c Sun Jan 19 23:49:32 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: subr_pool.c,v 1.264 2019/12/27 15:49:20 maxv Exp $ */ +/* $NetBSD: subr_pool.c,v 1.265 2020/01/19 23:49:32 chs Exp $ */ /* * Copyright (c) 1997, 1999, 2000, 2002, 2007, 2008, 2010, 2014, 2015, 2018 @@ -33,7 +33,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: subr_pool.c,v 1.264 2019/12/27 15:49:20 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: subr_pool.c,v 1.265 2020/01/19 23:49:32 chs Exp $"); #ifdef _KERNEL_OPT #include "opt_ddb.h" @@ -1145,7 +1145,7 @@ pool_get(struct pool *pp, int flags) pp->pr_nfail++; mutex_exit(>pr_lock); - KASSERT((flags & (PR_WAITOK|PR_NOWAIT)) == PR_NOWAIT); + KASSERT((flags & (PR_NOWAIT|PR_LIMITFAIL)) != 0); return NULL; } @@ -2509,7 +2509,7 @@ pool_cache_get_slow(pool_cache_cpu_t *cc object = pool_get(>pc_pool, flags); *objectp = object; if (__predict_false(object == NULL)) { - KASSERT((flags & (PR_WAITOK|PR_NOWAIT)) == PR_NOWAIT); + KASSERT((flags & (PR_NOWAIT|PR_LIMITFAIL)) != 0); return false; }
CVS commit: src/sys/dev/acpi
Module Name:src Committed By: chs Date: Mon Jan 13 00:19:43 UTC 2020 Modified Files: src/sys/dev/acpi: acpi_pci_link.c Log Message: apply FreeBSD revs r214848 and r214849: r214849 | jkim | 2010-11-05 13:24:26 -0700 (Fri, 05 Nov 2010) | 2 lines Add a forgotten change from the previous commit. r214848 | jkim | 2010-11-05 12:50:09 -0700 (Fri, 05 Nov 2010) | 13 lines Fix a use-after-free bug for extended IRQ resource[1]. When _PRS buffer is copied as a template for _SRS, a string pointer for descriptor name is also copied and it becomes stale as soon as it gets de-allocated[2]. Now _CRS is used as a template for _SRS as ACPI specification suggests if it is usable. The template from _PRS is still utilized but only when _CRS is not available or broken. To avoid use-after-free the problem in this case, however, only mandatory fields are copied, optional data is removed, and structure length is adjusted accordingly. Reported by:hps[1] Analyzed by:avg[2] Tested by: hps This also fixes reading past the end of a structure as detected by KASAN. To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/sys/dev/acpi/acpi_pci_link.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/acpi/acpi_pci_link.c diff -u src/sys/dev/acpi/acpi_pci_link.c:1.24 src/sys/dev/acpi/acpi_pci_link.c:1.25 --- src/sys/dev/acpi/acpi_pci_link.c:1.24 Fri Dec 6 07:27:06 2019 +++ src/sys/dev/acpi/acpi_pci_link.c Mon Jan 13 00:19:43 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_pci_link.c,v 1.24 2019/12/06 07:27:06 maxv Exp $ */ +/* $NetBSD: acpi_pci_link.c,v 1.25 2020/01/13 00:19:43 chs Exp $ */ /*- * Copyright (c) 2002 Mitsuru IWASAKI @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_pci_link.c,v 1.24 2019/12/06 07:27:06 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_pci_link.c,v 1.25 2020/01/13 00:19:43 chs Exp $"); #include #include @@ -255,6 +255,7 @@ link_add_crs(ACPI_RESOURCE *res, void *c static ACPI_STATUS link_add_prs(ACPI_RESOURCE *res, void *context) { + ACPI_RESOURCE *tmp; struct link_res_request *req; struct link *link; uint8_t *irqs = NULL; @@ -301,32 +302,28 @@ link_add_prs(ACPI_RESOURCE *res, void *c req->res_index++; /* - * Stash a copy of the resource for later use when - * doing _SRS. - * - * Note that in theory res->Length may exceed the size - * of ACPI_RESOURCE, due to variable length lists in - * subtypes. However, all uses of l_prs_template only - * rely on lists lengths of zero or one, for which - * sizeof(ACPI_RESOURCE) is sufficient space anyway. - * We cannot read longer than Length bytes, in case we - * read off the end of mapped memory. So we read - * whichever length is shortest, Length or - * sizeof(ACPI_RESOURCE). + * Stash a copy of the resource for later use when doing + * _SRS. */ - KASSERT(res->Length >= ACPI_RS_SIZE_MIN); + tmp = >l_prs_template; + if (is_ext_irq) { + memcpy(tmp, res, ACPI_RS_SIZE(tmp->Data.ExtendedIrq)); - memset(>l_prs_template, 0, sizeof(link->l_prs_template)); - memcpy(>l_prs_template, res, - MIN(res->Length, sizeof(link->l_prs_template))); + /* + * XXX acpi_AppendBufferResource() cannot handle + * optional data. + */ + memset(>Data.ExtendedIrq.ResourceSource, 0, + sizeof(tmp->Data.ExtendedIrq.ResourceSource)); + tmp->Length = ACPI_RS_SIZE(tmp->Data.ExtendedIrq); - if (is_ext_irq) { link->l_num_irqs = res->Data.ExtendedIrq.InterruptCount; link->l_trig = res->Data.ExtendedIrq.Triggering; link->l_pol = res->Data.ExtendedIrq.Polarity; ext_irqs = res->Data.ExtendedIrq.Interrupts; } else { + memcpy(tmp, res, ACPI_RS_SIZE(tmp->Data.Irq)); link->l_num_irqs = res->Data.Irq.InterruptCount; link->l_trig = res->Data.Irq.Triggering; link->l_pol = res->Data.Irq.Polarity; @@ -737,17 +734,16 @@ acpi_pci_link_add_reference(void *v, int static ACPI_STATUS acpi_pci_link_srs_from_crs(struct acpi_pci_link_softc *sc, ACPI_BUFFER *srsbuf) { - ACPI_RESOURCE *resource, *end, newres, *resptr; - ACPI_BUFFER crsbuf; + ACPI_RESOURCE *end, *res; ACPI_STATUS status; struct link *link; int i, in_dpf; /* Fetch the _CRS. */ - crsbuf.Pointer = NULL; - crsbuf.Length = ACPI_ALLOCATE_LOCAL_BUFFER; - status = AcpiGetCurrentResources(sc->pl_handle, ); - if (ACPI_SUCCESS(status) && crsbuf.Pointer == NULL) + srsbuf->Pointer = NULL; + srsbuf->Length = ACPI_ALLOCATE_BUFFER; + status = AcpiGetCurrentResources(sc->pl_handle, srsbuf); + if (ACPI_SUCCESS(status) && srsbuf->Pointer == NULL) status = AE_NO_MEMORY; if (ACPI_FAILURE(status)) { aprint_verbose("%s: Unable to fetch current resources: %s\n", @@ -756,14 +752,13 @@ acpi_pci_link_srs_from_crs(struct acpi_p } /* Fill in IRQ resources via link structures. */ - srsbuf->Pointer = NULL;
CVS commit: src/sys/uvm
Module Name:src Committed By: chs Date: Mon Dec 2 20:02:02 UTC 2019 Modified Files: src/sys/uvm: uvm_anon.c Log Message: fix the build for when UVMHIST is enabled. To generate a diff of this commit: cvs rdiff -u -r1.67 -r1.68 src/sys/uvm/uvm_anon.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/uvm/uvm_anon.c diff -u src/sys/uvm/uvm_anon.c:1.67 src/sys/uvm/uvm_anon.c:1.68 --- src/sys/uvm/uvm_anon.c:1.67 Sun Dec 1 23:14:47 2019 +++ src/sys/uvm/uvm_anon.c Mon Dec 2 20:02:02 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: uvm_anon.c,v 1.67 2019/12/01 23:14:47 uwe Exp $ */ +/* $NetBSD: uvm_anon.c,v 1.68 2019/12/02 20:02:02 chs Exp $ */ /* * Copyright (c) 1997 Charles D. Cranor and Washington University. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uvm_anon.c,v 1.67 2019/12/01 23:14:47 uwe Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uvm_anon.c,v 1.68 2019/12/02 20:02:02 chs Exp $"); #include "opt_uvmhist.h" @@ -209,6 +209,8 @@ uvm_anon_freelst(struct vm_amap *amap, s struct vm_anon **anonp = struct vm_page *pg; + UVMHIST_FUNC(__func__); UVMHIST_CALLED(maphist); + KASSERT(mutex_owned(amap->am_lock)); if (anonlst == NULL) {
CVS commit: src/sys/uvm
Module Name:src Committed By: chs Date: Wed May 8 16:00:01 UTC 2019 Modified Files: src/sys/uvm: uvm_glue.c Log Message: uvm_pagealloc() uses UVM_PGA_* flags, not UVM_KMF_* flags, and it is always nowait. fix uarea_poolpage_alloc() to not use flags from the wrong collection for calling uvm_pagealloc() and to wait itself if a page is not immediately available. To generate a diff of this commit: cvs rdiff -u -r1.167 -r1.168 src/sys/uvm/uvm_glue.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/uvm/uvm_glue.c diff -u src/sys/uvm/uvm_glue.c:1.167 src/sys/uvm/uvm_glue.c:1.168 --- src/sys/uvm/uvm_glue.c:1.167 Sun Apr 7 09:20:04 2019 +++ src/sys/uvm/uvm_glue.c Wed May 8 16:00:01 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: uvm_glue.c,v 1.167 2019/04/07 09:20:04 maxv Exp $ */ +/* $NetBSD: uvm_glue.c,v 1.168 2019/05/08 16:00:01 chs Exp $ */ /* * Copyright (c) 1997 Charles D. Cranor and Washington University. @@ -62,7 +62,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uvm_glue.c,v 1.167 2019/04/07 09:20:04 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uvm_glue.c,v 1.168 2019/05/08 16:00:01 chs Exp $"); #include "opt_kgdb.h" #include "opt_kstack.h" @@ -242,19 +242,22 @@ static pool_cache_t uvm_uarea_system_cac static void * uarea_poolpage_alloc(struct pool *pp, int flags) { + + KASSERT((flags & PR_WAITOK) != 0); + #if defined(PMAP_MAP_POOLPAGE) - if (USPACE == PAGE_SIZE && USPACE_ALIGN == 0) { + while (USPACE == PAGE_SIZE && USPACE_ALIGN == 0) { struct vm_page *pg; vaddr_t va; #if defined(PMAP_ALLOC_POOLPAGE) - pg = PMAP_ALLOC_POOLPAGE( - ((flags & PR_WAITOK) == 0 ? UVM_KMF_NOWAIT : 0)); + pg = PMAP_ALLOC_POOLPAGE(0); #else - pg = uvm_pagealloc(NULL, 0, NULL, - ((flags & PR_WAITOK) == 0 ? UVM_KMF_NOWAIT : 0)); + pg = uvm_pagealloc(NULL, 0, NULL, 0); #endif - if (pg == NULL) - return NULL; + if (pg == NULL) { + uvm_wait("uarea"); + continue; + } va = PMAP_MAP_POOLPAGE(VM_PAGE_TO_PHYS(pg)); KASSERT(va != 0); return (void *)va; @@ -266,9 +269,7 @@ uarea_poolpage_alloc(struct pool *pp, in return (void *)va; #endif return (void *)uvm_km_alloc(kernel_map, pp->pr_alloc->pa_pagesz, - USPACE_ALIGN, UVM_KMF_WIRED | - ((flags & PR_WAITOK) ? UVM_KMF_WAITVA : - (UVM_KMF_NOWAIT | UVM_KMF_TRYLOCK))); + USPACE_ALIGN, UVM_KMF_WIRED | UVM_KMF_WAITVA); } static void
CVS commit: src/sys/external/bsd/drm2/ttm
Module Name:src Committed By: chs Date: Sun Apr 21 15:49:50 UTC 2019 Modified Files: src/sys/external/bsd/drm2/ttm: ttm_bus_dma.c Log Message: in ttm_bus_dma_populate(), move the clearing of TTM_PAGE_FLAG_SWAPPED to be earlier to avoid wrongly asserting if bus_dmamap_load_pglist() fails. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/external/bsd/drm2/ttm/ttm_bus_dma.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/external/bsd/drm2/ttm/ttm_bus_dma.c diff -u src/sys/external/bsd/drm2/ttm/ttm_bus_dma.c:1.7 src/sys/external/bsd/drm2/ttm/ttm_bus_dma.c:1.8 --- src/sys/external/bsd/drm2/ttm/ttm_bus_dma.c:1.7 Thu Mar 9 08:27:18 2017 +++ src/sys/external/bsd/drm2/ttm/ttm_bus_dma.c Sun Apr 21 15:49:50 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: ttm_bus_dma.c,v 1.7 2017/03/09 08:27:18 maya Exp $ */ +/* $NetBSD: ttm_bus_dma.c,v 1.8 2019/04/21 15:49:50 chs Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ttm_bus_dma.c,v 1.7 2017/03/09 08:27:18 maya Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ttm_bus_dma.c,v 1.8 2019/04/21 15:49:50 chs Exp $"); #include @@ -70,6 +70,9 @@ ttm_bus_dma_populate(struct ttm_dma_tt * /* Mark it populated but unbound. */ ttm_dma->ttm.state = tt_unbound; + /* Mark it wired. */ + ttm_dma->ttm.page_flags &= ~TTM_PAGE_FLAG_SWAPPED; + /* Load the DMA map. */ /* XXX errno NetBSD->Linux */ ret = -bus_dmamap_load_pglist(ttm_dma->ttm.bdev->dmat, @@ -78,9 +81,6 @@ ttm_bus_dma_populate(struct ttm_dma_tt * if (ret) goto fail1; - /* Mark it wired. */ - ttm_dma->ttm.page_flags &= ~TTM_PAGE_FLAG_SWAPPED; - /* Success! */ return 0;
CVS commit: src/sys/uvm
Module Name:src Committed By: chs Date: Sun Apr 21 15:32:18 UTC 2019 Modified Files: src/sys/uvm: uvm_pdaemon.c Log Message: Draining pools from the pagedaemon thread can deadlock, because draining a pool can involve taking a lock which can be held by a thread which is blocked waiting for memory. Avoid this by moving the pool-draining work to a separate worker thread. To generate a diff of this commit: cvs rdiff -u -r1.109 -r1.110 src/sys/uvm/uvm_pdaemon.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/uvm/uvm_pdaemon.c diff -u src/sys/uvm/uvm_pdaemon.c:1.109 src/sys/uvm/uvm_pdaemon.c:1.110 --- src/sys/uvm/uvm_pdaemon.c:1.109 Sat Oct 28 00:37:13 2017 +++ src/sys/uvm/uvm_pdaemon.c Sun Apr 21 15:32:18 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: uvm_pdaemon.c,v 1.109 2017/10/28 00:37:13 pgoyette Exp $ */ +/* $NetBSD: uvm_pdaemon.c,v 1.110 2019/04/21 15:32:18 chs Exp $ */ /* * Copyright (c) 1997 Charles D. Cranor and Washington University. @@ -66,7 +66,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uvm_pdaemon.c,v 1.109 2017/10/28 00:37:13 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uvm_pdaemon.c,v 1.110 2019/04/21 15:32:18 chs Exp $"); #include "opt_uvmhist.h" #include "opt_readahead.h" @@ -79,6 +79,7 @@ __KERNEL_RCSID(0, "$NetBSD: uvm_pdaemon. #include #include #include +#include #include #include @@ -105,9 +106,16 @@ UVMHIST_DEFINE(pdhist); static void uvmpd_scan(void); static void uvmpd_scan_queue(void); static void uvmpd_tune(void); +static void uvmpd_pool_drain_thread(void *); +static void uvmpd_pool_drain_wakeup(void); static unsigned int uvm_pagedaemon_waiters; +/* State for the pool drainer thread */ +static kmutex_t uvmpd_pool_drain_lock; +static kcondvar_t uvmpd_pool_drain_cv; +static bool uvmpd_pool_drain_run = false; + /* * XXX hack to avoid hangs when large processes fork. */ @@ -229,14 +237,21 @@ uvmpd_tune(void) void uvm_pageout(void *arg) { - int bufcnt, npages = 0; + int npages = 0; int extrapages = 0; - struct pool *pp; UVMHIST_FUNC("uvm_pageout"); UVMHIST_CALLED(pdhist); UVMHIST_LOG(pdhist,"", 0, 0, 0, 0); + mutex_init(_pool_drain_lock, MUTEX_DEFAULT, IPL_VM); + cv_init(_pool_drain_cv, "pooldrain"); + + /* Create the pool drainer kernel thread. */ + if (kthread_create(PRI_VM, KTHREAD_MPSAFE, NULL, + uvmpd_pool_drain_thread, NULL, NULL, "pooldrain")) + panic("fork pooldrain"); + /* * ensure correct priority and set paging parameters... */ @@ -288,9 +303,6 @@ uvm_pageout(void *arg) * system only when entire pool page is empty. */ mutex_spin_enter(_fpageqlock); - bufcnt = uvmexp.freetarg - uvmexp.free; - if (bufcnt < 0) - bufcnt = 0; UVMHIST_LOG(pdhist," free/ftarg=%jd/%jd", uvmexp.free, uvmexp.freetarg, 0,0); @@ -331,16 +343,10 @@ uvm_pageout(void *arg) continue; /* - * kill unused metadata buffers. + * kick the pool drainer thread. */ - mutex_enter(_lock); - buf_drain(bufcnt << PAGE_SHIFT); - mutex_exit(_lock); - /* - * drain the pools. - */ - pool_drain(); + uvmpd_pool_drain_wakeup(); } /*NOTREACHED*/ } @@ -1022,3 +1028,53 @@ uvm_estimatepageable(int *active, int *i uvmpdpol_estimatepageable(active, inactive); } + +/* + * Use a separate thread for draining pools. + * This work can't done from the main pagedaemon thread because + * some pool allocators need to take vm_map locks. + */ + +static void +uvmpd_pool_drain_thread(void *arg) +{ + int bufcnt; + + for (;;) { + mutex_enter(_pool_drain_lock); + if (!uvmpd_pool_drain_run) { + cv_wait(_pool_drain_cv, _pool_drain_lock); + } + uvmpd_pool_drain_run = false; + mutex_exit(_pool_drain_lock); + + /* + * kill unused metadata buffers. + */ + mutex_spin_enter(_fpageqlock); + bufcnt = uvmexp.freetarg - uvmexp.free; + mutex_spin_exit(_fpageqlock); + if (bufcnt < 0) + bufcnt = 0; + + mutex_enter(_lock); + buf_drain(bufcnt << PAGE_SHIFT); + mutex_exit(_lock); + + /* + * drain a pool. + */ + pool_drain(NULL); + } + /*NOTREACHED*/ +} + +static void +uvmpd_pool_drain_wakeup(void) +{ + + mutex_enter(_pool_drain_lock); + uvmpd_pool_drain_run = true; + cv_signal(_pool_drain_cv); + mutex_exit(_pool_drain_lock); +}
CVS commit: src/sys/uvm
Module Name:src Committed By: chs Date: Sun Apr 21 15:27:59 UTC 2019 Modified Files: src/sys/uvm: uvm_fault.c Log Message: If a pager fault method returns ENOMEM but some memory appears to be reclaimable, wake up the pagedaemon and retry the fault. This fixes the problems with Xorg being killed with an "out of swap" message due to a transient memory shortage. To generate a diff of this commit: cvs rdiff -u -r1.204 -r1.205 src/sys/uvm/uvm_fault.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/uvm/uvm_fault.c diff -u src/sys/uvm/uvm_fault.c:1.204 src/sys/uvm/uvm_fault.c:1.205 --- src/sys/uvm/uvm_fault.c:1.204 Tue May 8 19:33:57 2018 +++ src/sys/uvm/uvm_fault.c Sun Apr 21 15:27:59 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: uvm_fault.c,v 1.204 2018/05/08 19:33:57 christos Exp $ */ +/* $NetBSD: uvm_fault.c,v 1.205 2019/04/21 15:27:59 chs Exp $ */ /* * Copyright (c) 1997 Charles D. Cranor and Washington University. @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uvm_fault.c,v 1.204 2018/05/08 19:33:57 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uvm_fault.c,v 1.205 2019/04/21 15:27:59 chs Exp $"); #include "opt_uvmhist.h" @@ -901,6 +901,16 @@ norng: * object fault routine responsible for * pmap_update(). */ + +/* + * Wake up the pagedaemon if the fault method + * failed for lack of memory but some can be + * reclaimed. + */ +if (error == ENOMEM && uvm_reclaimable()) { + uvm_wait("pgo_fault"); + error = ERESTART; +} } else { error = uvm_fault_lower(, , pages); }
CVS commit: src/sys/rump/librump/rumpvfs
Module Name:src Committed By: chs Date: Mon Jun 4 02:29:53 UTC 2018 Modified Files: src/sys/rump/librump/rumpvfs: rumpfs.c Log Message: initialize the new gop_putrange method pointer in rumpfs_genfsops too. To generate a diff of this commit: cvs rdiff -u -r1.152 -r1.153 src/sys/rump/librump/rumpvfs/rumpfs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/rump/librump/rumpvfs/rumpfs.c diff -u src/sys/rump/librump/rumpvfs/rumpfs.c:1.152 src/sys/rump/librump/rumpvfs/rumpfs.c:1.153 --- src/sys/rump/librump/rumpvfs/rumpfs.c:1.152 Mon Nov 20 17:00:35 2017 +++ src/sys/rump/librump/rumpvfs/rumpfs.c Mon Jun 4 02:29:53 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: rumpfs.c,v 1.152 2017/11/20 17:00:35 martin Exp $ */ +/* $NetBSD: rumpfs.c,v 1.153 2018/06/04 02:29:53 chs Exp $ */ /* * Copyright (c) 2009, 2010, 2011 Antti Kantee. All Rights Reserved. @@ -26,7 +26,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: rumpfs.c,v 1.152 2017/11/20 17:00:35 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rumpfs.c,v 1.153 2018/06/04 02:29:53 chs Exp $"); #include #include @@ -164,6 +164,7 @@ struct rumpfs_dent { struct genfs_ops rumpfs_genfsops = { .gop_size = genfs_size, .gop_write = genfs_gop_write, + .gop_putrange = genfs_gop_putrange, /* optional */ .gop_alloc = NULL,
CVS commit: src/external/cddl/osnet/sys/sys
Module Name:src Committed By: chs Date: Sun Jun 3 05:55:08 UTC 2018 Modified Files: src/external/cddl/osnet/sys/sys: proc.h sysmacros.h time.h types.h Log Message: tweak the osnet compat headers to allow building on MacOS and Linux hosts. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/external/cddl/osnet/sys/sys/proc.h cvs rdiff -u -r1.8 -r1.9 src/external/cddl/osnet/sys/sys/sysmacros.h cvs rdiff -u -r1.11 -r1.12 src/external/cddl/osnet/sys/sys/time.h cvs rdiff -u -r1.19 -r1.20 src/external/cddl/osnet/sys/sys/types.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/cddl/osnet/sys/sys/proc.h diff -u src/external/cddl/osnet/sys/sys/proc.h:1.7 src/external/cddl/osnet/sys/sys/proc.h:1.8 --- src/external/cddl/osnet/sys/sys/proc.h:1.7 Sat Jun 2 18:46:34 2018 +++ src/external/cddl/osnet/sys/sys/proc.h Sun Jun 3 05:55:08 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: proc.h,v 1.7 2018/06/02 18:46:34 christos Exp $ */ +/* $NetBSD: proc.h,v 1.8 2018/06/03 05:55:08 chs Exp $ */ /*- * Copyright (c) 2009 The NetBSD Foundation, Inc. @@ -61,7 +61,9 @@ #define _OPENSOLARIS_SYS_PROC_H_ #include_next +#ifdef __NetBSD__ #include +#endif #ifdef _KERNEL Index: src/external/cddl/osnet/sys/sys/sysmacros.h diff -u src/external/cddl/osnet/sys/sys/sysmacros.h:1.8 src/external/cddl/osnet/sys/sys/sysmacros.h:1.9 --- src/external/cddl/osnet/sys/sys/sysmacros.h:1.8 Mon May 28 21:05:10 2018 +++ src/external/cddl/osnet/sys/sys/sysmacros.h Sun Jun 3 05:55:08 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: sysmacros.h,v 1.8 2018/05/28 21:05:10 chs Exp $ */ +/* $NetBSD: sysmacros.h,v 1.9 2018/06/03 05:55:08 chs Exp $ */ /* * CDDL HEADER START @@ -32,6 +32,16 @@ #ifndef _SYS_SYSMACROS_H #define _SYS_SYSMACROS_H +/* + * Linux includes from with + * __SYSMACROS_DEPRECATED_INCLUSION defined during the include, + * but some of the definitions here break in that context, + * so if that symbol is defined then only define the few macros + * that we need there. + */ + +#ifndef __SYSMACROS_DEPRECATED_INCLUSION + #include #include @@ -52,6 +62,8 @@ extern "C" { #define btodt(BB) ((BB) >> DEV_BSHIFT) #define lbtod(BB) (((offset_t)(BB) + DEV_BSIZE - 1) >> DEV_BSHIFT) +#endif /* __SYSMACROS_DEPRECATED_INCLUSION */ + /* common macros */ #ifndef MIN #define MIN(a, b) ((a) < (b) ? (a) : (b)) @@ -66,6 +78,8 @@ extern "C" { #define SIGNOF(a) ((a) < 0 ? -1 : (a) > 0) #endif +#ifndef __SYSMACROS_DEPRECATED_INCLUSION + #ifdef _KERNEL /* @@ -469,4 +483,6 @@ highbit64(uint64_t i) } #endif +#endif /* __SYSMACROS_DEPRECATED_INCLUSION */ + #endif /* _SYS_SYSMACROS_H */ Index: src/external/cddl/osnet/sys/sys/time.h diff -u src/external/cddl/osnet/sys/sys/time.h:1.11 src/external/cddl/osnet/sys/sys/time.h:1.12 --- src/external/cddl/osnet/sys/sys/time.h:1.11 Sat Jun 2 18:46:34 2018 +++ src/external/cddl/osnet/sys/sys/time.h Sun Jun 3 05:55:08 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: time.h,v 1.11 2018/06/02 18:46:34 christos Exp $ */ +/* $NetBSD: time.h,v 1.12 2018/06/03 05:55:08 chs Exp $ */ /*- * Copyright (c) 2007 Pawel Jakub Dawidek @@ -92,8 +92,13 @@ ddi_get_lbolt64(void) #else +#ifdef __NetBSD__ int clock_gettime(clockid_t, struct timespec *) __RENAME(__clock_gettime50); +#endif +#ifdef __linux__ +#include +#endif static __inline hrtime_t gethrtime(void) { struct timespec ts; Index: src/external/cddl/osnet/sys/sys/types.h diff -u src/external/cddl/osnet/sys/sys/types.h:1.19 src/external/cddl/osnet/sys/sys/types.h:1.20 --- src/external/cddl/osnet/sys/sys/types.h:1.19 Fri Jun 1 00:56:19 2018 +++ src/external/cddl/osnet/sys/sys/types.h Sun Jun 3 05:55:08 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: types.h,v 1.19 2018/06/01 00:56:19 kre Exp $ */ +/* $NetBSD: types.h,v 1.20 2018/06/03 05:55:08 chs Exp $ */ /*- * Copyright (c) 2009 The NetBSD Foundation, Inc. @@ -65,11 +65,13 @@ */ #define longlong_t __hide_longlong_t #define u_longlong_t __hide_u_longlong_t + #ifndef _KERNEL #include #else #include #endif + #ifndef HAVE_NBTOOLS_CONFIG_H #ifdef _NETBSD_SOURCE #include_next @@ -81,6 +83,7 @@ #undef _NETBSD_SOURCE #endif #endif + #undef longlong_t #undef u_longlong_t #ifndef __defined_ll_t
CVS commit: src/external/cddl/osnet/dist/uts/common/fs/zfs
Module Name:src Committed By: chs Date: Sun Jun 3 03:05:56 UTC 2018 Modified Files: src/external/cddl/osnet/dist/uts/common/fs/zfs: dmu_tx.c Log Message: avoid calling kpause() with a delay of 0. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 \ src/external/cddl/osnet/dist/uts/common/fs/zfs/dmu_tx.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/cddl/osnet/dist/uts/common/fs/zfs/dmu_tx.c diff -u src/external/cddl/osnet/dist/uts/common/fs/zfs/dmu_tx.c:1.2 src/external/cddl/osnet/dist/uts/common/fs/zfs/dmu_tx.c:1.3 --- src/external/cddl/osnet/dist/uts/common/fs/zfs/dmu_tx.c:1.2 Mon May 28 21:05:07 2018 +++ src/external/cddl/osnet/dist/uts/common/fs/zfs/dmu_tx.c Sun Jun 3 03:05:56 2018 @@ -1151,7 +1151,11 @@ dmu_tx_delay(dmu_tx_t *tx, uint64_t dirt zfs_delay_resolution_ns * SBT_1NS, C_ABSOLUTE); #endif #ifdef __NetBSD__ - kpause("dmu_tx_delay", false, (wakeup - now) * hz / 10, NULL); + int timo = (wakeup - now) * hz / 10; + + if (timo == 0) + timo = 1; + kpause("dmu_tx_delay", false, timo, NULL); #endif #else hrtime_t delta = wakeup - gethrtime();
CVS commit: src/sys/uvm
Module Name:src Committed By: chs Date: Sat Jun 2 15:24:55 UTC 2018 Modified Files: src/sys/uvm: uvm_bio.c Log Message: add missing boilerplate for UVMHIST. To generate a diff of this commit: cvs rdiff -u -r1.96 -r1.97 src/sys/uvm/uvm_bio.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/uvm/uvm_bio.c diff -u src/sys/uvm/uvm_bio.c:1.96 src/sys/uvm/uvm_bio.c:1.97 --- src/sys/uvm/uvm_bio.c:1.96 Sat May 26 18:57:35 2018 +++ src/sys/uvm/uvm_bio.c Sat Jun 2 15:24:55 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: uvm_bio.c,v 1.96 2018/05/26 18:57:35 jdolecek Exp $ */ +/* $NetBSD: uvm_bio.c,v 1.97 2018/06/02 15:24:55 chs Exp $ */ /* * Copyright (c) 1998 Chuck Silvers. @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uvm_bio.c,v 1.96 2018/05/26 18:57:35 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uvm_bio.c,v 1.97 2018/06/02 15:24:55 chs Exp $"); #include "opt_uvmhist.h" #include "opt_ubc.h" @@ -816,6 +816,7 @@ ubc_alloc_direct(struct uvm_object *uobj int error; int gpflags = flags | PGO_NOTIMESTAMP | PGO_SYNCIO | PGO_ALLPAGES; int access_type = VM_PROT_READ; + UVMHIST_FUNC("ubc_alloc_direct"); UVMHIST_CALLED(ubchist); if (flags & UBC_WRITE) { if (flags & UBC_FAULTBUSY)
CVS commit: src/sys
Module Name:src Committed By: chs Date: Mon May 28 21:04:40 UTC 2018 Modified Files: src/sys/kern: kern_module.c src/sys/sys: module.h Log Message: add more accessor functions for various struct module fields. add a mechanism for registering callbacks to be called upon module load/unload. To generate a diff of this commit: cvs rdiff -u -r1.130 -r1.131 src/sys/kern/kern_module.c cvs rdiff -u -r1.41 -r1.42 src/sys/sys/module.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/kern_module.c diff -u src/sys/kern/kern_module.c:1.130 src/sys/kern/kern_module.c:1.131 --- src/sys/kern/kern_module.c:1.130 Thu Dec 14 22:28:59 2017 +++ src/sys/kern/kern_module.c Mon May 28 21:04:40 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_module.c,v 1.130 2017/12/14 22:28:59 pgoyette Exp $ */ +/* $NetBSD: kern_module.c,v 1.131 2018/05/28 21:04:40 chs Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_module.c,v 1.130 2017/12/14 22:28:59 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_module.c,v 1.131 2018/05/28 21:04:40 chs Exp $"); #define _MODULE_INTERNAL @@ -65,6 +65,21 @@ struct modlistmodule_list = TAIL struct modlistmodule_builtins = TAILQ_HEAD_INITIALIZER(module_builtins); static struct modlist module_bootlist = TAILQ_HEAD_INITIALIZER(module_bootlist); +struct module_callbacks { + TAILQ_ENTRY(module_callbacks) modcb_list; + void (*modcb_load)(struct module *); + void (*modcb_unload)(struct module *); +}; +TAILQ_HEAD(modcblist, module_callbacks); +static struct modcblist modcblist; + +static module_t *module_netbsd; +static const modinfo_t module_netbsd_modinfo = { + .mi_version = __NetBSD_Version__, + .mi_class = MODULE_CLASS_MISC, + .mi_name = "netbsd" +}; + static module_t *module_active; bool module_verbose_on; #ifdef MODULAR_DEFAULT_AUTOLOAD @@ -84,11 +99,14 @@ int (*module_load_vfs_vec)(const char *, static kauth_listener_t module_listener; +static specificdata_domain_t module_specificdata_domain; + /* Ensure that the kernel's link set isn't empty. */ static modinfo_t module_dummy; __link_set_add_rodata(modules, module_dummy); static module_t *module_newmodule(modsrc_t); +static void module_free(module_t *); static void module_require_force(module_t *); static int module_do_load(const char *, bool, int, prop_dictionary_t, module_t **, modclass_t modclass, bool); @@ -106,6 +124,9 @@ static bool module_merge_dicts(prop_dict static void sysctl_module_setup(void); static int sysctl_module_autotime(SYSCTLFN_PROTO); +static void module_callback_load(struct module *); +static void module_callback_unload(struct module *); + #define MODULE_CLASS_MATCH(mi, modclass) \ ((modclass) == MODULE_CLASS_ANY || (modclass) == (mi)->mi_class) @@ -116,6 +137,13 @@ module_incompat(const modinfo_t *mi, int mi->mi_name, modclass, mi->mi_class); } +struct module * +module_kernel(void) +{ + + return module_netbsd; +} + /* * module_error: * @@ -152,6 +180,30 @@ module_print(const char *fmt, ...) } } +/* + * module_name: + * + * Utility function: return the module's name. + */ +const char * +module_name(struct module *mod) +{ + + return mod->mod_info->mi_name; +} + +/* + * module_source: + * + * Utility function: return the module's source. + */ +modsrc_t +module_source(struct module *mod) +{ + + return mod->mod_source; +} + static int module_listener_cb(kauth_cred_t cred, kauth_action_t action, void *cookie, void *arg0, void *arg1, void *arg2, void *arg3) @@ -179,12 +231,22 @@ module_newmodule(modsrc_t source) mod = kmem_zalloc(sizeof(*mod), KM_SLEEP); mod->mod_source = source; - mod->mod_info = NULL; - mod->mod_flags = 0; + specificdata_init(module_specificdata_domain, >mod_sdref); return mod; } /* + * Free a module_t + */ +static void +module_free(module_t *mod) +{ + + specificdata_fini(module_specificdata_domain, >mod_sdref); + kmem_free(mod, sizeof(*mod)); +} + +/* * Require the -f (force) flag to load a module */ static void @@ -280,7 +342,7 @@ module_builtin_add(modinfo_t *const *mip if (rv != 0) { for (i = 0; i < nmodinfo; i++) { if (modp[i]) -kmem_free(modp[i], sizeof(*modp[i])); +module_free(modp[i]); } } kmem_free(modp, sizeof(*modp) * nmodinfo); @@ -347,6 +409,7 @@ module_init(void) } cv_init(_thread_cv, "mod_unld"); mutex_init(_thread_lock, MUTEX_DEFAULT, IPL_NONE); + TAILQ_INIT(); #ifdef MODULAR /* XXX */ module_init_md(); @@ -373,6 +436,11 @@ module_init(void) } sysctl_module_setup(); + module_specificdata_domain = specificdata_domain_create(); + + module_netbsd = module_newmodule(MODULE_SOURCE_KERNEL); + module_netbsd->mod_refcnt = 1; + module_netbsd->mod_info = _netbsd_modinfo; } /* @@ -685,21 +753,13 @@ module_lookup(const char *name) * responsibility to ensure that
CVS commit: src
Module Name:src Committed By: chs Date: Mon May 28 21:05:12 UTC 2018 Modified Files: src/distrib/sets/lists/base: shl.mi src/distrib/sets/lists/comp: mi shl.mi src/distrib/sets/lists/debug: mi shl.mi src/distrib/sets/lists/man: mi src/external/cddl/osnet: Makefile.inc Makefile.zfs src/external/cddl/osnet/dev/cyclic: cyclic.c cyclic_test.c src/external/cddl/osnet/dev/cyclic/arm: cyclic_machdep.c src/external/cddl/osnet/dev/cyclic/i386: cyclic_machdep.c src/external/cddl/osnet/dev/dtmalloc: dtmalloc.c src/external/cddl/osnet/dev/dtrace: dtrace_anon.c dtrace_cddl.h dtrace_debug.c dtrace_hacks.c dtrace_ioctl.c dtrace_load.c dtrace_modevent.c dtrace_sysctl.c dtrace_test.c dtrace_unload.c dtrace_vtime.c src/external/cddl/osnet/dev/dtrace/amd64: dtrace_asm.S dtrace_isa.c dtrace_subr.c src/external/cddl/osnet/dev/dtrace/arm: dtrace_asm.S dtrace_isa.c dtrace_subr.c regset.h src/external/cddl/osnet/dev/dtrace/i386: dtrace_asm.S dtrace_isa.c dtrace_subr.c src/external/cddl/osnet/dev/fbt: fbt.c src/external/cddl/osnet/dev/lockstat: lockstat.c src/external/cddl/osnet/dev/profile: profile.c src/external/cddl/osnet/dev/sdt: sdt.c src/external/cddl/osnet/dev/systrace: systrace.c src/external/cddl/osnet/dist/cmd/dtrace: dtrace.1 dtrace.c src/external/cddl/osnet/dist/cmd/zdb: zdb.c zdb_il.c src/external/cddl/osnet/dist/cmd/zfs: zfs_main.c src/external/cddl/osnet/dist/cmd/zpool: zpool_main.c zpool_vdev.c src/external/cddl/osnet/dist/cmd/ztest: ztest.c src/external/cddl/osnet/dist/common/acl: acl_common.c src/external/cddl/osnet/dist/common/ctf: ctf_types.c src/external/cddl/osnet/dist/common/nvpair: fnvpair.c nvpair.c src/external/cddl/osnet/dist/common/zfs: zfeature_common.c zfeature_common.h zfs_ioctl_compat.h zfs_prop.c zprop_common.c src/external/cddl/osnet/dist/lib/libctf/common: ctf_lib.c src/external/cddl/osnet/dist/lib/libdtrace/arm: dt_isadep.c src/external/cddl/osnet/dist/lib/libdtrace/common: drti.c dt_aggregate.c dt_as.c dt_cc.c dt_cg.c dt_consume.c dt_dis.c dt_dof.c dt_errtags.h dt_grammar.y dt_handle.c dt_ident.c dt_impl.h dt_link.c dt_module.c dt_open.c dt_options.c dt_parser.c dt_parser.h dt_pid.c dt_print.c dt_printf.c dt_proc.c dt_proc.h dt_provider.c dt_regset.c dt_subr.c dtrace.h src/external/cddl/osnet/dist/lib/libdtrace/i386: dt_isadep.c src/external/cddl/osnet/dist/lib/libgen/common: gmatch.c src/external/cddl/osnet/dist/lib/libnvpair: libnvpair.c src/external/cddl/osnet/dist/lib/libuutil/common: uu_misc.c src/external/cddl/osnet/dist/lib/libzfs/common: libzfs.h libzfs_compat.c libzfs_dataset.c libzfs_impl.h libzfs_import.c libzfs_mount.c libzfs_pool.c libzfs_sendrecv.c libzfs_util.c src/external/cddl/osnet/dist/lib/libzpool/common: kernel.c taskq.c util.c src/external/cddl/osnet/dist/tools/ctf/cvt: barrier.c barrier.h ctf.c ctfconvert.c ctfmerge.c ctftools.h dwarf.c merge.c output.c st_parse.c stabs.c strtab.c tdata.c util.c src/external/cddl/osnet/dist/uts/common: Makefile.files src/external/cddl/osnet/dist/uts/common/dtrace: dtrace.c fasttrap.c src/external/cddl/osnet/dist/uts/common/fs: vnode.c src/external/cddl/osnet/dist/uts/common/fs/zfs: arc.c dbuf.c ddt.c dmu.c dmu_diff.c dmu_send.c dmu_tx.c dnode.c dnode_sync.c dsl_dataset.c dsl_deleg.c dsl_dir.c dsl_pool.c lz4.c rrwlock.c sa.c sha256.c spa.c spa_config.c spa_history.c spa_misc.c space_map.c trim_map.c txg.c vdev.c vdev_disk.c vdev_file.c vdev_mirror.c vdev_raidz.c zap_micro.c zfs_acl.c zfs_ctldir.c zfs_dir.c zfs_fuid.c zfs_ioctl.c zfs_onexit.c zfs_replay.c zfs_rlock.c zfs_vfsops.c zfs_vnops.c zfs_znode.c zio.c zio_checksum.c zvol.c src/external/cddl/osnet/dist/uts/common/fs/zfs/sys: dbuf.h ddt.h dmu.h dsl_dataset.h refcount.h spa.h spa_impl.h vdev_disk.h vdev_impl.h zfs_dir.h zfs_ioctl.h zfs_rlock.h zfs_znode.h zio.h zio_checksum.h zio_compress.h zvol.h src/external/cddl/osnet/dist/uts/common/rpc: xdr.h src/external/cddl/osnet/dist/uts/common/sys: acl.h ccompile.h cmn_err.h ctf.h debug.h dtrace.h dtrace_impl.h errorq.h processor.h sysevent.h taskq.h src/external/cddl/osnet/dist/uts/common/sys/fm: util.h src/external/cddl/osnet/dist/uts/common/sys/fs: zfs.h src/external/cddl/osnet/dist/uts/common/zmod: deflate.c zlib.h zutil.c zutil.h src/external/cddl/osnet/include: alloca.h dtrace.h fcntl.h
CVS commit: src/sys
Module Name:src Committed By: chs Date: Mon May 28 21:04:42 UTC 2018 Modified Files: src/sys/kern: subr_copy.c src/sys/sys: systm.h Log Message: add copyin_pid(), to copyin from a different user address space. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/kern/subr_copy.c cvs rdiff -u -r1.275 -r1.276 src/sys/sys/systm.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/subr_copy.c diff -u src/sys/kern/subr_copy.c:1.7 src/sys/kern/subr_copy.c:1.8 --- src/sys/kern/subr_copy.c:1.7 Wed May 25 17:43:58 2016 +++ src/sys/kern/subr_copy.c Mon May 28 21:04:41 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: subr_copy.c,v 1.7 2016/05/25 17:43:58 christos Exp $ */ +/* $NetBSD: subr_copy.c,v 1.8 2018/05/28 21:04:41 chs Exp $ */ /*- * Copyright (c) 1997, 1998, 1999, 2002, 2007, 2008 The NetBSD Foundation, Inc. @@ -79,7 +79,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: subr_copy.c,v 1.7 2016/05/25 17:43:58 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: subr_copy.c,v 1.8 2018/05/28 21:04:41 chs Exp $"); #include #include @@ -300,6 +300,33 @@ copyout_proc(struct proc *p, const void } /* + * Like copyin(), but operates on an arbitrary pid. + */ +int +copyin_pid(pid_t pid, const void *uaddr, void *kaddr, size_t len) +{ + struct proc *p; + struct vmspace *vm; + int error; + + mutex_enter(proc_lock); + p = proc_find(pid); + if (p == NULL) { + mutex_exit(proc_lock); + return ESRCH; + } + mutex_enter(p->p_lock); + proc_vmspace_getref(p, ); + mutex_exit(p->p_lock); + mutex_exit(proc_lock); + + error = copyin_vmspace(vm, uaddr, kaddr, len); + + uvmspace_free(vm); + return error; +} + +/* * Like copyin(), except it operates on kernel addresses when the FKIOCTL * flag is passed in `ioctlflags' from the ioctl call. */ Index: src/sys/sys/systm.h diff -u src/sys/sys/systm.h:1.275 src/sys/sys/systm.h:1.276 --- src/sys/sys/systm.h:1.275 Sun Feb 4 17:31:51 2018 +++ src/sys/sys/systm.h Mon May 28 21:04:41 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: systm.h,v 1.275 2018/02/04 17:31:51 maxv Exp $ */ +/* $NetBSD: systm.h,v 1.276 2018/05/28 21:04:41 chs Exp $ */ /*- * Copyright (c) 1982, 1988, 1991, 1993 @@ -267,6 +267,7 @@ typedef int (*copyout_t)(const void *, v int copyin_proc(struct proc *, const void *, void *, size_t); int copyout_proc(struct proc *, const void *, void *, size_t); +int copyin_pid(pid_t, const void *, void *, size_t); int copyin_vmspace(struct vmspace *, const void *, void *, size_t); int copyout_vmspace(struct vmspace *, const void *, void *, size_t);
CVS commit: src/sys
(fshi - off - 1) >> PAGE_SHIFT); uvn_findpages(uobj, off + PAGE_SIZE, , [nback + 1], UFP_NOWAIT|UFP_NOALLOC|UFP_DIRTYONLY); @@ -1314,6 +1336,18 @@ skip_scan: return (error); } +/* + * Default putrange method for file systems that do not care + * how many pages are given to one GOP_WRITE() call. + */ +void +genfs_gop_putrange(struct vnode *vp, off_t off, off_t *lop, off_t *hip) +{ + + *lop = 0; + *hip = 0; +} + int genfs_gop_write(struct vnode *vp, struct vm_page **pgs, int npages, int flags) { Index: src/sys/miscfs/genfs/genfs_node.h diff -u src/sys/miscfs/genfs/genfs_node.h:1.21 src/sys/miscfs/genfs/genfs_node.h:1.22 --- src/sys/miscfs/genfs/genfs_node.h:1.21 Thu Jun 6 02:00:59 2013 +++ src/sys/miscfs/genfs/genfs_node.h Mon May 28 21:04:38 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_node.h,v 1.21 2013/06/06 02:00:59 dholland Exp $ */ +/* $NetBSD: genfs_node.h,v 1.22 2018/05/28 21:04:38 chs Exp $ */ /* * Copyright (c) 2001 Chuck Silvers. @@ -46,6 +46,7 @@ struct genfs_ops { struct kauth_cred *); int (*gop_write)(struct vnode *, struct vm_page **, int, int); void (*gop_markupdate)(struct vnode *, int); + void (*gop_putrange)(struct vnode *, off_t, off_t *, off_t *); }; #define GOP_SIZE(vp, size, eobp, flags) \ @@ -54,6 +55,8 @@ struct genfs_ops { (*VTOG(vp)->g_op->gop_alloc)((vp), (off), (len), (flags), (cred)) #define GOP_WRITE(vp, pgs, npages, flags) \ (*VTOG(vp)->g_op->gop_write)((vp), (pgs), (npages), (flags)) +#define GOP_PUTRANGE(vp, off, lop, hip) \ + (*VTOG(vp)->g_op->gop_putrange)((vp), (off), (lop), (hip)) /* * GOP_MARKUPDATE: mark vnode's timestamps for update. @@ -85,6 +88,7 @@ struct genfs_node { void genfs_size(struct vnode *, off_t, off_t *, int); void genfs_node_init(struct vnode *, const struct genfs_ops *); void genfs_node_destroy(struct vnode *); +void genfs_gop_putrange(struct vnode *, off_t, off_t *, off_t *); int genfs_gop_write(struct vnode *, struct vm_page **, int, int); int genfs_gop_write_rwmap(struct vnode *, struct vm_page **, int, int); int genfs_compat_gop_write(struct vnode *, struct vm_page **, int, int); Index: src/sys/nfs/nfs_node.c diff -u src/sys/nfs/nfs_node.c:1.122 src/sys/nfs/nfs_node.c:1.123 --- src/sys/nfs/nfs_node.c:1.122 Fri May 26 14:34:20 2017 +++ src/sys/nfs/nfs_node.c Mon May 28 21:04:38 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: nfs_node.c,v 1.122 2017/05/26 14:34:20 riastradh Exp $ */ +/* $NetBSD: nfs_node.c,v 1.123 2018/05/28 21:04:38 chs Exp $ */ /* * Copyright (c) 1989, 1993 @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: nfs_node.c,v 1.122 2017/05/26 14:34:20 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nfs_node.c,v 1.123 2018/05/28 21:04:38 chs Exp $"); #ifdef _KERNEL_OPT #include "opt_nfs.h" @@ -73,6 +73,7 @@ static const struct genfs_ops nfs_genfso .gop_size = nfs_gop_size, .gop_alloc = nfs_gop_alloc, .gop_write = nfs_gop_write, + .gop_putrange = genfs_gop_putrange, }; /* Index: src/sys/ufs/chfs/chfs_vfsops.c diff -u src/sys/ufs/chfs/chfs_vfsops.c:1.17 src/sys/ufs/chfs/chfs_vfsops.c:1.18 --- src/sys/ufs/chfs/chfs_vfsops.c:1.17 Tue Nov 14 22:06:40 2017 +++ src/sys/ufs/chfs/chfs_vfsops.c Mon May 28 21:04:38 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: chfs_vfsops.c,v 1.17 2017/11/14 22:06:40 riastradh Exp $ */ +/* $NetBSD: chfs_vfsops.c,v 1.18 2018/05/28 21:04:38 chs Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -99,6 +99,7 @@ const struct genfs_ops chfs_genfsops = { .gop_alloc = chfs_gop_alloc, .gop_write = genfs_gop_write, .gop_markupdate = ufs_gop_markupdate, + .gop_putrange = genfs_gop_putrange, }; struct pool chfs_inode_pool; Index: src/sys/ufs/ext2fs/ext2fs_vfsops.c diff -u src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.210 src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.211 --- src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.210 Sun Jul 30 14:23:54 2017 +++ src/sys/ufs/ext2fs/ext2fs_vfsops.c Mon May 28 21:04:38 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_vfsops.c,v 1.210 2017/07/30 14:23:54 riastradh Exp $ */ +/* $NetBSD: ext2fs_vfsops.c,v 1.211 2018/05/28 21:04:38 chs Exp $ */ /* * Copyright (c) 1989, 1991, 1993, 1994 @@ -60,7 +60,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.210 2017/07/30 14:23:54 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.211 2018/05/28 21:04:38 chs Exp $"); #if defined(_KERNEL_OPT) #include "opt_compat_netbsd.h" @@ -152,6 +152,7 @@ static const struct genfs_ops ext2fs_gen .gop_alloc = ext2fs_gop_alloc, .gop_write = genfs_gop_write, .gop_markupdate = ufs_gop_markupdate, + .gop_putrange = genfs_gop_putrange, }; static const struct ufs_ops ext2fs_ufsops = { Index: src/sys/ufs/ffs/ffs_vfsops.c diff -u src/sys/ufs/ffs/ffs_vfsops.c:1.356 src/sys/ufs/ffs/ffs_vfsops.c:1.357 --- src/sys/ufs/ffs/ffs_vfsops.c:1.356 Sun Jan 28 10:02:00 2018 +++ src/sys/ufs/ffs/ffs_vfsops.c Mon May 28 21:04:38 2018 @@
CVS commit: src/sys
Module Name:src Committed By: chs Date: Mon May 28 21:04:35 UTC 2018 Modified Files: src/sys/fs/tmpfs: tmpfs_subr.c src/sys/uvm: uvm_aobj.c uvm_extern.h Log Message: allow tmpfs files to be larger than 4GB. To generate a diff of this commit: cvs rdiff -u -r1.102 -r1.103 src/sys/fs/tmpfs/tmpfs_subr.c cvs rdiff -u -r1.126 -r1.127 src/sys/uvm/uvm_aobj.c cvs rdiff -u -r1.212 -r1.213 src/sys/uvm/uvm_extern.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/tmpfs/tmpfs_subr.c diff -u src/sys/fs/tmpfs/tmpfs_subr.c:1.102 src/sys/fs/tmpfs/tmpfs_subr.c:1.103 --- src/sys/fs/tmpfs/tmpfs_subr.c:1.102 Wed Jan 4 10:06:43 2017 +++ src/sys/fs/tmpfs/tmpfs_subr.c Mon May 28 21:04:35 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_subr.c,v 1.102 2017/01/04 10:06:43 hannken Exp $ */ +/* $NetBSD: tmpfs_subr.c,v 1.103 2018/05/28 21:04:35 chs Exp $ */ /* * Copyright (c) 2005-2013 The NetBSD Foundation, Inc. @@ -73,7 +73,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tmpfs_subr.c,v 1.102 2017/01/04 10:06:43 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tmpfs_subr.c,v 1.103 2018/05/28 21:04:35 chs Exp $"); #include #include @@ -275,7 +275,7 @@ tmpfs_newvnode(struct mount *mp, struct case VREG: /* Regular file. Create an underlying UVM object. */ node->tn_spec.tn_reg.tn_aobj = - uao_create(INT32_MAX - PAGE_SIZE, 0); + uao_create(INT64_MAX - PAGE_SIZE, 0); node->tn_spec.tn_reg.tn_aobj_pages = 0; break; default: Index: src/sys/uvm/uvm_aobj.c diff -u src/sys/uvm/uvm_aobj.c:1.126 src/sys/uvm/uvm_aobj.c:1.127 --- src/sys/uvm/uvm_aobj.c:1.126 Sat Oct 28 00:37:13 2017 +++ src/sys/uvm/uvm_aobj.c Mon May 28 21:04:35 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: uvm_aobj.c,v 1.126 2017/10/28 00:37:13 pgoyette Exp $ */ +/* $NetBSD: uvm_aobj.c,v 1.127 2018/05/28 21:04:35 chs Exp $ */ /* * Copyright (c) 1998 Chuck Silvers, Charles D. Cranor and @@ -38,7 +38,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uvm_aobj.c,v 1.126 2017/10/28 00:37:13 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uvm_aobj.c,v 1.127 2018/05/28 21:04:35 chs Exp $"); #ifdef _KERNEL_OPT #include "opt_uvmhist.h" @@ -408,12 +408,12 @@ uao_free(struct uvm_aobj *aobj) */ struct uvm_object * -uao_create(vsize_t size, int flags) +uao_create(voff_t size, int flags) { static struct uvm_aobj kernel_object_store; static kmutex_t kernel_object_lock; static int kobj_alloced __diagused = 0; - pgoff_t pages = round_page(size) >> PAGE_SHIFT; + pgoff_t pages = round_page((uint64_t)size) >> PAGE_SHIFT; struct uvm_aobj *aobj; int refs; @@ -700,9 +700,11 @@ uao_put(struct uvm_object *uobj, voff_t } else { stop = round_page(stop); } - if (stop > (aobj->u_pages << PAGE_SHIFT)) { - printf("uao_flush: strange, got an out of range " - "flush (fixed)\n"); + if (stop > (uint64_t)(aobj->u_pages << PAGE_SHIFT)) { + printf("uao_put: strange, got an out of range " + "flush 0x%jx > 0x%jx (fixed)\n", + (uintmax_t)stop, + (uintmax_t)(aobj->u_pages << PAGE_SHIFT)); stop = aobj->u_pages << PAGE_SHIFT; } by_list = (uobj->uo_npages <= Index: src/sys/uvm/uvm_extern.h diff -u src/sys/uvm/uvm_extern.h:1.212 src/sys/uvm/uvm_extern.h:1.213 --- src/sys/uvm/uvm_extern.h:1.212 Sat May 19 11:39:37 2018 +++ src/sys/uvm/uvm_extern.h Mon May 28 21:04:35 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: uvm_extern.h,v 1.212 2018/05/19 11:39:37 jdolecek Exp $ */ +/* $NetBSD: uvm_extern.h,v 1.213 2018/05/28 21:04:35 chs Exp $ */ /* * Copyright (c) 1997 Charles D. Cranor and Washington University. @@ -603,9 +603,10 @@ extern struct vm_map *phys_map; /* vm_machdep.c */ int vmapbuf(struct buf *, vsize_t); void vunmapbuf(struct buf *, vsize_t); +void ktext_write(void *, const void *, size_t); /* uvm_aobj.c */ -struct uvm_object *uao_create(vsize_t, int); +struct uvm_object *uao_create(voff_t, int); void uao_set_pgfl(struct uvm_object *, int); void uao_detach(struct uvm_object *); void uao_reference(struct uvm_object *);
CVS commit: src/sys/sys
Module Name:src Committed By: chs Date: Mon May 28 21:05:16 UTC 2018 Modified Files: src/sys/sys: param.h Log Message: welcome to 8.99.13: - uao_create()'s size is now 64-bit - new genfs op to let a file system constrain the range of pages passed to GOP_WRITE() - various module interface changes - changes to various MD hooks for the new dtrace To generate a diff of this commit: cvs rdiff -u -r1.563 -r1.564 src/sys/sys/param.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/sys/param.h diff -u src/sys/sys/param.h:1.563 src/sys/sys/param.h:1.564 --- src/sys/sys/param.h:1.563 Sat May 19 11:40:22 2018 +++ src/sys/sys/param.h Mon May 28 21:05:16 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: param.h,v 1.563 2018/05/19 11:40:22 jdolecek Exp $ */ +/* $NetBSD: param.h,v 1.564 2018/05/28 21:05:16 chs Exp $ */ /*- * Copyright (c) 1982, 1986, 1989, 1993 @@ -67,7 +67,7 @@ * 2.99.9 (299000900) */ -#define __NetBSD_Version__ 899001800 /* NetBSD 8.99.18 */ +#define __NetBSD_Version__ 899001900 /* NetBSD 8.99.19 */ #define __NetBSD_Prereq__(M,m,p) (M) * 1) + \ (m) * 100) + (p) * 100) <= __NetBSD_Version__)
CVS import: src/external/cddl/osnet
Module Name:src Committed By: chs Date: Mon May 28 20:53:06 UTC 2018 Update of /cvsroot/src/external/cddl/osnet In directory ivanova.netbsd.org:/tmp/cvs-serv14363 Log Message: import new CDDL dtrace and ZFS code from FreeBSD svn r315983. Status: Vendor Tag: FreeBSD Release Tags: CDDL-FreeBSD-r315983 C src/external/cddl/osnet/dist/cmd/dtrace/dtrace.1 C src/external/cddl/osnet/dist/cmd/dtrace/dtrace.c N src/external/cddl/osnet/dist/cmd/pyzfs/pyzfs.py N src/external/cddl/osnet/dist/cmd/stat/common/timestamp.c C src/external/cddl/osnet/dist/cmd/zdb/zdb_il.c C src/external/cddl/osnet/dist/cmd/zdb/zdb.c U src/external/cddl/osnet/dist/cmd/zfs/zfs_iter.c U src/external/cddl/osnet/dist/cmd/zfs/zfs_iter.h C src/external/cddl/osnet/dist/cmd/zfs/zfs_main.c U src/external/cddl/osnet/dist/cmd/zfs/zfs_util.h N src/external/cddl/osnet/dist/cmd/zhack/zhack.c N src/external/cddl/osnet/dist/cmd/zinject/translate.c N src/external/cddl/osnet/dist/cmd/zinject/zinject.c N src/external/cddl/osnet/dist/cmd/zinject/zinject.h N src/external/cddl/osnet/dist/cmd/zlook/zlook.c U src/external/cddl/osnet/dist/cmd/zpool/zpool_iter.c C src/external/cddl/osnet/dist/cmd/zpool/zpool_main.c U src/external/cddl/osnet/dist/cmd/zpool/zpool_util.c U src/external/cddl/osnet/dist/cmd/zpool/zpool_util.h C src/external/cddl/osnet/dist/cmd/zpool/zpool_vdev.c N src/external/cddl/osnet/dist/cmd/zstreamdump/zstreamdump.1 N src/external/cddl/osnet/dist/cmd/zstreamdump/zstreamdump.c C src/external/cddl/osnet/dist/cmd/ztest/ztest.c C src/external/cddl/osnet/dist/common/acl/acl_common.c U src/external/cddl/osnet/dist/common/acl/acl_common.h U src/external/cddl/osnet/dist/common/avl/avl.c C src/external/cddl/osnet/dist/common/ctf/ctf_create.c U src/external/cddl/osnet/dist/common/ctf/ctf_decl.c C src/external/cddl/osnet/dist/common/ctf/ctf_error.c U src/external/cddl/osnet/dist/common/ctf/ctf_hash.c C src/external/cddl/osnet/dist/common/ctf/ctf_impl.h U src/external/cddl/osnet/dist/common/ctf/ctf_labels.c U src/external/cddl/osnet/dist/common/ctf/ctf_lookup.c C src/external/cddl/osnet/dist/common/ctf/ctf_open.c C src/external/cddl/osnet/dist/common/ctf/ctf_types.c U src/external/cddl/osnet/dist/common/ctf/ctf_util.c N src/external/cddl/osnet/dist/common/nvpair/fnvpair.c C src/external/cddl/osnet/dist/common/nvpair/nvpair.c U src/external/cddl/osnet/dist/common/nvpair/nvpair_alloc_fixed.c U src/external/cddl/osnet/dist/common/unicode/u8_textprep.c N src/external/cddl/osnet/dist/common/util/strtolctype.h N src/external/cddl/osnet/dist/common/zfs/zfeature_common.c N src/external/cddl/osnet/dist/common/zfs/zfeature_common.h U src/external/cddl/osnet/dist/common/zfs/zfs_comutil.c U src/external/cddl/osnet/dist/common/zfs/zfs_comutil.h U src/external/cddl/osnet/dist/common/zfs/zfs_deleg.c U src/external/cddl/osnet/dist/common/zfs/zfs_deleg.h U src/external/cddl/osnet/dist/common/zfs/zfs_fletcher.c U src/external/cddl/osnet/dist/common/zfs/zfs_fletcher.h N src/external/cddl/osnet/dist/common/zfs/zfs_ioctl_compat.c N src/external/cddl/osnet/dist/common/zfs/zfs_ioctl_compat.h U src/external/cddl/osnet/dist/common/zfs/zfs_namecheck.c U src/external/cddl/osnet/dist/common/zfs/zfs_namecheck.h U src/external/cddl/osnet/dist/common/zfs/zfs_prop.c U src/external/cddl/osnet/dist/common/zfs/zfs_prop.h U src/external/cddl/osnet/dist/common/zfs/zpool_prop.c U src/external/cddl/osnet/dist/common/zfs/zprop_common.c U src/external/cddl/osnet/dist/head/storclass.h U src/external/cddl/osnet/dist/head/nlist.h U src/external/cddl/osnet/dist/head/note.h U src/external/cddl/osnet/dist/head/syms.h C src/external/cddl/osnet/dist/lib/libctf/common/ctf_lib.c C src/external/cddl/osnet/dist/lib/libctf/common/ctf.5 C src/external/cddl/osnet/dist/lib/libctf/common/ctf_subr.c U src/external/cddl/osnet/dist/lib/libctf/common/libctf.h N src/external/cddl/osnet/dist/lib/libdtrace/aarch64/dt_isadep.c C src/external/cddl/osnet/dist/lib/libdtrace/arm/dt_isadep.c C src/external/cddl/osnet/dist/lib/libdtrace/common/dt_aggregate.c C src/external/cddl/osnet/dist/lib/libdtrace/common/drti.c U src/external/cddl/osnet/dist/lib/libdtrace/common/dt_buf.c C src/external/cddl/osnet/dist/lib/libdtrace/common/dt_as.c U src/external/cddl/osnet/dist/lib/libdtrace/common/dt_as.h C src/external/cddl/osnet/dist/lib/libdtrace/common/dt_consume.c U src/external/cddl/osnet/dist/lib/libdtrace/common/dt_buf.h C src/external/cddl/osnet/dist/lib/libdtrace/common/dt_cc.c C src/external/cddl/osnet/dist/lib/libdtrace/common/dt_cg.c C src/external/cddl/osnet/dist/lib/libdtrace/common/dt_errtags.h C src/external/cddl/osnet/dist/lib/libdtrace/common/dt_decl.c C src/external/cddl/osnet/dist/lib/libdtrace/common/dt_decl.h C src/external/cddl/osnet/dist/lib/libdtrace/common/dt_dis.c C src/external/cddl/osnet/dist/lib/libdtrace/common/dt_dof.c U src/external/cddl/osnet/dist/lib/libdtrace/common/dt_dof.h C src/external/cddl/osnet/dist/lib/libdtrace/common/dt_error.c C
CVS commit: src/sys/sys
Module Name:src Committed By: chs Date: Sun Feb 25 18:55:23 UTC 2018 Modified Files: src/sys/sys: filio.h Log Message: add definitions of FIOSEEKDATA and FIOSEEKHOLE for ZFS. from FreeBSD. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/sys/sys/filio.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/sys/filio.h diff -u src/sys/sys/filio.h:1.10 src/sys/sys/filio.h:1.11 --- src/sys/sys/filio.h:1.10 Sun Dec 11 12:25:20 2005 +++ src/sys/sys/filio.h Sun Feb 25 18:55:23 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: filio.h,v 1.10 2005/12/11 12:25:20 christos Exp $ */ +/* $NetBSD: filio.h,v 1.11 2018/02/25 18:55:23 chs Exp $ */ /*- * Copyright (c) 1982, 1986, 1990, 1993, 1994 @@ -44,6 +44,9 @@ /* Generic file-descriptor ioctl's. */ #define FIOCLEX _IO('f', 1) /* set close on exec on fd */ #define FIONCLEX _IO('f', 2) /* remove close on exec */ +/* Handle lseek SEEK_DATA and SEEK_HOLE for holey file knowledge. */ +#define FIOSEEKDATA _IOWR('f', 97, off_t) /* SEEK_DATA */ +#define FIOSEEKHOLE _IOWR('f', 98, off_t) /* SEEK_HOLE */ #define FIONREAD _IOR('f', 127, int) /* get # bytes to read */ #define FIONBIO _IOW('f', 126, int) /* set/clear non-blocking i/o */ #define FIOASYNC _IOW('f', 125, int) /* set/clear async i/o */ @@ -55,7 +58,6 @@ * in send queue. */ #define FIONSPACE _IOR('f', 120, int) /* get space in send queue. */ - /* Ugly symbol for compatibility with other operating systems */ #define FIBMAP FIOGETBMAP
CVS commit: src/sys/kern
Module Name:src Committed By: chs Date: Sun Feb 25 18:54:29 UTC 2018 Modified Files: src/sys/kern: kern_mutex.c Log Message: add defines to control whether or not mutex operations are skipped after we have panic'd. no functional change. To generate a diff of this commit: cvs rdiff -u -r1.72 -r1.73 src/sys/kern/kern_mutex.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/kern_mutex.c diff -u src/sys/kern/kern_mutex.c:1.72 src/sys/kern/kern_mutex.c:1.73 --- src/sys/kern/kern_mutex.c:1.72 Tue Feb 6 07:46:24 2018 +++ src/sys/kern/kern_mutex.c Sun Feb 25 18:54:29 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_mutex.c,v 1.72 2018/02/06 07:46:24 ozaki-r Exp $ */ +/* $NetBSD: kern_mutex.c,v 1.73 2018/02/25 18:54:29 chs Exp $ */ /*- * Copyright (c) 2002, 2006, 2007, 2008 The NetBSD Foundation, Inc. @@ -40,7 +40,7 @@ #define __MUTEX_PRIVATE #include -__KERNEL_RCSID(0, "$NetBSD: kern_mutex.c,v 1.72 2018/02/06 07:46:24 ozaki-r Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_mutex.c,v 1.73 2018/02/25 18:54:29 chs Exp $"); #include #include @@ -60,6 +60,9 @@ __KERNEL_RCSID(0, "$NetBSD: kern_mutex.c #include +#define MUTEX_PANIC_SKIP_SPIN 1 +#define MUTEX_PANIC_SKIP_ADAPTIVE 1 + /* * When not running a debug kernel, spin mutexes are not much * more than an splraiseipl() and splx() pair. @@ -489,8 +492,10 @@ mutex_vector_enter(kmutex_t *mtx) * to reduce cache line ping-ponging between CPUs. */ do { +#if MUTEX_PANIC_SKIP_SPIN if (panicstr != NULL) break; +#endif while (MUTEX_SPINBIT_LOCKED_P(mtx)) { SPINLOCK_BACKOFF(count); #ifdef LOCKDEBUG @@ -547,10 +552,12 @@ mutex_vector_enter(kmutex_t *mtx) owner = mtx->mtx_owner; continue; } +#if MUTEX_PANIC_SKIP_ADAPTIVE if (__predict_false(panicstr != NULL)) { KPREEMPT_ENABLE(curlwp); return; } +#endif if (__predict_false(MUTEX_OWNER(owner) == curthread)) { MUTEX_ABORT(mtx, "locking against myself"); } @@ -726,8 +733,10 @@ mutex_vector_exit(kmutex_t *mtx) if (MUTEX_SPIN_P(mtx)) { #ifdef FULL if (__predict_false(!MUTEX_SPINBIT_LOCKED_P(mtx))) { +#if MUTEX_PANIC_SKIP_SPIN if (panicstr != NULL) return; +#endif MUTEX_ABORT(mtx, "exiting unheld spin mutex"); } MUTEX_UNLOCKED(mtx); @@ -737,11 +746,13 @@ mutex_vector_exit(kmutex_t *mtx) return; } +#ifdef MUTEX_PANIC_SKIP_ADAPTIVE if (__predict_false((uintptr_t)panicstr | cold)) { MUTEX_UNLOCKED(mtx); MUTEX_RELEASE(mtx); return; } +#endif curthread = (uintptr_t)curlwp; MUTEX_DASSERT(mtx, curthread != 0); @@ -932,8 +943,10 @@ mutex_spin_retry(kmutex_t *mtx) * to reduce cache line ping-ponging between CPUs. */ do { +#if MUTEX_PANIC_SKIP_SPIN if (panicstr != NULL) break; +#endif while (MUTEX_SPINBIT_LOCKED_P(mtx)) { SPINLOCK_BACKOFF(count); #ifdef LOCKDEBUG
CVS commit: src/share/mk
Module Name:src Committed By: chs Date: Sun Feb 25 18:53:23 UTC 2018 Modified Files: src/share/mk: bsd.host.mk sys.mk Log Message: add DTRACE_OPTS and HOST_DTRACE_OPTS to allow disabling various optimizations that interfere with using dtrace. use them when MKDTRACE=yes. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/share/mk/bsd.host.mk cvs rdiff -u -r1.129 -r1.130 src/share/mk/sys.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/share/mk/bsd.host.mk diff -u src/share/mk/bsd.host.mk:1.3 src/share/mk/bsd.host.mk:1.4 --- src/share/mk/bsd.host.mk:1.3 Sat Feb 20 15:18:46 2016 +++ src/share/mk/bsd.host.mk Sun Feb 25 18:53:23 2018 @@ -1,4 +1,4 @@ -# $NetBSD: bsd.host.mk,v 1.3 2016/02/20 15:18:46 christos Exp $ +# $NetBSD: bsd.host.mk,v 1.4 2018/02/25 18:53:23 chs Exp $ .if !defined(_BSD_HOST_MK_) _BSD_HOST_MK_=1 @@ -9,11 +9,16 @@ HOST_DBG?= -g HOST_DBG?= -O .endif +.if ${MKDTRACE:Uno} != "no" +# disable compiler options that interfere with dtrace +HOST_DTRACE_OPTS?= -fno-omit-frame-pointer -fno-optimize-sibling-calls -fno-ipa-sra +.endif + # Helpers for cross-compiling HOST_CC?= cc HOST_CFLAGS?= ${HOST_DBG} -HOST_COMPILE.c?=${HOST_CC} ${HOST_CFLAGS} ${HOST_CPPFLAGS} -c -HOST_COMPILE.cc?= ${HOST_CXX} ${HOST_CXXFLAGS} ${HOST_CPPFLAGS} -c +HOST_COMPILE.c?=${HOST_CC} ${HOST_CFLAGS} ${HOST_DTRACE_OPTS} ${HOST_CPPFLAGS} -c +HOST_COMPILE.cc?= ${HOST_CXX} ${HOST_CXXFLAGS} ${HOST_DTRACE_OPTS} ${HOST_CPPFLAGS} -c HOST_LINK.cc?= ${HOST_CXX} ${HOST_CXXFLAGS} ${HOST_CPPFLAGS} ${HOST_LDFLAGS} .if defined(HOSTPROG_CXX) HOST_LINK.c?= ${HOST_LINK.cc} Index: src/share/mk/sys.mk diff -u src/share/mk/sys.mk:1.129 src/share/mk/sys.mk:1.130 --- src/share/mk/sys.mk:1.129 Wed Mar 30 17:35:43 2016 +++ src/share/mk/sys.mk Sun Feb 25 18:53:23 2018 @@ -1,4 +1,4 @@ -# $NetBSD: sys.mk,v 1.129 2016/03/30 17:35:43 martin Exp $ +# $NetBSD: sys.mk,v 1.130 2018/02/25 18:53:23 chs Exp $ # @(#)sys.mk 8.2 (Berkeley) 3/21/94 # # This file contains the basic rules for make(1) and is read first @@ -37,9 +37,12 @@ DBG?= -O2 ${"${.TARGET:M*.po}" == "":? - .else DBG?= -O2 .endif +.if ${MKDTRACE:Uno} != "no" +DTRACE_OPTS?= -fno-omit-frame-pointer -fno-optimize-sibling-calls -fno-ipa-sra -fno-ipa-icf +.endif CFLAGS?= ${DBG} LDFLAGS?= -COMPILE.c?= ${CC} ${CFLAGS} ${CPPFLAGS} -c +COMPILE.c?= ${CC} ${CFLAGS} ${DTRACE_OPTS} ${CPPFLAGS} -c LINK.c?= ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} # C Type Format data is required for DTrace @@ -55,7 +58,7 @@ __ALLSRC3= ${empty(NETBSDSRCDIR):?${__AL __BUILDSEED= ${BUILDSEED}/${__ALLSRC3:O}/${.TARGET} _CXXSEED?= ${BUILDSEED:D-frandom-seed=${__BUILDSEED:hash}} -COMPILE.cc?= ${CXX} ${_CXXSEED} ${CXXFLAGS} ${CPPFLAGS} -c +COMPILE.cc?= ${CXX} ${_CXXSEED} ${CXXFLAGS} ${DTRACE_OPTS} ${CPPFLAGS} -c LINK.cc?= ${CXX} ${CXXFLAGS} ${CPPFLAGS} ${LDFLAGS} OBJC?= ${CC}
CVS commit: src/lib/libpthread
Module Name:src Committed By: chs Date: Sun Feb 25 18:51:18 UTC 2018 Modified Files: src/lib/libpthread: Makefile Log Message: remove hard-coded -fomit-frame-pointer for pthread stuff, let these use the same setting as the rest of the tree. the performance difference is marginal and this allows dtrace ustack() to work better. To generate a diff of this commit: cvs rdiff -u -r1.87 -r1.88 src/lib/libpthread/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libpthread/Makefile diff -u src/lib/libpthread/Makefile:1.87 src/lib/libpthread/Makefile:1.88 --- src/lib/libpthread/Makefile:1.87 Sun Jul 3 14:24:58 2016 +++ src/lib/libpthread/Makefile Sun Feb 25 18:51:18 2018 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.87 2016/07/03 14:24:58 christos Exp $ +# $NetBSD: Makefile,v 1.88 2018/02/25 18:51:18 chs Exp $ # WARNS?= 5 @@ -90,31 +90,13 @@ SRCS+= pthread_compat.c ALIGN_FUNCTIONS= ${${ACTIVE_CC} == "gcc":? -falign-functions=32 :} -.if ${MACHINE_CPU} != "m68k" && ${MACHINE_CPU} != "sh3" && ${MACHINE_ARCH} != "vax" -OMIT_FRAME_POINTER= -fomit-frame-pointer -.else -OMIT_FRAME_POINTER= -.endif - # The TSD routines are used in the implementation of profiling, and so # can't be profiled themselves. -COPTS.pthread_specific.c+= ${OMIT_FRAME_POINTER} ${ALIGN_FUNCTIONS} +COPTS.pthread_specific.c+= ${ALIGN_FUNCTIONS} pthread_specific.po: pthread_specific.o ${_MKTARGET_CREATE} cp pthread_specific.o pthread_specific.po -# Internal spinlock routines are performance critical. Don't profile them, -# it's incompatibile with -fomit-frame-pointer. -COPTS.pthread_lock.c+= ${OMIT_FRAME_POINTER} ${ALIGN_FUNCTIONS} -pthread_lock.po: pthread_lock.o - ${_MKTARGET_CREATE} - cp pthread_lock.o pthread_lock.po - -COPTS.pthread_mutex.c+= ${OMIT_FRAME_POINTER} ${ALIGN_FUNCTIONS} -pthread_mutex.po: pthread_mutex.o - ${_MKTARGET_CREATE} - cp pthread_mutex.o pthread_mutex.po - COPTS.pthread.c += -Wno-stack-protector -Wno-format-nonliteral COPTS.pthread_attr.c += -Wno-format-nonliteral
CVS commit: src/external/bsd/libproc/dist
Module Name:src Committed By: chs Date: Sun Feb 25 18:48:39 UTC 2018 Modified Files: src/external/bsd/libproc/dist: libproc.h Log Message: add some flag definitions from a newer version of FreeBSD's libproc that are needed by the new dtrace. these don't do anything yet, but dtrace doesn't mind. I'll do a full resync to the latest FreeBSD libproc / librtld_db later. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/external/bsd/libproc/dist/libproc.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/libproc/dist/libproc.h diff -u src/external/bsd/libproc/dist/libproc.h:1.3 src/external/bsd/libproc/dist/libproc.h:1.4 --- src/external/bsd/libproc/dist/libproc.h:1.3 Fri Jun 9 01:17:25 2017 +++ src/external/bsd/libproc/dist/libproc.h Sun Feb 25 18:48:39 2018 @@ -51,6 +51,11 @@ typedef void (*proc_child_func)(void *); #define PS_DEAD 5 #define PS_LOST 6 +/* Flags for proc_attach(). */ +#define PATTACH_FORCE 0x01 +#define PATTACH_RDONLY 0x02 +#define PATTACH_NOSTOP 0x04 + /* Reason values for proc_detach(). */ #define PRELEASE_HANG 1 #define PRELEASE_KILL 2
CVS commit: src/sys/arch
Module Name:src Committed By: chs Date: Sat Jan 27 23:07:36 UTC 2018 Modified Files: src/sys/arch/alpha/alpha: pmap.c src/sys/arch/m68k/m68k: pmap_motorola.c src/sys/arch/powerpc/oea: pmap.c src/sys/arch/sparc64/sparc64: pmap.c Log Message: apply the change from arch/x86/x86/pmap.c rev. 1.266 commitid vZRjvmxG7YTHLOfA: In pmap_enter_ma(), only try to allocate pves if we might need them, and even if that fails, only fail the operation if we later discover that we really do need them. If we are replacing an existing mapping, reuse the pv structure where possible. This implements the requirement that pmap_enter(PMAP_CANFAIL) must not fail when replacing an existing mapping with the first mapping of a new page, which is an unintended consequence of the changes from the rmind-uvmplock branch in 2011. The problem arises when pmap_enter(PMAP_CANFAIL) is used to replace an existing pmap mapping with a mapping of a different page (eg. to resolve a copy-on-write). If that fails and leaves the old pmap entry in place, then UVM won't hold the right locks when it eventually retries. This entanglement of the UVM and pmap locking was done in rmind-uvmplock in order to improve performance, but it also means that the UVM state and pmap state need to be kept in sync more than they did before. It would be possible to handle this in the UVM code instead of in the pmap code, but these pmap changes improve the handling of low memory situations in general, and handling this in UVM would be clunky, so this seemed like the better way to go. This somewhat indirectly fixes PR 52706 on the remaining platforms where this problem existed. To generate a diff of this commit: cvs rdiff -u -r1.261 -r1.262 src/sys/arch/alpha/alpha/pmap.c cvs rdiff -u -r1.69 -r1.70 src/sys/arch/m68k/m68k/pmap_motorola.c cvs rdiff -u -r1.94 -r1.95 src/sys/arch/powerpc/oea/pmap.c cvs rdiff -u -r1.307 -r1.308 src/sys/arch/sparc64/sparc64/pmap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/alpha/alpha/pmap.c diff -u src/sys/arch/alpha/alpha/pmap.c:1.261 src/sys/arch/alpha/alpha/pmap.c:1.262 --- src/sys/arch/alpha/alpha/pmap.c:1.261 Fri Dec 23 07:15:27 2016 +++ src/sys/arch/alpha/alpha/pmap.c Sat Jan 27 23:07:36 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.261 2016/12/23 07:15:27 cherry Exp $ */ +/* $NetBSD: pmap.c,v 1.262 2018/01/27 23:07:36 chs Exp $ */ /*- * Copyright (c) 1998, 1999, 2000, 2001, 2007, 2008 The NetBSD Foundation, Inc. @@ -140,7 +140,7 @@ #include /* RCS ID & Copyright macro defns */ -__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.261 2016/12/23 07:15:27 cherry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.262 2018/01/27 23:07:36 chs Exp $"); #include #include @@ -439,7 +439,8 @@ static struct pool_cache pmap_tlb_shootd * Internal routines */ static void alpha_protection_init(void); -static bool pmap_remove_mapping(pmap_t, vaddr_t, pt_entry_t *, bool, long); +static bool pmap_remove_mapping(pmap_t, vaddr_t, pt_entry_t *, bool, long, +pv_entry_t *); static void pmap_changebit(struct vm_page *, pt_entry_t, pt_entry_t, long); /* @@ -466,8 +467,9 @@ static int pmap_l1pt_ctor(void *, void * * PV table management functions. */ static int pmap_pv_enter(pmap_t, struct vm_page *, vaddr_t, pt_entry_t *, - bool); -static void pmap_pv_remove(pmap_t, struct vm_page *, vaddr_t, bool); + bool, pv_entry_t); +static void pmap_pv_remove(pmap_t, struct vm_page *, vaddr_t, bool, + pv_entry_t *); static void *pmap_pv_page_alloc(struct pool *, int); static void pmap_pv_page_free(struct pool *, void *); @@ -1266,7 +1268,7 @@ pmap_remove(pmap_t pmap, vaddr_t sva, va sva); #endif needisync |= pmap_remove_mapping(pmap, sva, -l3pte, true, cpu_id); +l3pte, true, cpu_id, NULL); } sva += PAGE_SIZE; } @@ -1343,7 +1345,7 @@ pmap_remove(pmap_t pmap, vaddr_t sva, va pmap_remove_mapping( pmap, sva, l3pte, true, - cpu_id); + cpu_id, NULL); } /* @@ -1450,7 +1452,7 @@ pmap_page_protect(struct vm_page *pg, vm panic("pmap_page_protect: bad mapping"); #endif if (pmap_remove_mapping(pmap, pv->pv_va, pv->pv_pte, - false, cpu_id) == true) { + false, cpu_id, NULL)) { if (pmap == pmap_kernel()) needkisync |= true; else @@ -1558,6 +1560,7 @@ pmap_enter(pmap_t pmap, vaddr_t va, padd { struct vm_page *pg; /* if != NULL, managed page */ pt_entry_t *pte, npte, opte; + pv_entry_t opv = NULL; paddr_t opa; bool tflush = true; bool hadasm = false; /* XXX gcc -Wuninitialized */ @@ -1750,14 +1753,15 @@ pmap_enter(pmap_t pmap, vaddr_t va, padd */ pmap_physpage_addref(pte); } - needisync |= pmap_remove_mapping(pmap, va, pte, true, cpu_id); + needisync |= pmap_remove_mapping(pmap, va, pte, true, cpu_id, ); validate_enterpv:
CVS commit: src/sys/arch/powerpc/include
Module Name:src Committed By: chs Date: Sun Dec 17 17:18:34 UTC 2017 Modified Files: src/sys/arch/powerpc/include: cpu.h Log Message: apply the same change for powerpc as mrg did for arm and mips: CPU_INFO_FOREACH() must always iterate at least the boot cpu. document this in sys/cpu.h and fix the arm and mips versions to check ncpu is non zero before using it as an iterator max. this should fix the new assert in init_main.c. To generate a diff of this commit: cvs rdiff -u -r1.102 -r1.103 src/sys/arch/powerpc/include/cpu.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/powerpc/include/cpu.h diff -u src/sys/arch/powerpc/include/cpu.h:1.102 src/sys/arch/powerpc/include/cpu.h:1.103 --- src/sys/arch/powerpc/include/cpu.h:1.102 Wed Oct 19 00:08:42 2016 +++ src/sys/arch/powerpc/include/cpu.h Sun Dec 17 17:18:34 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu.h,v 1.102 2016/10/19 00:08:42 nonaka Exp $ */ +/* $NetBSD: cpu.h,v 1.103 2017/12/17 17:18:34 chs Exp $ */ /* * Copyright (C) 1999 Wolfgang Solfrank. @@ -32,6 +32,7 @@ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + #ifndef _POWERPC_CPU_H_ #define _POWERPC_CPU_H_ @@ -54,6 +55,8 @@ struct cache_info { #include #include #include +#include +#include #endif #include @@ -191,7 +194,7 @@ extern struct cpuset_info cpuset_info; #define CPU_IS_PRIMARY(ci) ((ci)->ci_cpuid == 0) #define CPU_INFO_ITERATOR int #define CPU_INFO_FOREACH(cii, ci)\ - cii = 0, ci = _info[0]; cii < ncpu; cii++, ci++ + cii = 0, ci = _info[0]; cii < (ncpu ? ncpu : 1); cii++, ci++ #else #define cpu_number() 0
CVS commit: src/sys/kern
Module Name:src Committed By: chs Date: Fri Dec 15 16:05:51 UTC 2017 Modified Files: src/sys/kern: init_main.c Log Message: add some assertions to verify that CPU_INFO_FOREACH() works right early in the boot process. this detects existing bugs on some platforms. To generate a diff of this commit: cvs rdiff -u -r1.492 -r1.493 src/sys/kern/init_main.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/init_main.c diff -u src/sys/kern/init_main.c:1.492 src/sys/kern/init_main.c:1.493 --- src/sys/kern/init_main.c:1.492 Fri Oct 27 12:25:15 2017 +++ src/sys/kern/init_main.c Fri Dec 15 16:05:51 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: init_main.c,v 1.492 2017/10/27 12:25:15 joerg Exp $ */ +/* $NetBSD: init_main.c,v 1.493 2017/12/15 16:05:51 chs Exp $ */ /*- * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. @@ -97,7 +97,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.492 2017/10/27 12:25:15 joerg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.493 2017/12/15 16:05:51 chs Exp $"); #include "opt_ddb.h" #include "opt_inet.h" @@ -266,6 +266,19 @@ main(void) CPU_INFO_ITERATOR cii; struct cpu_info *ci; +#ifdef DIAGNOSTIC + /* + * Verify that CPU_INFO_FOREACH() knows about the boot CPU + * and only the boot CPU at this point. + */ + int cpucount = 0; + for (CPU_INFO_FOREACH(cii, ci)) { + KASSERT(ci == curcpu()); + cpucount++; + } + KASSERT(cpucount == 1); +#endif + l = #ifndef LWP0_CPU_INFO l->l_cpu = curcpu();
CVS commit: src/sys/ufs/ffs
Module Name:src Committed By: chs Date: Thu Dec 7 21:53:41 UTC 2017 Modified Files: src/sys/ufs/ffs: ffs_alloc.c Log Message: fix the UVM_PAGE_TRKOWN page-locking assertion at the top of ffs_alloc() to work right for multi-threaded processes. To generate a diff of this commit: cvs rdiff -u -r1.158 -r1.159 src/sys/ufs/ffs/ffs_alloc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ffs/ffs_alloc.c diff -u src/sys/ufs/ffs/ffs_alloc.c:1.158 src/sys/ufs/ffs/ffs_alloc.c:1.159 --- src/sys/ufs/ffs/ffs_alloc.c:1.158 Sun Aug 13 21:00:58 2017 +++ src/sys/ufs/ffs/ffs_alloc.c Thu Dec 7 21:53:41 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: ffs_alloc.c,v 1.158 2017/08/13 21:00:58 mlelstv Exp $ */ +/* $NetBSD: ffs_alloc.c,v 1.159 2017/12/07 21:53:41 chs Exp $ */ /*- * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. @@ -70,7 +70,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ffs_alloc.c,v 1.158 2017/08/13 21:00:58 mlelstv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ffs_alloc.c,v 1.159 2017/12/07 21:53:41 chs Exp $"); #if defined(_KERNEL_OPT) #include "opt_ffs.h" @@ -203,10 +203,12 @@ ffs_alloc(struct inode *ip, daddr_t lbn, * be locked by the current thread. */ - if (ITOV(ip)->v_type == VREG && - ffs_lblktosize(fs, (voff_t)lbn) < round_page(ITOV(ip)->v_size)) { + struct vnode *vp = ITOV(ip); + if (vp->v_type == VREG && + ffs_lblktosize(fs, (voff_t)lbn) < round_page(vp->v_size) && + ((vp->v_vflag & VV_MAPPED) != 0 || (size & PAGE_MASK) != 0 || + ffs_blkoff(fs, size) != 0)) { struct vm_page *pg; - struct vnode *vp = ITOV(ip); struct uvm_object *uobj = >v_uobj; voff_t off = trunc_page(ffs_lblktosize(fs, lbn)); voff_t endoff = round_page(ffs_lblktosize(fs, lbn) + size); @@ -214,10 +216,8 @@ ffs_alloc(struct inode *ip, daddr_t lbn, mutex_enter(uobj->vmobjlock); while (off < endoff) { pg = uvm_pagelookup(uobj, off); - KASSERT((pg == NULL && (vp->v_vflag & VV_MAPPED) == 0 && - (size & PAGE_MASK) == 0 && - ffs_blkoff(fs, size) == 0) || -(pg != NULL && pg->owner == curproc->p_pid && + KASSERT((pg != NULL && pg->owner_tag != NULL && + pg->owner == curproc->p_pid && pg->lowner == curlwp->l_lid)); off += PAGE_SIZE; }
CVS commit: src/sys/uvm
Module Name:src Committed By: chs Date: Mon Nov 20 21:06:54 UTC 2017 Modified Files: src/sys/uvm: uvm_fault.c Log Message: In uvm_fault_upper_enter(), if pmap_enter(PMAP_CANFAIL) fails, assert that the pmap did not leave around a now-stale pmap mapping for an old page. If such a pmap mapping still existed after we unlocked the vm_map, the UVM code would not know later that it would need to lock the lower layer object while calling the pmap to remove or replace that stale pmap mapping. See PR 52706 for further details. To generate a diff of this commit: cvs rdiff -u -r1.201 -r1.202 src/sys/uvm/uvm_fault.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/uvm/uvm_fault.c diff -u src/sys/uvm/uvm_fault.c:1.201 src/sys/uvm/uvm_fault.c:1.202 --- src/sys/uvm/uvm_fault.c:1.201 Sat Oct 28 00:37:13 2017 +++ src/sys/uvm/uvm_fault.c Mon Nov 20 21:06:54 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: uvm_fault.c,v 1.201 2017/10/28 00:37:13 pgoyette Exp $ */ +/* $NetBSD: uvm_fault.c,v 1.202 2017/11/20 21:06:54 chs Exp $ */ /* * Copyright (c) 1997 Charles D. Cranor and Washington University. @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uvm_fault.c,v 1.201 2017/10/28 00:37:13 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uvm_fault.c,v 1.202 2017/11/20 21:06:54 chs Exp $"); #include "opt_uvmhist.h" @@ -1211,7 +1211,7 @@ uvm_fault_upper_lookup( } /* - * uvm_fault_upper_neighbor: enter single lower neighbor page. + * uvm_fault_upper_neighbor: enter single upper neighbor page. * * => called with amap and anon locked. */ @@ -1493,6 +1493,8 @@ uvm_fault_upper_enter( struct uvm_object *uobj, struct vm_anon *anon, struct vm_page *pg, struct vm_anon *oanon) { + struct pmap *pmap = ufi->orig_map->pmap; + vaddr_t va = ufi->orig_rvaddr; struct vm_amap * const amap = ufi->entry->aref.ar_amap; UVMHIST_FUNC("uvm_fault_upper_enter"); UVMHIST_CALLED(maphist); @@ -1508,14 +1510,26 @@ uvm_fault_upper_enter( UVMHIST_LOG(maphist, " MAPPING: anon: pm=%#jx, va=%#jx, pg=%#jx, promote=%jd", - (uintptr_t)ufi->orig_map->pmap, ufi->orig_rvaddr, - (uintptr_t)pg, flt->promote); - if (pmap_enter(ufi->orig_map->pmap, ufi->orig_rvaddr, - VM_PAGE_TO_PHYS(pg), + (uintptr_t)pmap, va, (uintptr_t)pg, flt->promote); + if (pmap_enter(pmap, va, VM_PAGE_TO_PHYS(pg), flt->enter_prot, flt->access_type | PMAP_CANFAIL | (flt->wire_mapping ? PMAP_WIRED : 0)) != 0) { /* + * If pmap_enter() fails, it must not leave behind an existing + * pmap entry. In particular, a now-stale entry for a different + * page would leave the pmap inconsistent with the vm_map. + * This is not to imply that pmap_enter() should remove an + * existing mapping in such a situation (since that could create + * different problems, eg. if the existing mapping is wired), + * but rather that the pmap should be designed such that it + * never needs to fail when the new mapping is replacing an + * existing mapping and the new page has no existing mappings. + */ + + KASSERT(!pmap_extract(pmap, va, NULL)); + + /* * No need to undo what we did; we can simply think of * this as the pmap throwing away the mapping information. * @@ -1541,7 +1555,7 @@ uvm_fault_upper_enter( * done case 1! finish up by unlocking everything and returning success */ - pmap_update(ufi->orig_map->pmap); + pmap_update(pmap); uvmfault_unlockall(ufi, amap, uobj); return 0; }
CVS commit: src/sys/arch/arm
Module Name:src Committed By: chs Date: Fri Jul 7 00:34:09 UTC 2017 Modified Files: src/sys/arch/arm/arm32: exception.S src/sys/arch/arm/include/arm32: frame.h Log Message: split PUSHFRAMEINSVC into two pieces so that we can insert some additional instructions in the middle in undefinedinstruction_bounce, namely to add some additional space on the stack before the trapframe for undefineds from SVC mode. this extra space allows dtrace to emulate a "push" instruction. the initial version was from me and some improvements were from nick. To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/sys/arch/arm/arm32/exception.S cvs rdiff -u -r1.43 -r1.44 src/sys/arch/arm/include/arm32/frame.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/arm32/exception.S diff -u src/sys/arch/arm/arm32/exception.S:1.23 src/sys/arch/arm/arm32/exception.S:1.24 --- src/sys/arch/arm/arm32/exception.S:1.23 Sun Jun 21 15:00:06 2015 +++ src/sys/arch/arm/arm32/exception.S Fri Jul 7 00:34:09 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: exception.S,v 1.23 2015/06/21 15:00:06 matt Exp $ */ +/* $NetBSD: exception.S,v 1.24 2017/07/07 00:34:09 chs Exp $ */ /* * Copyright (c) 1994-1997 Mark Brinicombe. @@ -51,7 +51,7 @@ #include - RCSID("$NetBSD: exception.S,v 1.23 2015/06/21 15:00:06 matt Exp $") + RCSID("$NetBSD: exception.S,v 1.24 2017/07/07 00:34:09 chs Exp $") .text .align 0 @@ -258,7 +258,9 @@ ASEND(undefined_entry) */ ENTRY_NP(undefinedinstruction_bounce) - PUSHFRAMEINSVC + PUSHXXXREGSANDSWITCH + PUSHDTRACEGAP + PUSHTRAPFRAME(r2) ENABLE_ALIGNMENT_FAULTS mov r0, sp Index: src/sys/arch/arm/include/arm32/frame.h diff -u src/sys/arch/arm/include/arm32/frame.h:1.43 src/sys/arch/arm/include/arm32/frame.h:1.44 --- src/sys/arch/arm/include/arm32/frame.h:1.43 Thu Jun 22 08:44:21 2017 +++ src/sys/arch/arm/include/arm32/frame.h Fri Jul 7 00:34:09 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: frame.h,v 1.43 2017/06/22 08:44:21 skrll Exp $ */ +/* $NetBSD: frame.h,v 1.44 2017/07/07 00:34:09 chs Exp $ */ /* * Copyright (c) 1994-1997 Mark Brinicombe. @@ -95,6 +95,7 @@ void validate_trapframe(trapframe_t *, i #include "opt_cpuoptions.h" #include "opt_arm_debug.h" #include "opt_cputypes.h" +#include "opt_dtrace.h" #include @@ -440,13 +441,25 @@ LOCK_CAS_DEBUG_LOCALS msr cpsr_c, tmp /* Punch into SVC mode */ #endif -#define PUSHFRAMEINSVC \ +#define PUSHXXXREGSANDSWITCH \ stmdb sp, {r0-r3}; /* Save 4 registers */ \ mov r0, lr; /* Save xxx32 r14 */ \ mov r1, sp; /* Save xxx32 sp */ \ mrs r3, spsr; /* Save xxx32 spsr */ \ - SET_CPSR_MODE(r2, PSR_SVC32_MODE); \ - bic r2, sp, #7; /* Align new SVC sp */ \ + SET_CPSR_MODE(r2, PSR_SVC32_MODE) + +#ifdef KDTRACE_HOOKS +#define PUSHDTRACEGAP \ + and r2, r3, #(PSR_MODE); \ + cmp r2, #(PSR_SVC32_MODE); /* were we in SVC mode? */ \ + mov r2, sp; \ + subeq r2, r2, #(4 * 16); /* if so, leave a gap for dtrace */ +#else +#define PUSHDTRACEGAP /* nothing */ +#endif + +#define PUSHTRAPFRAME(rX) \ + bic r2, rX, #7; /* Align new SVC sp */ \ str r0, [r2, #-4]!; /* Push return address */ \ stmdb r2!, {sp, lr}; /* Push SVC sp, lr */ \ mov sp, r2; /* Keep stack aligned */ \ @@ -458,6 +471,10 @@ LOCK_CAS_DEBUG_LOCALS mrs r0, spsr; /* Get the SPSR */ \ str r0, [sp, #-TF_R0]! /* Push the SPSR onto the stack */ +#define PUSHFRAMEINSVC \ + PUSHXXXREGSANDSWITCH; \ + PUSHTRAPFRAME(sp) + /* * PULLFRAMEFROMSVCANDEXIT - macro to pull a trap frame from the stack * in SVC32 mode and restore the saved processor mode and PC.
CVS commit: src/external/gpl3/binutils/usr.sbin/dbsym
Module Name:src Committed By: chs Date: Thu Jul 6 02:34:00 UTC 2017 Modified Files: src/external/gpl3/binutils/usr.sbin/dbsym: dbsym.c Log Message: copy the CTF section too, if there is one. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/external/gpl3/binutils/usr.sbin/dbsym/dbsym.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/gpl3/binutils/usr.sbin/dbsym/dbsym.c diff -u src/external/gpl3/binutils/usr.sbin/dbsym/dbsym.c:1.4 src/external/gpl3/binutils/usr.sbin/dbsym/dbsym.c:1.5 --- src/external/gpl3/binutils/usr.sbin/dbsym/dbsym.c:1.4 Sun Aug 17 19:12:59 2014 +++ src/external/gpl3/binutils/usr.sbin/dbsym/dbsym.c Thu Jul 6 02:34:00 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: dbsym.c,v 1.4 2014/08/17 19:12:59 joerg Exp $ */ +/* $NetBSD: dbsym.c,v 1.5 2017/07/06 02:34:00 chs Exp $ */ /* * Copyright (c) 2001 Simon Burge (for Wasabi Systems) @@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1996 Christopher G. Demetriou.\ Copyright 2001 Simon Burge.\ All rights reserved."); -__RCSID("$NetBSD: dbsym.c,v 1.4 2014/08/17 19:12:59 joerg Exp $"); +__RCSID("$NetBSD: dbsym.c,v 1.5 2017/07/06 02:34:00 chs Exp $"); #endif /* not lint */ #include @@ -362,8 +362,9 @@ load_symtab(bfd *abfd, int fd, char **sy Elf32_External_Shdr *s32hdr = NULL; Elf64_External_Shdr *s64hdr = NULL; void *shdr; + char *shstrtab = NULL; u_int32_t osymtabsize, sh_offset; - int elftype, e_shnum, i, sh_size; + int elftype, e_shnum, i, sh_size, rv = 1, shstridx; off_t e_shoff; if (lseek(fd, 0, SEEK_SET) < 0) @@ -422,8 +423,19 @@ load_symtab(bfd *abfd, int fd, char **sy if (read(fd, shdr, sh_size) != sh_size) goto out; + shstridx = (ISELF64 + ? bfd_get_16(abfd, e64_hdr.e_shstrndx) + : bfd_get_16(abfd, e32_hdr.e_shstrndx)); + shstrtab = malloc(shstridx); + if (shstrtab == NULL) + goto out; + if (pread(fd, shstrtab, SH_SIZE(shstridx), SH_OFFSET(shstridx)) != + SH_SIZE(shstridx)) + goto out; + for (i = 0; i < e_shnum; i++) { - if (SH_TYPE(i) == SHT_SYMTAB || SH_TYPE(i) == SHT_STRTAB) { + if (SH_TYPE(i) == SHT_SYMTAB || SH_TYPE(i) == SHT_STRTAB || + !strcmp(shstrtab + SH_NAME(i), ".SUNW_ctf")) { osymtabsize = *symtabsize; *symtabsize += roundup(SH_SIZE(i), ISELF64 ? 8 : 4); if ((*symtab = realloc(*symtab, *symtabsize)) == NULL) @@ -467,10 +479,11 @@ load_symtab(bfd *abfd, int fd, char **sy bfd_put_16(abfd, 0, e32_hdr.e_phnum); } memcpy(*symtab, , sizeof(ehdr)); + rv = 0; - free(shdr); - return (0); out: + if (shstrtab != NULL) + free(shstrtab); free(shdr); - return (1); + return (rv); }
CVS commit: src/sys/arch/evbarm/awin
Module Name:src Committed By: chs Date: Wed Jul 5 23:04:09 UTC 2017 Modified Files: src/sys/arch/evbarm/awin: awin_start.S Log Message: in the awin_start startup code, set up a tiny stack in case a C function wants to use it. in the various *_mpinit functions, avoid using caller-saved registers since these call C functions. these changes allow -fno-omit-frame-pointer to work. To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/sys/arch/evbarm/awin/awin_start.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/evbarm/awin/awin_start.S diff -u src/sys/arch/evbarm/awin/awin_start.S:1.13 src/sys/arch/evbarm/awin/awin_start.S:1.14 --- src/sys/arch/evbarm/awin/awin_start.S:1.13 Mon Dec 26 13:28:59 2016 +++ src/sys/arch/evbarm/awin/awin_start.S Wed Jul 5 23:04:09 2017 @@ -41,7 +41,7 @@ #include #include -RCSID("$NetBSD: awin_start.S,v 1.13 2016/12/26 13:28:59 rjs Exp $") +RCSID("$NetBSD: awin_start.S,v 1.14 2017/07/05 23:04:09 chs Exp $") #if defined(VERBOSE_INIT_ARM) #define XPUTC(n) mov r0, n; bl xputc @@ -170,6 +170,10 @@ _C_LABEL(awin_start): #endif lsr r1, r1, #16 + /* Set up a small stack in case gtmr_bootdelay() wants it */ + movw sp, #:lower16:awin_initstkbase + movt sp, #:upper16:awin_initstkbase + // MP init based on SoC ID #if defined(ALLWINNER_A20) # if defined(ALLWINNER_A31) @@ -209,6 +213,13 @@ _C_LABEL(awin_start): .popsection #endif + .pushsection .bss + .align 8 +awin_initstk: + .space 32 +awin_initstkbase: + .popsection + #include #if defined(MULTIPROCESSOR) @@ -323,11 +334,11 @@ a31_mpinit: setend le // everything here is little-endian #endif - mov r12, #1 // CPU number + mov r10, #1 // CPU number a31_mpinit_cpu: - add r1, r12, #'0' + add r1, r10, #'0' XPUTC2(r1) /* Set where the other CPU(s) are going to execute */ @@ -339,7 +350,7 @@ a31_mpinit_cpu: /* Assert CPU core reset */ mov r1, #0 mov r2, #0x40 - mul r7, r12, r2 + mul r7, r10, r2 add r7, r7, #AWIN_A31_CPUCFG_CPU0_RST_CTRL_REG str r1, [r5, r7] dsb @@ -347,7 +358,7 @@ a31_mpinit_cpu: /* Ensure CPUX reset also invalidates its L1 caches */ ldr r1, [r5, #AWIN_CPUCFG_GENCTRL_REG] mov r0, #1 - lsl r0, r0, r12 + lsl r0, r0, r10 bic r1, r1, r0 str r1, [r5, #AWIN_CPUCFG_GENCTRL_REG] dsb @@ -355,13 +366,13 @@ a31_mpinit_cpu: /* Release power clamp */ mov r1, #0xe7 mov r2, #0x4 - mul r7, r12, r2 + mul r7, r10, r2 add r7, r7, #AWIN_A31_PRCM_CPUX_PWR_CLAMP_REG str r1, [r6, r7] dsb mov r2, #0x40 - mul r7, r12, r2 + mul r7, r10, r2 add r7, r7, #AWIN_A31_CPUCFG_CPU0_PWR_CLAMP_STATUS_REG 1: ldr r1, [r5, r7] @@ -375,13 +386,13 @@ a31_mpinit_cpu: /* Restore power clamp */ mov r1, #0 mov r2, #0x4 - mul r7, r12, r2 + mul r7, r10, r2 add r7, r7, #AWIN_A31_PRCM_CPUX_PWR_CLAMP_REG str r1, [r6, r7] dsb mov r2, #0x40 - mul r7, r12, r2 + mul r7, r10, r2 add r7, r7, #AWIN_A31_CPUCFG_CPU0_PWR_CLAMP_STATUS_REG 1: ldr r1, [r5, r7] @@ -395,7 +406,7 @@ a31_mpinit_cpu: /* Clear power-off gating */ ldr r1, [r6, #AWIN_A31_PRCM_PWROFF_GATING_REG] mov r0, #1 - lsl r0, r0, r12 + lsl r0, r0, r10 bic r1, r1, r0 str r1, [r6, #AWIN_A31_PRCM_PWROFF_GATING_REG] dsb @@ -407,14 +418,14 @@ a31_mpinit_cpu: /* Bring CPUX out of reset */ mov r1, #(AWIN_A31_CPUCFG_RST_CTRL_CPU_RESET|AWIN_A31_CPUCFG_RST_CTRL_CORE_RESET) mov r2, #0x40 - mul r7, r12, r2 + mul r7, r10, r2 add r7, r7, #AWIN_A31_CPUCFG_CPU0_RST_CTRL_REG str r1, [r5, r7] dsb /* If there is another CPU, start it */ - add r12, r12, #1 - cmp r12, #3 + add r10, r10, #1 + cmp r10, #3 ble a31_mpinit_cpu #ifdef __ARMEB__ @@ -462,11 +473,11 @@ a80_mpinit: setend le // everything here is little-endian #endif - mov r12, #1 // CPU number + mov r10, #1 // CPU number a80_mpinit_cpu: - add r1, r12, #'0' + add r1, r10, #'0' XPUTC2(r1) /* Set where the other CPU(s) are going to execute */ @@ -478,27 +489,27 @@ a80_mpinit_cpu: /* Assert CPU power on reset */ ldr r1, [r6, #AWIN_A80_RPRCM_CLUSTER0_RST_REG] mov r0, #1 - lsl r0, r0, r12 + lsl r0, r0, r10 bic r1, r1, r0 str r1, [r6, #AWIN_A80_RPRCM_CLUSTER0_RST_REG] /* Assert CPU core reset */ ldr r1, [r5, #AWIN_A80_RCPUCFG_CLUSTER0_RST_REG] mov r0, #1 - lsl r0, r0, r12 + lsl r0, r0, r10 bic r1, r1, r0 str r1, [r5, #AWIN_A80_RCPUCFG_CLUSTER0_RST_REG] /* Release power clamp */ mov r1, #0x00 mov r2, #0x4 - mul r7, r12, r2 + mul r7, r10, r2 add r7, r7, #AWIN_A80_RPRCM_CLUSTER0_PRW_CLAMP_REG str r1, [r6, r7] dsb mov r2, #0x40 - mul r7, r12, r2 + mul r7, r10, r2 add r7, r7, #AWIN_A80_RPRCM_CLUSTER0_PRW_CLAMP_STATUS_REG 1: ldr r1, [r5, r7] @@ -512,7 +523,7 @@ a80_mpinit_cpu: /* Clear power-off gating */ ldr r1, [r6, #AWIN_A80_RPRCM_CLUSTER0_PWR_GATING_REG] mov r0, #1 - lsl r0, r0, r12 + lsl r0, r0, r10 bic r1, r1, r0 str r1, [r6,
CVS commit: src/sys/arch/evbarm/fdt
Module Name:src Committed By: chs Date: Wed Jul 5 19:30:51 UTC 2017 Modified Files: src/sys/arch/evbarm/fdt: fdt_machdep.c Log Message: the extent code cannot use the full range of u_long, so ignore the last page before 4GB too. ok jmcneill@ To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/arch/evbarm/fdt/fdt_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/evbarm/fdt/fdt_machdep.c diff -u src/sys/arch/evbarm/fdt/fdt_machdep.c:1.8 src/sys/arch/evbarm/fdt/fdt_machdep.c:1.9 --- src/sys/arch/evbarm/fdt/fdt_machdep.c:1.8 Wed Jul 5 01:08:45 2017 +++ src/sys/arch/evbarm/fdt/fdt_machdep.c Wed Jul 5 19:30:51 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: fdt_machdep.c,v 1.8 2017/07/05 01:08:45 jmcneill Exp $ */ +/* $NetBSD: fdt_machdep.c,v 1.9 2017/07/05 19:30:51 chs Exp $ */ /*- * Copyright (c) 2015-2017 Jared McNeill@@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: fdt_machdep.c,v 1.8 2017/07/05 01:08:45 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fdt_machdep.c,v 1.9 2017/07/05 19:30:51 chs Exp $"); #include "opt_machdep.h" #include "opt_ddb.h" @@ -410,8 +410,8 @@ initarm(void *arg) #if !defined(_LP64) /* Cannot map memory above 4GB */ - if (memory_addr + memory_size > 0x1) - memory_size = 0x1 - memory_addr; + if (memory_addr + memory_size >= 0x1) + memory_size = 0x1 - memory_addr - PAGE_SIZE; #endif ram_size = (bus_size_t)memory_size;
CVS commit: src/sys/arch/xen/xen
Module Name:src Committed By: chs Date: Thu Jun 22 22:36:50 UTC 2017 Modified Files: src/sys/arch/xen/xen: privcmd.c Log Message: use UVM_FLAG_UNMAP instead of unmapping separately. To generate a diff of this commit: cvs rdiff -u -r1.50 -r1.51 src/sys/arch/xen/xen/privcmd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/xen/xen/privcmd.c diff -u src/sys/arch/xen/xen/privcmd.c:1.50 src/sys/arch/xen/xen/privcmd.c:1.51 --- src/sys/arch/xen/xen/privcmd.c:1.50 Thu Jun 1 02:45:08 2017 +++ src/sys/arch/xen/xen/privcmd.c Thu Jun 22 22:36:50 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: privcmd.c,v 1.50 2017/06/01 02:45:08 chs Exp $ */ +/* $NetBSD: privcmd.c,v 1.51 2017/06/22 22:36:50 chs Exp $ */ /*- * Copyright (c) 2004 Christian Limpach. @@ -27,7 +27,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: privcmd.c,v 1.50 2017/06/01 02:45:08 chs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: privcmd.c,v 1.51 2017/06/22 22:36:50 chs Exp $"); #include #include @@ -546,34 +546,20 @@ privcmd_map_obj(struct vm_map *map, vadd return EINVAL; } vm_map_unlock_read(map); - /* remove current entries */ - uvm_unmap1(map, start, start + size, 0); obj = kmem_alloc(sizeof(*obj), KM_SLEEP); privcmd_nobjects++; uvm_obj_init(>uobj, , true, 1); - mutex_enter(obj->uobj.vmobjlock); obj->maddr = maddr; obj->npages = npages; obj->domid = domid; - mutex_exit(obj->uobj.vmobjlock); uvmflag = UVM_MAPFLAG(prot, prot, UVM_INH_NONE, UVM_ADV_NORMAL, - UVM_FLAG_FIXED | UVM_FLAG_NOMERGE); + UVM_FLAG_FIXED | UVM_FLAG_UNMAP | UVM_FLAG_NOMERGE); error = uvm_map(map, , size, >uobj, 0, 0, uvmflag); - if (error) { - if (obj) - obj->uobj.pgops->pgo_detach(>uobj); - return error; - } - if (newstart != start) { - printf("uvm_map didn't give us back our vm space\n"); - uvm_unmap1(map, newstart, newstart + size, 0); - if (obj) - obj->uobj.pgops->pgo_detach(>uobj); - return EINVAL; - } - return 0; + if (error) + obj->uobj.pgops->pgo_detach(>uobj); + return error; } static const struct kernfs_fileop privcmd_fileops[] = {
CVS commit: src/sys/kern
Module Name:src Committed By: chs Date: Wed Jun 14 00:52:37 UTC 2017 Modified Files: src/sys/kern: kern_ksyms.c Log Message: create an nmap table for module symtabs too. needed by dtrace. To generate a diff of this commit: cvs rdiff -u -r1.84 -r1.85 src/sys/kern/kern_ksyms.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/kern_ksyms.c diff -u src/sys/kern/kern_ksyms.c:1.84 src/sys/kern/kern_ksyms.c:1.85 --- src/sys/kern/kern_ksyms.c:1.84 Thu Jul 7 06:55:43 2016 +++ src/sys/kern/kern_ksyms.c Wed Jun 14 00:52:37 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_ksyms.c,v 1.84 2016/07/07 06:55:43 msaitoh Exp $ */ +/* $NetBSD: kern_ksyms.c,v 1.85 2017/06/14 00:52:37 chs Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -73,7 +73,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_ksyms.c,v 1.84 2016/07/07 06:55:43 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_ksyms.c,v 1.85 2017/06/14 00:52:37 chs Exp $"); #if defined(_KERNEL) && defined(_KERNEL_OPT) #include "opt_copy_symtab.h" @@ -336,8 +336,9 @@ addsymtab(const char *name, void *symsta nglob = 0; for (i = n = 0; i < nsyms; i++) { - /* This breaks CTF mapping, so don't do it when - * DTrace is enabled + /* + * This breaks CTF mapping, so don't do it when + * DTrace is enabled. */ #ifndef KDTRACE_HOOKS /* @@ -396,6 +397,7 @@ addsymtab(const char *name, void *symsta tab->sd_symstart = nsym; tab->sd_symsize = n * sizeof(Elf_Sym); tab->sd_nglob = nglob; + addsymtab_strstart = str; if (kheapsort(nsym, n, sizeof(Elf_Sym), addsymtab_compar, ) != 0) panic("addsymtab"); @@ -731,11 +733,14 @@ ksyms_modload(const char *name, void *sy char *strstart, vsize_t strsize) { struct ksyms_symtab *st; + void *nmap; st = kmem_zalloc(sizeof(*st), KM_SLEEP); + nmap = kmem_zalloc(symsize / sizeof(Elf_Sym) * sizeof (uint32_t), + KM_SLEEP); mutex_enter(_lock); addsymtab(name, symstart, symsize, strstart, strsize, st, symstart, - NULL, 0, NULL); + NULL, 0, nmap); mutex_exit(_lock); } @@ -757,6 +762,8 @@ ksyms_modunload(const char *name) if (!ksyms_isopen) { TAILQ_REMOVE(_symtabs, st, sd_queue); ksyms_sizes_calc(); + kmem_free(st->sd_nmap, + st->sd_nmapsize * sizeof(uint32_t)); kmem_free(st, sizeof(*st)); } break; @@ -984,6 +991,8 @@ ksymsclose(dev_t dev, int oflags, int de next = TAILQ_NEXT(st, sd_queue); if (st->sd_gone) { TAILQ_REMOVE(_symtabs, st, sd_queue); + kmem_free(st->sd_nmap, + st->sd_nmapsize * sizeof(uint32_t)); kmem_free(st, sizeof(*st)); resize = true; }