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/sys/sys
Module Name:src Committed By: ad Date: Tue May 12 23:18:52 UTC 2020 Modified Files: src/sys/sys: param.h Log Message: NetBSD 9.99.61 - vfa_cache interface changed To generate a diff of this commit: cvs rdiff -u -r1.663 -r1.664 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.663 src/sys/sys/param.h:1.664 --- src/sys/sys/param.h:1.663 Tue May 5 08:05:44 2020 +++ src/sys/sys/param.h Tue May 12 23:18:52 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: param.h,v 1.663 2020/05/05 08:05:44 jdolecek Exp $ */ +/* $NetBSD: param.h,v 1.664 2020/05/12 23:18:52 ad Exp $ */ /*- * Copyright (c) 1982, 1986, 1989, 1993 @@ -67,7 +67,7 @@ * 2.99.9 (299000900) */ -#define __NetBSD_Version__ 999006000 /* NetBSD 9.99.60 */ +#define __NetBSD_Version__ 999006100 /* NetBSD 9.99.61 */ #define __NetBSD_Prereq__(M,m,p) (M) * 1) + \ (m) * 100) + (p) * 100) <= __NetBSD_Version__)
CVS commit: src/sys
Module Name:src Committed By: ad Date: Tue May 12 23:18:03 UTC 2020 Modified Files: src/sys/rump/include/rump: rump_namei.h src/sys/sys: namei.h Log Message: Regen. To generate a diff of this commit: cvs rdiff -u -r1.42 -r1.43 src/sys/rump/include/rump/rump_namei.h cvs rdiff -u -r1.108 -r1.109 src/sys/sys/namei.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/rump/include/rump/rump_namei.h diff -u src/sys/rump/include/rump/rump_namei.h:1.42 src/sys/rump/include/rump/rump_namei.h:1.43 --- src/sys/rump/include/rump/rump_namei.h:1.42 Sat Apr 4 20:52:18 2020 +++ src/sys/rump/include/rump/rump_namei.h Tue May 12 23:18:03 2020 @@ -1,11 +1,11 @@ -/* $NetBSD: rump_namei.h,v 1.42 2020/04/04 20:52:18 ad Exp $ */ +/* $NetBSD: rump_namei.h,v 1.43 2020/05/12 23:18:03 ad Exp $ */ /* * WARNING: GENERATED FILE. DO NOT EDIT * (edit namei.src and run make namei in src/sys/sys) * by: NetBSD: gennameih.awk,v 1.5 2009/12/23 14:17:19 pooka Exp - * from: NetBSD: namei.src,v 1.53 2020/04/04 20:49:31 ad Exp + * from: NetBSD: namei.src,v 1.54 2020/05/12 23:17:41 ad Exp */ #ifndef _RUMP_RUMP_NAMEI_H_ Index: src/sys/sys/namei.h diff -u src/sys/sys/namei.h:1.108 src/sys/sys/namei.h:1.109 --- src/sys/sys/namei.h:1.108 Sat Apr 4 20:52:18 2020 +++ src/sys/sys/namei.h Tue May 12 23:18:03 2020 @@ -1,11 +1,11 @@ -/* $NetBSD: namei.h,v 1.108 2020/04/04 20:52:18 ad Exp $ */ +/* $NetBSD: namei.h,v 1.109 2020/05/12 23:18:03 ad Exp $ */ /* * WARNING: GENERATED FILE. DO NOT EDIT * (edit namei.src and run make namei in src/sys/sys) * by: NetBSD: gennameih.awk,v 1.5 2009/12/23 14:17:19 pooka Exp - * from: NetBSD: namei.src,v 1.53 2020/04/04 20:49:31 ad Exp + * from: NetBSD: namei.src,v 1.54 2020/05/12 23:17:41 ad Exp */ /* @@ -302,7 +302,7 @@ int cache_revlookup(struct vnode *, stru int cache_diraccess(struct vnode *, int); void cache_enter(struct vnode *, struct vnode *, const char *, size_t, uint32_t); -void cache_enter_id(struct vnode *, mode_t, uid_t, gid_t); +void cache_enter_id(struct vnode *, mode_t, uid_t, gid_t, bool); bool cache_have_id(struct vnode *); void cache_vnode_init(struct vnode * ); void cache_vnode_fini(struct vnode * );
CVS commit: src/sys
Module Name:src Committed By: ad Date: Tue May 12 23:17:42 UTC 2020 Modified Files: src/sys/fs/tmpfs: tmpfs_subr.c src/sys/kern: vfs_cache.c src/sys/sys: namei.src src/sys/ufs/ffs: ffs_vfsops.c src/sys/ufs/ufs: ufs_vnops.c Log Message: cache_enter_id(): give it a boolean parameter to indicate whether the cached identity is valid. To generate a diff of this commit: cvs rdiff -u -r1.109 -r1.110 src/sys/fs/tmpfs/tmpfs_subr.c cvs rdiff -u -r1.141 -r1.142 src/sys/kern/vfs_cache.c cvs rdiff -u -r1.53 -r1.54 src/sys/sys/namei.src cvs rdiff -u -r1.367 -r1.368 src/sys/ufs/ffs/ffs_vfsops.c cvs rdiff -u -r1.252 -r1.253 src/sys/ufs/ufs/ufs_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_subr.c diff -u src/sys/fs/tmpfs/tmpfs_subr.c:1.109 src/sys/fs/tmpfs/tmpfs_subr.c:1.110 --- src/sys/fs/tmpfs/tmpfs_subr.c:1.109 Thu Apr 23 21:47:08 2020 +++ src/sys/fs/tmpfs/tmpfs_subr.c Tue May 12 23:17:41 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_subr.c,v 1.109 2020/04/23 21:47:08 ad Exp $ */ +/* $NetBSD: tmpfs_subr.c,v 1.110 2020/05/12 23:17:41 ad Exp $ */ /* * Copyright (c) 2005-2013 The NetBSD Foundation, Inc. @@ -73,7 +73,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tmpfs_subr.c,v 1.109 2020/04/23 21:47:08 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tmpfs_subr.c,v 1.110 2020/05/12 23:17:41 ad Exp $"); #include #include @@ -148,7 +148,7 @@ tmpfs_init_vnode(struct vnode *vp, tmpfs node->tn_vnode = vp; uvm_vnp_setsize(vp, node->tn_size); KASSERT(node->tn_mode != VNOVAL); - cache_enter_id(vp, node->tn_mode, node->tn_uid, node->tn_gid); + cache_enter_id(vp, node->tn_mode, node->tn_uid, node->tn_gid, true); } /* @@ -1041,7 +1041,7 @@ tmpfs_chmod(vnode_t *vp, mode_t mode, ka node->tn_mode = (mode & ALLPERMS); tmpfs_update(vp, TMPFS_UPDATE_CTIME); VN_KNOTE(vp, NOTE_ATTRIB); - cache_enter_id(vp, node->tn_mode, node->tn_uid, node->tn_gid); + cache_enter_id(vp, node->tn_mode, node->tn_uid, node->tn_gid, true); return 0; } @@ -1086,7 +1086,7 @@ tmpfs_chown(vnode_t *vp, uid_t uid, gid_ node->tn_gid = gid; tmpfs_update(vp, TMPFS_UPDATE_CTIME); VN_KNOTE(vp, NOTE_ATTRIB); - cache_enter_id(vp, node->tn_mode, node->tn_uid, node->tn_gid); + cache_enter_id(vp, node->tn_mode, node->tn_uid, node->tn_gid, true); return 0; } Index: src/sys/kern/vfs_cache.c diff -u src/sys/kern/vfs_cache.c:1.141 src/sys/kern/vfs_cache.c:1.142 --- src/sys/kern/vfs_cache.c:1.141 Thu Apr 23 22:58:36 2020 +++ src/sys/kern/vfs_cache.c Tue May 12 23:17:41 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_cache.c,v 1.141 2020/04/23 22:58:36 ad Exp $ */ +/* $NetBSD: vfs_cache.c,v 1.142 2020/05/12 23:17:41 ad Exp $ */ /*- * Copyright (c) 2008, 2019, 2020 The NetBSD Foundation, Inc. @@ -172,7 +172,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_cache.c,v 1.141 2020/04/23 22:58:36 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_cache.c,v 1.142 2020/05/12 23:17:41 ad Exp $"); #define __NAMECACHE_PRIVATE #ifdef _KERNEL_OPT @@ -683,8 +683,10 @@ cache_lookup_linked(struct vnode *dvp, c * First up check if the user is allowed to look up files in this * directory. */ - KASSERT(dvi->vi_nc_mode != VNOVAL && dvi->vi_nc_uid != VNOVAL && - dvi->vi_nc_gid != VNOVAL); + if (dvi->vi_nc_mode == VNOVAL) { + return false; + } + KASSERT(dvi->vi_nc_uid != VNOVAL && dvi->vi_nc_gid != VNOVAL); error = kauth_authorize_vnode(cred, KAUTH_ACCESS_ACTION(VEXEC, dvp->v_type, dvi->vi_nc_mode & ALLPERMS), dvp, NULL, genfs_can_access(dvp->v_type, dvi->vi_nc_mode & ALLPERMS, @@ -763,8 +765,11 @@ cache_revlookup(struct vnode *vp, struct * * I don't like it, I didn't come up with it, don't blame me! */ - KASSERT(vi->vi_nc_mode != VNOVAL && vi->vi_nc_uid != VNOVAL && - vi->vi_nc_gid != VNOVAL); + if (vi->vi_nc_mode == VNOVAL) { + rw_exit(>vi_nc_listlock); + return -1; + } + KASSERT(vi->vi_nc_uid != VNOVAL && vi->vi_nc_gid != VNOVAL); error = kauth_authorize_vnode(curlwp->l_cred, KAUTH_ACCESS_ACTION(VEXEC, vp->v_type, vi->vi_nc_mode & ALLPERMS), vp, NULL, genfs_can_access(vp->v_type, @@ -941,10 +946,11 @@ cache_enter(struct vnode *dvp, struct vn /* * Set identity info in cache for a vnode. We only care about directories - * so ignore other updates. + * so ignore other updates. The cached info may be marked invalid if the + * inode has an ACL. */ void -cache_enter_id(struct vnode *vp, mode_t mode, uid_t uid, gid_t gid) +cache_enter_id(struct vnode *vp, mode_t mode, uid_t uid, gid_t gid, bool valid) { vnode_impl_t *vi = VNODE_TO_VIMPL(vp); @@ -952,9 +958,15 @@ cache_enter_id(struct vnode *vp, mode_t /* Grab both locks, for forward & reverse lookup. */ rw_enter(>vi_nc_lock, RW_WRITER); rw_enter(>vi_nc_listlock, RW_WRITER); - vi->vi_nc_mode = mode; - vi->vi_nc_uid = uid; - vi->vi_nc_gid = gid; + if
CVS commit: src/sys/kern
Module Name:src Committed By: ad Date: Tue May 12 21:56:17 UTC 2020 Modified Files: src/sys/kern: kern_mutex.c Log Message: PR kern/55251 (use of ZFS may trigger kernel memory corruption (KASAN error)) Previous wasn't quite right. Redo it differently - disable preemption earlier instead. To generate a diff of this commit: cvs rdiff -u -r1.91 -r1.92 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.91 src/sys/kern/kern_mutex.c:1.92 --- src/sys/kern/kern_mutex.c:1.91 Tue May 12 21:24:29 2020 +++ src/sys/kern/kern_mutex.c Tue May 12 21:56:17 2020 @@ -1,7 +1,7 @@ -/* $NetBSD: kern_mutex.c,v 1.91 2020/05/12 21:24:29 ad Exp $ */ +/* $NetBSD: kern_mutex.c,v 1.92 2020/05/12 21:56:17 ad Exp $ */ /*- - * Copyright (c) 2002, 2006, 2007, 2008, 2019, 2020 The NetBSD Foundation, Inc. + * Copyright (c) 2002, 2006, 2007, 2008, 2019 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -40,7 +40,7 @@ #define __MUTEX_PRIVATE #include -__KERNEL_RCSID(0, "$NetBSD: kern_mutex.c,v 1.91 2020/05/12 21:24:29 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_mutex.c,v 1.92 2020/05/12 21:56:17 ad Exp $"); #include #include @@ -456,11 +456,13 @@ mutex_vector_enter(kmutex_t *mtx) /* * Handle spin mutexes. */ + KPREEMPT_DISABLE(curlwp); owner = mtx->mtx_owner; if (MUTEX_SPIN_P(owner)) { #if defined(LOCKDEBUG) && defined(MULTIPROCESSOR) u_int spins = 0; #endif + KPREEMPT_ENABLE(curlwp); MUTEX_SPIN_SPLRAISE(mtx); MUTEX_WANTLOCK(mtx); #ifdef FULL @@ -521,7 +523,6 @@ mutex_vector_enter(kmutex_t *mtx) * determine that the owner is not running on a processor, * then we stop spinning, and sleep instead. */ - KPREEMPT_DISABLE(curlwp); for (;;) { if (!MUTEX_OWNED(owner)) { /* @@ -545,12 +546,8 @@ mutex_vector_enter(kmutex_t *mtx) /* * Check to see if the owner is running on a processor. * If so, then we should just spin, as the owner will - * likely release the lock very soon. Unfortunately - * mtx_owner needs to be reloaded here with preemption - * now disabled, otherwise the LWP could already have - * been freed & destructed (see lwp_dtor()). + * likely release the lock very soon. */ - owner = mtx->mtx_owner; if (mutex_oncpu(owner)) { LOCKSTAT_START_TIMER(lsflag, spintime); count = SPINLOCK_BACKOFF_MIN;
CVS commit: src/sys/kern
Module Name:src Committed By: ad Date: Tue May 12 21:24:30 UTC 2020 Modified Files: src/sys/kern: kern_mutex.c Log Message: PR kern/55251: use of ZFS may trigger kernel memory corruption mutex_vector_enter(): reload mtx_owner with preemption disabled before calling mutex_oncpu(), otherwise lwp_dtor() can intervene. To generate a diff of this commit: cvs rdiff -u -r1.90 -r1.91 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.90 src/sys/kern/kern_mutex.c:1.91 --- src/sys/kern/kern_mutex.c:1.90 Sun Mar 8 00:26:06 2020 +++ src/sys/kern/kern_mutex.c Tue May 12 21:24:29 2020 @@ -1,7 +1,7 @@ -/* $NetBSD: kern_mutex.c,v 1.90 2020/03/08 00:26:06 chs Exp $ */ +/* $NetBSD: kern_mutex.c,v 1.91 2020/05/12 21:24:29 ad Exp $ */ /*- - * Copyright (c) 2002, 2006, 2007, 2008, 2019 The NetBSD Foundation, Inc. + * Copyright (c) 2002, 2006, 2007, 2008, 2019, 2020 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -40,7 +40,7 @@ #define __MUTEX_PRIVATE #include -__KERNEL_RCSID(0, "$NetBSD: kern_mutex.c,v 1.90 2020/03/08 00:26:06 chs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_mutex.c,v 1.91 2020/05/12 21:24:29 ad Exp $"); #include #include @@ -545,8 +545,12 @@ mutex_vector_enter(kmutex_t *mtx) /* * Check to see if the owner is running on a processor. * If so, then we should just spin, as the owner will - * likely release the lock very soon. + * likely release the lock very soon. Unfortunately + * mtx_owner needs to be reloaded here with preemption + * now disabled, otherwise the LWP could already have + * been freed & destructed (see lwp_dtor()). */ + owner = mtx->mtx_owner; if (mutex_oncpu(owner)) { LOCKSTAT_START_TIMER(lsflag, spintime); count = SPINLOCK_BACKOFF_MIN;
CVS commit: src/sys/kern
Module Name:src Committed By: riastradh Date: Tue May 12 20:50:17 UTC 2020 Modified Files: src/sys/kern: kern_entropy.c Log Message: Don't invoke callbacks of rndsources with collection disabled. To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/sys/kern/kern_entropy.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_entropy.c diff -u src/sys/kern/kern_entropy.c:1.21 src/sys/kern/kern_entropy.c:1.22 --- src/sys/kern/kern_entropy.c:1.21 Sun May 10 02:56:12 2020 +++ src/sys/kern/kern_entropy.c Tue May 12 20:50:17 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_entropy.c,v 1.21 2020/05/10 02:56:12 riastradh Exp $ */ +/* $NetBSD: kern_entropy.c,v 1.22 2020/05/12 20:50:17 riastradh Exp $ */ /*- * Copyright (c) 2019 The NetBSD Foundation, Inc. @@ -75,7 +75,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.21 2020/05/10 02:56:12 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.22 2020/05/12 20:50:17 riastradh Exp $"); #include #include @@ -1687,6 +1687,13 @@ entropy_request(size_t nbytes) if (!ISSET(rs->flags, RND_FLAG_HASCB)) continue; + /* + * Skip sources that are disabled altogether -- we + * would just ignore their samples anyway. + */ + if (ISSET(rs->flags, RND_FLAG_NO_COLLECT)) + continue; + /* Drop the lock while we call the callback. */ if (E->stage >= ENTROPY_WARM) mutex_exit(>lock);
CVS commit: src/usr.sbin/sysinst
Module Name:src Committed By: martin Date: Tue May 12 17:26:43 UTC 2020 Modified Files: src/usr.sbin/sysinst: defs.h disks.c main.c Log Message: PR 55202: disable swapping if we started it due to low ram To generate a diff of this commit: cvs rdiff -u -r1.60 -r1.61 src/usr.sbin/sysinst/defs.h cvs rdiff -u -r1.66 -r1.67 src/usr.sbin/sysinst/disks.c cvs rdiff -u -r1.24 -r1.25 src/usr.sbin/sysinst/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/usr.sbin/sysinst/defs.h diff -u src/usr.sbin/sysinst/defs.h:1.60 src/usr.sbin/sysinst/defs.h:1.61 --- src/usr.sbin/sysinst/defs.h:1.60 Tue May 12 17:04:00 2020 +++ src/usr.sbin/sysinst/defs.h Tue May 12 17:26:43 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: defs.h,v 1.60 2020/05/12 17:04:00 martin Exp $ */ +/* $NetBSD: defs.h,v 1.61 2020/05/12 17:26:43 martin Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -673,8 +673,14 @@ void disp_cur_fspart(int, int); int make_filesystems(struct install_partition_desc *); int make_fstab(struct install_partition_desc *); int mount_disks(struct install_partition_desc *); +/* + * set_swap_if_low_ram and set_swap return -1 on error, + * 0 if no swap was added on purpose and + * 1 if swap has been added (and needs to be cleared later). + */ int set_swap_if_low_ram(struct install_partition_desc *); int set_swap(struct install_partition_desc *); +void clear_swap(void); int check_swap(const char *, int); char *bootxx_name(struct install_partition_desc *); int get_dkwedges(struct dkwedge_info **, const char *); Index: src/usr.sbin/sysinst/disks.c diff -u src/usr.sbin/sysinst/disks.c:1.66 src/usr.sbin/sysinst/disks.c:1.67 --- src/usr.sbin/sysinst/disks.c:1.66 Wed Feb 19 18:08:03 2020 +++ src/usr.sbin/sysinst/disks.c Tue May 12 17:26:43 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: disks.c,v 1.66 2020/02/19 18:08:03 martin Exp $ */ +/* $NetBSD: disks.c,v 1.67 2020/05/12 17:26:43 martin Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -1905,9 +1905,12 @@ mount_disks(struct install_partition_des return error; } +static char swap_dev[PATH_MAX]; + int set_swap_if_low_ram(struct install_partition_desc *install) { + swap_dev[0] = 0; if (get_ramsize() <= TINY_RAM_SIZE) return set_swap(install); return 0; @@ -1917,9 +1920,9 @@ int set_swap(struct install_partition_desc *install) { size_t i; - char dev_buf[PATH_MAX]; int rval; + swap_dev[0] = 0; for (i = 0; i < install->num; i++) { if (install->infos[i].type == PT_swap) break; @@ -1928,15 +1931,27 @@ set_swap(struct install_partition_desc * return 0; if (!install->infos[i].parts->pscheme->get_part_device( - install->infos[i].parts, install->infos[i].cur_part_id, dev_buf, - sizeof dev_buf, NULL, plain_name, true, true)) + install->infos[i].parts, install->infos[i].cur_part_id, swap_dev, + sizeof swap_dev, NULL, plain_name, true, true)) return -1; - rval = swapctl(SWAP_ON, dev_buf, 0); - if (rval != 0) + rval = swapctl(SWAP_ON, swap_dev, 0); + if (rval != 0) { + swap_dev[0] = 0; return -1; + } - return 0; + return 1; +} + +void +clear_swap(void) +{ + + if (swap_dev[0] == 0) + return; + swapctl(SWAP_OFF, swap_dev, 0); + swap_dev[0] = 0; } int Index: src/usr.sbin/sysinst/main.c diff -u src/usr.sbin/sysinst/main.c:1.24 src/usr.sbin/sysinst/main.c:1.25 --- src/usr.sbin/sysinst/main.c:1.24 Wed Apr 22 23:43:12 2020 +++ src/usr.sbin/sysinst/main.c Tue May 12 17:26:43 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.24 2020/04/22 23:43:12 joerg Exp $ */ +/* $NetBSD: main.c,v 1.25 2020/05/12 17:26:43 martin Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -450,6 +450,7 @@ toplevel(void) if (chdir(home) != 0) (void)chdir("/"); unwind_mounts(); + clear_swap(); /* Display banner message in (english, francais, deutsch..) */ msg_display(MSG_hello); @@ -540,6 +541,7 @@ cleanup(void) chdir(getenv("HOME")); unwind_mounts(); umount_mnt2(); + clear_swap(); endwin();
CVS commit: src/usr.sbin/sysinst
Module Name:src Committed By: martin Date: Tue May 12 17:04:00 UTC 2020 Modified Files: src/usr.sbin/sysinst: defs.h install.c util.c Log Message: Ooops, backout previous - twice the entropy saving is not needed. Instead slightly improve the (slightly) hidden other code that already did it. To generate a diff of this commit: cvs rdiff -u -r1.59 -r1.60 src/usr.sbin/sysinst/defs.h cvs rdiff -u -r1.15 -r1.16 src/usr.sbin/sysinst/install.c cvs rdiff -u -r1.43 -r1.44 src/usr.sbin/sysinst/util.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.sbin/sysinst/defs.h diff -u src/usr.sbin/sysinst/defs.h:1.59 src/usr.sbin/sysinst/defs.h:1.60 --- src/usr.sbin/sysinst/defs.h:1.59 Tue May 12 16:18:04 2020 +++ src/usr.sbin/sysinst/defs.h Tue May 12 17:04:00 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: defs.h,v 1.59 2020/05/12 16:18:04 martin Exp $ */ +/* $NetBSD: defs.h,v 1.60 2020/05/12 17:04:00 martin Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -809,7 +809,6 @@ unsigned intget_kernel_set(void); unsigned intset_X11_selected(void); int get_and_unpack_sets(int, msg, msg, msg); int sanity_check(void); -void save_entropy(void); int set_timezone(void); void scripting_fprintf(FILE *, const char *, ...) __printflike(2, 3); void scripting_vfprintf(FILE *, const char *, va_list) __printflike(2, 0); Index: src/usr.sbin/sysinst/install.c diff -u src/usr.sbin/sysinst/install.c:1.15 src/usr.sbin/sysinst/install.c:1.16 --- src/usr.sbin/sysinst/install.c:1.15 Tue May 12 16:18:04 2020 +++ src/usr.sbin/sysinst/install.c Tue May 12 17:04:00 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: install.c,v 1.15 2020/05/12 16:18:04 martin Exp $ */ +/* $NetBSD: install.c,v 1.16 2020/05/12 17:04:00 martin Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -229,8 +229,6 @@ do_install(void) sanity_check(); - save_entropy(); - md_cleanup_install(); hit_enter_to_continue(MSG_instcomplete, NULL); Index: src/usr.sbin/sysinst/util.c diff -u src/usr.sbin/sysinst/util.c:1.43 src/usr.sbin/sysinst/util.c:1.44 --- src/usr.sbin/sysinst/util.c:1.43 Tue May 12 16:18:04 2020 +++ src/usr.sbin/sysinst/util.c Tue May 12 17:04:00 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: util.c,v 1.43 2020/05/12 16:18:04 martin Exp $ */ +/* $NetBSD: util.c,v 1.44 2020/05/12 17:04:00 martin Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -1086,6 +1086,7 @@ get_and_unpack_sets(int update, msg setu distinfo *dist; int status; int set, olderror, oldfound; + bool entropy_loaded = false; /* Ensure mountpoint for distribution files exists in current root. */ (void)mkdir("/mnt2", S_IRWXU| S_IRGRP|S_IXGRP | S_IROTH|S_IXOTH); @@ -1203,7 +1204,8 @@ get_and_unpack_sets(int update, msg setu /* Don't discard the system's old entropy if any */ run_program(RUN_CHROOT | RUN_SILENT, - "/etc/rc.d/random_seed start"); + "/etc/rc.d/random_seed start"); + entropy_loaded = true; } /* Configure the system */ @@ -1245,7 +1247,8 @@ get_and_unpack_sets(int update, msg setu umount_mnt2(); /* Save entropy -- on some systems it's ~all we'll ever get */ - run_program(RUN_DISPLAY | RUN_CHROOT | RUN_FATAL | RUN_PROGRESS, + if (!update || entropy_loaded) + run_program(RUN_SILENT | RUN_CHROOT | RUN_ERROR_OK, "/etc/rc.d/random_seed stop"); /* Install/Upgrade complete ... reboot or exit to script */ hit_enter_to_continue(success_msg, NULL); @@ -2199,21 +2202,6 @@ free_install_desc(struct install_partiti free(install->infos); } -/* - * Called while at the end of install when targetroot is still mounted - * and writable - */ -void -save_entropy(void) -{ - - if (!binary_available("rndctl")) - return; - - run_program(RUN_SILENT|RUN_ERROR_OK, "rndctl -S %s", - target_expand("/var/db/entropy-file")); -} - #ifdef MD_MAY_SWAP_TO bool may_swap_if_not_sdmmc(const char *disk)
CVS commit: src/usr.sbin/sysinst
Module Name:src Committed By: martin Date: Tue May 12 16:18:04 UTC 2020 Modified Files: src/usr.sbin/sysinst: defs.h install.c util.c Log Message: At the end of a new installation save entropy. To generate a diff of this commit: cvs rdiff -u -r1.58 -r1.59 src/usr.sbin/sysinst/defs.h cvs rdiff -u -r1.14 -r1.15 src/usr.sbin/sysinst/install.c cvs rdiff -u -r1.42 -r1.43 src/usr.sbin/sysinst/util.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.sbin/sysinst/defs.h diff -u src/usr.sbin/sysinst/defs.h:1.58 src/usr.sbin/sysinst/defs.h:1.59 --- src/usr.sbin/sysinst/defs.h:1.58 Wed Apr 22 23:43:12 2020 +++ src/usr.sbin/sysinst/defs.h Tue May 12 16:18:04 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: defs.h,v 1.58 2020/04/22 23:43:12 joerg Exp $ */ +/* $NetBSD: defs.h,v 1.59 2020/05/12 16:18:04 martin Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -809,6 +809,7 @@ unsigned intget_kernel_set(void); unsigned intset_X11_selected(void); int get_and_unpack_sets(int, msg, msg, msg); int sanity_check(void); +void save_entropy(void); int set_timezone(void); void scripting_fprintf(FILE *, const char *, ...) __printflike(2, 3); void scripting_vfprintf(FILE *, const char *, va_list) __printflike(2, 0); Index: src/usr.sbin/sysinst/install.c diff -u src/usr.sbin/sysinst/install.c:1.14 src/usr.sbin/sysinst/install.c:1.15 --- src/usr.sbin/sysinst/install.c:1.14 Thu Jan 16 13:56:24 2020 +++ src/usr.sbin/sysinst/install.c Tue May 12 16:18:04 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: install.c,v 1.14 2020/01/16 13:56:24 martin Exp $ */ +/* $NetBSD: install.c,v 1.15 2020/05/12 16:18:04 martin Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -229,6 +229,8 @@ do_install(void) sanity_check(); + save_entropy(); + md_cleanup_install(); hit_enter_to_continue(MSG_instcomplete, NULL); Index: src/usr.sbin/sysinst/util.c diff -u src/usr.sbin/sysinst/util.c:1.42 src/usr.sbin/sysinst/util.c:1.43 --- src/usr.sbin/sysinst/util.c:1.42 Sun Jan 26 14:37:29 2020 +++ src/usr.sbin/sysinst/util.c Tue May 12 16:18:04 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: util.c,v 1.42 2020/01/26 14:37:29 martin Exp $ */ +/* $NetBSD: util.c,v 1.43 2020/05/12 16:18:04 martin Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -2199,6 +2199,21 @@ free_install_desc(struct install_partiti free(install->infos); } +/* + * Called while at the end of install when targetroot is still mounted + * and writable + */ +void +save_entropy(void) +{ + + if (!binary_available("rndctl")) + return; + + run_program(RUN_SILENT|RUN_ERROR_OK, "rndctl -S %s", + target_expand("/var/db/entropy-file")); +} + #ifdef MD_MAY_SWAP_TO bool may_swap_if_not_sdmmc(const char *disk)
CVS commit: src/crypto/dist/ipsec-tools/src/setkey
Module Name:src Committed By: christos Date: Tue May 12 16:17:58 UTC 2020 Modified Files: src/crypto/dist/ipsec-tools/src/setkey: extern.h setkey.c token.l Log Message: - in script mode always output errors to stderr prefixed by the program name. - in command mode always output errors to stdout not prefixed " " " - perror(3) -> warn(3) To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/crypto/dist/ipsec-tools/src/setkey/extern.h cvs rdiff -u -r1.21 -r1.22 src/crypto/dist/ipsec-tools/src/setkey/setkey.c cvs rdiff -u -r1.25 -r1.26 src/crypto/dist/ipsec-tools/src/setkey/token.l Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/crypto/dist/ipsec-tools/src/setkey/extern.h diff -u src/crypto/dist/ipsec-tools/src/setkey/extern.h:1.8 src/crypto/dist/ipsec-tools/src/setkey/extern.h:1.9 --- src/crypto/dist/ipsec-tools/src/setkey/extern.h:1.8 Tue May 12 10:29:06 2020 +++ src/crypto/dist/ipsec-tools/src/setkey/extern.h Tue May 12 12:17:58 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: extern.h,v 1.8 2020/05/12 14:29:06 christos Exp $ */ +/* $NetBSD: extern.h,v 1.9 2020/05/12 16:17:58 christos Exp $ */ /* * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -46,6 +46,7 @@ void yyerror(const char *); #ifdef HAVE_POLICY_FWD extern int f_rfcmode; #endif +extern int f_mode; extern const char *filename; extern int lineno; extern int exit_now; @@ -53,3 +54,10 @@ extern int exit_now; extern int last_msg_type; extern uint32_t last_priority; #endif + +#define MODE_SCRIPT 1 +#define MODE_CMDDUMP 2 +#define MODE_CMDFLUSH 3 +#define MODE_PROMISC 4 +#define MODE_STDIN 5 + Index: src/crypto/dist/ipsec-tools/src/setkey/setkey.c diff -u src/crypto/dist/ipsec-tools/src/setkey/setkey.c:1.21 src/crypto/dist/ipsec-tools/src/setkey/setkey.c:1.22 --- src/crypto/dist/ipsec-tools/src/setkey/setkey.c:1.21 Tue May 12 10:29:06 2020 +++ src/crypto/dist/ipsec-tools/src/setkey/setkey.c Tue May 12 12:17:58 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: setkey.c,v 1.21 2020/05/12 14:29:06 christos Exp $ */ +/* $NetBSD: setkey.c,v 1.22 2020/05/12 16:17:58 christos Exp $ */ /* $KAME: setkey.c,v 1.36 2003/09/24 23:52:51 itojun Exp $ */ /* @@ -110,12 +110,6 @@ static void printdate(void); static int32_t gmt2local(time_t); static void stdin_loop(void); -#define MODE_SCRIPT 1 -#define MODE_CMDDUMP 2 -#define MODE_CMDFLUSH 3 -#define MODE_PROMISC 4 -#define MODE_STDIN 5 - int so; int f_forever = 0; @@ -275,8 +269,7 @@ main(int argc, char **argv) so = pfkey_open(); if (so < 0) { - perror("pfkey_open"); - exit(1); + err(1, "pfkey_open"); } switch (f_mode) { @@ -497,7 +490,7 @@ sendkeymsg_spigrep(unsigned int satype, tv.tv_sec = 1; tv.tv_usec = 0; if (setsockopt(so, SOL_SOCKET, SO_RCVTIMEO, , sizeof(tv)) < 0) { - perror("setsockopt"); + warn("setsockopt"); return NULL; } } @@ -531,14 +524,14 @@ sendkeymsg_spigrep(unsigned int satype, } if ((l = send(so, buf, len, 0)) < 0) { - perror("send"); + warn("send"); return NULL; } m = (struct sadb_msg *)rbuf; do { if ((l = recv(so, rbuf, sizeof(rbuf), 0)) < 0) { - perror("recv"); + warn("recv"); fail = 1; break; } @@ -638,7 +631,7 @@ sendkeymsg(char *buf, size_t len) tv.tv_sec = 1; tv.tv_usec = 0; if (setsockopt(so, SOL_SOCKET, SO_RCVTIMEO, , sizeof(tv)) < 0) { - perror("setsockopt"); + warn("setsockopt"); goto end; } } @@ -664,14 +657,14 @@ again: } if ((l = send(so, buf, len, 0)) < 0) { - perror("send"); + warn("send"); goto end; } msg = (struct sadb_msg *)rbuf; do { if ((l = recv(so, rbuf, sizeof(rbuf), 0)) < 0) { - perror("recv"); + warn("recv"); goto end; } @@ -706,15 +699,8 @@ postproc(struct sadb_msg *msg, int len) #endif if (msg->sadb_msg_errno != 0) { - char inf[80]; const char *errmsg = NULL; - if (f_mode == MODE_SCRIPT) - snprintf(inf, sizeof(inf), "The result of line %d: ", - lineno); - else - inf[0] = '\0'; - switch (msg->sadb_msg_errno) { case ENOENT: switch (msg->sadb_msg_type) { @@ -734,7 +720,10 @@ postproc(struct sadb_msg *msg, int len) default: errmsg = strerror(msg->sadb_msg_errno); } - printf("%s%s.\n", inf, errmsg); + if (f_mode == MODE_SCRIPT) + warnx("%s,%d: %s", filename, lineno, errmsg); + else + printf("%s.\n", errmsg); return -1; } @@ -806,18 +795,27 @@ verifypriority(struct sadb_msg *m) /* check pfkey message. */ if (pfkey_align(m, mhp)) { - printf("(%s\n", ipsec_strerror()); + if (f_mode == MODE_SCRIPT) + warnx("%s", ipsec_strerror()); + else + printf("%s\n", ipsec_strerror()); return 0; } if (pfkey_check(mhp)) { - printf("%s\n", ipsec_strerror()); + if (f_mode == MODE_SCRIPT) + warnx("%s", ipsec_strerror()); + else + printf("%s\n", ipsec_strerror()); return 0; } xpl = (struct sadb_x_policy *) mhp[SADB_X_EXT_POLICY]; if (xpl == NULL) { -
CVS commit: src/crypto/dist/ipsec-tools/src/setkey
Module Name:src Committed By: christos Date: Tue May 12 14:29:06 UTC 2020 Modified Files: src/crypto/dist/ipsec-tools/src/setkey: extern.h setkey.c token.l Log Message: Keep track of the filename to print in error messages. Change quoting of error string from [] to `'. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/crypto/dist/ipsec-tools/src/setkey/extern.h cvs rdiff -u -r1.20 -r1.21 src/crypto/dist/ipsec-tools/src/setkey/setkey.c cvs rdiff -u -r1.24 -r1.25 src/crypto/dist/ipsec-tools/src/setkey/token.l Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/crypto/dist/ipsec-tools/src/setkey/extern.h diff -u src/crypto/dist/ipsec-tools/src/setkey/extern.h:1.7 src/crypto/dist/ipsec-tools/src/setkey/extern.h:1.8 --- src/crypto/dist/ipsec-tools/src/setkey/extern.h:1.7 Sun Oct 14 04:27:39 2018 +++ src/crypto/dist/ipsec-tools/src/setkey/extern.h Tue May 12 10:29:06 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: extern.h,v 1.7 2018/10/14 08:27:39 maxv Exp $ */ +/* $NetBSD: extern.h,v 1.8 2020/05/12 14:29:06 christos Exp $ */ /* * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ void parse_init(void); /* token.l */ -int parse(FILE **); +int parse(const char *, FILE *); int parse_string(char *); /* setkey.c */ @@ -46,6 +46,7 @@ void yyerror(const char *); #ifdef HAVE_POLICY_FWD extern int f_rfcmode; #endif +extern const char *filename; extern int lineno; extern int exit_now; #ifdef HAVE_PFKEY_POLICY_PRIORITY Index: src/crypto/dist/ipsec-tools/src/setkey/setkey.c diff -u src/crypto/dist/ipsec-tools/src/setkey/setkey.c:1.20 src/crypto/dist/ipsec-tools/src/setkey/setkey.c:1.21 --- src/crypto/dist/ipsec-tools/src/setkey/setkey.c:1.20 Sun Feb 3 05:23:42 2019 +++ src/crypto/dist/ipsec-tools/src/setkey/setkey.c Tue May 12 10:29:06 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: setkey.c,v 1.20 2019/02/03 10:23:42 mrg Exp $ */ +/* $NetBSD: setkey.c,v 1.21 2020/05/12 14:29:06 christos Exp $ */ /* $KAME: setkey.c,v 1.36 2003/09/24 23:52:51 itojun Exp $ */ /* @@ -149,6 +149,7 @@ rkwarn(void) #endif int lineno; +const char *filename; int exit_now; static time_t thiszone; @@ -172,6 +173,7 @@ int main(int argc, char **argv) { FILE *fp = stdin; + const char *fname = ""; int c; if (argc == 1) { @@ -193,9 +195,11 @@ main(int argc, char **argv) f_mode = MODE_SCRIPT; if (strcmp(optarg, "-") == 0) { fp = stdin; +fname = ""; } else if ((fp = fopen(optarg, "r")) == NULL) { err(1, "Can't open `%s'", optarg); } + fname = optarg; break; case 'D': f_mode = MODE_CMDDUMP; @@ -286,7 +290,7 @@ main(int argc, char **argv) if (get_supported() < 0) { errx(1, "%s", ipsec_strerror()); } - if (parse()) + if (parse(fname, fp)) exit(1); break; case MODE_STDIN: @@ -826,7 +830,7 @@ verifypriority(struct sadb_msg *m) #endif static int -fileproc(const char *filename) +fileproc(const char *fname) { int fd; ssize_t len, l; @@ -834,7 +838,7 @@ fileproc(const char *filename) struct sadb_msg *msg; u_char rbuf[1024 * 32]; /* XXX: Enough ? Should I do MSG_PEEK ? */ - fd = open(filename, O_RDONLY); + fd = open(fname, O_RDONLY); if (fd < 0) return -1; Index: src/crypto/dist/ipsec-tools/src/setkey/token.l diff -u src/crypto/dist/ipsec-tools/src/setkey/token.l:1.24 src/crypto/dist/ipsec-tools/src/setkey/token.l:1.25 --- src/crypto/dist/ipsec-tools/src/setkey/token.l:1.24 Sun May 10 15:54:49 2020 +++ src/crypto/dist/ipsec-tools/src/setkey/token.l Tue May 12 10:29:06 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: token.l,v 1.24 2020/05/10 19:54:49 christos Exp $ */ +/* $NetBSD: token.l,v 1.25 2020/05/12 14:29:06 christos Exp $ */ /* $KAME: token.l,v 1.44 2003/10/21 07:20:58 itojun Exp $ */ /* @@ -336,23 +336,23 @@ yyfatal(const char *s) void yyerror(const char *s) { - warnx("line %d: %s at [%s]", lineno, s, yytext); + warnx("%s,%d: %s at `%s'", filename, lineno, s, yytext); } int -parse(FILE **fp) +parse(const char *fname, FILE *fp) { - yyin = *fp; - + yyin = fp; + filename = fname; lineno = 1; parse_init(); if (yyparse()) { - warnx("line %d: parse failed", lineno); - return(-1); + warnx("%s,%d: parse failed", filename, lineno); + return -1; } - return(0); + return 0; } int
CVS commit: src/sys/arch/mips/cavium/dev
Module Name:src Committed By: simonb Date: Tue May 12 14:04:50 UTC 2020 Modified Files: src/sys/arch/mips/cavium/dev: octeon_rnm.c Log Message: Oceton RNG/RNM driver modernisation to fit new entropy world order by riastradh@, with some tweaks to get working in RNG mode. XXX TODO: work out how to get raw entropy mode working. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/arch/mips/cavium/dev/octeon_rnm.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/mips/cavium/dev/octeon_rnm.c diff -u src/sys/arch/mips/cavium/dev/octeon_rnm.c:1.3 src/sys/arch/mips/cavium/dev/octeon_rnm.c:1.4 --- src/sys/arch/mips/cavium/dev/octeon_rnm.c:1.3 Tue May 12 10:37:10 2020 +++ src/sys/arch/mips/cavium/dev/octeon_rnm.c Tue May 12 14:04:50 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: octeon_rnm.c,v 1.3 2020/05/12 10:37:10 simonb Exp $ */ +/* $NetBSD: octeon_rnm.c,v 1.4 2020/05/12 14:04:50 simonb Exp $ */ /* * Copyright (c) 2007 Internet Initiative Japan, Inc. @@ -27,14 +27,13 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: octeon_rnm.c,v 1.3 2020/05/12 10:37:10 simonb Exp $"); +__KERNEL_RCSID(0, "$NetBSD: octeon_rnm.c,v 1.4 2020/05/12 14:04:50 simonb Exp $"); #include #include -#include -#include #include #include +#include #include #include @@ -45,26 +44,18 @@ __KERNEL_RCSID(0, "$NetBSD: octeon_rnm.c #include #define RNG_DELAY_CLOCK 91 -#define RNG_DEF_BURST_COUNT 10 - -int octeon_rnm_burst_count = RNG_DEF_BURST_COUNT; struct octeon_rnm_softc { - device_t sc_dev; - bus_space_tag_t sc_bust; bus_space_handle_t sc_regh; - + kmutex_t sc_lock; krndsource_t sc_rndsrc; /* /dev/random source */ - struct callout sc_rngto; /* rng timeout */ - int sc_rnghz; /* rng poll time */ }; static int octeon_rnm_match(device_t, struct cfdata *, void *); static void octeon_rnm_attach(device_t, device_t, void *); -static void octeon_rnm_rng(void *); -static inline uint64_t octeon_rnm_load(struct octeon_rnm_softc *); -static inline int octeon_rnm_iobdma(struct octeon_rnm_softc *); +static void octeon_rnm_rng(size_t, void *); +static uint64_t octeon_rnm_load(struct octeon_rnm_softc *); CFATTACH_DECL_NEW(octeon_rnm, sizeof(struct octeon_rnm_softc), octeon_rnm_match, octeon_rnm_attach, NULL, NULL); @@ -94,7 +85,6 @@ octeon_rnm_attach(device_t parent, devic aprint_normal("\n"); - sc->sc_dev = self; sc->sc_bust = aa->aa_bust; if (bus_space_map(aa->aa_bust, aa->aa_unit->addr, RNM_SIZE, 0, >sc_regh) != 0) { @@ -110,48 +100,81 @@ octeon_rnm_attach(device_t parent, devic return; } - bus_space_write_8(sc->sc_bust, sc->sc_regh, RNM_CTL_STATUS_OFFSET, - RNM_CTL_STATUS_RNG_EN | RNM_CTL_STATUS_ENT_EN); - - if (hz >= 100) - sc->sc_rnghz = hz / 100; - else - sc->sc_rnghz = 1; - - rnd_attach_source(>sc_rndsrc, device_xname(sc->sc_dev), - RND_TYPE_RNG, RND_FLAG_NO_ESTIMATE); + mutex_init(>sc_lock, MUTEX_DEFAULT, IPL_VM); - callout_init(>sc_rngto, 0); +#ifdef notyet + /* + * Enable the internal ring oscillator entropy source (ENT), + * but disable the LFSR/SHA-1 engine (RNG) so we get the raw RO + * samples. + * + * XXX simonb + * To access the raw entropy, it looks like this needs to be + * done through the IOBDMA. Put this in the "Too Hard For Now" + * basket and just use the RNG. + */ + bus_space_write_8(sc->sc_bust, sc->sc_regh, RNM_CTL_STATUS_OFFSET, + RNM_CTL_STATUS_EXP_ENT | RNM_CTL_STATUS_ENT_EN); - octeon_rnm_rng(sc); + /* + * Once entropy is enabled, 64 bits of raw entropy is available + * every 8 clock cycles. Wait a microsecond now before the + * random callback is called to much sure random data is + * available. + */ + delay(1); +#else + /* Enable the LFSR/SHA-1 engine (RNG). */ + bus_space_write_8(sc->sc_bust, sc->sc_regh, RNM_CTL_STATUS_OFFSET, + RNM_CTL_STATUS_RNG_EN | RNM_CTL_STATUS_ENT_EN); - aprint_normal("%s: random number generator enabled: %dhz\n", - device_xname(sc->sc_dev), sc->sc_rnghz); + /* + * Once entropy is enabled, a 64-bit random number is available + * every 81 clock cycles. Wait a microsecond now before the + * random callback is called to much sure random data is + * available. + */ + delay(1); +#endif + + rndsource_setcb(>sc_rndsrc, octeon_rnm_rng, sc); + rnd_attach_source(>sc_rndsrc, device_xname(self), RND_TYPE_RNG, + RND_FLAG_DEFAULT | RND_FLAG_HASCB); } static void -octeon_rnm_rng(void *vsc) +octeon_rnm_rng(size_t nbytes, void *vsc) { struct octeon_rnm_softc *sc = vsc; uint64_t rn; int i; - for (i = 0; i < octeon_rnm_burst_count; i++) { + /* Prevent concurrent access from emptying the FIFO. */ + mutex_enter(>sc_lock); + for (i = 0; i < howmany(nbytes, sizeof(rn)); i++) { rn = octeon_rnm_load(sc); rnd_add_data(>sc_rndsrc, , sizeof(rn), sizeof(rn) * NBBY); /* * XXX - * delay should be over RNG_DELAY_CLOCK cycles at least, -
CVS commit: src/lib/libc/sys
Module Name:src Committed By: kamil Date: Tue May 12 11:39:09 UTC 2020 Modified Files: src/lib/libc/sys: clone.2 Log Message: Remove mentions of CLONE_PID and CLONE_STOPPED CLONE_PID was removed in Linux 2.5.15 and recycled for CLONE_PIDFD since Linux 5.2. CLONE_STOPPED was removed in Linux 2.6.38 and recycled for CLONE_NEWCGROUP since Linux 4.6. To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/lib/libc/sys/clone.2 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/sys/clone.2 diff -u src/lib/libc/sys/clone.2:1.13 src/lib/libc/sys/clone.2:1.14 --- src/lib/libc/sys/clone.2:1.13 Sun Jan 29 11:44:54 2012 +++ src/lib/libc/sys/clone.2 Tue May 12 11:39:08 2020 @@ -1,4 +1,4 @@ -.\" $NetBSD: clone.2,v 1.13 2012/01/29 11:44:54 wiz Exp $ +.\" $NetBSD: clone.2,v 1.14 2020/05/12 11:39:08 kamil Exp $ .\" .\" Copyright (c) 2001 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 May 4, 2010 +.Dd May 12, 2020 .Dt CLONE 2 .Os .Sh NAME @@ -189,14 +189,10 @@ that are present in the Linux implementa .It .Dv CLONE_PARENT_SETTID .It -.Dv CLONE_PID -.It .Dv CLONE_PTRACE .It .Dv CLONE_SETTLS .It -.Dv CLONE_STOPPED -.It .Dv CLONE_SYSVSEM .It .Dv CLONE_THREAD
CVS commit: src/sys
Module Name:src Committed By: kamil Date: Tue May 12 11:21:10 UTC 2020 Modified Files: src/sys/kern: kern_fork.c src/sys/sys: sched.h Log Message: Remove the stub support of CLONE_PID in clone(2) CLONE_PID causes the child clonee to share the same process id as cloner. It was implemented for debugging purposes in the Linux kernel 2.0, restricted to root only in 2.3.21 and removed from Linux 2.5.16. The CLONE_PID bit was recycled for CLONE_PIDFD in Linux 5.2. To generate a diff of this commit: cvs rdiff -u -r1.224 -r1.225 src/sys/kern/kern_fork.c cvs rdiff -u -r1.88 -r1.89 src/sys/sys/sched.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_fork.c diff -u src/sys/kern/kern_fork.c:1.224 src/sys/kern/kern_fork.c:1.225 --- src/sys/kern/kern_fork.c:1.224 Thu May 7 20:02:34 2020 +++ src/sys/kern/kern_fork.c Tue May 12 11:21:09 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_fork.c,v 1.224 2020/05/07 20:02:34 kamil Exp $ */ +/* $NetBSD: kern_fork.c,v 1.225 2020/05/12 11:21:09 kamil Exp $ */ /*- * Copyright (c) 1999, 2001, 2004, 2006, 2007, 2008, 2019 @@ -68,7 +68,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_fork.c,v 1.224 2020/05/07 20:02:34 kamil Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_fork.c,v 1.225 2020/05/12 11:21:09 kamil Exp $"); #include "opt_ktrace.h" #include "opt_dtrace.h" @@ -158,9 +158,9 @@ sys___clone(struct lwp *l, const struct int flags, sig; /* - * We don't support the CLONE_PID or CLONE_PTRACE flags. + * We don't support the CLONE_PTRACE flag. */ - if (SCARG(uap, flags) & (CLONE_PID|CLONE_PTRACE)) + if (SCARG(uap, flags) & (CLONE_PTRACE)) return EINVAL; /* Index: src/sys/sys/sched.h diff -u src/sys/sys/sched.h:1.88 src/sys/sys/sched.h:1.89 --- src/sys/sys/sched.h:1.88 Sat Mar 14 18:08:39 2020 +++ src/sys/sys/sched.h Tue May 12 11:21:09 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: sched.h,v 1.88 2020/03/14 18:08:39 ad Exp $ */ +/* $NetBSD: sched.h,v 1.89 2020/05/12 11:21:09 kamil Exp $ */ /*- * Copyright (c) 1999, 2000, 2001, 2002, 2007, 2008, 2019, 2020 @@ -200,7 +200,6 @@ struct schedstate_percpu { #define CLONE_FS 0x0200 /* share "file system" info */ #define CLONE_FILES 0x0400 /* share file descriptors */ #define CLONE_SIGHAND 0x0800 /* share signal actions */ -#define CLONE_PID 0x1000 /* share process ID */ #define CLONE_PTRACE 0x2000 /* ptrace(2) continues on child */ #define CLONE_VFORK 0x4000 /* parent blocks until child
CVS commit: src/sys/arch/mips/cavium/dev
Module Name:src Committed By: simonb Date: Tue May 12 10:37:10 UTC 2020 Modified Files: src/sys/arch/mips/cavium/dev: octeon_rnm.c Log Message: If bus_space_map fails, just don't attach the driver instead of panicing. Check RNG built in self test, don't attach if that fails too. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/arch/mips/cavium/dev/octeon_rnm.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/mips/cavium/dev/octeon_rnm.c diff -u src/sys/arch/mips/cavium/dev/octeon_rnm.c:1.2 src/sys/arch/mips/cavium/dev/octeon_rnm.c:1.3 --- src/sys/arch/mips/cavium/dev/octeon_rnm.c:1.2 Tue Jan 8 19:41:09 2019 +++ src/sys/arch/mips/cavium/dev/octeon_rnm.c Tue May 12 10:37:10 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: octeon_rnm.c,v 1.2 2019/01/08 19:41:09 jdolecek Exp $ */ +/* $NetBSD: octeon_rnm.c,v 1.3 2020/05/12 10:37:10 simonb Exp $ */ /* * Copyright (c) 2007 Internet Initiative Japan, Inc. @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: octeon_rnm.c,v 1.2 2019/01/08 19:41:09 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: octeon_rnm.c,v 1.3 2020/05/12 10:37:10 simonb Exp $"); #include #include @@ -90,16 +90,25 @@ octeon_rnm_attach(device_t parent, devic { struct octeon_rnm_softc *sc = device_private(self); struct iobus_attach_args *aa = aux; - int status; + uint64_t bist_status; aprint_normal("\n"); sc->sc_dev = self; sc->sc_bust = aa->aa_bust; - status = bus_space_map(aa->aa_bust, aa->aa_unit->addr, RNM_SIZE, - 0, >sc_regh); - if (status != 0) - panic(": can't map i/o space"); + if (bus_space_map(aa->aa_bust, aa->aa_unit->addr, RNM_SIZE, + 0, >sc_regh) != 0) { + aprint_error_dev(self, "unable to map device\n"); + return; + } + + bist_status = bus_space_read_8(sc->sc_bust, sc->sc_regh, + RNM_BIST_STATUS_OFFSET); + if (bist_status) { + aprint_error_dev(self, "RNG built in self test failed: %#lx\n", + bist_status); + return; + } bus_space_write_8(sc->sc_bust, sc->sc_regh, RNM_CTL_STATUS_OFFSET, RNM_CTL_STATUS_RNG_EN | RNM_CTL_STATUS_ENT_EN);
CVS commit: src/share/man/man7
Module Name:src Committed By: leot Date: Tue May 12 10:20:16 UTC 2020 Modified Files: src/share/man/man7: hier.7 Log Message: Remove a reference to /etc/netstart It was removed in rc.d era and no longer honored (except by newbtconf(8)). Noticed by Ottavio Caruso on #netbsd@Freenode, thanks! To generate a diff of this commit: cvs rdiff -u -r1.139 -r1.140 src/share/man/man7/hier.7 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/man7/hier.7 diff -u src/share/man/man7/hier.7:1.139 src/share/man/man7/hier.7:1.140 --- src/share/man/man7/hier.7:1.139 Sat Apr 4 15:32:42 2020 +++ src/share/man/man7/hier.7 Tue May 12 10:20:16 2020 @@ -1,4 +1,4 @@ -.\" $NetBSD: hier.7,v 1.139 2020/04/04 15:32:42 jdolecek Exp $ +.\" $NetBSD: hier.7,v 1.140 2020/05/12 10:20:16 leot Exp $ .\" .\" Copyright (c) 1990, 1993, 1994 .\" The Regents of the University of California. All rights reserved. @@ -29,7 +29,7 @@ .\" .\" @(#)hier.7 8.5 (Berkeley) 6/1/94 .\" -.Dd January 10, 2020 +.Dd May 12, 2020 .Dt HIER 7 .Os .Sh NAME @@ -255,8 +255,6 @@ configuration files and databases. .It Pa netgroup Network groups; see .Xr netgroup 5 . -.It Pa netstart -Network startup script . .It Pa networks Network name database; see .Xr networks 5 .
CVS commit: src/sys/arch/mips/cavium/dev
Module Name:src Committed By: simonb Date: Tue May 12 10:12:08 UTC 2020 Modified Files: src/sys/arch/mips/cavium/dev: octeon_rnmreg.h Log Message: Add a few more bits. XXX convert to __BITS. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/arch/mips/cavium/dev/octeon_rnmreg.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/mips/cavium/dev/octeon_rnmreg.h diff -u src/sys/arch/mips/cavium/dev/octeon_rnmreg.h:1.1 src/sys/arch/mips/cavium/dev/octeon_rnmreg.h:1.2 --- src/sys/arch/mips/cavium/dev/octeon_rnmreg.h:1.1 Wed Apr 29 08:32:01 2015 +++ src/sys/arch/mips/cavium/dev/octeon_rnmreg.h Tue May 12 10:12:08 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: octeon_rnmreg.h,v 1.1 2015/04/29 08:32:01 hikaru Exp $ */ +/* $NetBSD: octeon_rnmreg.h,v 1.2 2020/05/12 10:12:08 simonb Exp $ */ /* * Copyright (c) 2007 Internet Initiative Japan, Inc. @@ -40,7 +40,9 @@ /* register bits */ -#define RNM_CTL_STATUS_XXX_63_4 UINT64_C(0xfff0) +#define RNM_CTL_STATUS_XXX_63_5 UINT64_C(0xfe00) +#define RNM_CTL_STATUS_ENT_SEL_MASK UINT64_C(0x01e0) +#define RNM_CTL_STATUS_EXP_ENT UINT64_C(0x0010) #define RNM_CTL_STATUS_RNG_RST UINT64_C(0x0008) #define RNM_CTL_STATUS_RNM_RST UINT64_C(0x0004) #define RNM_CTL_STATUS_RNG_EN UINT64_C(0x0002) @@ -64,6 +66,8 @@ "\177" /* new format */ \ "\020" /* hex display */ \ "\020" /* %016x format */ \ + "f\x05\x04" "ENT_SEL\0" \ + "b\x04" "EXP_ENT\0" \ "b\x03" "RNG_RST\0" \ "b\x02" "RNM_RST\0" \ "b\x01" "RNG_EN\0" \
CVS commit: src/sys/kern
Module Name:src Committed By: jdolecek Date: Tue May 12 10:02:56 UTC 2020 Modified Files: src/sys/kern: kern_pmf.c Log Message: need to take IFNET_LOCK() around if_stop (on suspend) and if_init (on resume) calls, those need to read and/or manipulate if_flags and hence need the lock for IFEF_MPSAFE drivers; the drivers can't do IFNET_LOCK() themselves, because the ioctl path call these hooks with the lock held fixes KASSERT() in xennet(4) while investigating PR port-xen/55207 To generate a diff of this commit: cvs rdiff -u -r1.42 -r1.43 src/sys/kern/kern_pmf.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_pmf.c diff -u src/sys/kern/kern_pmf.c:1.42 src/sys/kern/kern_pmf.c:1.43 --- src/sys/kern/kern_pmf.c:1.42 Mon Apr 20 21:39:05 2020 +++ src/sys/kern/kern_pmf.c Tue May 12 10:02:56 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_pmf.c,v 1.42 2020/04/20 21:39:05 ad Exp $ */ +/* $NetBSD: kern_pmf.c,v 1.43 2020/05/12 10:02:56 jdolecek Exp $ */ /*- * Copyright (c) 2007 Jared D. McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_pmf.c,v 1.42 2020/04/20 21:39:05 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_pmf.c,v 1.43 2020/05/12 10:02:56 jdolecek Exp $"); #include #include @@ -893,7 +893,9 @@ pmf_class_network_suspend(device_t dev, int s; s = splnet(); + IFNET_LOCK(ifp); (*ifp->if_stop)(ifp, 0); + IFNET_UNLOCK(ifp); splx(s); return true; @@ -904,14 +906,21 @@ pmf_class_network_resume(device_t dev, c { struct ifnet *ifp = device_pmf_class_private(dev); int s; + bool restart = false; s = splnet(); + IFNET_LOCK(ifp); if (ifp->if_flags & IFF_UP) { ifp->if_flags &= ~IFF_RUNNING; if ((*ifp->if_init)(ifp) != 0) aprint_normal_ifnet(ifp, "resume failed\n"); - if_start_lock(ifp); + restart = true; } + IFNET_UNLOCK(ifp); + + if (restart) + if_start_lock(ifp); + splx(s); return true;
CVS commit: src/sys/arch/xen/xen
Module Name:src Committed By: jdolecek Date: Tue May 12 09:54:02 UTC 2020 Modified Files: src/sys/arch/xen/xen: xbd_xenbus.c Log Message: move xen_intr_disestablish() call in xbd_xenbus_suspend() so it's executed without holding the xbd mutex, to avoid LOCKDEBUG assertion on suspend while here only disestablish the intr if it was established part of PR port-xen/55207 To generate a diff of this commit: cvs rdiff -u -r1.125 -r1.126 src/sys/arch/xen/xen/xbd_xenbus.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/xbd_xenbus.c diff -u src/sys/arch/xen/xen/xbd_xenbus.c:1.125 src/sys/arch/xen/xen/xbd_xenbus.c:1.126 --- src/sys/arch/xen/xen/xbd_xenbus.c:1.125 Thu May 7 19:25:57 2020 +++ src/sys/arch/xen/xen/xbd_xenbus.c Tue May 12 09:54:02 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: xbd_xenbus.c,v 1.125 2020/05/07 19:25:57 maxv Exp $ */ +/* $NetBSD: xbd_xenbus.c,v 1.126 2020/05/12 09:54:02 jdolecek Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -50,7 +50,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: xbd_xenbus.c,v 1.125 2020/05/07 19:25:57 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xbd_xenbus.c,v 1.126 2020/05/12 09:54:02 jdolecek Exp $"); #include "opt_xen.h" @@ -436,7 +436,10 @@ xbd_xenbus_detach(device_t dev, int flag } hypervisor_mask_event(sc->sc_evtchn); - xen_intr_disestablish(sc->sc_ih); + if (sc->sc_ih != NULL) { + xen_intr_disestablish(sc->sc_ih); + sc->sc_ih = NULL; + } mutex_enter(>sc_lock); while (xengnt_status(sc->sc_ring_gntref)) @@ -488,10 +491,14 @@ xbd_xenbus_suspend(device_t dev, const p hypervisor_mask_event(sc->sc_evtchn); sc->sc_backend_status = BLKIF_STATE_SUSPENDED; - xen_intr_disestablish(sc->sc_ih); mutex_exit(>sc_lock); + if (sc->sc_ih != NULL) { + xen_intr_disestablish(sc->sc_ih); + sc->sc_ih = NULL; + } + xenbus_device_suspend(sc->sc_xbusd); aprint_verbose_dev(dev, "removed event channel %d\n", sc->sc_evtchn);
CVS commit: src/sbin/rndctl
Module Name:src Committed By: simonb Date: Tue May 12 09:48:44 UTC 2020 Modified Files: src/sbin/rndctl: rndctl.c Log Message: Whitespace alignment nits. To generate a diff of this commit: cvs rdiff -u -r1.36 -r1.37 src/sbin/rndctl/rndctl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/rndctl/rndctl.c diff -u src/sbin/rndctl/rndctl.c:1.36 src/sbin/rndctl/rndctl.c:1.37 --- src/sbin/rndctl/rndctl.c:1.36 Thu May 7 19:13:38 2020 +++ src/sbin/rndctl/rndctl.c Tue May 12 09:48:44 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: rndctl.c,v 1.36 2020/05/07 19:13:38 riastradh Exp $ */ +/* $NetBSD: rndctl.c,v 1.37 2020/05/12 09:48:44 simonb Exp $ */ /*- * Copyright (c) 1997 Michael Graff. @@ -31,7 +31,7 @@ #include #ifndef lint -__RCSID("$NetBSD: rndctl.c,v 1.36 2020/05/07 19:13:38 riastradh Exp $"); +__RCSID("$NetBSD: rndctl.c,v 1.37 2020/05/12 09:48:44 simonb Exp $"); #endif #include @@ -90,8 +90,8 @@ usage(void) getprogname()); fprintf(stderr, " %s [-lsv] [-d devname | -t devtype]\n", getprogname()); - fprintf(stderr, " %s [-i] -L save-file\n", getprogname()); - fprintf(stderr, " %s -S save-file\n", getprogname()); + fprintf(stderr, " %s [-i] -L save-file\n", getprogname()); + fprintf(stderr, " %s -S save-file\n", getprogname()); exit(1); }
CVS commit: src/sys/arch/x86/x86
Module Name:src Committed By: msaitoh Date: Tue May 12 06:32:05 UTC 2020 Modified Files: src/sys/arch/x86/x86: cpu.c identcpu_subr.c Log Message: Don't use TSC freq value from CPUID if calibration works. - When it's the first call of cpu_get_tsc_freq() the HPET is not initialized, so try to use CPUID to get TSC freq. - If it's the 2nd call, don't use CPUID. Instead, print the difference between the calibrated value and CPUID's value if the verbose mode is set. To generate a diff of this commit: cvs rdiff -u -r1.190 -r1.191 src/sys/arch/x86/x86/cpu.c cvs rdiff -u -r1.3 -r1.4 src/sys/arch/x86/x86/identcpu_subr.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/x86/x86/cpu.c diff -u src/sys/arch/x86/x86/cpu.c:1.190 src/sys/arch/x86/x86/cpu.c:1.191 --- src/sys/arch/x86/x86/cpu.c:1.190 Fri May 8 22:01:55 2020 +++ src/sys/arch/x86/x86/cpu.c Tue May 12 06:32:05 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu.c,v 1.190 2020/05/08 22:01:55 ad Exp $ */ +/* $NetBSD: cpu.c,v 1.191 2020/05/12 06:32:05 msaitoh Exp $ */ /* * Copyright (c) 2000-2020 NetBSD Foundation, Inc. @@ -62,7 +62,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.190 2020/05/08 22:01:55 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.191 2020/05/12 06:32:05 msaitoh Exp $"); #include "opt_ddb.h" #include "opt_mpbios.h" /* for MPDEBUG */ @@ -1320,11 +1320,19 @@ cpu_shutdown(device_t dv, int how) void cpu_get_tsc_freq(struct cpu_info *ci) { - uint64_t freq = 0, t0, t1; + uint64_t freq = 0, freq_from_cpuid, t0, t1; int64_t overhead; if ((ci->ci_flags & CPUF_PRIMARY) != 0 && cpu_hascounter()) { - freq = cpu_tsc_freq_cpuid(ci); + /* + * If it's the first call of this function, try to get TSC + * freq from CPUID by calling cpu_tsc_freq_cpuid(). + * The function also set lapic_per_second variable if it's + * known. This is required for Intel's Comet Lake and newer + * processors to set LAPIC timer correctly. + */ + if (ci->ci_data.cpu_cc_freq == 0) + freq = freq_from_cpuid = cpu_tsc_freq_cpuid(ci); #if NHPET > 0 if (freq == 0) freq = hpet_tsc_freq(); @@ -1352,6 +1360,13 @@ cpu_get_tsc_freq(struct cpu_info *ci) t1 = cpu_counter(); freq = (t1 - t0 - overhead) * 10; } + if (ci->ci_data.cpu_cc_freq != 0) { + freq_from_cpuid = cpu_tsc_freq_cpuid(ci); + if ((freq_from_cpuid != 0) + && (freq != freq_from_cpuid)) +aprint_verbose_dev(ci->ci_dev, "TSC freq " +"calibrated %" PRIu64 " Hz\n", freq); + } } else { freq = cpu_info_primary.ci_data.cpu_cc_freq; } Index: src/sys/arch/x86/x86/identcpu_subr.c diff -u src/sys/arch/x86/x86/identcpu_subr.c:1.3 src/sys/arch/x86/x86/identcpu_subr.c:1.4 --- src/sys/arch/x86/x86/identcpu_subr.c:1.3 Sat Apr 25 15:26:18 2020 +++ src/sys/arch/x86/x86/identcpu_subr.c Tue May 12 06:32:05 2020 @@ -33,7 +33,7 @@ * See src/usr.sbin/cpuctl/{Makefile, arch/i386.c}). */ #include -__KERNEL_RCSID(0, "$NetBSD: identcpu_subr.c,v 1.3 2020/04/25 15:26:18 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: identcpu_subr.c,v 1.4 2020/05/12 06:32:05 msaitoh Exp $"); #ifdef _KERNEL_OPT #include "lapic.h" @@ -139,8 +139,8 @@ cpu_tsc_freq_cpuid(struct cpu_info *ci) #endif } if (freq != 0) - aprint_verbose_dev(ci->ci_dev, "TSC freq %" PRIu64 " Hz\n", - freq); + aprint_verbose_dev(ci->ci_dev, "TSC freq CPUID %" PRIu64 + " Hz\n", freq); return freq; }
CVS commit: src/usr.sbin/sysinst
Module Name:src Committed By: martin Date: Tue May 12 06:23:07 UTC 2020 Modified Files: src/usr.sbin/sysinst: bsddisklabel.c Log Message: Minor tweak to previous: when forcing a /usr partition just to have an arbitrary extendable partition, still use its default size initially. To generate a diff of this commit: cvs rdiff -u -r1.41 -r1.42 src/usr.sbin/sysinst/bsddisklabel.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.sbin/sysinst/bsddisklabel.c diff -u src/usr.sbin/sysinst/bsddisklabel.c:1.41 src/usr.sbin/sysinst/bsddisklabel.c:1.42 --- src/usr.sbin/sysinst/bsddisklabel.c:1.41 Mon May 11 17:40:50 2020 +++ src/usr.sbin/sysinst/bsddisklabel.c Tue May 12 06:23:07 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: bsddisklabel.c,v 1.41 2020/05/11 17:40:50 martin Exp $ */ +/* $NetBSD: bsddisklabel.c,v 1.42 2020/05/12 06:23:07 martin Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -1147,7 +1147,8 @@ fill_defaults(struct partition_usage_set wanted->infos[usr].size = wanted->infos[root].size - wanted->infos[root].limit; if (wanted->infos[usr].size <= 0) -wanted->infos[usr].size = 1; +wanted->infos[usr].size = max(1, +wanted->infos[usr].def_size); wanted->infos[root].size = wanted->infos[root].limit; if (wanted->infos[root].flags & PUIFLAG_EXTEND) {