CVS commit: src/sys/kern
Module Name:src Committed By: maxv Date: Mon Jan 22 07:22:52 UTC 2018 Modified Files: src/sys/kern: uipc_mbuf.c Log Message: Fix m_prepend(). If 'm' is not a pkthdr, it doesn't make sense to use MH_ALIGN, it should rather be M_ALIGN. I'm wondering whether there should not be a KASSERT to make sure 'm' is always a pkthdr. To generate a diff of this commit: cvs rdiff -u -r1.177 -r1.178 src/sys/kern/uipc_mbuf.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_mbuf.c diff -u src/sys/kern/uipc_mbuf.c:1.177 src/sys/kern/uipc_mbuf.c:1.178 --- src/sys/kern/uipc_mbuf.c:1.177 Sun Jan 14 16:59:37 2018 +++ src/sys/kern/uipc_mbuf.c Mon Jan 22 07:22:52 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: uipc_mbuf.c,v 1.177 2018/01/14 16:59:37 maxv Exp $ */ +/* $NetBSD: uipc_mbuf.c,v 1.178 2018/01/22 07:22:52 maxv Exp $ */ /* * Copyright (c) 1999, 2001 The NetBSD Foundation, Inc. @@ -62,7 +62,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uipc_mbuf.c,v 1.177 2018/01/14 16:59:37 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uipc_mbuf.c,v 1.178 2018/01/22 07:22:52 maxv Exp $"); #ifdef _KERNEL_OPT #include "opt_mbuftrace.h" @@ -666,6 +666,7 @@ m_prepend(struct mbuf *m, int len, int h m_freem(m); return (NULL); } + if (m->m_flags & M_PKTHDR) { M_MOVE_PKTHDR(mn, m); } else { @@ -673,8 +674,15 @@ m_prepend(struct mbuf *m, int len, int h } mn->m_next = m; m = mn; - if (len < MHLEN) - MH_ALIGN(m, len); + + if (m->m_flags & M_PKTHDR) { + if (len < MHLEN) + MH_ALIGN(m, len); + } else { + if (len < MLEN) + M_ALIGN(m, len); + } + m->m_len = len; return (m); }
CVS commit: src/sys/sys
Module Name:src Committed By: maxv Date: Mon Jan 22 07:11:45 UTC 2018 Modified Files: src/sys/sys: mbuf.h Log Message: Add KASSERTs in *_ALIGN: ensure the mbuf is of the correct type, and also make sure m->m_data points at the beginning of the mbuf. To generate a diff of this commit: cvs rdiff -u -r1.174 -r1.175 src/sys/sys/mbuf.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/mbuf.h diff -u src/sys/sys/mbuf.h:1.174 src/sys/sys/mbuf.h:1.175 --- src/sys/sys/mbuf.h:1.174 Sun Jan 14 17:16:58 2018 +++ src/sys/sys/mbuf.h Mon Jan 22 07:11:45 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: mbuf.h,v 1.174 2018/01/14 17:16:58 maxv Exp $ */ +/* $NetBSD: mbuf.h,v 1.175 2018/01/22 07:11:45 maxv Exp $ */ /*- * Copyright (c) 1996, 1997, 1999, 2001, 2007 The NetBSD Foundation, Inc. @@ -604,6 +604,8 @@ do { \ */ #define M_ALIGN(m, len) \ do { \ + KASSERT(((m)->m_flags & (M_PKTHDR|M_EXT)) == 0); \ + KASSERT(M_LEADINGSPACE(m) == 0);\ (m)->m_data += (MLEN - (len)) &~ (sizeof(long) - 1); \ } while (/* CONSTCOND */ 0) @@ -613,6 +615,9 @@ do { \ */ #define MH_ALIGN(m, len) \ do { \ + KASSERT(((m)->m_flags & M_PKTHDR) != 0); \ + KASSERT(((m)->m_flags & M_EXT) == 0);\ + KASSERT(M_LEADINGSPACE(m) == 0);\ (m)->m_data += (MHLEN - (len)) &~ (sizeof(long) - 1); \ } while (/* CONSTCOND */ 0)
CVS commit: src/sys/netinet
Module Name:src Committed By: maxv Date: Mon Jan 22 06:56:25 UTC 2018 Modified Files: src/sys/netinet: ip_icmp.c Log Message: Adapt previous, reintroduce MH_ALIGN. It's used as an optimization - we can later prepend something to the current mbuf without having to allocate a new mbuf. To generate a diff of this commit: cvs rdiff -u -r1.163 -r1.164 src/sys/netinet/ip_icmp.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/netinet/ip_icmp.c diff -u src/sys/netinet/ip_icmp.c:1.163 src/sys/netinet/ip_icmp.c:1.164 --- src/sys/netinet/ip_icmp.c:1.163 Fri Jan 19 13:17:29 2018 +++ src/sys/netinet/ip_icmp.c Mon Jan 22 06:56:25 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: ip_icmp.c,v 1.163 2018/01/19 13:17:29 maxv Exp $ */ +/* $NetBSD: ip_icmp.c,v 1.164 2018/01/22 06:56:25 maxv Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -94,7 +94,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ip_icmp.c,v 1.163 2018/01/19 13:17:29 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ip_icmp.c,v 1.164 2018/01/22 06:56:25 maxv Exp $"); #ifdef _KERNEL_OPT #include "opt_ipsec.h" @@ -345,6 +345,9 @@ icmp_error(struct mbuf *n, int type, int panic("icmp_error"); ICMP_STATINC(ICMP_STAT_OUTHIST + type); + if ((m->m_flags & M_EXT) == 0) + MH_ALIGN(m, m->m_len); + /* * Get pointers on the IP header and the ICMP header. */
CVS commit: src/usr.sbin/fstyp
Module Name:src Committed By: joerg Date: Mon Jan 22 01:34:42 UTC 2018 Modified Files: src/usr.sbin/fstyp: Makefile Log Message: Ignore pragma warnings with clang for the zfs code. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/usr.sbin/fstyp/Makefile 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/fstyp/Makefile diff -u src/usr.sbin/fstyp/Makefile:1.1 src/usr.sbin/fstyp/Makefile:1.2 --- src/usr.sbin/fstyp/Makefile:1.1 Tue Jan 9 03:31:15 2018 +++ src/usr.sbin/fstyp/Makefile Mon Jan 22 01:34:42 2018 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.1 2018/01/09 03:31:15 christos Exp $ +# $NetBSD: Makefile,v 1.2 2018/01/22 01:34:42 joerg Exp $ .include @@ -25,4 +25,6 @@ CFLAGS+= -I${NETBSDSRCDIR}/external/cddl LDADD+= -lnvpair -lzfs .endif +CWARNFLAGS.clang+= -Wno-unknown-pragmas + .include
CVS commit: xsrc/external/mit/libdrm/dist
Module Name:xsrc Committed By: christos Date: Sun Jan 21 21:49:51 UTC 2018 Modified Files: xsrc/external/mit/libdrm/dist: util_double_list.h util_math.h Log Message: use __typeof__ instead of typeof To generate a diff of this commit: cvs rdiff -u -r1.1.1.2 -r1.2 xsrc/external/mit/libdrm/dist/util_double_list.h cvs rdiff -u -r1.1.1.1 -r1.2 xsrc/external/mit/libdrm/dist/util_math.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: xsrc/external/mit/libdrm/dist/util_double_list.h diff -u xsrc/external/mit/libdrm/dist/util_double_list.h:1.1.1.2 xsrc/external/mit/libdrm/dist/util_double_list.h:1.2 --- xsrc/external/mit/libdrm/dist/util_double_list.h:1.1.1.2 Sat Mar 4 18:15:50 2017 +++ xsrc/external/mit/libdrm/dist/util_double_list.h Sun Jan 21 16:49:51 2018 @@ -110,7 +110,7 @@ static inline void list_delinit(struct l #ifndef container_of #define container_of(ptr, sample, member)\ (void *)((char *)(ptr) \ - - ((char *)&((typeof(sample))0)->member)) + - ((char *)&((__typeof__(sample))0)->member)) #endif #define LIST_FOR_EACH_ENTRY(pos, head, member)\ Index: xsrc/external/mit/libdrm/dist/util_math.h diff -u xsrc/external/mit/libdrm/dist/util_math.h:1.1.1.1 xsrc/external/mit/libdrm/dist/util_math.h:1.2 --- xsrc/external/mit/libdrm/dist/util_math.h:1.1.1.1 Tue Aug 16 22:14:49 2016 +++ xsrc/external/mit/libdrm/dist/util_math.h Sun Jan 21 16:49:51 2018 @@ -29,6 +29,6 @@ #define MAX3( A, B, C ) ((A) > (B) ? MAX2(A, C) : MAX2(B, C)) #define __align_mask(value, mask) (((value) + (mask)) & ~(mask)) -#define ALIGN(value, alignment)__align_mask(value, (typeof(value))((alignment) - 1)) +#define ALIGN(value, alignment)__align_mask(value, (__typeof__(value))((alignment) - 1)) #endif /*_UTIL_MATH_H_*/
CVS commit: xsrc/external/mit/libdrm/dist
Module Name:xsrc Committed By: christos Date: Sun Jan 21 21:48:54 UTC 2018 Modified Files: xsrc/external/mit/libdrm/dist: libdrm_lists.h Log Message: use __typeof__ instead of typeof. To generate a diff of this commit: cvs rdiff -u -r1.1.1.2 -r1.2 xsrc/external/mit/libdrm/dist/libdrm_lists.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: xsrc/external/mit/libdrm/dist/libdrm_lists.h diff -u xsrc/external/mit/libdrm/dist/libdrm_lists.h:1.1.1.2 xsrc/external/mit/libdrm/dist/libdrm_lists.h:1.2 --- xsrc/external/mit/libdrm/dist/libdrm_lists.h:1.1.1.2 Mon Mar 17 03:51:42 2014 +++ xsrc/external/mit/libdrm/dist/libdrm_lists.h Sun Jan 21 16:48:54 2018 @@ -96,18 +96,18 @@ typedef struct _drmMMListHead (__item) = (__temp), (__temp) = (__item)->prev) #define DRMLISTFOREACHENTRY(__item, __list, __head)\ - for ((__item) = DRMLISTENTRY(typeof(*__item), (__list)->next, __head); \ + for ((__item) = DRMLISTENTRY(__typeof__(*__item), (__list)->next, __head); \ &(__item)->__head != (__list);\ - (__item) = DRMLISTENTRY(typeof(*__item), \ + (__item) = DRMLISTENTRY(__typeof__(*__item), \ (__item)->__head.next, __head)) #define DRMLISTFOREACHENTRYSAFE(__item, __temp, __list, __head)\ - for ((__item) = DRMLISTENTRY(typeof(*__item), (__list)->next, __head), \ - (__temp) = DRMLISTENTRY(typeof(*__item), \ + for ((__item) = DRMLISTENTRY(__typeof__(*__item), (__list)->next, __head), \ + (__temp) = DRMLISTENTRY(__typeof__(*__item), \ (__item)->__head.next, __head); \ &(__item)->__head != (__list);\ (__item) = (__temp), \ - (__temp) = DRMLISTENTRY(typeof(*__item), \ + (__temp) = DRMLISTENTRY(__typeof__(*__item), \ (__temp)->__head.next, __head)) #define DRMLISTJOIN(__list, __join) if (!DRMLISTEMPTY(__list)) { \
CVS commit: src/sys/nfs
Module Name:src Committed By: christos Date: Sun Jan 21 20:36:50 UTC 2018 Modified Files: src/sys/nfs: nfs.h nfs_clntsocket.c nfs_socket.c nfs_subs.c Log Message: PR/40491: From Tobias Ulmer in tech-kern@: 1. Protect the nfs request queue with its own mutex 2. make the nfs_receive queue check for signals so that intr mounts can be interrupted. XXX: pullup-8 To generate a diff of this commit: cvs rdiff -u -r1.75 -r1.76 src/sys/nfs/nfs.h cvs rdiff -u -r1.5 -r1.6 src/sys/nfs/nfs_clntsocket.c cvs rdiff -u -r1.198 -r1.199 src/sys/nfs/nfs_socket.c cvs rdiff -u -r1.229 -r1.230 src/sys/nfs/nfs_subs.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/nfs/nfs.h diff -u src/sys/nfs/nfs.h:1.75 src/sys/nfs/nfs.h:1.76 --- src/sys/nfs/nfs.h:1.75 Mon Apr 20 09:12:24 2015 +++ src/sys/nfs/nfs.h Sun Jan 21 15:36:49 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: nfs.h,v 1.75 2015/04/20 13:12:24 riastradh Exp $ */ +/* $NetBSD: nfs.h,v 1.76 2018/01/21 20:36:49 christos Exp $ */ /* * Copyright (c) 1989, 1993, 1995 * The Regents of the University of California. All rights reserved. @@ -341,6 +341,7 @@ struct nfsreq { * Queue head for nfsreq's */ extern TAILQ_HEAD(nfsreqhead, nfsreq) nfs_reqq; +extern kmutex_t nfs_reqq_lock; /* Flag values for r_flags */ #define R_TIMING 0x01 /* timing request (in mntp) */ Index: src/sys/nfs/nfs_clntsocket.c diff -u src/sys/nfs/nfs_clntsocket.c:1.5 src/sys/nfs/nfs_clntsocket.c:1.6 --- src/sys/nfs/nfs_clntsocket.c:1.5 Fri Jun 17 10:28:29 2016 +++ src/sys/nfs/nfs_clntsocket.c Sun Jan 21 15:36:49 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: nfs_clntsocket.c,v 1.5 2016/06/17 14:28:29 christos Exp $ */ +/* $NetBSD: nfs_clntsocket.c,v 1.6 2018/01/21 20:36:49 christos Exp $ */ /* * Copyright (c) 1989, 1991, 1993, 1995 @@ -39,7 +39,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: nfs_clntsocket.c,v 1.5 2016/06/17 14:28:29 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nfs_clntsocket.c,v 1.6 2018/01/21 20:36:49 christos Exp $"); #ifdef _KERNEL_OPT #include "opt_nfs.h" @@ -294,9 +294,11 @@ errout: rcvflg = 0; error = (*so->so_receive)(so, getnam, , mp, NULL, ); - if (error == EWOULDBLOCK && - (rep->r_flags & R_SOFTTERM)) -return (EINTR); + if (error == EWOULDBLOCK) { +int intr = nfs_sigintr(rep->r_nmp, rep, l); +if (intr) + error = intr; + } } while (error == EWOULDBLOCK); len -= auio.uio_resid; if (!error && *mp == NULL) @@ -403,6 +405,7 @@ nfsmout: * Iff no match, just drop the datagram */ s = splsoftnet(); + mutex_enter(_reqq_lock); TAILQ_FOREACH(rep, _reqq, r_chain) { if (rep->r_mrep != NULL || rxid != rep->r_xid) continue; @@ -468,6 +471,7 @@ nfsmout: nmp->nm_timeouts = 0; break; } + mutex_exit(_reqq_lock); splx(s); nfs_rcvunlock(nmp); /* @@ -653,7 +657,9 @@ tryagain: * to put it LAST so timer finds oldest requests first. */ s = splsoftnet(); + mutex_enter(_reqq_lock); TAILQ_INSERT_TAIL(_reqq, rep, r_chain); + mutex_exit(_reqq_lock); nfs_timer_start(); /* @@ -695,7 +701,9 @@ tryagain: * RPC done, unlink the request. */ s = splsoftnet(); + mutex_enter(_reqq_lock); TAILQ_REMOVE(_reqq, rep, r_chain); + mutex_exit(_reqq_lock); /* * Decrement the outstanding request count. Index: src/sys/nfs/nfs_socket.c diff -u src/sys/nfs/nfs_socket.c:1.198 src/sys/nfs/nfs_socket.c:1.199 --- src/sys/nfs/nfs_socket.c:1.198 Fri Jun 17 10:28:29 2016 +++ src/sys/nfs/nfs_socket.c Sun Jan 21 15:36:49 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: nfs_socket.c,v 1.198 2016/06/17 14:28:29 christos Exp $ */ +/* $NetBSD: nfs_socket.c,v 1.199 2018/01/21 20:36:49 christos Exp $ */ /* * Copyright (c) 1989, 1991, 1993, 1995 @@ -39,7 +39,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: nfs_socket.c,v 1.198 2016/06/17 14:28:29 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nfs_socket.c,v 1.199 2018/01/21 20:36:49 christos Exp $"); #ifdef _KERNEL_OPT #include "opt_nfs.h" @@ -166,6 +166,7 @@ int nfsrtton = 0; struct nfsrtt nfsrtt; static const int nfs_backoff[8] = { 2, 4, 8, 16, 32, 64, 128, 256, }; struct nfsreqhead nfs_reqq; +kmutex_t nfs_reqq_lock; static callout_t nfs_timer_ch; static struct evcnt nfs_timer_ev; static struct evcnt nfs_timer_start_ev; @@ -385,6 +386,7 @@ nfs_reconnect(struct nfsreq *rep) * on old socket. */ s = splsoftnet(); + mutex_enter(_reqq_lock); TAILQ_FOREACH(rp, _reqq, r_chain) { if (rp->r_nmp == nmp) { if ((rp->r_flags & R_MUSTRESEND) == 0) @@ -392,6 +394,7 @@ nfs_reconnect(struct nfsreq *rep) rp->r_rexmit = 0; } } + mutex_exit(_reqq_lock); splx(s); return (0); } @@ -759,7 +762,7 @@ nfs_timer(void *arg) nfs_timer_ev.ev_count++; - mutex_enter(softnet_lock); /* XXX PR 40491 */ + mutex_enter(_reqq_lock); TAILQ_FOREACH(rep, _reqq, r_chain) { more = true; nmp = rep->r_nmp; @@ -813,7 +816,7 @@ nfs_timer(void
CVS commit: [perseant-stdc-iso10646] src/lib/libc/citrus
Module Name:src Committed By: perseant Date: Sun Jan 21 19:35:10 UTC 2018 Added Files: src/lib/libc/citrus [perseant-stdc-iso10646]: citrus_trie.c citrus_trie.h Log Message: Add files missing from previous commit To generate a diff of this commit: cvs rdiff -u -r0 -r1.1.2.1 src/lib/libc/citrus/citrus_trie.c \ src/lib/libc/citrus/citrus_trie.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Added files: Index: src/lib/libc/citrus/citrus_trie.c diff -u /dev/null src/lib/libc/citrus/citrus_trie.c:1.1.2.1 --- /dev/null Sun Jan 21 19:35:10 2018 +++ src/lib/libc/citrus/citrus_trie.c Sun Jan 21 19:35:10 2018 @@ -0,0 +1,404 @@ +#include "citrus_trie.h" +#ifdef DEBUG_TRIE +# include "modules/citrus_euc_data.h" +# include "citrus_trie_test.h" +#endif + +static void citrus_trie_dump_table_recursive(citrus_trie_node_t, size_t, FILE *, int); +static void citrus_trie_load_table_recursive(citrus_trie_node_t, size_t, FILE *); +static void citrus_trie_init_recursive(citrus_trie_node_t *, VALUE_TYPE *, int, int *, int *); + +citrus_trie_header_t +citrus_trie_create(unsigned int flags, size_t bitwidth, + size_t nlevels, size_t off, size_t len) +{ + citrus_trie_header_t h; + + h = (citrus_trie_header_t)malloc(sizeof(*h)); + h->th_flags = flags; + h->th_bitwidth = bitwidth; + h->th_bitmask = (1 << bitwidth) - 1; + h->th_off = off; + h->th_level = nlevels - 1; +#ifdef DEBUG_TRIE + h->th_size = sizeof(*h); +#endif + h->th_root = citrus_trie_node_create(h, h->th_level, len); + + return h; +} + +citrus_trie_node_t +citrus_trie_node_create(citrus_trie_header_t h, size_t level, size_t len) +{ + int i; + citrus_trie_node_t t; + + t = (citrus_trie_node_t)citrus_trie_malloc(h, sizeof(*t)); + t->tr_len = len; + if (len > 0) { + t->tr_u = (union citrus_trie_node_union *)citrus_trie_malloc(h, len * sizeof(*t->tr_u)); + if (level == 0) { + for (i = 0; i < len; i++) +t->tr_u[i].u_value = INVALID_VALUE; + } else { + for (i = 0; i < len; i++) +t->tr_u[i].u_child = NULL; + } + } else + t->tr_u = NULL; + + return t; +} + +int +citrus_trie_node_insert(citrus_trie_header_t h, citrus_trie_node_t t, size_t level, citrus_trie_key_t key, VALUE_TYPE value) +{ + size_t idx, i, olen; + + idx = (key >> (level * h->th_bitwidth)) & h->th_bitmask; + if (idx < h->th_off) + return EINVAL; + + idx -= h->th_off; + if (t->tr_len <= idx) { + olen = t->tr_len; + t->tr_len = idx + 1; +#ifdef DEBUG_TRIE + h->th_size += (t->tr_len - olen) * sizeof(*t->tr_u); +#endif + t->tr_u = (union citrus_trie_node_union *)realloc(t->tr_u, t->tr_len * sizeof(*t->tr_u)); + for (i = olen; i < t->tr_len; i++) { + if (level == 0) +t->tr_u[i].u_value = INVALID_VALUE; + else +t->tr_u[i].u_child = NULL; + } + } + + if (level == 0) { + t->tr_u[idx].u_value = value; + return 0; + } else { + if (t->tr_u[idx].u_child == NULL) + t->tr_u[idx].u_child = citrus_trie_node_create(h, level - 1, 0); + return citrus_trie_node_insert(h, t->tr_u[idx].u_child, level - 1, + key, value); + } +} + +int +citrus_trie_insert(citrus_trie_header_t h, citrus_trie_key_t key, VALUE_TYPE value) +{ + int r = citrus_trie_node_insert(h, h->th_root, h->th_level, key, value); +#ifdef DEBUG_TRIE + int c = citrus_trie_lookup(h, key); + if (c != value) + fprintf(stderr, "Error on insert: key %x expected %x got %x\n", (unsigned)key, value, c); +#endif + return r; +} + +VALUE_TYPE +citrus_trie_node_lookup(citrus_trie_header_t h, citrus_trie_node_t t, size_t level, citrus_trie_key_t key) +{ + size_t idx; + + idx = (key >> (level * h->th_bitwidth)) & h->th_bitmask; + if (idx < h->th_off) + return INVALID_VALUE; + + idx -= h->th_off; + if (idx >= t->tr_len) + return INVALID_VALUE; + + if (level == 0) { + return t->tr_u[idx].u_value; + } + return citrus_trie_node_lookup(h, t->tr_u[idx].u_child, level - 1, key); +} + +VALUE_TYPE +citrus_trie_lookup(citrus_trie_header_t h, citrus_trie_key_t key) +{ + return citrus_trie_node_lookup(h, h->th_root, h->th_level, key); +} + +/* + * Assume VALUE_TYPE flat[N][2]. + */ +citrus_trie_header_t +citrus_trie_create_from_flat(VALUE_TYPE *flat, size_t bitwidth, int count) { + VALUE_TYPE ne_key; + int i, j; + unsigned val; + citrus_trie_header_t h; + size_t bitmask = (1 << bitwidth) - 1; + size_t maxshift = (8 * sizeof(VALUE_TYPE)) / bitwidth; + size_t min = bitmask, max = 0, level = 0; + + /* Loop through every element to see what + level, off and len should be */ + for (i = 0; i < count; i++) { + ne_key = flat[i * 2]; + for (j = 0; j < maxshift; j++) { + val = (ne_key >> (j * bitwidth)) & bitmask; + if (level < j + 1 && val) +level = j + 1; + if (min > val) +min = val; + if (max < val) +max = val; + } + } + + h = citrus_trie_create(0x0, bitwidth, level, min, max - min + 1); + + /* Now add every value */ + for (i = 0; i < count; i++) { + ne_key = flat[i * 2]; + + citrus_trie_insert(h, ne_key, flat[i * 2
CVS commit: src/sys/dev/pci
Module Name:src Committed By: sevan Date: Sun Jan 21 18:37:34 UTC 2018 Modified Files: src/sys/dev/pci: pcidevs.h pcidevs_data.h Log Message: regen To generate a diff of this commit: cvs rdiff -u -r1.1297 -r1.1298 src/sys/dev/pci/pcidevs.h cvs rdiff -u -r1.1296 -r1.1297 src/sys/dev/pci/pcidevs_data.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/pci/pcidevs.h diff -u src/sys/dev/pci/pcidevs.h:1.1297 src/sys/dev/pci/pcidevs.h:1.1298 --- src/sys/dev/pci/pcidevs.h:1.1297 Tue Jan 9 09:19:27 2018 +++ src/sys/dev/pci/pcidevs.h Sun Jan 21 18:37:33 2018 @@ -1,10 +1,10 @@ -/* $NetBSD: pcidevs.h,v 1.1297 2018/01/09 09:19:27 msaitoh Exp $ */ +/* $NetBSD: pcidevs.h,v 1.1298 2018/01/21 18:37:33 sevan Exp $ */ /* * THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT. * * generated from: - * NetBSD: pcidevs,v 1.1304 2018/01/09 09:19:05 msaitoh Exp + * NetBSD: pcidevs,v 1.1305 2018/01/21 18:33:56 sevan Exp */ /* @@ -5512,6 +5512,7 @@ #define PCI_PRODUCT_NVIDIA_GEFORCE4_MX440 0x0171 /* GeForce4 MX 440 */ #define PCI_PRODUCT_NVIDIA_GEFORCE4_MX420 0x0172 /* GeForce4 MX 420 */ #define PCI_PRODUCT_NVIDIA_GF4_MX440_SE 0x0173 /* GeForce4 MX 440 SE */ +#define PCI_PRODUCT_NVIDIA_GF4_MX440_GO 0x0174 /* GeForce4 MX 440 Go */ #define PCI_PRODUCT_NVIDIA_QUADRO4_500XGL 0x0178 /* Quadro4 500XGL */ #define PCI_PRODUCT_NVIDIA_QUADRO4_200NVS 0x017a /* Quadro4 200/400NVS */ #define PCI_PRODUCT_NVIDIA_GF4_MX440_8X 0x0181 /* GeForce4 MX 440 (AGP8X) */ Index: src/sys/dev/pci/pcidevs_data.h diff -u src/sys/dev/pci/pcidevs_data.h:1.1296 src/sys/dev/pci/pcidevs_data.h:1.1297 --- src/sys/dev/pci/pcidevs_data.h:1.1296 Tue Jan 9 09:19:27 2018 +++ src/sys/dev/pci/pcidevs_data.h Sun Jan 21 18:37:33 2018 @@ -1,10 +1,10 @@ -/* $NetBSD: pcidevs_data.h,v 1.1296 2018/01/09 09:19:27 msaitoh Exp $ */ +/* $NetBSD: pcidevs_data.h,v 1.1297 2018/01/21 18:37:33 sevan Exp $ */ /* * THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT. * * generated from: - * NetBSD: pcidevs,v 1.1304 2018/01/09 09:19:05 msaitoh Exp + * NetBSD: pcidevs,v 1.1305 2018/01/21 18:33:56 sevan Exp */ /* @@ -9521,6 +9521,8 @@ static const uint16_t pci_products[] = { 26884, 26817, 26901, 0, PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF4_MX440_SE, 26884, 26817, 26897, 26905, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF4_MX440_GO, + 26884, 26817, 26897, 26828, 0, PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADRO4_500XGL, 26774, 26908, 0, PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADRO4_200NVS, @@ -15861,9 +15863,9 @@ static const char pci_words[] = { "." "4300\0" /* 1 refs @ 26799 */ "256\0" /* 1 refs @ 26804 */ "GeForce2\0" /* 7 refs @ 26808 */ - "MX\0" /* 10 refs @ 26817 */ + "MX\0" /* 11 refs @ 26817 */ "100/200\0" /* 1 refs @ 26820 */ - "Go\0" /* 5 refs @ 26828 */ + "Go\0" /* 6 refs @ 26828 */ "Quadro2\0" /* 2 refs @ 26831 */ "MXR/EX\0" /* 1 refs @ 26839 */ "6600\0" /* 5 refs @ 26846 */ @@ -15873,9 +15875,9 @@ static const char pci_words[] = { "." "(DDR)\0" /* 1 refs @ 26864 */ "6200TC\0" /* 1 refs @ 26870 */ "6200LE\0" /* 1 refs @ 26877 */ - "GeForce4\0" /* 15 refs @ 26884 */ + "GeForce4\0" /* 16 refs @ 26884 */ "460\0" /* 1 refs @ 26893 */ - "440\0" /* 4 refs @ 26897 */ + "440\0" /* 5 refs @ 26897 */ "420\0" /* 3 refs @ 26901 */ "SE\0" /* 4 refs @ 26905 */ "500XGL\0" /* 1 refs @ 26908 */
CVS commit: src/sys/dev/pci
Module Name:src Committed By: sevan Date: Sun Jan 21 18:33:56 UTC 2018 Modified Files: src/sys/dev/pci: pcidevs Log Message: Add the GeForce4 MX440 Go, as found on the 17" flat panel G4 iMac (PowerMac4,5). Thanks to Jasper Wallace for the loan of the hardware. To generate a diff of this commit: cvs rdiff -u -r1.1304 -r1.1305 src/sys/dev/pci/pcidevs 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/pci/pcidevs diff -u src/sys/dev/pci/pcidevs:1.1304 src/sys/dev/pci/pcidevs:1.1305 --- src/sys/dev/pci/pcidevs:1.1304 Tue Jan 9 09:19:05 2018 +++ src/sys/dev/pci/pcidevs Sun Jan 21 18:33:56 2018 @@ -1,4 +1,4 @@ -$NetBSD: pcidevs,v 1.1304 2018/01/09 09:19:05 msaitoh Exp $ +$NetBSD: pcidevs,v 1.1305 2018/01/21 18:33:56 sevan Exp $ /* * Copyright (c) 1995, 1996 Christopher G. Demetriou @@ -5505,6 +5505,7 @@ product NVIDIA GEFORCE4_MX460 0x0170 GeF product NVIDIA GEFORCE4_MX440 0x0171 GeForce4 MX 440 product NVIDIA GEFORCE4_MX420 0x0172 GeForce4 MX 420 product NVIDIA GF4_MX440_SE 0x0173 GeForce4 MX 440 SE +product NVIDIA GF4_MX440_GO 0x0174 GeForce4 MX 440 Go product NVIDIA QUADRO4_500XGL 0x0178 Quadro4 500XGL product NVIDIA QUADRO4_200NVS 0x017a Quadro4 200/400NVS product NVIDIA GF4_MX440_8X 0x0181 GeForce4 MX 440 (AGP8X)
CVS commit: src/sys/dev/pci
Module Name:src Committed By: christos Date: Sun Jan 21 18:12:37 UTC 2018 Modified Files: src/sys/dev/pci: if_iwm.c Log Message: CID-1427736: Appease coverity using KASSERT To generate a diff of this commit: cvs rdiff -u -r1.77 -r1.78 src/sys/dev/pci/if_iwm.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/pci/if_iwm.c diff -u src/sys/dev/pci/if_iwm.c:1.77 src/sys/dev/pci/if_iwm.c:1.78 --- src/sys/dev/pci/if_iwm.c:1.77 Wed Jan 10 13:39:50 2018 +++ src/sys/dev/pci/if_iwm.c Sun Jan 21 13:12:37 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: if_iwm.c,v 1.77 2018/01/10 18:39:50 mlelstv Exp $ */ +/* $NetBSD: if_iwm.c,v 1.78 2018/01/21 18:12:37 christos Exp $ */ /* OpenBSD: if_iwm.c,v 1.148 2016/11/19 21:07:08 stsp Exp */ #define IEEE80211_NO_HT /* @@ -106,7 +106,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_iwm.c,v 1.77 2018/01/10 18:39:50 mlelstv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_iwm.c,v 1.78 2018/01/21 18:12:37 christos Exp $"); #include #include @@ -5248,6 +5248,7 @@ iwm_fill_probe_req(struct iwm_softc *sc, memset(preq, 0, sizeof(*preq)); + KASSERT(ic->ic_des_esslen < sizeof(ic->ic_des_essid)); if (remain < sizeof(*wh) + 2 + ic->ic_des_esslen) return ENOBUFS;
CVS commit: src/sys/uvm
Module Name:src Committed By: christos Date: Sun Jan 21 17:58:43 UTC 2018 Modified Files: src/sys/uvm: uvm_physseg.c Log Message: CID-1427737: Pacify coverity using KASSERT To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/uvm/uvm_physseg.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_physseg.c diff -u src/sys/uvm/uvm_physseg.c:1.8 src/sys/uvm/uvm_physseg.c:1.9 --- src/sys/uvm/uvm_physseg.c:1.8 Sun Mar 19 19:30:39 2017 +++ src/sys/uvm/uvm_physseg.c Sun Jan 21 12:58:43 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: uvm_physseg.c,v 1.8 2017/03/19 23:30:39 riastradh Exp $ */ +/* $NetBSD: uvm_physseg.c,v 1.9 2018/01/21 17:58:43 christos Exp $ */ /* * Copyright (c) 1997 Charles D. Cranor and Washington University. @@ -1147,10 +1147,10 @@ uvm_physseg_seg_alloc_from_slab(uvm_phys struct uvm_physseg *seg; struct vm_page *pgs = NULL; - seg = HANDLE_TO_PHYSSEG_NODE(upm); - KASSERT(pages > 0); + seg = HANDLE_TO_PHYSSEG_NODE(upm); + if (__predict_false(seg->ext == NULL)) { /* * This is a situation unique to boot time. @@ -1161,7 +1161,10 @@ uvm_physseg_seg_alloc_from_slab(uvm_phys */ KASSERT(uvm.page_init_done != true); - seg->ext = HANDLE_TO_PHYSSEG_NODE(uvm_physseg_get_prev(upm))->ext; + uvm_physseg_t upmp = uvm_physseg_get_prev(upm); + KASSERT(upmp != UVM_PHYSSEG_TYPE_INVALID); + + seg->ext = HANDLE_TO_PHYSSEG_NODE(upmp)->ext; KASSERT(seg->ext != NULL); }
CVS commit: src/sys/dev
Module Name:src Committed By: christos Date: Sun Jan 21 17:34:33 UTC 2018 Modified Files: src/sys/dev: audio.c Log Message: CID-1427745: kill possible buffer overflows. To generate a diff of this commit: cvs rdiff -u -r1.450 -r1.451 src/sys/dev/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/dev/audio.c diff -u src/sys/dev/audio.c:1.450 src/sys/dev/audio.c:1.451 --- src/sys/dev/audio.c:1.450 Thu Jan 11 23:10:10 2018 +++ src/sys/dev/audio.c Sun Jan 21 12:34:33 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: audio.c,v 1.450 2018/01/12 04:10:10 nat Exp $ */ +/* $NetBSD: audio.c,v 1.451 2018/01/21 17:34:33 christos Exp $ */ /*- * Copyright (c) 2016 Nathanial Sloss@@ -148,7 +148,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.450 2018/01/12 04:10:10 nat Exp $"); +__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.451 2018/01/21 17:34:33 christos Exp $"); #ifdef _KERNEL_OPT #include "audio.h" @@ -5775,11 +5775,15 @@ audio_get_port(struct audio_softc *sc, m } +static void +unitscopy(mixer_devinfo_t *di, const char *name) +{ + strlcpy(di->un.v.units.name, name, sizeof(di->un.v.units.name)); +} + static int audio_query_devinfo(struct audio_softc *sc, mixer_devinfo_t *di) { - char mixLabel[255]; - KASSERT(mutex_owned(sc->sc_lock)); if (sc->sc_static_nmixer_states == 0 || sc->sc_nmixer_states == 0) @@ -5790,27 +5794,27 @@ audio_query_devinfo(struct audio_softc * if (di->index == sc->sc_static_nmixer_states - 1) { di->mixer_class = sc->sc_static_nmixer_states -1; di->next = di->prev = AUDIO_MIXER_LAST; - strcpy(di->label.name, AudioCvirtchan); + strlcpy(di->label.name, AudioCvirtchan, + sizeof(di->label.name)); di->type = AUDIO_MIXER_CLASS; } else if ((di->index - sc->sc_static_nmixer_states) % 2 == 0) { di->mixer_class = sc->sc_static_nmixer_states -1; - snprintf(mixLabel, sizeof(mixLabel), AudioNdac"%d", + snprintf(di->label.name, sizeof(di->label.name), + AudioNdac"%d", (di->index - sc->sc_static_nmixer_states) / 2); - strcpy(di->label.name, mixLabel); di->type = AUDIO_MIXER_VALUE; di->next = di->prev = AUDIO_MIXER_LAST; di->un.v.num_channels = 1; - strcpy(di->un.v.units.name, AudioNvolume); + unitscopy(di, AudioNvolume); } else { di->mixer_class = sc->sc_static_nmixer_states -1; - snprintf(mixLabel, sizeof(mixLabel), + snprintf(di->label.name, sizeof(di->label.name), AudioNmicrophone "%d", (di->index - sc->sc_static_nmixer_states) / 2); - strcpy(di->label.name, mixLabel); di->type = AUDIO_MIXER_VALUE; di->next = di->prev = AUDIO_MIXER_LAST; di->un.v.num_channels = 1; - strcpy(di->un.v.units.name, AudioNvolume); + unitscopy(di, AudioNvolume); } return 0;
CVS commit: src/sys/kern
Module Name:src Committed By: christos Date: Sun Jan 21 17:22:56 UTC 2018 Modified Files: src/sys/kern: core_elf32.c Log Message: CID-1427760: While overrun can't happen, make it obvious that it can't To generate a diff of this commit: cvs rdiff -u -r1.55 -r1.56 src/sys/kern/core_elf32.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/core_elf32.c diff -u src/sys/kern/core_elf32.c:1.55 src/sys/kern/core_elf32.c:1.56 --- src/sys/kern/core_elf32.c:1.55 Thu May 4 07:12:23 2017 +++ src/sys/kern/core_elf32.c Sun Jan 21 12:22:55 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: core_elf32.c,v 1.55 2017/05/04 11:12:23 kamil Exp $ */ +/* $NetBSD: core_elf32.c,v 1.56 2018/01/21 17:22:55 christos Exp $ */ /* * Copyright (c) 2001 Wasabi Systems, Inc. @@ -40,7 +40,7 @@ */ #include -__KERNEL_RCSID(1, "$NetBSD: core_elf32.c,v 1.55 2017/05/04 11:12:23 kamil Exp $"); +__KERNEL_RCSID(1, "$NetBSD: core_elf32.c,v 1.56 2018/01/21 17:22:55 christos Exp $"); #ifdef _KERNEL_OPT #include "opt_coredump.h" @@ -505,12 +505,12 @@ save_note_bytes(struct note_state *ns, c * All but the last buffer is full. */ for (;;) { - copylen = min(len, sizeof nb->nb_data - ns->ns_offset); + copylen = min(len, sizeof(nb->nb_data) - ns->ns_offset); wp = nb->nb_data + ns->ns_offset; memcpy(wp, data, copylen); if (copylen == len) break; - nb->nb_next = kmem_alloc(sizeof *nb->nb_next, KM_SLEEP); + nb->nb_next = kmem_alloc(sizeof(*nb->nb_next), KM_SLEEP); nb = nb->nb_next; ns->ns_last = nb; ns->ns_count++; @@ -519,8 +519,9 @@ save_note_bytes(struct note_state *ns, c data = (const unsigned char *)data + copylen; } - while (copylen & (ELFROUNDSIZE - 1)) - wp[copylen++] = 0; + while ((copylen & (ELFROUNDSIZE - 1)) && + wp + copylen < nb->nb_data + sizeof(nb->nb_data)) + wp[copylen++] = 0; ns->ns_offset += copylen; }
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: christos Date: Sun Jan 21 16:51:15 UTC 2018 Modified Files: src/sys/arch/amd64/amd64: db_disasm.c Log Message: CID-1364351: Fix uninitialized warnings. To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/sys/arch/amd64/amd64/db_disasm.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/amd64/amd64/db_disasm.c diff -u src/sys/arch/amd64/amd64/db_disasm.c:1.23 src/sys/arch/amd64/amd64/db_disasm.c:1.24 --- src/sys/arch/amd64/amd64/db_disasm.c:1.23 Fri Mar 25 06:14:43 2016 +++ src/sys/arch/amd64/amd64/db_disasm.c Sun Jan 21 11:51:14 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: db_disasm.c,v 1.23 2016/03/25 10:14:43 shm Exp $ */ +/* $NetBSD: db_disasm.c,v 1.24 2018/01/21 16:51:14 christos Exp $ */ /* * Mach Operating System @@ -33,7 +33,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: db_disasm.c,v 1.23 2016/03/25 10:14:43 shm Exp $"); +__KERNEL_RCSID(0, "$NetBSD: db_disasm.c,v 1.24 2018/01/21 16:51:14 christos Exp $"); #ifndef _KERNEL #include @@ -1376,20 +1376,33 @@ db_disasm(db_addr_t loc, bool altfmt) switch (i_mode & 0xFF) { case E: - db_print_address(seg, rex, size, ); - break; case Eind: - db_printf("*"); - db_print_address(seg, rex, size, ); - break; case Ed: - db_print_address(seg, rex, LONG, ); - break; case Ew: - db_print_address(seg, rex, WORD, ); - break; case Eb: - db_print_address(seg, rex, BYTE, ); + if (!ip->i_has_modrm) { +db_printf("Bad address mode %#x without modrm", +i_mode); +break; + } + switch (i_mode & 0xFF) { + case E: +db_print_address(seg, rex, size, ); +break; + case Eind: +db_printf("*"); +db_print_address(seg, rex, size, ); +break; + case Ed: +db_print_address(seg, rex, LONG, ); +break; + case Ew: +db_print_address(seg, rex, WORD, ); +break; + case Eb: +db_print_address(seg, rex, BYTE, ); +break; + } break; case R: { int ext = ((rex & REX_R) != 0);
CVS commit: src/sys/kern
Module Name:src Committed By: christos Date: Sun Jan 21 16:55:25 UTC 2018 Modified Files: src/sys/kern: subr_disk_mbr.c Log Message: CID-1427768: Off by one To generate a diff of this commit: cvs rdiff -u -r1.48 -r1.49 src/sys/kern/subr_disk_mbr.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_disk_mbr.c diff -u src/sys/kern/subr_disk_mbr.c:1.48 src/sys/kern/subr_disk_mbr.c:1.49 --- src/sys/kern/subr_disk_mbr.c:1.48 Sat Jan 6 22:35:43 2018 +++ src/sys/kern/subr_disk_mbr.c Sun Jan 21 11:55:25 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: subr_disk_mbr.c,v 1.48 2018/01/07 03:35:43 christos Exp $ */ +/* $NetBSD: subr_disk_mbr.c,v 1.49 2018/01/21 16:55:25 christos Exp $ */ /* * Copyright (c) 1982, 1986, 1988 Regents of the University of California. @@ -54,7 +54,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: subr_disk_mbr.c,v 1.48 2018/01/07 03:35:43 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: subr_disk_mbr.c,v 1.49 2018/01/21 16:55:25 christos Exp $"); #include #include @@ -724,7 +724,7 @@ setdisklabel(struct disklabel *olp, stru while (openmask != 0) { i = ffs(openmask) - 1; openmask &= ~(1 << i); - if (i > nlp->d_npartitions) + if (i >= nlp->d_npartitions) return (EBUSY); opp = >d_partitions[i]; npp = >d_partitions[i];
CVS commit: src/sys/arch/mips/mips
Module Name:src Committed By: flxd Date: Sun Jan 21 16:38:25 UTC 2018 Modified Files: src/sys/arch/mips/mips: bus_space_alignstride_chipdep.c Log Message: fix typo To generate a diff of this commit: cvs rdiff -u -r1.29 -r1.30 \ src/sys/arch/mips/mips/bus_space_alignstride_chipdep.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/mips/bus_space_alignstride_chipdep.c diff -u src/sys/arch/mips/mips/bus_space_alignstride_chipdep.c:1.29 src/sys/arch/mips/mips/bus_space_alignstride_chipdep.c:1.30 --- src/sys/arch/mips/mips/bus_space_alignstride_chipdep.c:1.29 Wed Jul 20 17:57:00 2016 +++ src/sys/arch/mips/mips/bus_space_alignstride_chipdep.c Sun Jan 21 16:38:25 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: bus_space_alignstride_chipdep.c,v 1.29 2016/07/20 17:57:00 macallan Exp $ */ +/* $NetBSD: bus_space_alignstride_chipdep.c,v 1.30 2018/01/21 16:38:25 flxd Exp $ */ /*- * Copyright (c) 1998, 2000, 2001 The NetBSD Foundation, Inc. @@ -86,7 +86,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: bus_space_alignstride_chipdep.c,v 1.29 2016/07/20 17:57:00 macallan Exp $"); +__KERNEL_RCSID(0, "$NetBSD: bus_space_alignstride_chipdep.c,v 1.30 2018/01/21 16:38:25 flxd Exp $"); #ifdef CHIP_EXTENT #include @@ -835,7 +835,7 @@ __BS(write_2)(void *v, bus_space_handle_ KASSERT((off & 1) == 0); h += CHIP_OFF16(off); -#if CHIP_ACCES_SIZE <= 2 +#if CHIP_ACCESS_SIZE <= 2 mips_sh(h, CHIP_SWAP16(val)); #else const int shift = (h & (CHIP_ACCESS_SIZE - 1)) * 8;
CVS commit: src/sys/net80211
Module Name:src Committed By: maxv Date: Sun Jan 21 14:18:21 UTC 2018 Modified Files: src/sys/net80211: ieee80211_node.h Log Message: Switch sp_timoff to u_int16_t, to prevent possible overflow in ieee80211_recv_mgmt_beacon(). Actually this field is unused. To generate a diff of this commit: cvs rdiff -u -r1.28 -r1.29 src/sys/net80211/ieee80211_node.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/net80211/ieee80211_node.h diff -u src/sys/net80211/ieee80211_node.h:1.28 src/sys/net80211/ieee80211_node.h:1.29 --- src/sys/net80211/ieee80211_node.h:1.28 Tue Jan 16 18:42:43 2018 +++ src/sys/net80211/ieee80211_node.h Sun Jan 21 14:18:21 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: ieee80211_node.h,v 1.28 2018/01/16 18:42:43 maxv Exp $ */ +/* $NetBSD: ieee80211_node.h,v 1.29 2018/01/21 14:18:21 maxv Exp $ */ /*- * Copyright (c) 2001 Atsushi Onoe * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting @@ -303,7 +303,7 @@ struct ieee80211_scanparams { u_int8_t sp_fhindex; u_int8_t sp_erp; u_int16_t sp_bintval; - u_int8_t sp_timoff; + u_int16_t sp_timoff; u_int8_t *sp_tim; u_int8_t *sp_tstamp; u_int8_t *sp_country;
CVS commit: src/sys/net80211
Module Name:src Committed By: maxv Date: Sun Jan 21 14:13:49 UTC 2018 Modified Files: src/sys/net80211: ieee80211_input.c Log Message: Appease the overflow check, 4 is enough. To generate a diff of this commit: cvs rdiff -u -r1.109 -r1.110 src/sys/net80211/ieee80211_input.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/net80211/ieee80211_input.c diff -u src/sys/net80211/ieee80211_input.c:1.109 src/sys/net80211/ieee80211_input.c:1.110 --- src/sys/net80211/ieee80211_input.c:1.109 Wed Jan 17 16:03:16 2018 +++ src/sys/net80211/ieee80211_input.c Sun Jan 21 14:13:49 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: ieee80211_input.c,v 1.109 2018/01/17 16:03:16 maxv Exp $ */ +/* $NetBSD: ieee80211_input.c,v 1.110 2018/01/21 14:13:49 maxv Exp $ */ /* * Copyright (c) 2001 Atsushi Onoe @@ -37,7 +37,7 @@ __FBSDID("$FreeBSD: src/sys/net80211/ieee80211_input.c,v 1.81 2005/08/10 16:22:29 sam Exp $"); #endif #ifdef __NetBSD__ -__KERNEL_RCSID(0, "$NetBSD: ieee80211_input.c,v 1.109 2018/01/17 16:03:16 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ieee80211_input.c,v 1.110 2018/01/21 14:13:49 maxv Exp $"); #endif #ifdef _KERNEL_OPT @@ -2141,7 +2141,7 @@ ieee80211_recv_mgmt_beacon(struct ieee80 break; case IEEE80211_ELEMID_TIM: /* XXX ATIM? */ - IEEE80211_VERIFY_LENGTH(frm[1], 5); + IEEE80211_VERIFY_LENGTH(frm[1], 4); scan.sp_tim = frm; scan.sp_timoff = frm - mtod(m0, u_int8_t *); break;
CVS commit: src/share/misc
Module Name:src Committed By: alnsn Date: Sun Jan 21 14:01:55 UTC 2018 Modified Files: src/share/misc: acronyms.comp Log Message: Add KASLR. To generate a diff of this commit: cvs rdiff -u -r1.188 -r1.189 src/share/misc/acronyms.comp Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/share/misc/acronyms.comp diff -u src/share/misc/acronyms.comp:1.188 src/share/misc/acronyms.comp:1.189 --- src/share/misc/acronyms.comp:1.188 Wed Jan 10 08:47:30 2018 +++ src/share/misc/acronyms.comp Sun Jan 21 14:01:55 2018 @@ -1,4 +1,4 @@ -$NetBSD: acronyms.comp,v 1.188 2018/01/10 08:47:30 pgoyette Exp $ +$NetBSD: acronyms.comp,v 1.189 2018/01/21 14:01:55 alnsn Exp $ 3WHS three-way handshake 8VSB 8-state vestigial side band modulation AA anti-aliasing @@ -650,6 +650,7 @@ JIT just in time JPEG Joint Photographic Experts Group JRE Java Runtime Environment JTAG joint test action group +KASLR kernel address space layout randomization KB keyboard KB kilobyte KBD keyboard
CVS commit: src/sys/dev/usb
Module Name:src Committed By: skrll Date: Sun Jan 21 13:57:12 UTC 2018 Modified Files: src/sys/dev/usb: if_athn_usb.c if_atu.c if_aue.c if_axe.c if_axen.c if_bwfm_usb.c if_cdce.c if_cue.c if_kue.c if_otus.c if_rum.c if_run.c if_smsc.c if_udav.c if_upgt.c if_upl.c if_ural.c if_url.c if_urndis.c if_urtw.c if_urtwn.c if_zyd.c irmce.c pseye.c ualea.c ubt.c ucom.c udsir.c ugen.c uhso.c uirda.c ulpt.c umass.c umidi.c uscanner.c usscanner.c ustir.c utoppy.c uvideo.c Log Message: PR kern/52931 Kernel panics with Atheros usb wireless interface Audit the flags to usbd_create_xfer so that USBD_FORCE_SHORT_XFER is supplied wherever such a transfer is setup. We can drop USBD_SHORT_XFER_OK as it has not bearing on number of TDs To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/sys/dev/usb/if_athn_usb.c \ src/sys/dev/usb/if_run.c cvs rdiff -u -r1.55 -r1.56 src/sys/dev/usb/if_atu.c \ src/sys/dev/usb/if_urtwn.c cvs rdiff -u -r1.141 -r1.142 src/sys/dev/usb/if_aue.c cvs rdiff -u -r1.83 -r1.84 src/sys/dev/usb/if_axe.c cvs rdiff -u -r1.11 -r1.12 src/sys/dev/usb/if_axen.c cvs rdiff -u -r1.3 -r1.4 src/sys/dev/usb/if_bwfm_usb.c \ src/sys/dev/usb/irmce.c cvs rdiff -u -r1.44 -r1.45 src/sys/dev/usb/if_cdce.c src/sys/dev/usb/if_zyd.c cvs rdiff -u -r1.76 -r1.77 src/sys/dev/usb/if_cue.c cvs rdiff -u -r1.90 -r1.91 src/sys/dev/usb/if_kue.c cvs rdiff -u -r1.31 -r1.32 src/sys/dev/usb/if_otus.c cvs rdiff -u -r1.58 -r1.59 src/sys/dev/usb/if_rum.c cvs rdiff -u -r1.32 -r1.33 src/sys/dev/usb/if_smsc.c cvs rdiff -u -r1.51 -r1.52 src/sys/dev/usb/if_udav.c cvs rdiff -u -r1.17 -r1.18 src/sys/dev/usb/if_upgt.c cvs rdiff -u -r1.60 -r1.61 src/sys/dev/usb/if_upl.c cvs rdiff -u -r1.52 -r1.53 src/sys/dev/usb/if_ural.c cvs rdiff -u -r1.56 -r1.57 src/sys/dev/usb/if_url.c cvs rdiff -u -r1.16 -r1.17 src/sys/dev/usb/if_urndis.c cvs rdiff -u -r1.13 -r1.14 src/sys/dev/usb/if_urtw.c cvs rdiff -u -r1.23 -r1.24 src/sys/dev/usb/pseye.c cvs rdiff -u -r1.8 -r1.9 src/sys/dev/usb/ualea.c cvs rdiff -u -r1.59 -r1.60 src/sys/dev/usb/ubt.c cvs rdiff -u -r1.119 -r1.120 src/sys/dev/usb/ucom.c cvs rdiff -u -r1.5 -r1.6 src/sys/dev/usb/udsir.c cvs rdiff -u -r1.136 -r1.137 src/sys/dev/usb/ugen.c cvs rdiff -u -r1.26 -r1.27 src/sys/dev/usb/uhso.c cvs rdiff -u -r1.42 -r1.43 src/sys/dev/usb/uirda.c \ src/sys/dev/usb/usscanner.c cvs rdiff -u -r1.98 -r1.99 src/sys/dev/usb/ulpt.c cvs rdiff -u -r1.162 -r1.163 src/sys/dev/usb/umass.c cvs rdiff -u -r1.73 -r1.74 src/sys/dev/usb/umidi.c cvs rdiff -u -r1.81 -r1.82 src/sys/dev/usb/uscanner.c cvs rdiff -u -r1.38 -r1.39 src/sys/dev/usb/ustir.c cvs rdiff -u -r1.29 -r1.30 src/sys/dev/usb/utoppy.c cvs rdiff -u -r1.45 -r1.46 src/sys/dev/usb/uvideo.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/usb/if_athn_usb.c diff -u src/sys/dev/usb/if_athn_usb.c:1.24 src/sys/dev/usb/if_athn_usb.c:1.25 --- src/sys/dev/usb/if_athn_usb.c:1.24 Wed Oct 18 16:01:58 2017 +++ src/sys/dev/usb/if_athn_usb.c Sun Jan 21 13:57:11 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: if_athn_usb.c,v 1.24 2017/10/18 16:01:58 jmcneill Exp $ */ +/* $NetBSD: if_athn_usb.c,v 1.25 2018/01/21 13:57:11 skrll Exp $ */ /* $OpenBSD: if_athn_usb.c,v 1.12 2013/01/14 09:50:31 jsing Exp $ */ /*- @@ -22,7 +22,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_athn_usb.c,v 1.24 2017/10/18 16:01:58 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_athn_usb.c,v 1.25 2018/01/21 13:57:11 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -671,7 +671,7 @@ athn_usb_alloc_rx_list(struct athn_usb_s data->sc = usc; /* Backpointer for callbacks. */ error = usbd_create_xfer(usc->usc_rx_data_pipe, - ATHN_USB_RXBUFSZ, USBD_SHORT_XFER_OK, 0, >xfer); + ATHN_USB_RXBUFSZ, 0, 0, >xfer); if (error) { aprint_error_dev(usc->usc_dev, "could not allocate xfer\n"); @@ -718,7 +718,7 @@ athn_usb_alloc_tx_list(struct athn_usb_s data->sc = usc; /* Backpointer for callbacks. */ error = usbd_create_xfer(usc->usc_tx_data_pipe, - ATHN_USB_TXBUFSZ, USBD_SHORT_XFER_OK, 0, >xfer); + ATHN_USB_TXBUFSZ, USBD_FORCE_SHORT_XFER, 0, >xfer); if (error) { aprint_error_dev(usc->usc_dev, "could not create xfer on TX pipe\n"); Index: src/sys/dev/usb/if_run.c diff -u src/sys/dev/usb/if_run.c:1.24 src/sys/dev/usb/if_run.c:1.25 --- src/sys/dev/usb/if_run.c:1.24 Fri Nov 17 13:08:48 2017 +++ src/sys/dev/usb/if_run.c Sun Jan 21 13:57:12 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: if_run.c,v 1.24 2017/11/17 13:08:48 skrll Exp $ */ +/* $NetBSD: if_run.c,v 1.25 2018/01/21 13:57:12 skrll Exp $ */ /* $OpenBSD: if_run.c,v 1.90 2012/03/24 15:11:04 jsg Exp $ */ /*- @@ -23,7 +23,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_run.c,v 1.24 2017/11/17 13:08:48 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_run.c,v 1.25 2018/01/21 13:57:12 skrll Exp $"); #ifdef
CVS commit: src/sys/arch/amd64
Module Name:src Committed By: maxv Date: Sun Jan 21 11:21:40 UTC 2018 Modified Files: src/sys/arch/amd64/amd64: amd64_trap.S locore.S machdep.c vector.S src/sys/arch/amd64/conf: kern.ldscript kern.ldscript.kaslr src/sys/arch/amd64/include: frameasm.h Log Message: Unmap the kernel from userland in SVS, and leave only the needed trampolines. As explained below, SVS should now completely mitigate Meltdown on GENERIC kernels, even though it needs some more tweaking for GENERIC_KASLR. Until now the kernel entry points looked like: FUNC(intr) pushq $ERR pushq $TRAPNO INTRENTRY ... handle interrupt ... INTRFASTEXIT END(intr) With this change they are split and become: FUNC(handle) ... handle interrupt ... INTRFASTEXIT END(handle) TEXT_USER_BEGIN FUNC(intr) pushq $ERR pushq $TRAPNO INTRENTRY jmp handle END(intr) TEXT_USER_END A new section is introduced, .text.user, that contains minimal kernel entry/exit points. In order to choose what to put in this section, two macros are introduced, TEXT_USER_BEGIN and TEXT_USER_END. The section is mapped in userland with normal 4K pages. In GENERIC, the section is 4K-page-aligned and embedded in .text, which is mapped with large pages. That is to say, when an interrupt comes in, the CPU has the user page tables loaded and executes the 'intr' functions on 4K pages; after calling SVS_ENTER (in INTRENTRY) these 4K pages become 2MB large pages, and remain so when executing in kernel mode. In GENERIC_KASLR, the section is 4K-page-aligned and independent from the other kernel texts. The prekern just picks it up and maps it at a random address. In GENERIC, SVS should now completely mitigate Meltdown: what we put in .text.user is not secret. In GENERIC_KASLR, SVS would have to be improved a bit more: the 'jmp handle' instruction is actually secret, since it leaks the address of the section we are jumping into. By exploiting Meltdown on Intel, this theoretically allows a local user to reconstruct the address of the first text section. But given that our KASLR produces several texts, and that each section is not correlated with the others, the level of protection KASLR provides is still good. To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/sys/arch/amd64/amd64/amd64_trap.S cvs rdiff -u -r1.147 -r1.148 src/sys/arch/amd64/amd64/locore.S cvs rdiff -u -r1.294 -r1.295 src/sys/arch/amd64/amd64/machdep.c cvs rdiff -u -r1.55 -r1.56 src/sys/arch/amd64/amd64/vector.S cvs rdiff -u -r1.25 -r1.26 src/sys/arch/amd64/conf/kern.ldscript cvs rdiff -u -r1.4 -r1.5 src/sys/arch/amd64/conf/kern.ldscript.kaslr cvs rdiff -u -r1.30 -r1.31 src/sys/arch/amd64/include/frameasm.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/amd64/amd64/amd64_trap.S diff -u src/sys/arch/amd64/amd64/amd64_trap.S:1.22 src/sys/arch/amd64/amd64/amd64_trap.S:1.23 --- src/sys/arch/amd64/amd64/amd64_trap.S:1.22 Sat Jan 20 14:27:15 2018 +++ src/sys/arch/amd64/amd64/amd64_trap.S Sun Jan 21 11:21:40 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: amd64_trap.S,v 1.22 2018/01/20 14:27:15 maxv Exp $ */ +/* $NetBSD: amd64_trap.S,v 1.23 2018/01/21 11:21:40 maxv Exp $ */ /* * Copyright (c) 1998, 2007, 2008, 2017 The NetBSD Foundation, Inc. @@ -95,13 +95,19 @@ #define PRE_TRAP #endif +#define TRAPENTRY \ + INTRENTRY ; \ + jmp .Lalltraps_noentry + #define TRAP_NJ(a) PRE_TRAP ; pushq $(a) #define ZTRAP_NJ(a) PRE_TRAP ; pushq $0 ; pushq $(a) -#define TRAP(a) TRAP_NJ(a) ; jmp _C_LABEL(alltraps) -#define ZTRAP(a) ZTRAP_NJ(a) ; jmp _C_LABEL(alltraps) +#define TRAP(a) TRAP_NJ(a) ; TRAPENTRY +#define ZTRAP(a) ZTRAP_NJ(a) ; TRAPENTRY .text + TEXT_USER_BEGIN + IDTVEC(trap00) ZTRAP(T_DIVIDE) IDTVEC_END(trap00) @@ -361,24 +367,6 @@ IDTVEC(intrspurious) jmp .Lalltraps_checkusr IDTVEC_END(intrspurious) -/* - * trap() calls here when it detects a fault in INTRFASTEXIT (loading the - * segment registers or during the iret itself). The address of the (possibly - * reconstructed) user trap frame is passed as an argument. - * - * Typically the code will have raised a SIGSEGV which will be actioned - * by the code below. - */ - .type _C_LABEL(trap_return_fault_return), @function -LABEL(trap_return_fault_return) - mov %rdi,%rsp /* frame for user return */ -#ifdef DIAGNOSTIC - /* We can't recover the saved %rbx, so suppress warning */ - movl CPUVAR(ILEVEL),%ebx -#endif - jmp .Lalltraps_checkusr -END(trap_return_fault_return) - #ifndef check_swapgs /* * We need to worry about traps in kernel mode while the kernel %gs isn't @@ -423,12 +411,33 @@ NENTRY(check_swapgs) END(check_swapgs) #endif + TEXT_USER_END
CVS commit: src/sys/arch/amd64
Module Name:src Committed By: maxv Date: Sun Jan 21 10:59:21 UTC 2018 Modified Files: src/sys/arch/amd64/include: pmap.h src/sys/arch/amd64/stand/prekern: pdir.h Log Message: Increase the size of the initial mapping of the kernel. KASLR kernels are bigger than their GENERIC counterparts, and the limit will soon be hit on them. To generate a diff of this commit: cvs rdiff -u -r1.41 -r1.42 src/sys/arch/amd64/include/pmap.h cvs rdiff -u -r1.3 -r1.4 src/sys/arch/amd64/stand/prekern/pdir.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/amd64/include/pmap.h diff -u src/sys/arch/amd64/include/pmap.h:1.41 src/sys/arch/amd64/include/pmap.h:1.42 --- src/sys/arch/amd64/include/pmap.h:1.41 Sun Jan 7 16:10:16 2018 +++ src/sys/arch/amd64/include/pmap.h Sun Jan 21 10:59:21 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.h,v 1.41 2018/01/07 16:10:16 maxv Exp $ */ +/* $NetBSD: pmap.h,v 1.42 2018/01/21 10:59:21 maxv Exp $ */ /* * Copyright (c) 1997 Charles D. Cranor and Washington University. @@ -176,7 +176,7 @@ #define NKL4_KIMG_ENTRIES 1 #define NKL3_KIMG_ENTRIES 1 -#define NKL2_KIMG_ENTRIES 32 +#define NKL2_KIMG_ENTRIES 48 /* * Since kva space is below the kernel in its entirety, we start off Index: src/sys/arch/amd64/stand/prekern/pdir.h diff -u src/sys/arch/amd64/stand/prekern/pdir.h:1.3 src/sys/arch/amd64/stand/prekern/pdir.h:1.4 --- src/sys/arch/amd64/stand/prekern/pdir.h:1.3 Fri Nov 17 07:07:52 2017 +++ src/sys/arch/amd64/stand/prekern/pdir.h Sun Jan 21 10:59:21 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: pdir.h,v 1.3 2017/11/17 07:07:52 maxv Exp $ */ +/* $NetBSD: pdir.h,v 1.4 2018/01/21 10:59:21 maxv Exp $ */ /* * Copyright (c) 2017 The NetBSD Foundation, Inc. All rights reserved. @@ -46,7 +46,7 @@ #define NKL4_KIMG_ENTRIES 1 #define NKL3_KIMG_ENTRIES 1 -#define NKL2_KIMG_ENTRIES 32 +#define NKL2_KIMG_ENTRIES 48 /* * Now we define various constants for playing with virtual addresses.
CVS commit: src/sys/dev/wscons
Module Name:src Committed By: martin Date: Sun Jan 21 10:30:51 UTC 2018 Modified Files: src/sys/dev/wscons: wsemul_vt100.c Log Message: Try to fix previous to make it compile. To generate a diff of this commit: cvs rdiff -u -r1.43 -r1.44 src/sys/dev/wscons/wsemul_vt100.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/wscons/wsemul_vt100.c diff -u src/sys/dev/wscons/wsemul_vt100.c:1.43 src/sys/dev/wscons/wsemul_vt100.c:1.44 --- src/sys/dev/wscons/wsemul_vt100.c:1.43 Sun Jan 21 01:18:48 2018 +++ src/sys/dev/wscons/wsemul_vt100.c Sun Jan 21 10:30:51 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: wsemul_vt100.c,v 1.43 2018/01/21 01:18:48 christos Exp $ */ +/* $NetBSD: wsemul_vt100.c,v 1.44 2018/01/21 10:30:51 martin Exp $ */ /* * Copyright (c) 1998 @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wsemul_vt100.c,v 1.43 2018/01/21 01:18:48 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wsemul_vt100.c,v 1.44 2018/01/21 10:30:51 martin Exp $"); #ifdef _KERNEL_OPT #include "opt_wsmsgattrs.h" @@ -805,7 +805,6 @@ wsemul_vt100_output_dcs(struct wsemul_vt #endif vd->nargs = VT100_EMUL_NARGS; } - newstate = VT100_EMUL_STATE_STRING; switch (c) { case '$': return VT100_EMUL_STATE_DCS_DOLLAR; @@ -823,6 +822,7 @@ wsemul_vt100_output_dcs(struct wsemul_vt #endif break; } + return VT100_EMUL_STATE_STRING; } return VT100_EMUL_STATE_DCS;
CVS commit: src/sys/arch/powerpc/include
Module Name:src Committed By: mrg Date: Sun Jan 21 09:25:45 UTC 2018 Modified Files: src/sys/arch/powerpc/include: spr.h Log Message: fix some logic errors in the previous and fix non-kernel builds. To generate a diff of this commit: cvs rdiff -u -r1.49 -r1.50 src/sys/arch/powerpc/include/spr.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/spr.h diff -u src/sys/arch/powerpc/include/spr.h:1.49 src/sys/arch/powerpc/include/spr.h:1.50 --- src/sys/arch/powerpc/include/spr.h:1.49 Sun Jan 21 08:46:48 2018 +++ src/sys/arch/powerpc/include/spr.h Sun Jan 21 09:25:45 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: spr.h,v 1.49 2018/01/21 08:46:48 mrg Exp $ */ +/* $NetBSD: spr.h,v 1.50 2018/01/21 09:25:45 mrg Exp $ */ /* * Copyright (c) 2001, The NetBSD Foundation, Inc. @@ -28,7 +28,7 @@ #ifndef _POWERPC_SPR_H_ #define _POWERPC_SPR_H_ -#ifndef _LOCORE +#if !defined(_LOCORE) && defined(_KERNEL) #include @@ -88,7 +88,7 @@ mtspr32(int reg, uint32_t val) static inline uint64_t mfspr(int reg) { - if ((oeacpufeat & OEACPU_64_BRIDGE) != 0) + if ((oeacpufeat & (OEACPU_64_BRIDGE|OEACPU_64)) != 0) return mfspr64(reg); return mfspr32(reg); } @@ -96,24 +96,24 @@ mfspr(int reg) /* This as an inline breaks as 'reg' ends up not being an immediate */ #define mtspr(reg, val) \ ( {\ - if ((oeacpufeat & OEACPU_64_BRIDGE) != 0) \ + if ((oeacpufeat & (OEACPU_64_BRIDGE|OEACPU_64)) != 0) \ mtspr64(reg, (uint64_t)val); \ else \ mtspr32(reg, val);\ } ) #else /* PPC_OEA + PPC_OEA64 + PPC_OEA64_BRIDGE != 1 */ -#if defined (PPC_OEA) || defined (PPC_OEA64_BRIDGE) -#define mfspr(r) mfspr32(r) -#define mtspr(r,v) mtspr32(r,v) -#else +#if defined(PPC_OEA64) || defined(PPC_OEA64_BRIDGE) #define mfspr(r) mfspr64(r) #define mtspr(r,v) mtspr64(r,v) +#else +#define mfspr(r) mfspr32(r) +#define mtspr(r,v) mtspr32(r,v) #endif #endif /* PPC_OEA + PPC_OEA64 + PPC_OEA64_BRIDGE > 1 */ -#endif /* _LOCORE */ +#endif /* !_LOCORE && _KERNEL */ /* * Special Purpose Register declarations.
CVS commit: src/sys/arch/powerpc
Module Name:src Committed By: mrg Date: Sun Jan 21 08:46:49 UTC 2018 Modified Files: src/sys/arch/powerpc/include: spr.h src/sys/arch/powerpc/oea: cpu_subr.c ofwoea_machdep.c Log Message: fix ofppc/pegasosII (and maybe others). don't assume PPC_OEA64_BRIDGE means we have a 64 bit cpu (code for 64 bit in bridge and normal 32 bit can co-exist due to fixups the early boot code does has, and ofppc builds GENERIC this way): - fix mtmsr()/mfmsr() to use the right method based upon the actually cpu booted on. - fix cpu_setup() to have 32 bit and 64 bit hid0 variables and operate on the right one based upon the current cpu. restore a minor optimisation of not writing hid0 if it didn't change. in set_timebase() check if OF_finddevice("/cpus/@0") failed and returned -1 before using it for OF_getprop(). To generate a diff of this commit: cvs rdiff -u -r1.48 -r1.49 src/sys/arch/powerpc/include/spr.h cvs rdiff -u -r1.87 -r1.88 src/sys/arch/powerpc/oea/cpu_subr.c cvs rdiff -u -r1.41 -r1.42 src/sys/arch/powerpc/oea/ofwoea_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/powerpc/include/spr.h diff -u src/sys/arch/powerpc/include/spr.h:1.48 src/sys/arch/powerpc/include/spr.h:1.49 --- src/sys/arch/powerpc/include/spr.h:1.48 Sat Jan 20 03:50:28 2018 +++ src/sys/arch/powerpc/include/spr.h Sun Jan 21 08:46:48 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: spr.h,v 1.48 2018/01/20 03:50:28 simonb Exp $ */ +/* $NetBSD: spr.h,v 1.49 2018/01/21 08:46:48 mrg Exp $ */ /* * Copyright (c) 2001, The NetBSD Foundation, Inc. @@ -29,50 +29,90 @@ #define _POWERPC_SPR_H_ #ifndef _LOCORE -#ifdef PPC_OEA64_BRIDGE +#include + +#if defined(PPC_OEA64_BRIDGE) || defined (_ARCH_PPC64) static inline uint64_t -mfspr(int reg) +mfspr64(int reg) { uint64_t ret; register_t h, l; - __asm volatile( "mfspr %0,%2;" \ - "srdi %1,%0,32;" \ + + __asm volatile( "mfspr %0,%2;" + "srdi %1,%0,32;" : "=r"(l), "=r"(h) : "K"(reg)); ret = ((uint64_t)h << 32) | l; return ret; } -#define mtspr(reg, v) \ -( { \ - volatile register_t h, l; \ - uint64_t val = v; \ - h = (val >> 32); \ - l = val & 0x; \ - __asm volatile( \ - "sldi %2,%2,32;" \ - "or %2,%2,%1;" \ - "sync;" \ - "mtspr %0,%2;" \ - "mfspr %1,%0;" \ - "mfspr %1,%0;" \ - "mfspr %1,%0;" \ - "mfspr %1,%0;" \ - "mfspr %1,%0;" \ - "mfspr %1,%0;" \ - : : "K"(reg), "r"(l), "r"(h)); \ +/* This as an inline breaks as 'reg' ends up not being an immediate */ +#define mtspr64(reg, v) \ +( {\ + volatile register_t h, l;\ +\ + uint64_t val = v; \ + h = (val >> 32); \ + l = val & 0x; \ + __asm volatile( "sldi %2,%2,32;" \ + "or %2,%2,%1;"\ + "sync;" \ + "mtspr %0,%2;"\ + "mfspr %2,%0;"\ + "mfspr %2,%0;"\ + "mfspr %2,%0;"\ + "mfspr %2,%0;"\ + "mfspr %2,%0;"\ + "mfspr %2,%0;"\ + : : "K"(reg), "r"(l), "r"(h)); \ } ) +#endif /* PPC_OEA64_BRIDGE || _ARCH_PPC64 */ + +static inline uint64_t +mfspr32(int reg) +{ + register_t val; + __asm volatile("mfspr %0,%1" : "=r"(val) : "K"(reg)); + return val; +} + +static inline void +mtspr32(int reg, uint32_t val) +{ + + __asm volatile("mtspr %0,%1" : : "K"(reg), "r"(val)); +} + +#if (defined(PPC_OEA) + defined(PPC_OEA64) + defined(PPC_OEA64_BRIDGE)) > 1 +static inline uint64_t +mfspr(int reg) +{ + if ((oeacpufeat & OEACPU_64_BRIDGE) != 0) + return mfspr64(reg); + return mfspr32(reg); +} + +/* This as an inline breaks as 'reg' ends up not being an immediate */ +#define mtspr(reg, val) \ +( {\ + if ((oeacpufeat & OEACPU_64_BRIDGE) != 0) \ + mtspr64(reg, (uint64_t)val); \ + else \ + mtspr32(reg, val);\ +} ) +#else /* PPC_OEA + PPC_OEA64 + PPC_OEA64_BRIDGE != 1 */ + +#if defined (PPC_OEA) || defined (PPC_OEA64_BRIDGE) +#define mfspr(r) mfspr32(r) +#define mtspr(r,v) mtspr32(r,v) #else -#define mtspr(reg, val) \ - __asm volatile("mtspr %0,%1" : : "K"(reg), "r"(val)) -#ifdef __GNUC__ -#define mfspr(reg) \ - ( { register_t val; \ - __asm volatile("mfspr %0,%1" : "=r"(val) : "K"(reg)); \ - val; } ) +#define mfspr(r) mfspr64(r) +#define mtspr(r,v) mtspr64(r,v) #endif -#endif /* PPC_OEA64_BRIDGE */ + +#endif /* PPC_OEA + PPC_OEA64 + PPC_OEA64_BRIDGE > 1 */ + #endif /* _LOCORE */ /* Index: src/sys/arch/powerpc/oea/cpu_subr.c diff -u src/sys/arch/powerpc/oea/cpu_subr.c:1.87 src/sys/arch/powerpc/oea/cpu_subr.c:1.88 --- src/sys/arch/powerpc/oea/cpu_subr.c:1.87 Sat Jan 6 09:46:22 2018 +++ src/sys/arch/powerpc/oea/cpu_subr.c Sun Jan 21 08:46:48 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu_subr.c,v 1.87 2018/01/06 09:46:22 snj Exp $ */ +/* $NetBSD: cpu_subr.c,v 1.88 2018/01/21 08:46:48 mrg Exp $ */ /*- * Copyright (c) 2001 Matt Thomas. @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cpu_subr.c,v 1.87 2018/01/06
CVS commit: src/sys/arch/xen/conf
Module Name:src Committed By: maxv Date: Sun Jan 21 08:33:46 UTC 2018 Modified Files: src/sys/arch/xen/conf: Makefile.xen Log Message: Fix the build, on Xen too amd64_trap.S needs to be compiled independently. To generate a diff of this commit: cvs rdiff -u -r1.44 -r1.45 src/sys/arch/xen/conf/Makefile.xen 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/conf/Makefile.xen diff -u src/sys/arch/xen/conf/Makefile.xen:1.44 src/sys/arch/xen/conf/Makefile.xen:1.45 --- src/sys/arch/xen/conf/Makefile.xen:1.44 Tue Dec 12 08:27:32 2017 +++ src/sys/arch/xen/conf/Makefile.xen Sun Jan 21 08:33:46 2018 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.xen,v 1.44 2017/12/12 08:27:32 pgoyette Exp $ +# $NetBSD: Makefile.xen,v 1.45 2018/01/21 08:33:46 maxv Exp $ # NetBSD: Makefile.i386,v 1.132 2003/07/05 16:56:10 simonb Exp # Makefile for NetBSD @@ -66,6 +66,9 @@ KERN_AS= obj ## (4) local objects, compile rules, and dependencies ## MD_OBJS= locore.o spl.o copy.o vector.o +.if ${XEN_BUILD} == amd64 +MD_OBJS+= amd64_trap.o +.endif MD_CFILES= MD_SFILES= $S/arch/${XEN_BUILD}/${XEN_BUILD}/locore.S \ @@ -73,6 +76,10 @@ MD_SFILES= $S/arch/${XEN_BUILD}/${XEN_BU $S/arch/${XEN_BUILD}/${XEN_BUILD}/vector.S \ $S/arch/${XEN_BUILD}/${XEN_BUILD}/copy.S +.if ${XEN_BUILD} == amd64 +MD_SFILES+= $S/arch/${XEN_BUILD}/${XEN_BUILD}/amd64_trap.S +.endif + copy.o: $S/arch/${XEN_BUILD}/${XEN_BUILD}/copy.S assym.h ${NORMAL_S} @@ -84,6 +91,12 @@ spl.o: $S/arch/${XEN_BUILD}/${XEN_BUILD} vector.o: $S/arch/${XEN_BUILD}/${XEN_BUILD}/vector.S assym.h ${NORMAL_S} + +.if ${XEN_BUILD} == amd64 +amd64_trap.o: $S/arch/${XEN_BUILD}/${XEN_BUILD}/amd64_trap.S assym.h + ${NORMAL_S} +.endif + .ifndef noBEGIN .if !make(obj) && !make(clean) && !make(cleandir) .BEGIN::
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: maxv Date: Sun Jan 21 08:20:31 UTC 2018 Modified Files: src/sys/arch/amd64/amd64: machdep.c Log Message: Make it possible for SVS to map in the user page tables a 4K kernel page contained in a 2MB large page. Will be used soon. To generate a diff of this commit: cvs rdiff -u -r1.293 -r1.294 src/sys/arch/amd64/amd64/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/amd64/amd64/machdep.c diff -u src/sys/arch/amd64/amd64/machdep.c:1.293 src/sys/arch/amd64/amd64/machdep.c:1.294 --- src/sys/arch/amd64/amd64/machdep.c:1.293 Sat Jan 20 13:42:07 2018 +++ src/sys/arch/amd64/amd64/machdep.c Sun Jan 21 08:20:30 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.293 2018/01/20 13:42:07 maxv Exp $ */ +/* $NetBSD: machdep.c,v 1.294 2018/01/21 08:20:30 maxv Exp $ */ /* * Copyright (c) 1996, 1997, 1998, 2000, 2006, 2007, 2008, 2011 @@ -110,7 +110,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.293 2018/01/20 13:42:07 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.294 2018/01/21 08:20:30 maxv Exp $"); /* #define XENDEBUG_LOW */ @@ -2278,12 +2278,11 @@ struct svs_utls { static pd_entry_t * svs_tree_add(struct cpu_info *ci, vaddr_t va) { - extern pd_entry_t * const normal_pdes[]; extern const vaddr_t ptp_masks[]; extern const int ptp_shifts[]; extern const long nbpd[]; - pd_entry_t *srcpde, *dstpde; - size_t i, idx, pidx, mod; + pd_entry_t *dstpde; + size_t i, pidx, mod; struct vm_page *pg; paddr_t pa; @@ -2291,12 +2290,6 @@ svs_tree_add(struct cpu_info *ci, vaddr_ mod = (size_t)-1; for (i = PTP_LEVELS; i > 1; i--) { - idx = pl_i(va, i); - srcpde = normal_pdes[i - 2]; - - if (!pmap_valid_entry(srcpde[idx])) { - panic("%s: page not mapped", __func__); - } pidx = pl_i(va % mod, i); if (!pmap_valid_entry(dstpde[pidx])) { @@ -2320,19 +2313,44 @@ svs_tree_add(struct cpu_info *ci, vaddr_ static void svs_page_add(struct cpu_info *ci, vaddr_t va) { - pd_entry_t *srcpde, *dstpde; + pd_entry_t *srcpde, *dstpde, pde; size_t idx, pidx; + paddr_t pa; /* Create levels L4, L3 and L2. */ dstpde = svs_tree_add(ci, va); - /* Enter L1. */ + pidx = pl1_i(va % NBPD_L2); + + /* + * If 'va' is in a large page, we need to compute its physical + * address manually. + */ + idx = pl2_i(va); + srcpde = L2_BASE; + if (!pmap_valid_entry(srcpde[idx])) { + panic("%s: L2 page not mapped", __func__); + } + if (srcpde[idx] & PG_PS) { + pa = srcpde[idx] & PG_2MFRAME; + pa += (paddr_t)(va % NBPD_L2); + pde = (srcpde[idx] & ~(PG_PS|PG_2MFRAME)) | pa; + + if (pmap_valid_entry(dstpde[pidx])) { + panic("%s: L1 page already mapped", __func__); + } + dstpde[pidx] = pde; + return; + } + + /* + * Normal page, just copy the PDE. + */ idx = pl1_i(va); srcpde = L1_BASE; if (!pmap_valid_entry(srcpde[idx])) { panic("%s: L1 page not mapped", __func__); } - pidx = pl1_i(va % NBPD_L2); if (pmap_valid_entry(dstpde[pidx])) { panic("%s: L1 page already mapped", __func__); }