svn commit: r282337 - head/sys/kern
Author: bz Date: Sat May 2 08:31:16 2015 New Revision: 282337 URL: https://svnweb.freebsd.org/changeset/base/282337 Log: Fix an off-by-one bug in string/array handling which lead to memory overwrite and follow-up assertion errors on at least ARM after r282257, with nvp_magic being 0x6e7600: Assertion failed: ((nvp)-nvp_magic == 0x6e7670), function nvpair_name, file .../subr_nvpair.c, line 713. Sponsored by: DARPA/AFRL Modified: head/sys/kern/subr_nvpair.c Modified: head/sys/kern/subr_nvpair.c == --- head/sys/kern/subr_nvpair.c Sat May 2 04:19:11 2015(r282336) +++ head/sys/kern/subr_nvpair.c Sat May 2 08:31:16 2015(r282337) @@ -733,7 +733,7 @@ nvpair_allocv(const char *name, int type if (nvp != NULL) { nvp-nvp_name = (char *)(nvp + 1); memcpy(nvp-nvp_name, name, namelen); - nvp-nvp_name[namelen + 1] = '\0'; + nvp-nvp_name[namelen] = '\0'; nvp-nvp_type = type; nvp-nvp_data = data; nvp-nvp_datasize = datasize; ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r282338 - in head: etc/mtree usr.bin/soelim usr.bin/soelim/tests
Author: bapt Date: Sat May 2 11:09:58 2015 New Revision: 282338 URL: https://svnweb.freebsd.org/changeset/base/282338 Log: Add regression tests for soelim(1) Added: head/usr.bin/soelim/tests/ head/usr.bin/soelim/tests/Makefile (contents, props changed) head/usr.bin/soelim/tests/basic (contents, props changed) head/usr.bin/soelim/tests/basic.in (contents, props changed) head/usr.bin/soelim/tests/basic.out (contents, props changed) head/usr.bin/soelim/tests/nonexisting.in (contents, props changed) head/usr.bin/soelim/tests/soelim.sh (contents, props changed) Modified: head/etc/mtree/BSD.tests.dist head/usr.bin/soelim/Makefile Modified: head/etc/mtree/BSD.tests.dist == --- head/etc/mtree/BSD.tests.dist Sat May 2 08:31:16 2015 (r282337) +++ head/etc/mtree/BSD.tests.dist Sat May 2 11:09:58 2015 (r282338) @@ -546,6 +546,8 @@ regress.multitest.out .. .. +soelim +.. timeout .. tr Modified: head/usr.bin/soelim/Makefile == --- head/usr.bin/soelim/MakefileSat May 2 08:31:16 2015 (r282337) +++ head/usr.bin/soelim/MakefileSat May 2 11:09:58 2015 (r282338) @@ -1,5 +1,11 @@ # $FreeBSD$ +.include src.opts.mk + PROG= soelim +.if ${MK_TESTS} != no +SUBDIR+= tests +.endif + .include bsd.prog.mk Added: head/usr.bin/soelim/tests/Makefile == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/usr.bin/soelim/tests/Makefile Sat May 2 11:09:58 2015 (r282338) @@ -0,0 +1,13 @@ +# $FreeBSD$ + +TESTSDIR= ${TESTSBASE}/usr.bin/soelim + +ATF_TESTS_SH= soelim + +FILES= nonexisting.in \ + basic.in \ + basic \ + basic.out +FILESDIR= ${TESTSDIR} + +.include bsd.test.mk Added: head/usr.bin/soelim/tests/basic == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/usr.bin/soelim/tests/basic Sat May 2 11:09:58 2015 (r282338) @@ -0,0 +1 @@ +basic has been included Added: head/usr.bin/soelim/tests/basic.in == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/usr.bin/soelim/tests/basic.in Sat May 2 11:09:58 2015 (r282338) @@ -0,0 +1,3 @@ +This is a test +.so basic +end Added: head/usr.bin/soelim/tests/basic.out == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/usr.bin/soelim/tests/basic.out Sat May 2 11:09:58 2015 (r282338) @@ -0,0 +1,3 @@ +This is a test +basic has been included +end Added: head/usr.bin/soelim/tests/nonexisting.in == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/usr.bin/soelim/tests/nonexisting.inSat May 2 11:09:58 2015 (r282338) @@ -0,0 +1,3 @@ +This is a test +.so nonexistingfile +This is next Added: head/usr.bin/soelim/tests/soelim.sh == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/usr.bin/soelim/tests/soelim.sh Sat May 2 11:09:58 2015 (r282338) @@ -0,0 +1,96 @@ +# $FreeBSD$ + +atf_test_case stdin +stdin_head() +{ + atf_set descr stdin functionality +} + +stdin_body() +{ + # no file after .so + atf_check \ + -o inline:.so\n \ + -e empty \ + -s exit:0 \ + soelim -EOF +.so +EOF + + # only space after .so + atf_check \ + -o inline:.so \n \ + -e empty \ + -s exit:0 \ + soelim -EOF +.so +EOF + + # explicit stdin + atf_check \ + -o inline:.so\n \ + -e empty \ + -s exit:0 \ + soelim - -EOF +.so +EOF + + atf_check \ + -o empty \ + -e inline:soelim: can't open 'afile': No such file or directory\n \ + -s exit:1 \ + soelim -EOF +.so afile +EOF + + atf_check \ + -o inline:.soafile\n \ + -e empty \ + -s exit:0 \ + soelim -EOF +.soafile +EOF + + atf_check \ + -o empty \ + -e inline:soelim: can't open 'afile': No such file or directory\n \ + -s exit:1 \ + soelim -C -EOF +.soafile +EOF +} + +atf_test_case files +files_head() +{ + atf_set descr testing
svn commit: r282339 - in head: etc/mtree usr.bin/col usr.bin/col/tests
Author: bapt Date: Sat May 2 12:08:28 2015 New Revision: 282339 URL: https://svnweb.freebsd.org/changeset/base/282339 Log: Add regression test about reverse line feed to col(1) Added: head/usr.bin/col/tests/ head/usr.bin/col/tests/Makefile (contents, props changed) head/usr.bin/col/tests/col.sh (contents, props changed) head/usr.bin/col/tests/rlf.in (contents, props changed) head/usr.bin/col/tests/rlf2.in (contents, props changed) Modified: head/etc/mtree/BSD.tests.dist head/usr.bin/col/Makefile Modified: head/etc/mtree/BSD.tests.dist == --- head/etc/mtree/BSD.tests.dist Sat May 2 11:09:58 2015 (r282338) +++ head/etc/mtree/BSD.tests.dist Sat May 2 12:08:28 2015 (r282339) @@ -514,6 +514,8 @@ .. cmp .. +col +.. comm .. cut Modified: head/usr.bin/col/Makefile == --- head/usr.bin/col/Makefile Sat May 2 11:09:58 2015(r282338) +++ head/usr.bin/col/Makefile Sat May 2 12:08:28 2015(r282339) @@ -1,6 +1,12 @@ # @(#)Makefile8.1 (Berkeley) 6/6/93 # $FreeBSD$ +.include src.opts.mk + PROG= col +.if ${MK_TESTS} != no +SUBDIR+= tests +.endif + .include bsd.prog.mk Added: head/usr.bin/col/tests/Makefile == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/usr.bin/col/tests/Makefile Sat May 2 12:08:28 2015 (r282339) @@ -0,0 +1,11 @@ +# $FreeBSD$ + +TESTSDIR= ${TESTSBASE}/usr.bin/col + +ATF_TESTS_SH= col + +FILES= rlf.in \ + rlf2.in +FILESDIR= ${TESTSDIR} + +.include bsd.test.mk Added: head/usr.bin/col/tests/col.sh == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/usr.bin/col/tests/col.sh Sat May 2 12:08:28 2015 (r282339) @@ -0,0 +1,39 @@ +# $FreeBSD$ + +atf_test_case rlf + +rlf_head() +{ + atf_set descr testing reverse line feed +} +rlf_body() +{ + atf_check \ + -o inline:a b\n \ + -e empty \ + -s exit:0 \ + col $(atf_get_srcdir)/rlf.in + + atf_check \ + -o inline:ab3\n \ + -e empty \ + -s exit:0 \ + col $(atf_get_srcdir)/rlf2.in + + atf_check \ + -o inline:a b3\n \ + -e empty \ + -s exit:0 \ + col -x $(atf_get_srcdir)/rlf2.in + + atf_check \ + -o inline:ab3\n \ + -e empty \ + -s exit:0 \ + col -p $(atf_get_srcdir)/rlf2.in +} + +atf_init_test_cases() +{ + atf_add_test_case rlf +} Added: head/usr.bin/col/tests/rlf.in == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/usr.bin/col/tests/rlf.in Sat May 2 12:08:28 2015 (r282339) @@ -0,0 +1,2 @@ +a + 7b Added: head/usr.bin/col/tests/rlf2.in == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/usr.bin/col/tests/rlf2.in Sat May 2 12:08:28 2015 (r282339) @@ -0,0 +1,2 @@ +a + 7b ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r282343 - stable/9/sys/fs/nfsserver
Author: rmacklem Date: Sat May 2 12:58:04 2015 New Revision: 282343 URL: https://svnweb.freebsd.org/changeset/base/282343 Log: MFC: r281962 Fix the NFS server's handling of a bogus NFSv2 ROOT RPC. The ROOT RPC is deprecated in the NFSv2 RFC, RFC-1094 and should never be used by a client. Modified: stable/9/sys/fs/nfsserver/nfs_nfsdkrpc.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/fs/ (props changed) Modified: stable/9/sys/fs/nfsserver/nfs_nfsdkrpc.c == --- stable/9/sys/fs/nfsserver/nfs_nfsdkrpc.cSat May 2 12:22:24 2015 (r282342) +++ stable/9/sys/fs/nfsserver/nfs_nfsdkrpc.cSat May 2 12:58:04 2015 (r282343) @@ -120,7 +120,8 @@ nfssvc_program(struct svc_req *rqst, SVC memset(nd, 0, sizeof(nd)); if (rqst-rq_vers == NFS_VER2) { - if (rqst-rq_proc NFSV2PROC_STATFS) { + if (rqst-rq_proc NFSV2PROC_STATFS || + newnfs_nfsv3_procid[rqst-rq_proc] == NFSPROC_NOOP) { svcerr_noproc(rqst); svc_freereq(rqst); goto out; ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r282344 - head/usr.sbin/bhyve
Author: mav Date: Sat May 2 14:43:37 2015 New Revision: 282344 URL: https://svnweb.freebsd.org/changeset/base/282344 Log: Handle ATA_SEND_FPDMA_QUEUED as NCQ in ahci_port_stop(). MFC after:1 week Modified: head/usr.sbin/bhyve/pci_ahci.c Modified: head/usr.sbin/bhyve/pci_ahci.c == --- head/usr.sbin/bhyve/pci_ahci.c Sat May 2 12:58:04 2015 (r282343) +++ head/usr.sbin/bhyve/pci_ahci.c Sat May 2 14:43:37 2015 (r282344) @@ -418,7 +418,8 @@ ahci_port_stop(struct ahci_port *p) slot = aior-slot; cfis = aior-cfis; if (cfis[2] == ATA_WRITE_FPDMA_QUEUED || - cfis[2] == ATA_READ_FPDMA_QUEUED) + cfis[2] == ATA_READ_FPDMA_QUEUED || + cfis[2] == ATA_SEND_FPDMA_QUEUED) ncq = 1; if (ncq) ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r282345 - head/usr.sbin/bhyve
Author: mav Date: Sat May 2 16:11:29 2015 New Revision: 282345 URL: https://svnweb.freebsd.org/changeset/base/282345 Log: Initialize PxCMD on reset and make its read-only bits such. MFC after:2 weeks Modified: head/usr.sbin/bhyve/pci_ahci.c Modified: head/usr.sbin/bhyve/pci_ahci.c == --- head/usr.sbin/bhyve/pci_ahci.c Sat May 2 14:43:37 2015 (r282344) +++ head/usr.sbin/bhyve/pci_ahci.c Sat May 2 16:11:29 2015 (r282345) @@ -490,6 +490,9 @@ ahci_reset(struct pci_ahci_softc *sc) for (i = 0; i sc-ports; i++) { sc-port[i].ie = 0; sc-port[i].is = 0; + sc-port[i].cmd = (AHCI_P_CMD_SUD | AHCI_P_CMD_POD); + if (sc-port[i].bctx) + sc-port[i].cmd |= AHCI_P_CMD_CPS; sc-port[i].sctl = 0; ahci_port_reset(sc-port[i]); } @@ -1941,8 +1944,15 @@ pci_ahci_port_write(struct pci_ahci_soft break; case AHCI_P_CMD: { - p-cmd = value; - + p-cmd = ~(AHCI_P_CMD_ST | AHCI_P_CMD_SUD | AHCI_P_CMD_POD | + AHCI_P_CMD_CLO | AHCI_P_CMD_FRE | AHCI_P_CMD_APSTE | + AHCI_P_CMD_ATAPI | AHCI_P_CMD_DLAE | AHCI_P_CMD_ALPE | + AHCI_P_CMD_ASP | AHCI_P_CMD_ICC_MASK); + p-cmd |= (AHCI_P_CMD_ST | AHCI_P_CMD_SUD | AHCI_P_CMD_POD | + AHCI_P_CMD_CLO | AHCI_P_CMD_FRE | AHCI_P_CMD_APSTE | + AHCI_P_CMD_ATAPI | AHCI_P_CMD_DLAE | AHCI_P_CMD_ALPE | + AHCI_P_CMD_ASP | AHCI_P_CMD_ICC_MASK) value; + if (!(value AHCI_P_CMD_ST)) { ahci_port_stop(p); } else { @@ -1970,6 +1980,10 @@ pci_ahci_port_write(struct pci_ahci_soft p-cmd = ~AHCI_P_CMD_CLO; } + if (value AHCI_P_CMD_ICC_MASK) { + p-cmd = ~AHCI_P_CMD_ICC_MASK; + } + ahci_handle_port(p); break; } ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r282340 - stable/10/sys/fs/nfsserver
Author: rmacklem Date: Sat May 2 12:18:28 2015 New Revision: 282340 URL: https://svnweb.freebsd.org/changeset/base/282340 Log: MFC: r281962 Fix the NFS server's handling of a bogus NFSv2 ROOT RPC. The ROOT RPC is deprecated in the NFSv2 RFC, RFC-1094 and should never be used by a client. Modified: stable/10/sys/fs/nfsserver/nfs_nfsdkrpc.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/fs/nfsserver/nfs_nfsdkrpc.c == --- stable/10/sys/fs/nfsserver/nfs_nfsdkrpc.c Sat May 2 12:08:28 2015 (r282339) +++ stable/10/sys/fs/nfsserver/nfs_nfsdkrpc.c Sat May 2 12:18:28 2015 (r282340) @@ -120,7 +120,8 @@ nfssvc_program(struct svc_req *rqst, SVC memset(nd, 0, sizeof(nd)); if (rqst-rq_vers == NFS_VER2) { - if (rqst-rq_proc NFSV2PROC_STATFS) { + if (rqst-rq_proc NFSV2PROC_STATFS || + newnfs_nfsv3_procid[rqst-rq_proc] == NFSPROC_NOOP) { svcerr_noproc(rqst); svc_freereq(rqst); goto out; ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r282341 - head/usr.bin/col/tests
Author: bapt Date: Sat May 2 12:19:24 2015 New Revision: 282341 URL: https://svnweb.freebsd.org/changeset/base/282341 Log: Actually push the right tests Modified: head/usr.bin/col/tests/col.sh Modified: head/usr.bin/col/tests/col.sh == --- head/usr.bin/col/tests/col.sh Sat May 2 12:18:28 2015 (r282340) +++ head/usr.bin/col/tests/col.sh Sat May 2 12:19:24 2015 (r282341) @@ -15,22 +15,16 @@ rlf_body() col $(atf_get_srcdir)/rlf.in atf_check \ - -o inline:ab3\n \ + -o inline:ab\n \ -e empty \ -s exit:0 \ col $(atf_get_srcdir)/rlf2.in atf_check \ - -o inline:a b3\n \ + -o inline:a b\n \ -e empty \ -s exit:0 \ col -x $(atf_get_srcdir)/rlf2.in - - atf_check \ - -o inline:ab3\n \ - -e empty \ - -s exit:0 \ - col -p $(atf_get_srcdir)/rlf2.in } atf_init_test_cases() ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r282342 - head/usr.bin/col
Author: bapt Date: Sat May 2 12:22:24 2015 New Revision: 282342 URL: https://svnweb.freebsd.org/changeset/base/282342 Log: Capsicumize col(1) Modified: head/usr.bin/col/col.c Modified: head/usr.bin/col/col.c == --- head/usr.bin/col/col.c Sat May 2 12:19:24 2015(r282341) +++ head/usr.bin/col/col.c Sat May 2 12:22:24 2015(r282342) @@ -45,11 +45,15 @@ static char sccsid[] = @(#)col.c 8.5 (B #include sys/cdefs.h __FBSDID($FreeBSD$); +#include sys/capsicum.h + #include err.h +#include errno.h #include locale.h #include stdio.h #include stdlib.h #include string.h +#include termios.h #include unistd.h #include wchar.h #include wctype.h @@ -129,9 +133,24 @@ main(int argc, char **argv) int this_line; /* line l points to */ int nflushd_lines; /* number of lines that were flushed */ int adjust, opt, warned, width; + cap_rights_t rights; + unsigned long cmd; (void)setlocale(LC_CTYPE, ); + cap_rights_init(rights, CAP_FSTAT, CAP_READ); + if (cap_rights_limit(STDIN_FILENO, rights) 0 errno != ENOSYS) + err(1, unable to limit rights for stdin); + cap_rights_init(rights, CAP_FSTAT, CAP_WRITE, CAP_IOCTL); + if (cap_rights_limit(STDOUT_FILENO, rights) 0 errno != ENOSYS) + err(1, unable to limit rights for stdout); + cmd = TIOCGETA; /* required by isatty(3) in printf(3) */ + if (cap_ioctls_limit(STDOUT_FILENO, cmd, 1) 0 errno != ENOSYS) + err(1, unable to limit ioctls for stdout); + + if (cap_enter() 0 errno != ENOSYS) + err(1, unable to enter capability mode); + max_bufd_lines = 128; compress_spaces = 1;/* compress spaces into tabs */ while ((opt = getopt(argc, argv, bfhl:px)) != -1) ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r282346 - in head: lib/libcapsicum lib/libcasper lib/libnv lib/libnv/tests sbin/casperd sys/dev/pci sys/kern sys/sys usr.sbin/iovctl
Author: oshogbo Date: Sat May 2 17:45:52 2015 New Revision: 282346 URL: https://svnweb.freebsd.org/changeset/base/282346 Log: Approved, oprócz użycie RESTORE_ERRNO() do ustawiania errno. Change the nvlist_recv() function to take additional argument that specifies flags expected on the received nvlist. Receiving a nvlist with different set of flags than the ones we expect might lead to undefined behaviour, which might be potentially dangerous. Update consumers of this and related functions and update the tests. Approved by: pjd (mentor) Update man page for nvlist_unpack, nvlist_recv, nvlist_xfer, cap_recv_nvlist and cap_xfer_nvlist. Reviewed by: AllanJude Approved by: pjd (mentor) Modified: head/lib/libcapsicum/libcapsicum.3 head/lib/libcapsicum/libcapsicum.c head/lib/libcapsicum/libcapsicum.h head/lib/libcapsicum/libcapsicum_dns.c head/lib/libcapsicum/libcapsicum_grp.c head/lib/libcapsicum/libcapsicum_pwd.c head/lib/libcapsicum/libcapsicum_random.c head/lib/libcapsicum/libcapsicum_service.c head/lib/libcapsicum/libcapsicum_sysctl.c head/lib/libcasper/libcasper.c head/lib/libnv/nv.3 head/lib/libnv/tests/nv_tests.cc head/lib/libnv/tests/nvlist_send_recv_test.c head/sbin/casperd/casperd.c head/sbin/casperd/zygote.c head/sys/dev/pci/pci_iov.c head/sys/kern/subr_nvlist.c head/sys/sys/nv.h head/usr.sbin/iovctl/iovctl.c Modified: head/lib/libcapsicum/libcapsicum.3 == --- head/lib/libcapsicum/libcapsicum.3 Sat May 2 16:11:29 2015 (r282345) +++ head/lib/libcapsicum/libcapsicum.3 Sat May 2 17:45:52 2015 (r282346) @@ -27,7 +27,7 @@ .\ .\ $FreeBSD$ .\ -.Dd April 14, 2014 +.Dd May 2, 2015 .Dt LIBCAPSICUM 3 .Os .Sh NAME @@ -68,9 +68,9 @@ .Ft int .Fn cap_send_nvlist const cap_channel_t *chan const nvlist_t *nvl .Ft nvlist_t * -.Fn cap_recv_nvlist const cap_channel_t *chan +.Fn cap_recv_nvlist const cap_channel_t *chan int flags .Ft nvlist_t * -.Fn cap_xfer_nvlist const cap_channel_t *chan nvlist_t *nvl +.Fn cap_xfer_nvlist const cap_channel_t *chan nvlist_t *nvl int flags .In libcapsicum_service.h .Ft cap_channel_t * .Fn cap_service_open const cap_channel_t *chan const char *name @@ -171,11 +171,23 @@ Most services should provide higher leve The .Fn cap_recv_nvlist function receives the given nvlist over the given capability. +The +.Fa flags +argument defines what type the top nvlist is expected to be. +If the nvlist flags do not match the flags passed to +.Fn cap_recv_nvlist , +the nvlist will not be returned. .Pp The .Fn cap_xfer_nvlist function sends the given nvlist, destroys it and receives new nvlist in response over the given capability. +The +.Fa flags +argument defines what type the top nvlist is expected to be. +If the nvlist flags do not match the flags passed to +.Fn cap_xfer_nvlist , +the nvlist will not be returned. It does not matter if the function succeeds or fails, the nvlist given for sending will always be destroyed once the function returns. .Pp Modified: head/lib/libcapsicum/libcapsicum.c == --- head/lib/libcapsicum/libcapsicum.c Sat May 2 16:11:29 2015 (r282345) +++ head/lib/libcapsicum/libcapsicum.c Sat May 2 17:45:52 2015 (r282346) @@ -142,7 +142,7 @@ cap_clone(const cap_channel_t *chan) nvl = nvlist_create(0); nvlist_add_string(nvl, cmd, clone); - nvl = cap_xfer_nvlist(chan, nvl); + nvl = cap_xfer_nvlist(chan, nvl, 0); if (nvl == NULL) return (NULL); if (nvlist_get_number(nvl, error) != 0) { @@ -195,7 +195,7 @@ cap_limit_set(const cap_channel_t *chan, nvlmsg = nvlist_create(0); nvlist_add_string(nvlmsg, cmd, limit_set); nvlist_add_nvlist(nvlmsg, limits, limits); - nvlmsg = cap_xfer_nvlist(chan, nvlmsg); + nvlmsg = cap_xfer_nvlist(chan, nvlmsg, 0); if (nvlmsg == NULL) { nvlist_destroy(limits); return (-1); @@ -218,7 +218,7 @@ cap_limit_get(const cap_channel_t *chan, nvlmsg = nvlist_create(0); nvlist_add_string(nvlmsg, cmd, limit_get); - nvlmsg = cap_xfer_nvlist(chan, nvlmsg); + nvlmsg = cap_xfer_nvlist(chan, nvlmsg, 0); if (nvlmsg == NULL) return (-1); error = (int)nvlist_get_number(nvlmsg, error); @@ -246,21 +246,21 @@ cap_send_nvlist(const cap_channel_t *cha } nvlist_t * -cap_recv_nvlist(const cap_channel_t *chan) +cap_recv_nvlist(const cap_channel_t *chan, int flags) { assert(chan != NULL); assert(chan-cch_magic == CAP_CHANNEL_MAGIC); - return (nvlist_recv(chan-cch_sock)); + return (nvlist_recv(chan-cch_sock, flags)); } nvlist_t * -cap_xfer_nvlist(const cap_channel_t *chan, nvlist_t *nvl) +cap_xfer_nvlist(const cap_channel_t *chan, nvlist_t *nvl, int flags) {
svn commit: r282347 - in head: lib/libnv sys/kern sys/sys
Author: oshogbo Date: Sat May 2 18:03:47 2015 New Revision: 282347 URL: https://svnweb.freebsd.org/changeset/base/282347 Log: Introduce the NV_FLAG_NO_UNIQUE flag. When set, it allows to store multiple values using the same key in a nvlist. Approved by: pjd (mentor) Obtained from:WHEEL Systems (http://www.wheelsystems.com) Update man page. Reviewed by: AllanJude Approved by: pjd (mentor) Modified: head/lib/libnv/nv.3 head/sys/kern/subr_nvlist.c head/sys/kern/subr_nvpair.c head/sys/sys/nv.h Modified: head/lib/libnv/nv.3 == --- head/lib/libnv/nv.3 Sat May 2 17:45:52 2015(r282346) +++ head/lib/libnv/nv.3 Sat May 2 18:03:47 2015(r282347) @@ -232,6 +232,8 @@ The following flag can be provided: .Bl -tag -width NV_FLAG_IGNORE_CASE -compact -offset indent .It Dv NV_FLAG_IGNORE_CASE Perform case-insensitive lookups of provided names. +.It Dv NV_FLAG_NO_UNIQUE +Names in the nvlist do not have to be unique. .El .Pp The Modified: head/sys/kern/subr_nvlist.c == --- head/sys/kern/subr_nvlist.c Sat May 2 17:45:52 2015(r282346) +++ head/sys/kern/subr_nvlist.c Sat May 2 18:03:47 2015(r282347) @@ -88,7 +88,7 @@ __FBSDID($FreeBSD$); #endif #defineNV_FLAG_PRIVATE_MASK(NV_FLAG_BIG_ENDIAN) -#defineNV_FLAG_PUBLIC_MASK (NV_FLAG_IGNORE_CASE) +#defineNV_FLAG_PUBLIC_MASK (NV_FLAG_IGNORE_CASE | NV_FLAG_NO_UNIQUE) #defineNV_FLAG_ALL_MASK(NV_FLAG_PRIVATE_MASK | NV_FLAG_PUBLIC_MASK) #defineNVLIST_MAGIC0x6e766c/* nvl */ @@ -1074,10 +1074,12 @@ nvlist_add_nvpair(nvlist_t *nvl, const n ERRNO_SET(nvlist_error(nvl)); return; } - if (nvlist_exists(nvl, nvpair_name(nvp))) { - nvl-nvl_error = EEXIST; - ERRNO_SET(nvlist_error(nvl)); - return; + if ((nvl-nvl_flags NV_FLAG_NO_UNIQUE) == 0) { + if (nvlist_exists(nvl, nvpair_name(nvp))) { + nvl-nvl_error = EEXIST; + ERRNO_SET(nvlist_error(nvl)); + return; + } } newnvp = nvpair_clone(nvp); @@ -1266,11 +1268,13 @@ nvlist_move_nvpair(nvlist_t *nvl, nvpair ERRNO_SET(nvlist_error(nvl)); return; } - if (nvlist_exists(nvl, nvpair_name(nvp))) { - nvpair_free(nvp); - nvl-nvl_error = EEXIST; - ERRNO_SET(nvl-nvl_error); - return; + if ((nvl-nvl_flags NV_FLAG_NO_UNIQUE) == 0) { + if (nvlist_exists(nvl, nvpair_name(nvp))) { + nvpair_free(nvp); + nvl-nvl_error = EEXIST; + ERRNO_SET(nvl-nvl_error); + return; + } } nvpair_insert(nvl-nvl_head, nvp, nvl); Modified: head/sys/kern/subr_nvpair.c == --- head/sys/kern/subr_nvpair.c Sat May 2 17:45:52 2015(r282346) +++ head/sys/kern/subr_nvpair.c Sat May 2 18:03:47 2015(r282347) @@ -143,7 +143,8 @@ nvpair_insert(struct nvl_head *head, nvp NVPAIR_ASSERT(nvp); PJDLOG_ASSERT(nvp-nvp_list == NULL); - PJDLOG_ASSERT(!nvlist_exists(nvl, nvpair_name(nvp))); + PJDLOG_ASSERT((nvlist_flags(nvl) NV_FLAG_NO_UNIQUE) != 0 || + !nvlist_exists(nvl, nvpair_name(nvp))); TAILQ_INSERT_TAIL(head, nvp, nvp_next); nvp-nvp_list = nvl; Modified: head/sys/sys/nv.h == --- head/sys/sys/nv.h Sat May 2 17:45:52 2015(r282346) +++ head/sys/sys/nv.h Sat May 2 18:03:47 2015(r282347) @@ -64,6 +64,10 @@ typedef struct nvlist nvlist_t; * Perform case-insensitive lookups of provided names. */ #defineNV_FLAG_IGNORE_CASE 0x01 +/* + * Names don't have to be unique. + */ +#defineNV_FLAG_NO_UNIQUE 0x02 #if defined(_KERNEL) defined(MALLOC_DECLARE) MALLOC_DECLARE(M_NVLIST); ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r282351 - head/sys/amd64/vmm
Author: neel Date: Sat May 2 19:07:49 2015 New Revision: 282351 URL: https://svnweb.freebsd.org/changeset/base/282351 Log: Don't advertise the Intel SMX capability to the guest. Reported by: Leon Dang (ld...@nahannisys.com) MFC after:1 week Modified: head/sys/amd64/vmm/x86.c Modified: head/sys/amd64/vmm/x86.c == --- head/sys/amd64/vmm/x86.cSat May 2 18:12:34 2015(r282350) +++ head/sys/amd64/vmm/x86.cSat May 2 19:07:49 2015(r282351) @@ -230,10 +230,11 @@ x86_emulate_cpuid(struct vm *vm, int vcp regs[1] |= (vcpu_id CPUID__0001_APICID_SHIFT); /* -* Don't expose VMX, SpeedStep or TME capability. +* Don't expose VMX, SpeedStep, TME or SMX capability. * Advertise x2APIC capability and Hypervisor guest. */ regs[2] = ~(CPUID2_VMX | CPUID2_EST | CPUID2_TM2); + regs[2] = ~(CPUID2_SMX); regs[2] |= CPUID2_HV; ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r282348 - head/lib/libnv/tests
Author: oshogbo Date: Sat May 2 18:07:47 2015 New Revision: 282348 URL: https://svnweb.freebsd.org/changeset/base/282348 Log: Add test case for unpack with diffrent flags. Approved by: pjd (mentor) Modified: head/lib/libnv/tests/nv_tests.cc Modified: head/lib/libnv/tests/nv_tests.cc == --- head/lib/libnv/tests/nv_tests.ccSat May 2 18:03:47 2015 (r282347) +++ head/lib/libnv/tests/nv_tests.ccSat May 2 18:07:47 2015 (r282348) @@ -450,6 +450,40 @@ ATF_TEST_CASE_BODY(nvlist_pack__empty_nv free(packed); } +ATF_TEST_CASE_WITHOUT_HEAD(nvlist_unpack__flags_nvlist); +ATF_TEST_CASE_BODY(nvlist_unpack__flags_nvlist) +{ + nvlist_t *nvl, *unpacked; + void *packed; + size_t packed_size; + + nvl = nvlist_create(NV_FLAG_NO_UNIQUE); + ATF_REQUIRE(nvl != NULL); + + nvlist_add_bool(nvl, name, true); + ATF_REQUIRE(!nvlist_empty(nvl)); + ATF_REQUIRE(nvlist_exists_bool(nvl, name)); + + packed = nvlist_pack(nvl, packed_size); + ATF_REQUIRE(packed != NULL); + + unpacked = nvlist_unpack(packed, packed_size, 0); + ATF_REQUIRE(unpacked == NULL); + + unpacked = nvlist_unpack(packed, packed_size, NV_FLAG_IGNORE_CASE); + ATF_REQUIRE(unpacked == NULL); + + unpacked = nvlist_unpack(packed, packed_size, NV_FLAG_NO_UNIQUE); + ATF_REQUIRE(unpacked != NULL); + ATF_REQUIRE(unpacked != nvl); + ATF_REQUIRE(!nvlist_empty(unpacked)); + ATF_REQUIRE(nvlist_exists_bool(unpacked, name)); + + nvlist_destroy(unpacked); + nvlist_destroy(nvl); + free(packed); +} + static void verify_null(const nvlist_t *nvl, int type) { @@ -1206,6 +1240,7 @@ ATF_INIT_TEST_CASES(tp) ATF_ADD_TEST_CASE(tp, nvlist_pack__multiple_values); ATF_ADD_TEST_CASE(tp, nvlist_pack__error_nvlist); ATF_ADD_TEST_CASE(tp, nvlist_unpack__duplicate_key); + ATF_ADD_TEST_CASE(tp, nvlist_unpack__flags_nvlist); ATF_ADD_TEST_CASE(tp, nvlist_move_string__single_insert); ATF_ADD_TEST_CASE(tp, nvlist_move_nvlist__single_insert); ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r282350 - head/sys/kern
Author: oshogbo Date: Sat May 2 18:12:34 2015 New Revision: 282350 URL: https://svnweb.freebsd.org/changeset/base/282350 Log: nv_malloc can fail in userland. Add check to prevent a NULL pointer dereference. Pointed out by: mjg Approved by: pjd (mentor) Modified: head/sys/kern/subr_nvlist.c Modified: head/sys/kern/subr_nvlist.c == --- head/sys/kern/subr_nvlist.c Sat May 2 18:10:45 2015(r282349) +++ head/sys/kern/subr_nvlist.c Sat May 2 18:12:34 2015(r282350) @@ -129,6 +129,8 @@ nvlist_create(int flags) PJDLOG_ASSERT((flags ~(NV_FLAG_PUBLIC_MASK)) == 0); nvl = nv_malloc(sizeof(*nvl)); + if (nvl == NULL) + return (NULL); nvl-nvl_error = 0; nvl-nvl_flags = flags; nvl-nvl_parent = NULL; ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r282349 - head/sys/kern
Author: oshogbo Date: Sat May 2 18:10:45 2015 New Revision: 282349 URL: https://svnweb.freebsd.org/changeset/base/282349 Log: Remove duplicated code using macro template for the nvlist_add_.* functions. Approved by: pjd (mentor) Modified: head/sys/kern/subr_nvlist.c Modified: head/sys/kern/subr_nvlist.c == --- head/sys/kern/subr_nvlist.c Sat May 2 18:07:47 2015(r282348) +++ head/sys/kern/subr_nvlist.c Sat May 2 18:10:45 2015(r282349) @@ -1142,45 +1142,8 @@ nvlist_add_null(nvlist_t *nvl, const cha } void -nvlist_add_bool(nvlist_t *nvl, const char *name, bool value) -{ - nvpair_t *nvp; - - if (nvlist_error(nvl) != 0) { - ERRNO_SET(nvlist_error(nvl)); - return; - } - - nvp = nvpair_create_bool(name, value); - if (nvp == NULL) { - nvl-nvl_error = ERRNO_OR_DEFAULT(ENOMEM); - ERRNO_SET(nvl-nvl_error); - } else { - nvlist_move_nvpair(nvl, nvp); - } -} - -void -nvlist_add_number(nvlist_t *nvl, const char *name, uint64_t value) -{ - nvpair_t *nvp; - - if (nvlist_error(nvl) != 0) { - ERRNO_SET(nvlist_error(nvl)); - return; - } - - nvp = nvpair_create_number(name, value); - if (nvp == NULL) { - nvl-nvl_error = ERRNO_OR_DEFAULT(ENOMEM); - ERRNO_SET(nvl-nvl_error); - } else { - nvlist_move_nvpair(nvl, nvp); - } -} - -void -nvlist_add_string(nvlist_t *nvl, const char *name, const char *value) +nvlist_add_binary(nvlist_t *nvl, const char *name, const void *value, +size_t size) { nvpair_t *nvp; @@ -1189,7 +1152,7 @@ nvlist_add_string(nvlist_t *nvl, const c return; } - nvp = nvpair_create_string(name, value); + nvp = nvpair_create_binary(name, value, size); if (nvp == NULL) { nvl-nvl_error = ERRNO_OR_DEFAULT(ENOMEM); ERRNO_SET(nvl-nvl_error); @@ -1198,63 +1161,36 @@ nvlist_add_string(nvlist_t *nvl, const c } } -void -nvlist_add_nvlist(nvlist_t *nvl, const char *name, const nvlist_t *value) -{ - nvpair_t *nvp; - - if (nvlist_error(nvl) != 0) { - ERRNO_SET(nvlist_error(nvl)); - return; - } - nvp = nvpair_create_nvlist(name, value); - if (nvp == NULL) { - nvl-nvl_error = ERRNO_OR_DEFAULT(ENOMEM); - ERRNO_SET(nvl-nvl_error); - } else { - nvlist_move_nvpair(nvl, nvp); - } +#defineNVLIST_ADD(vtype, type) \ +void \ +nvlist_add_##type(nvlist_t *nvl, const char *name, vtype value) \ +{ \ + nvpair_t *nvp; \ + \ + if (nvlist_error(nvl) != 0) { \ + ERRNO_SET(nvlist_error(nvl)); \ + return; \ + } \ + \ + nvp = nvpair_create_##type(name, value);\ + if (nvp == NULL) { \ + nvl-nvl_error = ERRNO_OR_DEFAULT(ENOMEM); \ + ERRNO_SET(nvl-nvl_error); \ + } else {\ + nvlist_move_nvpair(nvl, nvp); \ + } \ } +NVLIST_ADD(bool, bool) +NVLIST_ADD(uint64_t, number) +NVLIST_ADD(const char *, string) +NVLIST_ADD(const nvlist_t *, nvlist) #ifndef _KERNEL -void -nvlist_add_descriptor(nvlist_t *nvl, const char *name, int value) -{ - nvpair_t *nvp; - - if (nvlist_error(nvl) != 0) { - errno = nvlist_error(nvl); - return; - } - - nvp = nvpair_create_descriptor(name, value); - if (nvp == NULL) - nvl-nvl_error = errno = (errno != 0 ? errno : ENOMEM); - else - nvlist_move_nvpair(nvl, nvp); -} +NVLIST_ADD(int, descriptor); #endif -void -nvlist_add_binary(nvlist_t *nvl, const char *name, const void *value, -size_t size) -{ - nvpair_t *nvp; - - if (nvlist_error(nvl) != 0) { - ERRNO_SET(nvlist_error(nvl)); - return; - } - - nvp = nvpair_create_binary(name, value, size); - if (nvp == NULL) { - nvl-nvl_error = ERRNO_OR_DEFAULT(ENOMEM); -
Re: svn commit: r282280 - in head/sys/dev: e1000 ixgbe ixl
On Fri, May 01, 2015 at 10:47:43AM -0400, John Baldwin wrote: J J While you are here, let me remind you about this plan: J J J J https://lists.freebsd.org/pipermail/svn-src-head/2014-October/063575.html J J J J We can prototype the API to userland now, write down a utility that uses J J it, or add the functionality to an existing utility. And start with Intel J J drivers, that seem to be most interested in extra stats. J J J J So the importaing thing here is that if_get_counter() is still doing J J per-ifnet stats. The stat you underlined above is per-queue instead. J J We well need more explicitly knowledge of queues outside of drivers J J and in the stack itself to support a generic framework for per-queue J J stats. J J This depends on how generic we want the API to be. Of course, we can add J an extra argument to if_get_counter(). J J However, if we don't expect the number of queues to exceed a reasonable J number of 255 :), we can fit the functionality into existing API. J We can keep the queue number in the highest 8 bits of the ift_counter J parameter. J J #defineIFCOUNTER_MASK 0x00ff J #defineIFCOUNTER_QUEUE(c) ((c) 24) J J I'd prefer that expose queues more directly and figure out how to handle J per-queue stats then (e.g. do we have some sort of driver-independent J structure that each ifnet has 1 or more of that maps to a queue and has J driver provided methods, etc. If so you could have a driver method for J queue stats). Note that I did use if_get_counter to report the J per-interface stats instead of adding a new sysctl. What do you prefer: an extra argument to the if_get_counter() or a extra ifop? -- Totus tuus, Glebius. ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r282352 - head/sys/arm/arm
Author: loos Date: Sat May 2 20:14:43 2015 New Revision: 282352 URL: https://svnweb.freebsd.org/changeset/base/282352 Log: Remove an unused variable. Modified: head/sys/arm/arm/machdep.c Modified: head/sys/arm/arm/machdep.c == --- head/sys/arm/arm/machdep.c Sat May 2 19:07:49 2015(r282351) +++ head/sys/arm/arm/machdep.c Sat May 2 20:14:43 2015(r282352) @@ -1055,7 +1055,6 @@ kenv_next(char *cp) static void print_kenv(void) { - int len; char *cp; debugf(loader passed (static) kenv:\n); @@ -1065,7 +1064,6 @@ print_kenv(void) } debugf( kern_envp = 0x%08x\n, (uint32_t)kern_envp); - len = 0; for (cp = kern_envp; cp != NULL; cp = kenv_next(cp)) debugf( %x %s\n, (uint32_t)cp, cp); } ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r282353 - head/sys/vm
Author: glebius Date: Sat May 2 20:27:37 2015 New Revision: 282353 URL: https://svnweb.freebsd.org/changeset/base/282353 Log: Instead of reading, validating and adjusting value of the vm.swap_async_max in the main swapper work cycle, do it in the sysctl handler. This removes extra mutex acquisition from the main cycle and makes the sysctl knob return error on an invalid value, instead of accepting and fixing it. Reviewed by: kib Sponsored by: Netflix Sponsored by: Nginx, Inc. Modified: head/sys/vm/swap_pager.c Modified: head/sys/vm/swap_pager.c == --- head/sys/vm/swap_pager.cSat May 2 20:14:43 2015(r282352) +++ head/sys/vm/swap_pager.cSat May 2 20:27:37 2015(r282353) @@ -328,17 +328,16 @@ static int nsw_wcount_async; /* limit wr static int nsw_wcount_async_max;/* assigned maximum*/ static int nsw_cluster_max;/* maximum VOP I/O allowed */ +static int sysctl_swap_async_max(SYSCTL_HANDLER_ARGS); +SYSCTL_PROC(_vm, OID_AUTO, swap_async_max, CTLTYPE_INT | CTLFLAG_RW, +NULL, 0, sysctl_swap_async_max, I, Maximum running async swap ops); + static struct swblock **swhash; static int swhash_mask; static struct mtx swhash_mtx; -static int swap_async_max = 4; /* maximum in-progress async I/O's */ static struct sx sw_alloc_sx; - -SYSCTL_INT(_vm, OID_AUTO, swap_async_max, - CTLFLAG_RW, swap_async_max, 0, Maximum running async swap ops); - /* * named and unnamed anon region objects. Try to reduce the overhead * of searching a named list by hashing it just a little. @@ -1350,39 +1349,6 @@ swap_pager_putpages(vm_object_t object, /* * Step 2 * -* Update nsw parameters from swap_async_max sysctl values. -* Do not let the sysop crash the machine with bogus numbers. -*/ - mtx_lock(pbuf_mtx); - if (swap_async_max != nsw_wcount_async_max) { - int n; - - /* -* limit range -*/ - if ((n = swap_async_max) nswbuf / 2) - n = nswbuf / 2; - if (n 1) - n = 1; - swap_async_max = n; - - /* -* Adjust difference ( if possible ). If the current async -* count is too low, we may not be able to make the adjustment -* at this time. -*/ - n -= nsw_wcount_async_max; - if (nsw_wcount_async + n = 0) { - nsw_wcount_async += n; - nsw_wcount_async_max += n; - wakeup(nsw_wcount_async); - } - } - mtx_unlock(pbuf_mtx); - - /* -* Step 3 -* * Assign swap blocks and issue I/O. We reallocate swap on the fly. * The page is left dirty until the pageout operation completes * successfully. @@ -2835,3 +2801,40 @@ swaponvp(struct thread *td, struct vnode NODEV, 0); return (0); } + +static int +sysctl_swap_async_max(SYSCTL_HANDLER_ARGS) +{ + int error, new, n; + + new = nsw_wcount_async_max; + error = sysctl_handle_int(oidp, new, 0, req); + if (error != 0 || req-newptr == NULL) + return (error); + + if (new nswbuf / 2 || new 1) + return (EINVAL); + + mtx_lock(pbuf_mtx); + while (nsw_wcount_async_max != new) { + /* +* Adjust difference. If the current async count is too low, +* we will need to sqeeze our update slowly in. Sleep with a +* higher priority than getpbuf() to finish faster. +*/ + n = new - nsw_wcount_async_max; + if (nsw_wcount_async + n = 0) { + nsw_wcount_async += n; + nsw_wcount_async_max += n; + wakeup(nsw_wcount_async); + } else { + nsw_wcount_async_max -= nsw_wcount_async; + nsw_wcount_async = 0; + msleep(nsw_wcount_async, pbuf_mtx, PSWP, + swpsysctl, 0); + } + } + mtx_unlock(pbuf_mtx); + + return (0); +} ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r282355 - head/sys/net
Author: glebius Date: Sat May 2 20:37:40 2015 New Revision: 282355 URL: https://svnweb.freebsd.org/changeset/base/282355 Log: After r281643 an #ifdef IFT_FOO preprocessor directive returns false, since types became a enum C type. Some software uses such ifdefs to determine whether an operating systems supports certain interface type. Of course, such check is bogus. E.g. FreeBSD defines about 250 interface types, but supports only around 20. However, we need not upset such software so provide a set of defines. The current set was taken to suffice the dhcpd. Reported tested by: Guy Yur guyyur gmail.com Modified: head/sys/net/if_types.h Modified: head/sys/net/if_types.h == --- head/sys/net/if_types.h Sat May 2 20:31:27 2015(r282354) +++ head/sys/net/if_types.h Sat May 2 20:37:40 2015(r282355) @@ -254,4 +254,20 @@ typedef enum { IFT_PFLOG = 0xf6, /* PF packet filter logging */ IFT_PFSYNC = 0xf7, /* PF packet filter synchronization */ } ifType; + +/* + * Some (broken) software uses #ifdef IFT_TYPE to check whether + * an operating systems supports certain interface type. Lack of + * ifdef leads to a piece of functionality compiled out. + */ +#ifndef BURN_BRIDGES +#defineIFT_BRIDGE IFT_BRIDGE +#defineIFT_PPP IFT_PPP +#defineIFT_PROPVIRTUAL IFT_PROPVIRTUAL +#defineIFT_L2VLAN IFT_L2VLAN +#defineIFT_L3IPVLANIFT_L3IPVLAN +#defineIFT_IEEE1394IFT_IEEE1394 +#defineIFT_INFINIBAND IFT_INFINIBAND +#endif + #endif /* !_NET_IF_TYPES_H_ */ ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r282354 - in head: sys/netinet6 usr.sbin/rtsold
Author: glebius Date: Sat May 2 20:31:27 2015 New Revision: 282354 URL: https://svnweb.freebsd.org/changeset/base/282354 Log: Remove #ifdef IFT_FOO. Submitted by: Guy Yur guyyur gmail.com Modified: head/sys/netinet6/in6.c head/sys/netinet6/in6_ifattach.c head/sys/netinet6/nd6.c head/sys/netinet6/nd6_nbr.c head/usr.sbin/rtsold/if.c Modified: head/sys/netinet6/in6.c == --- head/sys/netinet6/in6.c Sat May 2 20:27:37 2015(r282353) +++ head/sys/netinet6/in6.c Sat May 2 20:31:27 2015(r282354) @@ -1997,18 +1997,9 @@ in6_if2idlen(struct ifnet *ifp) { switch (ifp-if_type) { case IFT_ETHER: /* RFC2464 */ -#ifdef IFT_PROPVIRTUAL case IFT_PROPVIRTUAL: /* XXX: no RFC. treat it as ether */ -#endif -#ifdef IFT_L2VLAN case IFT_L2VLAN:/* ditto */ -#endif -#ifdef IFT_IEEE80211 case IFT_IEEE80211: /* ditto */ -#endif -#ifdef IFT_MIP - case IFT_MIP: /* ditto */ -#endif case IFT_INFINIBAND: return (64); case IFT_FDDI: /* RFC2467 */ Modified: head/sys/netinet6/in6_ifattach.c == --- head/sys/netinet6/in6_ifattach.cSat May 2 20:27:37 2015 (r282353) +++ head/sys/netinet6/in6_ifattach.cSat May 2 20:31:27 2015 (r282354) @@ -274,9 +274,7 @@ found: case IFT_ISO88025: case IFT_ATM: case IFT_IEEE1394: -#ifdef IFT_IEEE80211 case IFT_IEEE80211: -#endif /* IEEE802/EUI64 cases - what others? */ /* IEEE1394 uses 16byte length address starting with EUI64 */ if (addrlen 8) @@ -338,9 +336,7 @@ found: break; case IFT_GIF: -#ifdef IFT_STF case IFT_STF: -#endif /* * RFC2893 says: SHOULD use IPv4 address as ifid source. * however, IPv4 address is not very suitable as unique Modified: head/sys/netinet6/nd6.c == --- head/sys/netinet6/nd6.c Sat May 2 20:27:37 2015(r282353) +++ head/sys/netinet6/nd6.c Sat May 2 20:31:27 2015(r282354) @@ -2145,12 +2145,8 @@ nd6_need_cache(struct ifnet *ifp) case IFT_ETHER: case IFT_FDDI: case IFT_IEEE1394: -#ifdef IFT_L2VLAN case IFT_L2VLAN: -#endif -#ifdef IFT_IEEE80211 case IFT_IEEE80211: -#endif case IFT_INFINIBAND: case IFT_BRIDGE: case IFT_PROPVIRTUAL: @@ -2235,12 +2231,8 @@ nd6_storelladdr(struct ifnet *ifp, struc switch (ifp-if_type) { case IFT_ETHER: case IFT_FDDI: -#ifdef IFT_L2VLAN case IFT_L2VLAN: -#endif -#ifdef IFT_IEEE80211 case IFT_IEEE80211: -#endif case IFT_BRIDGE: case IFT_ISO88025: ETHER_MAP_IPV6_MULTICAST(SIN6(dst)-sin6_addr, Modified: head/sys/netinet6/nd6_nbr.c == --- head/sys/netinet6/nd6_nbr.c Sat May 2 20:27:37 2015(r282353) +++ head/sys/netinet6/nd6_nbr.c Sat May 2 20:31:27 2015(r282354) @@ -1149,12 +1149,8 @@ nd6_ifptomac(struct ifnet *ifp) case IFT_ETHER: case IFT_FDDI: case IFT_IEEE1394: -#ifdef IFT_L2VLAN case IFT_L2VLAN: -#endif -#ifdef IFT_IEEE80211 case IFT_IEEE80211: -#endif case IFT_INFINIBAND: case IFT_BRIDGE: case IFT_ISO88025: @@ -1549,9 +1545,7 @@ nd6_dad_duplicated(struct ifaddr *ifa, s case IFT_FDDI: case IFT_ATM: case IFT_IEEE1394: -#ifdef IFT_IEEE80211 case IFT_IEEE80211: -#endif case IFT_INFINIBAND: in6 = ia-ia_addr.sin6_addr; if (in6_get_hw_ifid(ifp, in6) == 0 Modified: head/usr.sbin/rtsold/if.c == --- head/usr.sbin/rtsold/if.c Sat May 2 20:27:37 2015(r282353) +++ head/usr.sbin/rtsold/if.c Sat May 2 20:31:27 2015(r282354) @@ -247,9 +247,7 @@ lladdropt_length(struct sockaddr_dl *sdl { switch (sdl-sdl_type) { case IFT_ETHER: -#ifdef IFT_IEEE80211 case IFT_IEEE80211: -#endif return (ROUNDUP8(ETHER_ADDR_LEN + 2)); default: return (0); @@ -265,9 +263,7 @@ lladdropt_fill(struct sockaddr_dl *sdl, switch (sdl-sdl_type) { case IFT_ETHER: -#ifdef IFT_IEEE80211 case IFT_IEEE80211: -#endif ndopt-nd_opt_len = (ROUNDUP8(ETHER_ADDR_LEN + 2)) 3; addr = (char *)(ndopt + 1); memcpy(addr, LLADDR(sdl), ETHER_ADDR_LEN); ___
svn commit: r282357 - head/sys/arm/broadcom/bcm2835
Author: loos Date: Sat May 2 22:24:33 2015 New Revision: 282357 URL: https://svnweb.freebsd.org/changeset/base/282357 Log: Add the routines to query and setup the framebuffer state using the BCM2835_MBOX_CHAN_PROP channel. The old channel (BCM2835_MBOX_CHAN_FB) seems deprecated on recent firmware versions and is causing a freeze on RPi 2. The actual changes in the framebuffer drivers will follow in subsequent commits. Modified: head/sys/arm/broadcom/bcm2835/bcm2835_mbox.c head/sys/arm/broadcom/bcm2835/bcm2835_mbox_prop.h Modified: head/sys/arm/broadcom/bcm2835/bcm2835_mbox.c == --- head/sys/arm/broadcom/bcm2835/bcm2835_mbox.cSat May 2 20:41:49 2015(r282356) +++ head/sys/arm/broadcom/bcm2835/bcm2835_mbox.cSat May 2 22:24:33 2015(r282357) @@ -318,6 +318,47 @@ bcm2835_mbox_init_dma(device_t dev, size return (buf); } +static int +bcm2835_mbox_err(device_t dev, bus_addr_t msg_phys, uint32_t resp_phys, + struct bcm2835_mbox_hdr *msg, size_t len) +{ + int idx; + struct bcm2835_mbox_tag_hdr *tag; + uint8_t *last; + + if ((uint32_t)msg_phys != resp_phys) { + device_printf(dev, response channel mismatch\n); + return (EIO); + } + if (msg-code != BCM2835_MBOX_CODE_RESP_SUCCESS) { + device_printf(dev, mbox response error\n); + return (EIO); + } + + /* Loop until the end tag. */ + tag = (struct bcm2835_mbox_tag_hdr *)(msg + 1); + last = (uint8_t *)msg + len; + for (idx = 0; tag-tag != 0; idx++) { + if ((tag-val_len BCM2835_MBOX_TAG_VAL_LEN_RESPONSE) == 0) { + device_printf(dev, tag %d response error\n, idx); + return (EIO); + } + /* Clear the response bit. */ + tag-val_len = ~BCM2835_MBOX_TAG_VAL_LEN_RESPONSE; + + /* Next tag. */ + tag = (struct bcm2835_mbox_tag_hdr *)((uint8_t *)tag + + sizeof(*tag) + tag-val_buf_size); + + if ((uint8_t *)tag last) { + device_printf(dev, mbox buffer size error\n); + return (EIO); + } + } + + return (0); +} + int bcm2835_mbox_set_power_state(device_t dev, uint32_t device_id, boolean_t on) { @@ -413,3 +454,136 @@ bcm2835_mbox_get_clock_rate(device_t dev return (0); } + +int +bcm2835_mbox_fb_get_w_h(device_t dev, struct bcm2835_fb_config *fb) +{ + device_t mbox; + int err; + bus_dma_tag_t msg_tag; + bus_dmamap_t msg_map; + bus_addr_t msg_phys; + struct msg_fb_get_w_h *msg; + uint32_t reg; + + /* get mbox device */ + mbox = devclass_get_device(devclass_find(mbox), 0); + if (mbox == NULL) { + device_printf(dev, can't find mbox\n); + return (ENXIO); + } + + /* Allocate memory for the message */ + msg = bcm2835_mbox_init_dma(dev, sizeof(*msg), msg_tag, msg_map, + msg_phys); + if (msg == NULL) + return (ENOMEM); + + memset(msg, 0, sizeof(*msg)); + msg-hdr.buf_size = sizeof(*msg); + msg-hdr.code = BCM2835_MBOX_CODE_REQ; + BCM2835_MBOX_INIT_TAG(msg-physical_w_h, GET_PHYSICAL_W_H); + msg-physical_w_h.tag_hdr.val_len = 0; + BCM2835_MBOX_INIT_TAG(msg-virtual_w_h, GET_VIRTUAL_W_H); + msg-virtual_w_h.tag_hdr.val_len = 0; + BCM2835_MBOX_INIT_TAG(msg-offset, GET_VIRTUAL_OFFSET); + msg-offset.tag_hdr.val_len = 0; + msg-end_tag = 0; + + bus_dmamap_sync(msg_tag, msg_map, BUS_DMASYNC_PREWRITE); + MBOX_WRITE(mbox, BCM2835_MBOX_CHAN_PROP, (uint32_t)msg_phys); + bus_dmamap_sync(msg_tag, msg_map, BUS_DMASYNC_POSTWRITE); + + bus_dmamap_sync(msg_tag, msg_map, BUS_DMASYNC_PREREAD); + MBOX_READ(mbox, BCM2835_MBOX_CHAN_PROP, reg); + bus_dmamap_sync(msg_tag, msg_map, BUS_DMASYNC_POSTREAD); + + err = bcm2835_mbox_err(dev, msg_phys, reg, msg-hdr, sizeof(*msg)); + if (err == 0) { + fb-xres = msg-physical_w_h.body.resp.width; + fb-yres = msg-physical_w_h.body.resp.height; + fb-vxres = msg-virtual_w_h.body.resp.width; + fb-vyres = msg-virtual_w_h.body.resp.height; + fb-xoffset = msg-offset.body.resp.x; + fb-yoffset = msg-offset.body.resp.y; + } + + bus_dmamap_unload(msg_tag, msg_map); + bus_dmamem_free(msg_tag, msg, msg_map); + bus_dma_tag_destroy(msg_tag); + + return (err); +} + +int +bcm2835_mbox_fb_init(device_t dev, struct bcm2835_fb_config *fb) +{ + device_t mbox; + int err; + bus_dma_tag_t msg_tag; + bus_dmamap_t msg_map; + bus_addr_t msg_phys; + struct msg_fb_setup *msg; + uint32_t reg; + + /* get mbox
svn commit: r282359 - head/sys/arm/broadcom/bcm2835
Author: loos Date: Sat May 2 22:48:56 2015 New Revision: 282359 URL: https://svnweb.freebsd.org/changeset/base/282359 Log: Fix the vt(4) framebuffer driver on RPi 2. Use the BCM2835_MBOX_CHAN_PROP mbox channel to setup the framebuffer, remove DMA code (its now done in bcm2835_mbox.c). Also adjust the color palette when bcm2708_fb.fbswap is set. The firmware used on RPi 2 uses this mode. Tested on:RPi-B and RPi 2 with 16, 24 and 32bpp Note: The 32bpp mode on RPi-B has the red and blue swapped, this is a know problem (not a driver problem). Modified: head/sys/arm/broadcom/bcm2835/bcm2835_fbd.c Modified: head/sys/arm/broadcom/bcm2835/bcm2835_fbd.c == --- head/sys/arm/broadcom/bcm2835/bcm2835_fbd.c Sat May 2 22:40:41 2015 (r282358) +++ head/sys/arm/broadcom/bcm2835/bcm2835_fbd.c Sat May 2 22:48:56 2015 (r282359) @@ -35,170 +35,35 @@ __FBSDID($FreeBSD$); #include sys/systm.h #include sys/bio.h #include sys/bus.h -#include sys/conf.h -#include sys/endian.h +#include sys/fbio.h #include sys/kernel.h -#include sys/kthread.h -#include sys/lock.h #include sys/malloc.h #include sys/module.h -#include sys/mutex.h -#include sys/queue.h -#include sys/resource.h -#include sys/rman.h -#include sys/time.h -#include sys/timetc.h -#include sys/fbio.h -#include sys/consio.h - -#include sys/kdb.h #include vm/vm.h #include vm/pmap.h -#include machine/bus.h -#include machine/cpu.h -#include machine/cpufunc.h -#include machine/fdt.h -#include machine/resource.h -#include machine/intr.h - #include dev/fdt/fdt_common.h #include dev/ofw/ofw_bus.h #include dev/ofw/ofw_bus_subr.h #include dev/fb/fbreg.h #include dev/vt/vt.h +#include dev/vt/colors/vt_termcolors.h -#include arm/broadcom/bcm2835/bcm2835_mbox.h -#include arm/broadcom/bcm2835/bcm2835_vcbus.h +#include arm/broadcom/bcm2835/bcm2835_mbox_prop.h #include fb_if.h #include mbox_if.h -#define FB_WIDTH 640 -#define FB_HEIGHT 480 -#define FB_DEPTH 24 - -struct bcm_fb_config { - uint32_txres; - uint32_tyres; - uint32_tvxres; - uint32_tvyres; - uint32_tpitch; - uint32_tbpp; - uint32_txoffset; - uint32_tyoffset; - /* Filled by videocore */ - uint32_tbase; - uint32_tscreen_size; -}; +#defineFB_DEPTH24 struct bcmsc_softc { - device_tdev; struct fb_info *info; - bus_dma_tag_t dma_tag; - bus_dmamap_tdma_map; - struct bcm_fb_config* fb_config; - bus_addr_t fb_config_phys; - struct intr_config_hook init_hook; }; static int bcm_fb_probe(device_t); static int bcm_fb_attach(device_t); -static void bcm_fb_dmamap_cb(void *arg, bus_dma_segment_t *segs, int nseg, -int err); - -static void -bcm_fb_init(void *arg) -{ - volatile struct bcm_fb_config *fb_config; - struct bcmsc_softc *sc; - struct fb_info *info; - phandle_t node; - pcell_t cell; - device_t mbox; - device_t fbd; - int err = 0; - - sc = arg; - fb_config = sc-fb_config; - node = ofw_bus_get_node(sc-dev); - - fb_config-xres = 0; - fb_config-yres = 0; - fb_config-bpp = 0; - fb_config-vxres = 0; - fb_config-vyres = 0; - fb_config-xoffset = 0; - fb_config-yoffset = 0; - fb_config-base = 0; - fb_config-pitch = 0; - fb_config-screen_size = 0; - - if ((OF_getprop(node, broadcom,width, cell, sizeof(cell))) 0) - fb_config-xres = (int)fdt32_to_cpu(cell); - if (fb_config-xres == 0) - fb_config-xres = FB_WIDTH; - - if ((OF_getprop(node, broadcom,height, cell, sizeof(cell))) 0) - fb_config-yres = (uint32_t)fdt32_to_cpu(cell); - if (fb_config-yres == 0) - fb_config-yres = FB_HEIGHT; - - if ((OF_getprop(node, broadcom,depth, cell, sizeof(cell))) 0) - fb_config-bpp = (uint32_t)fdt32_to_cpu(cell); - if (fb_config-bpp == 0) - fb_config-bpp = FB_DEPTH; - - bus_dmamap_sync(sc-dma_tag, sc-dma_map, - BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD); - - mbox = devclass_get_device(devclass_find(mbox), 0); - if (mbox) { - MBOX_WRITE(mbox, BCM2835_MBOX_CHAN_FB, sc-fb_config_phys); - MBOX_READ(mbox, BCM2835_MBOX_CHAN_FB, err); - } - bus_dmamap_sync(sc-dma_tag, sc-dma_map, - BUS_DMASYNC_POSTREAD); - - if (fb_config-base != 0) { - device_printf(sc-dev, %dx%d(%dx%d@%d,%d) %dbpp\n, - fb_config-xres, fb_config-yres, - fb_config-vxres, fb_config-vyres, -
svn commit: r282358 - head/sys/arm/broadcom/bcm2835
Author: loos Date: Sat May 2 22:40:41 2015 New Revision: 282358 URL: https://svnweb.freebsd.org/changeset/base/282358 Log: Fix the sc(4) framebuffer driver on RPi 2. Use the BCM2835_MBOX_CHAN_PROP mbox channel to setup the framebuffer, remove unused code and unnecessary includes. Adjust the color palette when bcm2708_fb.fbswap is set on /chosen/bootargs node of DTB. The firmware used on RPi 2 uses this mode. Tested on:RPi-B and RPi 2 with 16, 24 and 32bpp Modified: head/sys/arm/broadcom/bcm2835/bcm2835_fb.c Modified: head/sys/arm/broadcom/bcm2835/bcm2835_fb.c == --- head/sys/arm/broadcom/bcm2835/bcm2835_fb.c Sat May 2 22:24:33 2015 (r282357) +++ head/sys/arm/broadcom/bcm2835/bcm2835_fb.c Sat May 2 22:40:41 2015 (r282358) @@ -29,46 +29,27 @@ __FBSDID($FreeBSD$); #include sys/param.h #include sys/systm.h -#include sys/bio.h #include sys/bus.h -#include sys/conf.h -#include sys/endian.h +#include sys/consio.h +#include sys/fbio.h +#include sys/kdb.h #include sys/kernel.h -#include sys/kthread.h -#include sys/lock.h #include sys/malloc.h #include sys/module.h -#include sys/mutex.h -#include sys/queue.h -#include sys/resource.h -#include sys/rman.h -#include sys/time.h -#include sys/timetc.h -#include sys/fbio.h -#include sys/consio.h -#include sys/kdb.h - -#include machine/bus.h -#include machine/cpu.h -#include machine/cpufunc.h -#include machine/resource.h -#include machine/intr.h +#include vm/vm.h +#include vm/pmap.h +#include dev/fb/fbreg.h #include dev/fdt/fdt_common.h #include dev/ofw/ofw_bus.h #include dev/ofw/ofw_bus_subr.h - -#include dev/fb/fbreg.h #include dev/syscons/syscons.h -#include arm/broadcom/bcm2835/bcm2835_mbox.h -#include arm/broadcom/bcm2835/bcm2835_vcbus.h +#include arm/broadcom/bcm2835/bcm2835_mbox_prop.h #include mbox_if.h -#defineBCMFB_FONT_HEIGHT 16 - struct argb { uint8_t a; uint8_t r; @@ -101,40 +82,15 @@ static u_char mouse_pointer[16] = { 0x0c, 0x0c, 0x06, 0x06, 0x00, 0x00, 0x00, 0x00 }; -#define FB_WIDTH 640 -#define FB_HEIGHT 480 -#define FB_DEPTH 24 - -struct bcm_fb_config { - uint32_txres; - uint32_tyres; - uint32_tvxres; - uint32_tvyres; - uint32_tpitch; - uint32_tbpp; - uint32_txoffset; - uint32_tyoffset; - /* Filled by videocore */ - uint32_tbase; - uint32_tscreen_size; -}; +#defineBCMFB_FONT_HEIGHT 16 +#defineBCMFB_FONT_WIDTH8 +#defineFB_WIDTH640 +#defineFB_HEIGHT 480 +#defineFB_DEPTH24 struct bcmsc_softc { - device_tdev; - struct cdev * cdev; - struct mtx mtx; - bus_dma_tag_t dma_tag; - bus_dmamap_tdma_map; - struct bcm_fb_config* fb_config; - bus_addr_t fb_config_phys; - struct intr_config_hook init_hook; - -}; - -struct video_adapter_softc { /* Videoadpater part */ video_adapter_t va; - int console; intptr_tfb_addr; intptr_tfb_paddr; @@ -149,199 +105,75 @@ struct video_adapter_softc { unsigned intymargin; unsigned char *font; + int fbswap; int initialized; }; -static struct bcmsc_softc *bcmsc_softc; -static struct video_adapter_softc va_softc; - -#definebcm_fb_lock(_sc)mtx_lock((_sc)-mtx) -#definebcm_fb_unlock(_sc) mtx_unlock((_sc)-mtx) -#definebcm_fb_lock_assert(sc) mtx_assert((_sc)-mtx, MA_OWNED) +static struct bcmsc_softc bcmsc; static int bcm_fb_probe(device_t); static int bcm_fb_attach(device_t); -static void bcm_fb_dmamap_cb(void *arg, bus_dma_segment_t *segs, int nseg, int err); static void bcmfb_update_margins(video_adapter_t *adp); static int bcmfb_configure(int); -static void -bcm_fb_init(void *arg) -{ - struct bcmsc_softc *sc = arg; - struct video_adapter_softc *va_sc = va_softc; - int err; - volatile struct bcm_fb_config* fb_config = sc-fb_config; - phandle_t node; - pcell_t cell; - device_t mbox; - - node = ofw_bus_get_node(sc-dev); - - fb_config-xres = 0; - fb_config-yres = 0; - fb_config-bpp = 0; - - if ((OF_getprop(node, broadcom,width, cell, sizeof(cell))) 0) - fb_config-xres = (int)fdt32_to_cpu(cell); - if (fb_config-xres == 0) - fb_config-xres = FB_WIDTH; - - if ((OF_getprop(node, broadcom,height, cell, sizeof(cell))) 0) - fb_config-yres = (uint32_t)fdt32_to_cpu(cell); - if (fb_config-yres == 0) - fb_config-yres =