Index: Makefile.inc1 =========================================================================== --- Makefile.inc1 2012/02/10 02:20:13 #466 +++ Makefile.inc1 2012/02/10 02:20:13 @@ -479,12 +479,18 @@ cd ${.CURDIR}/cddl/lib; ${LIB32WMAKE} DIRPRFX=cddl/lib/ ${_t} .endif cd ${.CURDIR}/gnu/lib; ${LIB32WMAKE} DIRPRFX=gnu/lib/ ${_t} + cd ${.CURDIR}/usr.bin/ldd; \ + ${LIB32WMAKE} DESTDIR=${LIB32TMP} ${_t} + cd ${.CURDIR}/usr.bin/gcore; \ + ${LIB32WMAKE} DESTDIR=${LIB32TMP} ${_t} .if ${MK_CRYPT} != "no" cd ${.CURDIR}/secure/lib; ${LIB32WMAKE} DIRPRFX=secure/lib/ ${_t} .endif .if ${MK_KERBEROS} != "no" cd ${.CURDIR}/kerberos5/lib; ${LIB32WMAKE} DIRPRFX=kerberos5/lib ${_t} .endif + cd ${.CURDIR}/gnu/usr.bin/cc/include; \ + ${LIB32WMAKE} DESTDIR=${LIB32TMP} ${_t} .endfor .for _dir in usr.bin/lex/lib cd ${.CURDIR}/${_dir}; ${LIB32WMAKE} DIRPRFX=${_dir}/ obj @@ -501,6 +507,7 @@ DIRPRFX=libexec/rtld-elf/ ${_t} cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32WMAKE} \ DIRPRFX=usr.bin/ldd ${_t} + cd ${.CURDIR}/usr.bin/gcore; PROG=gcore32 ${LIB32WMAKE} DESTDIR=${LIB32TMP} ${_t} .endfor distribute32 install32: @@ -518,6 +525,7 @@ cd ${.CURDIR}/libexec/rtld-elf; \ PROG=ld-elf32.so.1 ${LIB32IMAKE} ${.TARGET:S/32$//} cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32IMAKE} ${.TARGET:S/32$//} + cd ${.CURDIR}/usr.bin/gcore; PROG=gcore32 ${LIB32IMAKE} ${.TARGET:S/32$//} .endif WMAKE_TGTS= Index: TODO.txt =========================================================================== *** /dev/null Fri Feb 10 02:19:45 2012 --- TODO.txt Fri Feb 10 02:20:18 2012 *************** *** 0 **** --- 1,107 ---- + + $P4: //depot/projects/hammer/TODO.txt#19 $ + + reread the logs etc and check out the "XXX worry about this later" stuff + + performance tuning (segment registers etc at context switch time, pmap) + + ddb (needs a dwarf2 based unwinder to get stack traces and a disassembler) + (peter: basic functionality, uses -fno-omit-frame-pointer.. disassembler + still expects 32 bit code but compiles) + + SSE/SSE2 support in libc (the fpget/set*() functions need to adjust the + SSE MXCSR register as well as the x87 control word - netbsd have already + done this, we can look at theirs) + (XXX mostly done. need better libm support still) + + make ia32 binary support more robust, including things that do important + ioctls etc. + (XXX: improving. csh etc work now. execve() was the bug) + (XXX: Need USER_LDT for i386 binaries.) + (XXX: need some ioctl translators and a few syscall translators that + take dense structures with different packing) + (XXX: kern.ps_strings and kern.usrstack are prime examples of the 4/8 byte + long problem). + + Fix sysctl(2) int/long mess, especially for kern.ps_strings and + kern.usrstack. The current hack is Just Wrong. What is needed is a + syscall wrapper for it that downconverts the "long" values from 64 bit to + 32 bit for the 32 bit binaries. This is going to need a table of important + "long" sysctls to translate. + + ======= DONE ======= + + USER_LDT (however, there is a syscall to set the %fs and %gs base values + to arbitary 64 bit addresses). + XXX; changed compat library implementations to not use user_ldt. + + ppp(8) (compiler bug, hack in http://people.freebsd.org/~peter/hammer.diff, + but gcc-3.3 would be much better) + + ACPI + (compiles/runs.. test more) + + boot blocks (need gcc -m32 to work) + (fixed in p4 tree, needs binutils patches etc) + + increase direct map base size to 4GB to cover all of pci mapping space + so that pmap_mapdev can use it without consuming kvm. + + libstdc++.so (build bug, tries to link libgcc.a (non-pic) into the .so, + but the libstdc++.a works). + + do something about config changes for binutils to enable i386 output + XXX david committed part of it, and fixed the other half better. + + 128TB of user process VM space (the support is there, but there is + a bug somewhere as it crosses the 512G mark into a new pml4e) + + full 2MB pmap page support in pmap (ifdef'ed out, some stuff uses vtopte() + where it shouldn't, and the direct pte map interface needs to be made + aware of it) + + threads (get/setusercontext/swapcontext/makecontext etc and kse kernel bits) + (peter: started work on libc_r, but it crashes still) + (David Xu and Dan did the kse bits, libc_r works too. no libthr) + + X server (supported in ports) + + make release (should be mostly there, with the bootblock patches) + + revert ppp(8) compiler bug workaround after gcc-3.3 is imported. + + SMP (acpi MADT table based etc, ignore mptable stuff) + + factor out common compat/freebsd32/* and compat/ia32/* from ia64 and amd64 + trees. freebsd32 should be for running 32 bit binaries on a 64 bit kernel, + while ia32 is for special MD bits. Lots of missing syscalls. + (XXX: lots done. ia64 MD needed. still some missing syscalls) + + netstat -i coredumps. Investigate. + Is this a compiler bug or a libkvm or /dev/kmem bug? + + kld module support (the elf_machdep.c relocator is wrong, it uses the old value + rather than addends like it should. See alpha/sparc64 for clues.) + XXX: can't do this without hacking binutils. + XXX: no, its worse than that. Its completely impossible with the current + binutils without writing a whole bunch of bfd code. No way in hell. + Instead, just give in and write a .o file loader, eg: the .kld file that + we use as the final step towards producing the .ko file. + + finish the missing relocation types in rtld-elf/amd64/reloc.c (easy) + + see if openssl can use the assembler x86-64 routines. (easy) + + add userland access to hardware debug registers via ptrace/procfs. + + gdb6.0 import (FSF build works) + + crashdumps + + teach libkvm about crashdumps. (need to lookup KPML4, 4 level page tree etc) + + kld preload support, teach the loader how to read new-style .ko files, + as well as kldxref. kldxref should be easy, it should be able to just + read the modmetadata section directly, apply the relocs for that section, + and use that to find the pointers to the other sections. + Index: bin/ps/print.c =========================================================================== --- bin/ps/print.c 2012/02/10 02:20:13 #62 +++ bin/ps/print.c 2012/02/10 02:20:13 @@ -115,7 +115,11 @@ command(KINFO *k, VARENT *ve) { char *vis_args, *vis_env, *str; +#if 0 + int flag; + flag = k->ki_p->ki_flag; +#endif if (cflag) { /* If it is the last field, then don't pad */ if (STAILQ_NEXT(ve, next_ve) == NULL) { @@ -129,6 +133,20 @@ return (str); } +#if 0 + if (showthreads && (k->ki_p->ki_flag & P_SYSTEM) != 0 && + k->ki_p->ki_numthreads > 1) { + /* If it is the last field, then don't pad */ + char *kth; + asprintf(&kth, "{%s}", k->ki_p->ki_ocomm); + if (STAILQ_NEXT(ve, next_ve) == NULL) + (void)printf("%s", kth); + else + (void)printf("%-*s", v->width, kth); + free(kth); + return; + } +#endif if ((vis_args = malloc(strlen(k->ki_args) * 4 + 1)) == NULL) errx(1, "malloc failed"); strvis(vis_args, k->ki_args, VIS_TAB | VIS_NL | VIS_NOSLASH); Index: contrib/binutils/bfd/elf64-x86-64.c =========================================================================== --- contrib/binutils/bfd/elf64-x86-64.c 2012/02/10 02:20:13 #9 +++ contrib/binutils/bfd/elf64-x86-64.c 2012/02/10 02:20:13 @@ -952,7 +952,8 @@ non-constant sections. */ if (info->shared && (sec->flags & SEC_ALLOC) != 0 - && (sec->flags & SEC_READONLY) != 0) + && (sec->flags & SEC_READONLY) != 0 + && getenv("BFD_STFU") == NULL) { (*_bfd_error_handler) (_("%B: relocation %s against `%s' can not be used when making a shared object; recompile with -fPIC"), @@ -2333,6 +2334,11 @@ unresolved_reloc = FALSE; break; + case R_X86_64_32S: + if (getenv("BFD_STFU") == NULL) { + break; + } + /* Fall Through */ case R_X86_64_PC8: case R_X86_64_PC16: case R_X86_64_PC32: @@ -2474,7 +2480,10 @@ } outrel.r_info = ELF64_R_INFO (sindx, r_type); - outrel.r_addend = relocation + rel->r_addend; + if (r_type == R_X86_64_32S && getenv("BFD_STFU") != NULL) + outrel.r_addend = rel->r_addend; + else + outrel.r_addend = relocation + rel->r_addend; } } Index: contrib/gcc/gcc.c =========================================================================== --- contrib/gcc/gcc.c 2012/02/10 02:20:13 #26 +++ contrib/gcc/gcc.c 2012/02/10 02:20:13 @@ -780,12 +780,16 @@ static const char *trad_capable_cpp = "cc1 -E %{traditional|ftraditional|traditional-cpp:-traditional-cpp}"; +#ifndef INCLUDE32 +#define INCLUDE32 " " +#endif + /* We don't wrap .d files in %W{} since a missing .d file, and therefore no dependency entry, confuses make into thinking a .o file that happens to exist is up-to-date. */ static const char *cpp_unique_options = "%{C|CC:%{!E:%eGCC does not support -C or -CC without -E}}\ - %{!Q:-quiet} %{nostdinc*} %{C} %{CC} %{v} %{I*&F*} %{P} %I\ + %{!Q:-quiet} %{nostdinc*} %{C} %{CC} %{v}"INCLUDE32"%{I*&F*} %{P} %I\ %{MD:-MD %{!o:%b.d}%{o*:%.d%*}}\ %{MMD:-MMD %{!o:%b.d}%{o*:%.d%*}}\ %{M} %{MM} %{MF*} %{MG} %{MP} %{MQ*} %{MT*}\ Index: contrib/gdb/gdb/solib-svr4.c =========================================================================== --- contrib/gdb/gdb/solib-svr4.c 2012/02/10 02:20:13 #3 +++ contrib/gdb/gdb/solib-svr4.c 2012/02/10 02:20:13 @@ -1028,7 +1028,14 @@ be trivial on GNU/Linux). Therefore, we have to try an alternate mechanism to find the dynamic linker's base address. */ - tmp_fd = solib_open (buf, &tmp_pathname); +#if defined(__i386__) || defined(COMPAT_32BIT) + if ((strcmp(buf, "/usr/libexec/ld-elf.so.1") == 0 || + strcmp(buf, "/libexec/ld-elf.so.1") == 0) && + access("/libexec/ld-elf32.so.1", 0) == 0) + tmp_fd = solib_open ("/libexec/ld-elf32.so.1", &tmp_pathname); + else +#endif + tmp_fd = solib_open (buf, &tmp_pathname); if (tmp_fd >= 0) tmp_bfd = bfd_fdopenr (tmp_pathname, gnutarget, tmp_fd); Index: etc/Makefile =========================================================================== --- etc/Makefile 2012/02/10 02:20:13 #130 +++ etc/Makefile 2012/02/10 02:20:13 @@ -187,12 +187,14 @@ ${BSM_ETC_RESTRICTED_FILES} ${BSM_ETC_DIR} cd ${.CURDIR}; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 0500 \ ${BSM_ETC_EXEC_FILES} ${BSM_ETC_DIR} +.if !defined(NO_BIND_CHROOT) .if ${MK_BIND_MTREE} != "no" @if [ ! -e ${DESTDIR}/etc/namedb ]; then \ set -x; \ ln -s ../var/named/etc/namedb ${DESTDIR}/etc/namedb; \ fi .endif +.endif .if ${MK_BIND_ETC} != "no" ${_+_}cd ${.CURDIR}/namedb; ${MAKE} install .endif @@ -266,15 +268,22 @@ mtree -eU ${MTREE_FOLLOWS_SYMLINKS} -f ${.CURDIR}/mtree/BSD.var.dist -p ${DESTDIR}/var mtree -eU ${MTREE_FOLLOWS_SYMLINKS} -f ${.CURDIR}/mtree/BSD.usr.dist -p ${DESTDIR}/usr mtree -eU ${MTREE_FOLLOWS_SYMLINKS} -f ${.CURDIR}/mtree/BSD.include.dist \ - -p ${DESTDIR}/usr/include + -p ${DESTDIR}${INCLUDEDIR} .if ${MK_BIND_LIBS} != "no" mtree -deU ${MTREE_FOLLOWS_SYMLINKS} -f ${.CURDIR}/mtree/BIND.include.dist \ - -p ${DESTDIR}/usr/include + -p ${DESTDIR}/${INCLUDEDIR} .endif .if ${MK_BIND_MTREE} != "no" +.if defined(NO_BIND_CHROOT) + mtree -deU ${MTREE_FOLLOWS_SYMLINKS} -f ${.CURDIR}/mtree/BIND.etc.dist \ + -p ${DESTDIR}/etc + mtree -deU ${MTREE_FOLLOWS_SYMLINKS} -f ${.CURDIR}/mtree/BIND.var.dist \ + -p ${DESTDIR}/var +.else mtree -deU ${MTREE_FOLLOWS_SYMLINKS} -f ${.CURDIR}/mtree/BIND.chroot.dist \ -p ${DESTDIR}/var/named .endif +.endif .if ${MK_GROFF} != "no" mtree -deU ${MTREE_FOLLOWS_SYMLINKS} -f ${.CURDIR}/mtree/BSD.groff.dist -p ${DESTDIR}/usr .endif Index: etc/mtree/BIND.etc.dist =========================================================================== *** /dev/null Fri Feb 10 02:19:45 2012 --- etc/mtree/BIND.etc.dist Fri Feb 10 02:20:18 2012 *************** *** 0 **** --- 1,14 ---- + # $FreeBSD: src/etc/mtree/BIND.chroot.dist,v 1.5 2004/09/29 03:43:10 dougb Exp $ + # + # Please see the file src/etc/mtree/README before making changes to this file. + # + + /set type=dir uname=root gname=wheel mode=0755 + . + namedb + master + .. + slave uname=bind + .. + .. + .. Index: etc/mtree/BIND.var.dist =========================================================================== *** /dev/null Fri Feb 10 02:19:45 2012 --- etc/mtree/BIND.var.dist Fri Feb 10 02:20:19 2012 *************** *** 0 **** --- 1,19 ---- + # $FreeBSD: src/etc/mtree/BIND.chroot.dist,v 1.5 2004/09/29 03:43:10 dougb Exp $ + # + # Please see the file src/etc/mtree/README before making changes to this file. + # + + /set type=dir uname=root gname=wheel mode=0755 + . + /set type=dir uname=bind gname=wheel mode=0755 + dump + .. + log uname=root + .. + run uname=root + named gname=bind + .. + .. + stats + .. + .. Index: gnu/usr.bin/binutils/ld/Makefile.amd64 =========================================================================== --- gnu/usr.bin/binutils/ld/Makefile.amd64 2012/02/10 02:20:13 #10 +++ gnu/usr.bin/binutils/ld/Makefile.amd64 2012/02/10 02:20:13 @@ -12,7 +12,7 @@ ${NATIVE_EMULATION} "" no ${NATIVE_EMULATION} ${TARGET_TUPLE} X86_EMULATION= elf_i386_fbsd -_i386_path= \"${TOOLS_PREFIX}/usr/lib32\" +_i386_path= \"${TOOLS_PREFIX}/lib32\":\"${TOOLS_PREFIX}/usr/lib32\" EMS+= ${X86_EMULATION} .for ext in ${ELF_SCR_EXT} LDSCRIPTS+= ${X86_EMULATION}.${ext} Index: gnu/usr.bin/cc/cc_tools/freebsd-native.h =========================================================================== --- gnu/usr.bin/cc/cc_tools/freebsd-native.h 2012/02/10 02:20:13 #25 +++ gnu/usr.bin/cc/cc_tools/freebsd-native.h 2012/02/10 02:20:13 @@ -23,6 +23,9 @@ #else #define STANDARD_INCLUDE_DIR PREFIX"/include" #endif +#ifdef __amd64__ +#define INCLUDE32 " %{m32:-I"PREFIX"/include32} " +#endif /* Under FreeBSD, the normal location of the compiler back ends is the /usr/libexec directory. @@ -44,7 +47,11 @@ #undef MD_STARTFILE_PREFIX /* We don't need one for now. */ #define STANDARD_STARTFILE_PREFIX PREFIX"/lib/" +#ifdef __amd64__ +#define STARTFILE_PREFIX_SPEC "%{m32:"PREFIX"/lib32/} %{!m32:"PREFIX"/lib/}" +#else #define STARTFILE_PREFIX_SPEC PREFIX"/lib/" +#endif #if 0 #define LIBGCC_SPEC "%{shared: -lgcc_pic} \ Index: gnu/usr.bin/grep/grep.c =========================================================================== --- gnu/usr.bin/grep/grep.c 2012/02/10 02:20:13 #12 +++ gnu/usr.bin/grep/grep.c 2012/02/10 02:20:13 @@ -102,6 +102,7 @@ INCLUDE_OPTION, EXCLUDE_OPTION, EXCLUDE_FROM_OPTION, + EXCLUDE_JUNK_OPTION, LINE_BUFFERED_OPTION, LABEL_OPTION }; @@ -123,6 +124,7 @@ {"extended-regexp", no_argument, NULL, 'E'}, {"exclude", required_argument, NULL, EXCLUDE_OPTION}, {"exclude-from", required_argument, NULL, EXCLUDE_FROM_OPTION}, + {"exclude-junk", no_argument, NULL, EXCLUDE_JUNK_OPTION}, {"file", required_argument, NULL, 'f'}, {"files-with-matches", no_argument, NULL, 'l'}, {"files-without-match", no_argument, NULL, 'L'}, @@ -169,6 +171,7 @@ int match_words; int match_lines; unsigned char eolbyte; +int exclude_junk; /* For error messages. */ /* The name the program was run with, stripped of any leading path. */ @@ -1709,6 +1712,10 @@ label = optarg; break; + case EXCLUDE_JUNK_OPTION: + exclude_junk = 1; + break; + case 0: /* long options */ break; Index: gnu/usr.bin/grep/grep.h =========================================================================== --- gnu/usr.bin/grep/grep.h 2012/02/10 02:20:13 #4 +++ gnu/usr.bin/grep/grep.h 2012/02/10 02:20:13 @@ -42,3 +42,4 @@ extern int match_words; /* -w */ extern int match_lines; /* -x */ extern unsigned char eolbyte; /* -z */ +extern int exclude_junk; /* --exclude-junk */ Index: gnu/usr.bin/grep/savedir.c =========================================================================== --- gnu/usr.bin/grep/savedir.c 2012/02/10 02:20:13 #4 +++ gnu/usr.bin/grep/savedir.c 2012/02/10 02:20:13 @@ -71,6 +71,7 @@ #include #include "savedir.h" +#include "grep.h" char *path; size_t pathlen; @@ -136,6 +137,15 @@ { off_t size_needed = (namep - name_space) + NAMLEN (dp) + 2; + /* Exclude SCM control files and other known junk */ + if (exclude_junk && + (strcmp(dp->d_name, ".svn") == 0 || + strcmp(dp->d_name, "CVS") == 0 || + strcmp(dp->d_name, "RCS") == 0 || + strcmp(dp->d_name, "obj") == 0 || + strcmp(dp->d_name, "compile") == 0) && isdir1 (dir, dp->d_name)) + continue; + if ((included_patterns || excluded_patterns) && !isdir1 (dir, dp->d_name)) { Index: include/Makefile =========================================================================== --- include/Makefile 2012/02/10 02:20:13 #157 +++ include/Makefile 2012/02/10 02:20:13 @@ -6,11 +6,12 @@ .include CLEANFILES= osreldate.h version vers.c -SUBDIR= arpa gssapi protocols rpcsvc rpc +SUBDIR= arpa ${_gssapi} protocols rpcsvc rpc INCS= a.out.h ar.h assert.h bitstring.h complex.h cpio.h _ctype.h ctype.h \ db.h \ - dirent.h dlfcn.h elf.h elf-hints.h err.h fmtmsg.h fnmatch.h fstab.h \ - fts.h ftw.h getopt.h glob.h grp.h gssapi.h \ + dirent.h dlfcn.h elf.h elf-hints.h err.h float.h floatingpoint.h \ + fmtmsg.h fnmatch.h fstab.h fts.h ftw.h getopt.h glob.h grp.h \ + ${_gssapi_h} \ ieeefp.h ifaddrs.h \ inttypes.h iso646.h kenv.h langinfo.h libgen.h limits.h link.h \ locale.h malloc.h malloc_np.h memory.h monetary.h mpool.h mqueue.h \ @@ -19,15 +20,13 @@ printf.h proc_service.h pthread.h \ pthread_np.h pwd.h ranlib.h readpassphrase.h regex.h \ res_update.h resolv.h runetype.h search.h semaphore.h setjmp.h \ - signal.h spawn.h stab.h stdalign.h stdatomic.h stdbool.h stddef.h \ + signal.h spawn.h stab.h stdalign.h stdarg.h stdatomic.h stdbool.h stddef.h \ stdnoreturn.h stdio.h stdlib.h string.h stringlist.h \ strings.h sysexits.h tar.h termios.h tgmath.h \ time.h timeconv.h timers.h ttyent.h \ ulimit.h unistd.h utime.h utmpx.h uuid.h varargs.h vis.h \ wchar.h wctype.h wordexp.h xlocale.h _xlocale_ctype.h -MHDRS= float.h floatingpoint.h stdarg.h - PHDRS= sched.h _semaphore.h LHDRS= aio.h errno.h fcntl.h linker_set.h poll.h stdint.h syslog.h \ @@ -86,6 +85,11 @@ _fs_nwfs= fs/nwfs .endif +.if ${MK_KERBEROS} != "no" +_gssapi= gssapi +_gssapi_h= gssapi.h +.endif + # Define SHARED to indicate whether you want symbolic links to the system # source (``symlinks''), or a separate copy (``copies''). ``symlinks'' is # probably only useful for developers and should be avoided if you do not @@ -112,9 +116,6 @@ .for i in ${LHDRS} INCSLINKS+= sys/$i ${INCLUDEDIR}/$i .endfor -.for i in ${MHDRS} -INCSLINKS+= machine/$i ${INCLUDEDIR}/$i -.endfor .for i in ${PHDRS} INCSLINKS+= sys/$i ${INCLUDEDIR}/$i .endfor @@ -146,6 +147,12 @@ -f ${.CURDIR}/../etc/mtree/BIND.include.dist \ -p ${DESTDIR}${INCLUDEDIR} .endif +.if ${MACHINE_ARCH} == "amd64" && ${MK_LIB32} != "no" + if [ -L ${DESTDIR}${INCLUDEDIR}32/machine ]; then \ + rm -f ${DESTDIR}${INCLUDEDIR}32/machine; \ + fi + mkdir -p ${DESTDIR}${INCLUDEDIR}32/machine +.endif copies: .for i in ${LDIRS} ${LSUBDIRS} ${LSUBSUBDIRS} altq crypto machine machine/pc \ @@ -157,6 +164,13 @@ done .endif .endfor +.if ${MACHINE_ARCH} == "amd64" && ${MK_LIB32} != "no" + mkdir -p ${DESTDIR}${INCLUDEDIR}32/machine + cd ${DESTDIR}${INCLUDEDIR}32/machine; \ + for h in *.h; do \ + if [ -L $$h ]; then rm -f $$h; fi; \ + done +.endif .for i in ${LDIRS} ${LSUBDIRS:Ndev/acpica:Ndev/bktr} ${LSUBSUBDIRS} cd ${.CURDIR}/../sys; \ ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 $i/*.h \ @@ -215,6 +229,11 @@ cd ${.CURDIR}/../sys/rpc; \ ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 types.h \ ${DESTDIR}${INCLUDEDIR}/rpc +.if ${MACHINE_ARCH} == "amd64" && ${MK_LIB32} != "no" + cd ${.CURDIR}/../sys/i386/include; \ + ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 *.h \ + ${DESTDIR}${INCLUDEDIR}32/machine +.endif symlinks: @${ECHO} "Setting up symlinks to kernel source tree..." @@ -315,3 +334,10 @@ ln -fs ../../../sys/rpc/$$h \ ${DESTDIR}${INCLUDEDIR}/rpc; \ done +.if ${MACHINE_ARCH} == "amd64" && ${MK_LIB32} != "no" + cd ${.CURDIR}/../sys/i386/include; \ + for h in *.h; do \ + ln -fs ../../../sys/i386/include/$$h \ + ${DESTDIR}${INCLUDEDIR}32/machine; \ + done +.endif Index: include/float.h =========================================================================== *** /dev/null Fri Feb 10 02:19:45 2012 --- include/float.h Fri Feb 10 02:20:19 2012 *************** *** 0 **** --- 1,28 ---- + /*- + * Copyright (c) 2004 Peter Wemm + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + #include Index: include/floatingpoint.h =========================================================================== *** /dev/null Fri Feb 10 02:19:45 2012 --- include/floatingpoint.h Fri Feb 10 02:20:19 2012 *************** *** 0 **** --- 1,28 ---- + /*- + * Copyright (c) 2004 Peter Wemm + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + #include Index: include/stdarg.h =========================================================================== *** /dev/null Fri Feb 10 02:19:45 2012 --- include/stdarg.h Fri Feb 10 02:20:19 2012 *************** *** 0 **** --- 1,28 ---- + /*- + * Copyright (c) 2004 Peter Wemm + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + #include Index: lib/Makefile =========================================================================== --- lib/Makefile 2012/02/10 02:20:13 #142 +++ lib/Makefile 2012/02/10 02:20:13 @@ -231,4 +231,8 @@ _libusb= libusb .endif +.if ${MK_KERBEROS} != "no" +_libgssapi= libgssapi +.endif + .include Index: lib/libc/stdlib/system.c =========================================================================== --- lib/libc/stdlib/system.c 2012/02/10 02:20:13 #5 +++ lib/libc/stdlib/system.c 2012/02/10 02:20:13 @@ -56,39 +56,39 @@ if (!command) /* just checking... */ return(1); - /* - * Ignore SIGINT and SIGQUIT, block SIGCHLD. Remember to save - * existing signal dispositions. - */ - ign.sa_handler = SIG_IGN; - (void)sigemptyset(&ign.sa_mask); - ign.sa_flags = 0; - (void)_sigaction(SIGINT, &ign, &intact); - (void)_sigaction(SIGQUIT, &ign, &quitact); (void)sigemptyset(&newsigblock); (void)sigaddset(&newsigblock, SIGCHLD); (void)_sigprocmask(SIG_BLOCK, &newsigblock, &oldsigblock); - switch(pid = fork()) { + switch(pid = vfork()) { case -1: /* error */ break; case 0: /* child */ /* * Restore original signal dispositions and exec the command. */ - (void)_sigaction(SIGINT, &intact, NULL); - (void)_sigaction(SIGQUIT, &quitact, NULL); (void)_sigprocmask(SIG_SETMASK, &oldsigblock, NULL); execl(_PATH_BSHELL, "sh", "-c", command, (char *)NULL); _exit(127); default: /* parent */ + /* + * If we are running means that the child has either completed + * its execve, or has failed. + * Block SIGINT/QUIT because sh -c handles it and wait for + * it to clean up. + */ + ign.sa_handler = SIG_IGN; + (void)sigemptyset(&ign.sa_mask); + ign.sa_flags = 0; + (void)_sigaction(SIGINT, &ign, &intact); + (void)_sigaction(SIGQUIT, &ign, &quitact); savedpid = pid; do { pid = _wait4(savedpid, &pstat, 0, (struct rusage *)0); } while (pid == -1 && errno == EINTR); + (void)_sigaction(SIGINT, &intact, NULL); + (void)_sigaction(SIGQUIT, &quitact, NULL); break; } - (void)_sigaction(SIGINT, &intact, NULL); - (void)_sigaction(SIGQUIT, &quitact, NULL); (void)_sigprocmask(SIG_SETMASK, &oldsigblock, NULL); return(pid == -1 ? -1 : pstat); } Index: lib/libkvm/kvm_amd64.c =========================================================================== --- lib/libkvm/kvm_amd64.c 2012/02/10 02:20:13 #10 +++ lib/libkvm/kvm_amd64.c 2012/02/10 02:20:13 @@ -76,6 +76,11 @@ void *mmapbase; size_t mmapsize; pml4_entry_t *PML4; +#if 0 + int mp_maxcpus; + int pcpu_recsize; + char *pcpu; +#endif }; /* @@ -355,3 +360,74 @@ } return (_kvm_vatop(kd, va, pa)); } + +#if 0 +static int +_kvm_initpcpu(kvm_t *kd) +{ + struct nlist nlist[2]; + u_long pa; + struct vmstate *vm = kd->vmst; + + nlist[0].n_name = "mp_maxcpus"; + nlist[1].n_name = 0; + if (kvm_nlist(kd, nlist) == 0) { + if (kvm_read(kd, nlist[0].n_value, &vm->mp_maxcpus, + sizeof(vm->mp_maxcpus)) != sizeof(vm->mp_maxcpus)) { + _kvm_err(kd, kd->program, "cannot read mp_maxcpus"); + } else { + /* UP system; symbol doesn't exist */ + vmst->mp_maxcpus = 1; + } + /* + * The __pcpu array may have different inter-record padding or may + * grow additional fields. We have to adapt the best we can. + */ + nlist[0].n_name = "pcpu_size"; + nlist[1].n_name = 0; + if (kvm_nlist(kd, nlist) == 0) { + if (kvm_read(kd, nlist[0].n_value, &vm->pcpu_recsize, + sizeof(vm->pcpu_recsize)) != sizeof(vm->pcpu_recsize)) { + _kvm_err(kd, kd->program, "cannot read pcpu_size"); + } else { + /* Older kernel's dont have it. Hope for the best. */ + vmst->pcpu_recsize = sizeof(struct pcpu); + } + vm->pcpu = _kvm_malloc(kd, vm->pcpu_recsize * vm->mp_maxcpus); + + nlist[0].n_name = "__pcpu"; + nlist[1].n_name = 0; + + if (kvm_nlist(kd, nlist) != 0) { + _kvm_err(kd, kd->program, "bad namelist - no pcpu"); + return (-1); + } + if (kvm_read(kd, nlist[0].n_value, vm->pcpu, + vm->pcpu_recsize * vm->mp_maxcpus) != + vm->pcpu_recsize * vm->mp_maxcpus) { + _kvm_err(kd, kd->program, "cannot read pcpu chunk"); + return (-1); + } + return (0); +} + +struct pcpu * +kvm_pcpu_get(kvm_t *kd, int cpu) +{ + struct vmstate *vm = kd->vmst; + + if (ISALIVE(kd)) { + _kvm_err(kd, kd->program, "kvm_initpcpu called in live kernel!"); + return (NULL); + } + if (vm->mp_maxcpus == 0 || vm->pcpu == NULL) { + if (_kvm_initpcpu(kd) != 0) + return (NULL); + } + + if (cpu < 0 || cpu > vm->vm_maxcpus) + _kvm_err(kd, kd->program, ""); + return (NULL); /* EDOOFUS actually */ + return ((struct pcpu *)&vm->pcpu[cpu * vm->pcpu_recsize]); +} +#endif Index: lib/libutil/kld.c =========================================================================== --- lib/libutil/kld.c 2012/02/10 02:20:13 #3 +++ lib/libutil/kld.c 2012/02/10 02:20:13 @@ -38,32 +38,8 @@ int kld_isloaded(const char *name) { - struct kld_file_stat fstat; - struct module_stat mstat; - const char *ko; - int fid, mid; - - for (fid = kldnext(0); fid > 0; fid = kldnext(fid)) { - fstat.version = sizeof(fstat); - if (kldstat(fid, &fstat) != 0) - continue; - /* check if the file name matches the supplied name */ - if (strcmp(fstat.name, name) == 0) - return (1); - /* strip .ko and try again */ - if ((ko = strstr(fstat.name, ".ko")) != NULL && - strlen(name) == (size_t)(ko - fstat.name) && - strncmp(fstat.name, name, ko - fstat.name) == 0) - return (1); - /* look for a matching module within the file */ - for (mid = kldfirstmod(fid); mid > 0; mid = modfnext(mid)) { - mstat.version = sizeof(mstat); - if (modstat(mid, &mstat) != 0) - continue; - if (strcmp(mstat.name, name) == 0) - return (1); - } - } + if (modfind(name) != -1 || kldfind(name) != -1) + return (1); return (0); } Index: libexec/rtld-elf/Makefile =========================================================================== --- libexec/rtld-elf/Makefile 2012/02/10 02:20:13 #39 +++ libexec/rtld-elf/Makefile 2012/02/10 02:20:13 @@ -9,7 +9,7 @@ malloc.c xmalloc.c debug.c libmap.c MAN= rtld.1 CSTD?= gnu99 -CFLAGS+= -Wall -DFREEBSD_ELF -DIN_RTLD +CFLAGS+= -Wall -DFREEBSD_ELF -DIN_RTLD -g -DDEBUG .if exists(${.CURDIR}/${MACHINE_ARCH}) RTLD_ARCH= ${MACHINE_ARCH} .else Index: libexec/rtld-elf/rtld.c =========================================================================== --- libexec/rtld-elf/rtld.c 2012/02/10 02:20:13 #124 +++ libexec/rtld-elf/rtld.c 2012/02/10 02:20:13 @@ -1212,8 +1212,12 @@ } if (refobj != NULL && refobj->z_origin) return origin_subst(xname, refobj->origin_path); - else - return xstrdup(xname); +#ifdef COMPAT_32BIT + name = lm_find(NULL, xname); + if (name) + return xstrdup(name); +#endif + return xstrdup(xname); } if (libmap_disable || (refobj == NULL) || Index: sbin/dmesg/dmesg.c =========================================================================== --- sbin/dmesg/dmesg.c 2012/02/10 02:20:13 #14 +++ sbin/dmesg/dmesg.c 2012/02/10 02:20:13 @@ -124,8 +124,10 @@ if (nl[X_MSGBUF].n_type == 0) errx(1, "%s: msgbufp not found", nlistf ? nlistf : "namelist"); - if (KREAD(nl[X_MSGBUF].n_value, bufp) || KREAD((long)bufp, cur)) - errx(1, "kvm_read: %s", kvm_geterr(kd)); + if (KREAD(nl[X_MSGBUF].n_value, bufp)) + errx(1, "kvm_read: msgbufp: %s", kvm_geterr(kd)); + if (KREAD((long)bufp, cur)) + errx(1, "kvm_read: msgbuf: %s", kvm_geterr(kd)); if (cur.msg_magic != MSG_MAGIC) errx(1, "kernel message buffer has different magic " "number"); Index: sbin/savecore/savecore.c =========================================================================== --- sbin/savecore/savecore.c 2012/02/10 02:20:13 #42 +++ sbin/savecore/savecore.c 2012/02/10 02:20:13 @@ -79,6 +79,7 @@ #include #include #include +#include /* The size of the buffer used for I/O. */ #define BUFFERSIZE (1024*1024) @@ -102,6 +103,10 @@ uint64_t dumplen; time_t t; const char *stat_str; + const struct kerneldumpheader_v1 *h_v1 = (const struct kerneldumpheader_v1 *)h; + char *uuid_string; + uint32_t uuid_ret; + uuid_t u; fprintf(f, "Dump header from device %s\n", device); fprintf(f, " Architecture: %s\n", h->architecture); @@ -116,7 +121,18 @@ fprintf(f, " Hostname: %s\n", h->hostname); fprintf(f, " Magic: %s\n", h->magic); fprintf(f, " Version String: %s", h->versionstring); - fprintf(f, " Panic String: %s\n", h->panicstring); + if (dtoh32(h->version) == KERNELDUMPVERSION_V1) { + fprintf(f, " Panic String: %s\n", h_v1->panicstring); + } else { + fprintf(f, " Panic String: %s\n", h->panicstring); + uuid_string = NULL; + memcpy(&u, h->uuid, sizeof(u)); + uuid_to_string(&u, &uuid_string, &uuid_ret); + if (uuid_ret == uuid_s_ok) + fprintf(f, " Build uuid: %s\n", uuid_string); + if (uuid_string) + free(uuid_string); + } fprintf(f, " Dump Parity: %u\n", h->parity); fprintf(f, " Bounds: %d\n", bounds); @@ -439,7 +455,8 @@ } } else if (memcmp(kdhl.magic, KERNELDUMPMAGIC, sizeof kdhl.magic) == 0) { - if (dtoh32(kdhl.version) != KERNELDUMPVERSION) { + if (dtoh32(kdhl.version) != KERNELDUMPVERSION && + dtoh32(kdhl.version) != KERNELDUMPVERSION_V1) { syslog(LOG_ERR, "unknown version (%d) in last dump header on %s", dtoh32(kdhl.version), device); @@ -467,7 +484,8 @@ syslog(LOG_ERR, "unable to force dump - bad magic"); goto closefd; } - if (dtoh32(kdhl.version) != KERNELDUMPVERSION) { + if (dtoh32(kdhl.version) != KERNELDUMPVERSION && + dtoh32(kdhl.version) != KERNELDUMPVERSION_V1) { syslog(LOG_ERR, "unknown version (%d) in last dump header on %s", dtoh32(kdhl.version), device); Index: share/mk/bsd.lib.mk =========================================================================== --- share/mk/bsd.lib.mk 2012/02/10 02:20:13 #102 +++ share/mk/bsd.lib.mk 2012/02/10 02:20:13 @@ -33,6 +33,15 @@ NO_WERROR= .endif +# valgrind help +.if ${MACHINE_ARCH} == "amd64" +CFLAGS+= -fno-omit-frame-pointer +DEBUG_FLAGS+=-g +.endif +.if ${MACHINE_ARCH} == "i386" +DEBUG_FLAGS+=-g +.endif + .if defined(DEBUG_FLAGS) CFLAGS+= ${DEBUG_FLAGS} Index: sys/amd64/amd64/db_disasm.c =========================================================================== --- sys/amd64/amd64/db_disasm.c 2012/02/10 02:20:13 #7 +++ sys/amd64/amd64/db_disasm.c 2012/02/10 02:20:13 @@ -30,11 +30,27 @@ /* * Instruction disassembler. */ +#ifdef _KERNEL #include #include #include #include +#else +#include +#include +#include + +typedef unsigned long db_addr_t; +#define db_printf printf +#define db_printsym(x, y) printf("%#lx", (long)(x)); +typedef int boolean_t; +typedef unsigned int db_expr_t; +#define FALSE 0 +#define TRUE 1 +void db_read_bytes(db_addr_t addr, int size, char *data) { memcpy(data, (void *)addr, size); } +db_expr_t db_get_value(db_addr_t addr, int size, boolean_t is_signed); +#endif /* * Size attributes @@ -950,6 +966,7 @@ } addrp->is_reg = FALSE; addrp->index = 0; +/* printf("[[short_addr %d, mod %d rm %d, rex %x]]", short_addr,mod, rm, rex); */ if (short_addr) size = LONG; @@ -967,6 +984,7 @@ } else have_sib = 0; +/* printf("[mod %d]", mod); */ switch (mod) { case 0: if (rm == 5) { @@ -1005,6 +1023,7 @@ int rex; struct i_addr * addrp; { +/* printf("[rex:0x%x,size=%d]", rex, size); */ if (addrp->is_reg) { db_printf("%s", db_reg[rex != 0 ? 1 : 0][(size == LONG && (rex & REX_W)) ? QUAD : size][addrp->disp]); return; @@ -1157,6 +1176,9 @@ size = LONG; seg = 0; +#ifndef _KERNEL +printf("0x%08x: ", loc); +#endif /* * Get prefixes */ @@ -1331,130 +1353,190 @@ if (!first) db_printf(","); +#ifdef _KERNEL +#define M(s) do { } while (0) +#else +#if 0 +#define M(s) printf(s) +#else +#define M(s) do { } while (0) +#endif +#endif switch (i_mode & 0xFF) { case E: + M("[E]"); db_print_address(seg, size, rex, &address); break; case Eind: + M("[Eind]"); db_printf("*"); db_print_address(seg, size, rex, &address); break; case El: + M("[El]"); db_print_address(seg, (rex & REX_W) ? QUAD : LONG, rex, &address); break; case EL: + M("[EL]"); db_print_address(seg, LONG, 0, &address); break; case Ew: + M("[Ew]"); db_print_address(seg, WORD, rex, &address); break; case Eb: + M("[Eb]"); db_print_address(seg, BYTE, rex, &address); break; case R: + M("[R]"); db_printf("%s", db_reg[rex != 0 ? 1 : 0][(size == LONG && (rex & REX_W)) ? QUAD : size][f_reg(rex, regmodrm)]); break; case Rw: + M("[Rw]"); db_printf("%s", db_reg[rex != 0 ? 1 : 0][WORD][f_reg(rex, regmodrm)]); break; case Ri: + M("[Ri]"); db_printf("%s", db_reg[0][QUAD][f_rm(rex, inst)]); break; case Ril: + M("[Ril]"); db_printf("%s", db_reg[rex != 0 ? 1 : 0][(rex & REX_R) ? QUAD : LONG][f_rm(rex, inst)]); break; case S: + M("[S]"); db_printf("%s", db_seg_reg[f_reg(rex, regmodrm)]); break; case Si: + M("[Si]"); db_printf("%s", db_seg_reg[f_reg(rex, inst)]); break; case A: + M("[A]"); db_printf("%s", db_reg[rex != 0 ? 1 : 0][size][0]); /* acc */ break; case BX: + M("[BX]"); if (seg) db_printf("%s:", seg); db_printf("(%s)", short_addr ? "%bx" : "%ebx"); break; case CL: + M("[CL]"); db_printf("%%cl"); break; case DX: + M("[DX]"); db_printf("%%dx"); break; case SI: + M("[SI]"); if (seg) db_printf("%s:", seg); db_printf("(%s)", short_addr ? "%si" : "%rsi"); break; case DI: + M("[DI]"); db_printf("%%es:(%s)", short_addr ? "%di" : "%rdi"); break; case CR: + M("[CR]"); db_printf("%%cr%d", f_reg(rex, regmodrm)); break; case DR: + M("[DR]"); db_printf("%%dr%d", f_reg(rex, regmodrm)); break; case TR: + M("[TR]"); db_printf("%%tr%d", f_reg(rex, regmodrm)); break; case I: + M("[I]"); len = db_lengths[size]; get_value_inc(imm, loc, len, FALSE); +#ifdef _KERNEL db_printf("$%#r", imm); +#else + db_printf("$%#x", imm); +#endif break; case Is: + M("[Is]"); len = db_lengths[(size == LONG && (rex & REX_W)) ? QUAD : size]; get_value_inc(imm, loc, len, FALSE); +#ifdef _KERNEL db_printf("$%+#r", imm); +#else + db_printf("$%#x", imm); +#endif break; case Ib: + M("[Ib]"); get_value_inc(imm, loc, 1, FALSE); +#ifdef _KERNEL db_printf("$%#r", imm); +#else + db_printf("$%#x", imm); +#endif break; case Iba: + M("[Iba]"); get_value_inc(imm, loc, 1, FALSE); if (imm != 0x0a) +#ifdef _KERNEL db_printf("$%#r", imm); +#else + db_printf("$%#x", imm); +#endif break; case Ibs: + M("[Ibs]"); get_value_inc(imm, loc, 1, TRUE); if (size == WORD) imm &= 0xFFFF; +#ifdef _KERNEL db_printf("$%+#r", imm); +#else + db_printf("$%#x", imm); +#endif break; case Iw: + M("[Iw]"); get_value_inc(imm, loc, 2, FALSE); +#ifdef _KERNEL db_printf("$%#r", imm); +#else + db_printf("$%#x", imm); +#endif break; case Ilq: @@ -1464,15 +1546,21 @@ break; case O: + M("[O]"); len = (short_addr ? 2 : 4); get_value_inc(displ, loc, len, FALSE); if (seg) +#ifdef _KERNEL db_printf("%s:%+#r",seg, displ); +#else + db_printf("%s:%#x",seg, displ); +#endif else db_printsym((db_addr_t)displ, DB_STGY_ANY); break; case Db: + M("[Db]"); get_value_inc(displ, loc, 1, TRUE); displ += loc; if (size == WORD) @@ -1481,6 +1569,7 @@ break; case Dl: + M("[Dl]"); len = db_lengths[(size == LONG && (rex & REX_W)) ? QUAD : size]; get_value_inc(displ, loc, len, FALSE); displ += loc; @@ -1490,21 +1579,87 @@ break; case o1: + M("[o1]"); db_printf("$1"); break; case o3: + M("[o3]"); db_printf("$3"); break; case OS: + M("[OS]"); len = db_lengths[size]; get_value_inc(imm, loc, len, FALSE); /* offset */ get_value_inc(imm2, loc, 2, FALSE); /* segment */ +#ifdef _KERNEL db_printf("$%#r,%#r", imm2, imm); +#else + db_printf("$%#x,%#x", imm2, imm); +#endif break; } } db_printf("\n"); return (loc); +#undef M } + +#ifndef _KERNEL +/* Just self-disassemble for a a few instructions */ +int +main(int ac, char *av[]) +{ + db_addr_t base = (db_addr_t)main; + int i; + for (i = 0; i < 60; i++) + base = db_disasm(base, 0); + return 0; +} +void tasm(void) +{ + asm("push %si"); +} + +/* + * Access unaligned data items on aligned (longword) + * boundaries. + */ + +static unsigned db_extend[] = { /* table for sign-extending */ + 0, + 0xFFFFFF80U, + 0xFFFF8000U, + 0xFF800000U +}; + +db_expr_t +db_get_value(addr, size, is_signed) + db_addr_t addr; + register int size; + boolean_t is_signed; +{ + char data[sizeof(int)]; + register db_expr_t value; + register int i; + + db_read_bytes(addr, size, data); + + value = 0; +#if BYTE_MSF + for (i = 0; i < size; i++) +#else /* BYTE_LSF */ + for (i = size - 1; i >= 0; i--) +#endif + { + value = (value << 8) + (data[i] & 0xFF); + } + + if (size < 4) { + if (is_signed && (value & db_extend[size]) != 0) + value |= db_extend[size]; + } + return (value); +} +#endif Index: sys/amd64/amd64/exception.S =========================================================================== --- sys/amd64/amd64/exception.S 2012/02/10 02:20:13 #55 +++ sys/amd64/amd64/exception.S 2012/02/10 02:20:13 @@ -317,7 +317,7 @@ movl $T_PROTFLT,TF_TRAPNO(%rsp) movq $0,TF_ADDR(%rsp) movq %rdi,TF_RDI(%rsp) /* free up a GP register */ - leaq doreti_iret(%rip),%rdi + leaq doreti_iret(%rip),%rdi /* iretq trapped */ cmpq %rdi,TF_RIP(%rsp) je 1f /* kernel but with user gsbase!! */ testb $SEL_RPL_MASK,TF_CS(%rsp) /* Did we come from kernel? */ Index: sys/amd64/amd64/machdep.c =========================================================================== --- sys/amd64/amd64/machdep.c 2012/02/10 02:20:13 #195 +++ sys/amd64/amd64/machdep.c 2012/02/10 02:20:13 @@ -203,6 +203,7 @@ struct region_descriptor r_gdt, r_idt; struct pcpu __pcpu[MAXCPU]; +int pcpu_size = sizeof(__pcpu[0]); struct mtx icu_lock; @@ -2380,6 +2381,10 @@ DBREG_DR7_LEN(dbregs->dr[7], i) == DBREG_DR7_LEN_8) return (EINVAL); } + /* + * Bits 5-12 and 32-63 are reserved for dr6, and bits 10-15 and + * 32-63 of dr7 are reserved. However, bits 32-63 cause a GPF. + */ if ((dbregs->dr[6] & 0xffffffff00000000ul) != 0 || (dbregs->dr[7] & 0xffffffff00000000ul) != 0) return (EINVAL); Index: sys/amd64/amd64/minidump_machdep.c =========================================================================== --- sys/amd64/amd64/minidump_machdep.c 2012/02/10 02:20:13 #16 +++ sys/amd64/amd64/minidump_machdep.c 2012/02/10 02:20:13 @@ -40,6 +40,7 @@ #ifdef SW_WATCHDOG #include #endif +#include #include #include #include @@ -333,6 +334,7 @@ mdhdr.kernbase = VM_MIN_KERNEL_ADDRESS; mdhdr.dmapbase = DMAP_MIN_ADDRESS; mdhdr.dmapend = DMAP_MAX_ADDRESS; + strncpy(mdhdr.build_uuid, build_uuid, sizeof(mdhdr.build_uuid) - 1); mkdumpheader(&kdh, KERNELDUMPMAGIC, KERNELDUMP_AMD64_VERSION, dumpsize, di->blocksize); Index: sys/amd64/amd64/pmap.c =========================================================================== --- sys/amd64/amd64/pmap.c 2012/02/10 02:20:13 #323 +++ sys/amd64/amd64/pmap.c 2012/02/10 02:20:13 @@ -426,13 +426,20 @@ pmap->pm_stats.resident_count -= count; } -PMAP_INLINE pt_entry_t * -vtopte(vm_offset_t va) +static __inline pt_entry_t * +_vtopte(vm_offset_t va) { u_int64_t mask = ((1ul << (NPTEPGSHIFT + NPDEPGSHIFT + NPDPEPGSHIFT + NPML4EPGSHIFT)) - 1); return (PTmap + ((va >> PAGE_SHIFT) & mask)); } +pt_entry_t * +vtopte(vm_offset_t va) +{ + + return (_vtopte(va)); +} +#define vtopte(v) _vtopte(v) static __inline pd_entry_t * vtopde(vm_offset_t va) @@ -1075,7 +1082,7 @@ * Normal, non-SMP, invalidation functions. * We inline these within pmap.c for speed. */ -PMAP_INLINE void +static __inline void pmap_invalidate_page(pmap_t pmap, vm_offset_t va) { @@ -1083,7 +1090,7 @@ invlpg(va); } -PMAP_INLINE void +static __inline void pmap_invalidate_range(pmap_t pmap, vm_offset_t sva, vm_offset_t eva) { vm_offset_t addr; @@ -1093,7 +1100,7 @@ invlpg(addr); } -PMAP_INLINE void +static __inline void pmap_invalidate_all(pmap_t pmap) { @@ -1101,7 +1108,7 @@ invltlb(); } -PMAP_INLINE void +static __inline void pmap_invalidate_cache(void) { @@ -1315,7 +1322,7 @@ * Add a wired page to the kva. * Note: not SMP coherent. */ -PMAP_INLINE void +void pmap_kenter(vm_offset_t va, vm_paddr_t pa) { pt_entry_t *pte; @@ -1337,7 +1344,7 @@ * Remove a page from the kernel pagetables. * Note: not SMP coherent. */ -PMAP_INLINE void +void pmap_kremove(vm_offset_t va) { pt_entry_t *pte; @@ -1406,10 +1413,12 @@ pmap_qremove(vm_offset_t sva, int count) { vm_offset_t va; + pt_entry_t *pte; va = sva; while (count-- > 0) { - pmap_kremove(va); + pte = vtopte(va); + pte_clear(pte); va += PAGE_SIZE; } pmap_invalidate_range(kernel_pmap, sva, va); @@ -4078,6 +4087,11 @@ vm_page_lock_queues(); PMAP_LOCK(pmap); TAILQ_FOREACH_SAFE(pc, &pmap->pm_pvchunk, pc_list, npc) { + /* + * XXX removal of the sva/eva bounding wasn't necessary + * after all because we still have to work around the + * skipping of a PG_W page. oops. + */ allfree = 1; for (field = 0; field < _NPCM; field++) { inuse = (~(pc->pc_map[field])) & pc_freemask[field]; @@ -5090,15 +5104,20 @@ } void -pmap_activate(struct thread *td) +pmap_switch_vmspace(struct vmspace *vm) { pmap_t pmap, oldpmap; u_int cpuid; + struct thread *td; u_int64_t cr3; + td = curthread; + oldpmap = vmspace_pmap(td->td_proc->p_vmspace); + PROC_VMSPACE_LOCK(td->td_proc); + td->td_proc->p_vmspace = vm; + PROC_VMSPACE_UNLOCK(td->td_proc); + pmap = vmspace_pmap(vm); critical_enter(); - pmap = vmspace_pmap(td->td_proc->p_vmspace); - oldpmap = PCPU_GET(curpmap); cpuid = PCPU_GET(cpuid); #ifdef SMP CPU_CLR_ATOMIC(cpuid, &oldpmap->pm_active); Index: sys/amd64/conf/NOTES =========================================================================== --- sys/amd64/conf/NOTES 2012/02/10 02:20:13 #110 +++ sys/amd64/conf/NOTES 2012/02/10 02:20:13 @@ -6,6 +6,8 @@ # # $FreeBSD: src/sys/amd64/conf/NOTES,v 1.112 2011/12/28 23:26:58 delphij Exp $ # +# (XXX from i386:NOTES,v 1.1220) +# # # We want LINT to cover profiling as well. @@ -281,6 +283,7 @@ # Network interfaces: # +# cs: IBM Etherjet and other Crystal Semi CS89x0-based adapters # ed: Western Digital and SMC 80xx; Novell NE1000 and NE2000; 3Com 3C503 # HP PC Lan+, various PC Card devices # (requires miibus) @@ -298,6 +301,9 @@ # wpi: Intel 3945ABG Wireless LAN controller # Requires the wpi firmware module +device cs +hint.cs.0.at="isa" +hint.cs.0.port="0x300" device ed options ED_3C503 options ED_HPP @@ -387,12 +393,12 @@ device aac device aacp # SCSI Passthrough interface (optional, CAM required) -# # Highpoint RocketRAID 27xx. device hpt27xx # # Highpoint RocketRAID 182x. +# device hptmv # Index: sys/amd64/include/cpufunc.h =========================================================================== --- sys/amd64/include/cpufunc.h 2012/02/10 02:20:13 #32 +++ sys/amd64/include/cpufunc.h 2012/02/10 02:20:13 @@ -481,41 +481,13 @@ __asm __volatile("mwait" : : "a" (hints), "c" (extensions)); } -#ifdef _KERNEL -/* This is defined in but is too painful to get to */ -#ifndef MSR_FSBASE -#define MSR_FSBASE 0xc0000100 -#endif static __inline void load_fs(u_short sel) { - /* Preserve the fsbase value across the selector load */ - __asm __volatile("rdmsr; movw %0,%%fs; wrmsr" - : : "rm" (sel), "c" (MSR_FSBASE) : "eax", "edx"); + __asm __volatile("movw %0,%%fs" : : "rm" (sel)); } -#ifndef MSR_GSBASE -#define MSR_GSBASE 0xc0000101 -#endif -static __inline void -load_gs(u_short sel) -{ - /* - * Preserve the gsbase value across the selector load. - * Note that we have to disable interrupts because the gsbase - * being trashed happens to be the kernel gsbase at the time. - */ - __asm __volatile("pushfq; cli; rdmsr; movw %0,%%gs; wrmsr; popfq" - : : "rm" (sel), "c" (MSR_GSBASE) : "eax", "edx"); -} -#else -/* Usable by userland */ -static __inline void -load_fs(u_short sel) -{ - __asm __volatile("movw %0,%%fs" : : "rm" (sel)); -} - +#ifndef _KERNEL /* Do not use in kernel */ static __inline void load_gs(u_short sel) { Index: sys/amd64/include/minidump.h =========================================================================== --- sys/amd64/include/minidump.h 2012/02/10 02:20:13 #2 +++ sys/amd64/include/minidump.h 2012/02/10 02:20:13 @@ -41,6 +41,7 @@ uint64_t kernbase; uint64_t dmapbase; uint64_t dmapend; + char build_uuid[40]; }; #endif /* _MACHINE_MINIDUMP_H_ */ Index: sys/amd64/include/pcpu.h =========================================================================== --- sys/amd64/include/pcpu.h 2012/02/10 02:20:13 #23 +++ sys/amd64/include/pcpu.h 2012/02/10 02:20:13 @@ -80,6 +80,7 @@ PCPU_XEN_FIELDS #ifdef _KERNEL +#define PCPU_MD_ALIGN __aligned(64) /* use unique cache line per entry */ #ifdef lint Index: sys/boot/i386/Makefile.inc =========================================================================== --- sys/boot/i386/Makefile.inc 2012/02/10 02:20:13 #15 +++ sys/boot/i386/Makefile.inc 2012/02/10 02:20:13 @@ -12,7 +12,7 @@ .if ${MACHINE_CPUARCH} == "amd64" CFLAGS+= -m32 -march=i386 ACFLAGS+= -m32 -LDFLAGS+= -m elf_i386_fbsd +LDFLAGS+= -m elf_i386_fbsd -L${LIBDIR} AFLAGS+= --32 .endif Index: sys/boot/i386/pxeldr/Makefile =========================================================================== --- sys/boot/i386/pxeldr/Makefile 2012/02/10 02:20:13 #13 +++ sys/boot/i386/pxeldr/Makefile 2012/02/10 02:20:13 @@ -1,5 +1,7 @@ # $FreeBSD: src/sys/boot/i386/pxeldr/Makefile,v 1.18 2011/02/20 19:33:47 dim Exp $ +BOOT_PXELDR_PROBE_KEYBOARD=yes + # Pick up ../Makefile.inc early. .include Index: sys/conf/files =========================================================================== --- sys/conf/files 2012/02/10 02:20:13 #1086 +++ sys/conf/files 2012/02/10 02:20:13 @@ -2496,6 +2496,7 @@ kern/vfs_subr.c standard kern/vfs_syscalls.c standard kern/vfs_vnops.c standard +kern/ylock.c optional ylock # # Kernel GSS-API # Index: sys/conf/newvers.sh =========================================================================== --- sys/conf/newvers.sh 2012/02/10 02:20:13 #52 +++ sys/conf/newvers.sh 2012/02/10 02:20:13 @@ -86,6 +86,7 @@ touch version v=`cat version` u=${USER:-root} d=`pwd` h=${HOSTNAME:-`hostname`} t=`date` i=`${MAKE:-make} -V KERN_IDENT` +uuid=`uuidgen` for dir in /bin /usr/bin /usr/local/bin; do if [ -x "${dir}/svnversion" ] ; then @@ -140,6 +141,7 @@ char osrelease[sizeof(RELSTR) > 32 ? sizeof(RELSTR) : 32] = RELSTR; int osreldate = ${RELDATE}; char kern_ident[] = "${i}"; +char build_uuid[] = "${uuid}"; EOF echo $((v + 1)) > version Index: sys/dev/si/si.c =========================================================================== --- sys/dev/si/si.c 2012/02/10 02:20:13 #37 +++ sys/dev/si/si.c 2012/02/10 02:20:13 @@ -1549,7 +1549,7 @@ /* This is very very bad. The card has crashed. */ /* XXX the driver breaks at this point */ if (err == ETIMEDOUT) - DPRINT(("%s: tsleep1 timeout. hi_stat %s, sp_pend %s\n", pp->sp_name, si_cmdname(ccbp->hi_stat), si_cmdname(pp->sp_pend))); + DPRINT((pp, DBG_PARAM, "%s: tsleep1 timeout. hi_stat %s, sp_pend %s\n", pp->sp_name, si_cmdname(ccbp->hi_stat), si_cmdname(pp->sp_pend))); splx(oldspl); return; } @@ -1586,7 +1586,7 @@ if (err) { DPRINT((pp, DBG_PARAM, "sicmd2 tsleep error: hi_stat (%s) sp_pend (%s)\n", si_cmdname(ccbp->hi_stat), si_cmdname(pp->sp_pend))); if (err == ETIMEDOUT) { - DPRINT(("%s: tsleep2 timeout. hi_stat %s, sp_pend %s\n", pp->sp_name, si_cmdname(ccbp->hi_stat), si_cmdname(pp->sp_pend))); + DPRINT((pp, DBG_PARAM, "%s: tsleep2 timeout. hi_stat %s, sp_pend %s\n", pp->sp_name, si_cmdname(ccbp->hi_stat), si_cmdname(pp->sp_pend))); } break; } Index: sys/dev/sio/sio.c =========================================================================== --- sys/dev/sio/sio.c 2012/02/10 02:20:13 #132 +++ sys/dev/sio/sio.c 2012/02/10 02:20:13 @@ -1833,7 +1833,7 @@ */ com->fifo_image = com->unit == siotsunit ? 0 : t->c_ispeed <= 4800 - ? FIFO_ENABLE : FIFO_ENABLE | FIFO_RX_MEDH; + ? FIFO_ENABLE : FIFO_ENABLE | FIFO_RX_MEDL; #ifdef COM_ESP /* * The Hayes ESP card needs the fifo DMA mode bit set Index: sys/dev/uart/uart_bus_acpi.c =========================================================================== --- sys/dev/uart/uart_bus_acpi.c 2012/02/10 02:20:13 #4 +++ sys/dev/uart/uart_bus_acpi.c 2012/02/10 02:20:13 @@ -41,11 +41,12 @@ #include static int uart_acpi_probe(device_t dev); +static int uart_acpi_attach(device_t dev); static device_method_t uart_acpi_methods[] = { /* Device interface */ DEVMETHOD(device_probe, uart_acpi_probe), - DEVMETHOD(device_attach, uart_bus_attach), + DEVMETHOD(device_attach, uart_acpi_attach), DEVMETHOD(device_detach, uart_bus_detach), { 0, 0 } }; @@ -81,4 +82,49 @@ return (ENXIO); } +/* XXX find matching 'port' if it exists. */ +/* + * Don't cut and paste this to other drivers. It is a horrible kludge + * which will fail to work and also be unnecessary in future versions. + */ +static void +uart_acpi_kludge_unit(device_t dev) +{ + devclass_t dc; + int err; + int start; + int unit; + u_int port; + + port = bus_get_resource_start(dev, SYS_RES_IOPORT, 0); + if (port == -1) + device_printf(dev, "cannot find start port"); + unit = 0; + start = 0; + while (resource_int_value("uart", unit, "port", &start) == 0 && + start > 0) { + if (start == port) + break; + else + unit++; + } + if (device_get_unit(dev) < unit) { + dc = device_get_devclass(dev); + while (devclass_get_device(dc, unit)) + unit++; + device_printf(dev, "moving to uart%d\n", unit); + err = device_set_unit(dev, unit); /* EVIL DO NOT COPY */ + if (err) + device_printf(dev, "error moving device %d\n", err); + } +} + +static int +uart_acpi_attach(device_t dev) +{ + + uart_acpi_kludge_unit(dev); + return (uart_bus_attach(dev)); +} + DRIVER_MODULE(uart, acpi, uart_acpi_driver, uart_devclass, 0, 0); Index: sys/dev/uart/uart_bus_puc.c =========================================================================== --- sys/dev/uart/uart_bus_puc.c 2012/02/10 02:20:13 #3 +++ sys/dev/uart/uart_bus_puc.c 2012/02/10 02:20:13 @@ -44,11 +44,12 @@ #include static int uart_puc_probe(device_t dev); +static int uart_puc_attach(device_t dev); static device_method_t uart_puc_methods[] = { /* Device interface */ DEVMETHOD(device_probe, uart_puc_probe), - DEVMETHOD(device_attach, uart_bus_attach), + DEVMETHOD(device_attach, uart_puc_attach), DEVMETHOD(device_detach, uart_bus_detach), /* Serdev interface */ DEVMETHOD(serdev_ihand, uart_bus_ihand), @@ -84,4 +85,40 @@ return (uart_bus_probe(dev, 0, rclk, 0, 0)); } +/* + * Don't cut and paste this to other drivers. It is a horrible kludge + * which will fail to work and also be unnecessary in future versions. + */ +static void +uart_puc_kludge_unit(device_t dev) +{ + devclass_t dc; + int err; + int start; + int unit; + + unit = 0; + start = 0; + while (resource_int_value("uart", unit, "port", &start) == 0 && + start > 0) + unit++; + if (device_get_unit(dev) < unit) { + dc = device_get_devclass(dev); + while (devclass_get_device(dc, unit)) + unit++; + device_printf(dev, "moving to uart%d\n", unit); + err = device_set_unit(dev, unit); /* EVIL DO NOT COPY */ + if (err) + device_printf(dev, "error moving device %d\n", err); + } +} + +static int +uart_puc_attach(device_t dev) +{ + + uart_puc_kludge_unit(dev); + return (uart_bus_attach(dev)); +} + DRIVER_MODULE(uart, puc, uart_puc_driver, uart_devclass, 0, 0); Index: sys/fs/devfs/devfs_vfsops.c =========================================================================== --- sys/fs/devfs/devfs_vfsops.c 2012/02/10 02:20:13 #43 +++ sys/fs/devfs/devfs_vfsops.c 2012/02/10 02:20:13 @@ -186,4 +186,4 @@ .vfs_unmount = devfs_unmount, }; -VFS_SET(devfs_vfsops, devfs, VFCF_SYNTHETIC); +VFS_SET(devfs_vfsops, devfs, VFCF_SYNTHETIC | VFCF_JAIL); Index: sys/i386/i386/pmap.c =========================================================================== --- sys/i386/i386/pmap.c 2012/02/10 02:20:13 #424 +++ sys/i386/i386/pmap.c 2012/02/10 02:20:13 @@ -5120,13 +5120,16 @@ } void -pmap_activate(struct thread *td) +pmap_switch_vmspace(struct vmspace *vm) { pmap_t pmap, oldpmap; u_int cpuid; + struct thread *td; u_int32_t cr3; + td = curthread; critical_enter(); + td->td_proc->p_vmspace = vm; pmap = vmspace_pmap(td->td_proc->p_vmspace); oldpmap = PCPU_GET(curpmap); cpuid = PCPU_GET(cpuid); Index: sys/i386/include/pcpu.h =========================================================================== --- sys/i386/include/pcpu.h 2012/02/10 02:20:13 #30 +++ sys/i386/include/pcpu.h 2012/02/10 02:20:13 @@ -105,6 +105,7 @@ PCPU_XEN_FIELDS #ifdef _KERNEL +#define PCPU_MD_ALIGN __aligned(64) /* max cache line size */ #ifdef lint ==== //depot/vendor/freebsd/src/sys/i386/include/privatespace.h#4 - === Index: sys/kern/init_sysent.c =========================================================================== --- sys/kern/init_sysent.c 2012/02/10 02:20:13 #165 +++ sys/kern/init_sysent.c 2012/02/10 02:20:13 @@ -26,6 +26,12 @@ #define compat4(n, name) 0, (sy_call_t *)nosys #endif +#ifdef COMPAT_FREEBSD6 +#define compat6(n, name) n, (sy_call_t *)__CONCAT(freebsd6_,name) +#else +#define compat6(n, name) 0, (sy_call_t *)nosys +#endif + #ifdef COMPAT_FREEBSD7 #define compat7(n, name) n, (sy_call_t *)__CONCAT(freebsd7_,name) #else @@ -207,8 +213,8 @@ { AS(msgsys_args), (sy_call_t *)lkmressys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 170 = msgsys */ { AS(shmsys_args), (sy_call_t *)lkmressys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 171 = shmsys */ { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 172 = nosys */ - { AS(freebsd6_pread_args), (sy_call_t *)freebsd6_pread, AUE_PREAD, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 173 = freebsd6_pread */ - { AS(freebsd6_pwrite_args), (sy_call_t *)freebsd6_pwrite, AUE_PWRITE, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 174 = freebsd6_pwrite */ + { compat6(AS(freebsd6_pread_args),pread), AUE_PREAD, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 173 = freebsd6 pread */ + { compat6(AS(freebsd6_pwrite_args),pwrite), AUE_PWRITE, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 174 = freebsd6 pwrite */ { AS(setfib_args), (sy_call_t *)sys_setfib, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 175 = setfib */ { AS(ntp_adjtime_args), (sy_call_t *)sys_ntp_adjtime, AUE_NTP_ADJTIME, NULL, 0, 0, 0, SY_THR_STATIC }, /* 176 = ntp_adjtime */ { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 177 = sfork */ @@ -231,11 +237,11 @@ { AS(__getrlimit_args), (sy_call_t *)sys_getrlimit, AUE_GETRLIMIT, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 194 = getrlimit */ { AS(__setrlimit_args), (sy_call_t *)sys_setrlimit, AUE_SETRLIMIT, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 195 = setrlimit */ { AS(getdirentries_args), (sy_call_t *)sys_getdirentries, AUE_GETDIRENTRIES, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 196 = getdirentries */ - { AS(freebsd6_mmap_args), (sy_call_t *)freebsd6_mmap, AUE_MMAP, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 197 = freebsd6_mmap */ + { compat6(AS(freebsd6_mmap_args),mmap), AUE_MMAP, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 197 = freebsd6 mmap */ { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 198 = __syscall */ - { AS(freebsd6_lseek_args), (sy_call_t *)freebsd6_lseek, AUE_LSEEK, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 199 = freebsd6_lseek */ - { AS(freebsd6_truncate_args), (sy_call_t *)freebsd6_truncate, AUE_TRUNCATE, NULL, 0, 0, 0, SY_THR_STATIC }, /* 200 = freebsd6_truncate */ - { AS(freebsd6_ftruncate_args), (sy_call_t *)freebsd6_ftruncate, AUE_FTRUNCATE, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 201 = freebsd6_ftruncate */ + { compat6(AS(freebsd6_lseek_args),lseek), AUE_LSEEK, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 199 = freebsd6 lseek */ + { compat6(AS(freebsd6_truncate_args),truncate), AUE_TRUNCATE, NULL, 0, 0, 0, SY_THR_STATIC }, /* 200 = freebsd6 truncate */ + { compat6(AS(freebsd6_ftruncate_args),ftruncate), AUE_FTRUNCATE, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 201 = freebsd6 ftruncate */ { AS(sysctl_args), (sy_call_t *)sys___sysctl, AUE_SYSCTL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 202 = __sysctl */ { AS(mlock_args), (sy_call_t *)sys_mlock, AUE_MLOCK, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 203 = mlock */ { AS(munlock_args), (sy_call_t *)sys_munlock, AUE_MUNLOCK, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 204 = munlock */ @@ -452,9 +458,9 @@ { AS(__mac_execve_args), (sy_call_t *)sys___mac_execve, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 415 = __mac_execve */ { AS(sigaction_args), (sy_call_t *)sys_sigaction, AUE_SIGACTION, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 416 = sigaction */ { AS(sigreturn_args), (sy_call_t *)sys_sigreturn, AUE_SIGRETURN, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 417 = sigreturn */ - { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 418 = __xstat */ - { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 419 = __xfstat */ - { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 420 = __xlstat */ + { AS(__xstat_args), (sy_call_t *)sys___xstat, AUE_STAT, NULL, 0, 0, 0, SY_THR_STATIC }, /* 418 = __xstat */ + { AS(__xfstat_args), (sy_call_t *)sys___xfstat, AUE_FSTAT, NULL, 0, 0, 0, SY_THR_STATIC }, /* 419 = __xfstat */ + { AS(__xlstat_args), (sy_call_t *)sys___xlstat, AUE_LSTAT, NULL, 0, 0, 0, SY_THR_STATIC }, /* 420 = __xlstat */ { AS(getcontext_args), (sy_call_t *)sys_getcontext, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 421 = getcontext */ { AS(setcontext_args), (sy_call_t *)sys_setcontext, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 422 = setcontext */ { AS(swapcontext_args), (sy_call_t *)sys_swapcontext, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 423 = swapcontext */ Index: sys/kern/kern_clock.c =========================================================================== --- sys/kern/kern_clock.c 2012/02/10 02:20:13 #105 +++ sys/kern/kern_clock.c 2012/02/10 02:20:13 @@ -408,6 +408,11 @@ #ifdef SW_WATCHDOG EVENTHANDLER_REGISTER(watchdog_list, watchdog_config, NULL, 0); #endif + /* + * Arrange for ticks to go negative just 5 minutes after boot + * to help catch sign problems sooner. + */ + ticks = INT_MAX - (hz * 5 * 60); } /* Index: sys/kern/kern_descrip.c =========================================================================== --- sys/kern/kern_descrip.c 2012/02/10 02:20:13 #280 +++ sys/kern/kern_descrip.c 2012/02/10 02:20:13 @@ -1328,6 +1328,31 @@ return (error); } +#ifndef _SYS_SYSPROTO_H_ +struct __xfstat_args { + int ver; + int fd; + struct _new_stat *sb; +}; +#endif +/* ARGSUSED */ +int +sys___xfstat(struct thread *td, struct __xfstat_args *uap) +{ + struct stat ub; + struct _new_stat nub; + int error; + + if (uap->ver != __STATVER) + return (EOPNOTSUPP); + error = kern_fstat(td, uap->fd, &ub); + if (error == 0) { + cvtnewstat(&ub, &nub); + error = copyout(&nub, uap->sb, sizeof(nub)); + } + return (error); +} + int kern_fstat(struct thread *td, int fd, struct stat *sbp) { Index: sys/kern/kern_jail.c =========================================================================== --- sys/kern/kern_jail.c 2012/02/10 02:20:13 #145 +++ sys/kern/kern_jail.c 2012/02/10 02:20:13 @@ -3965,8 +3965,7 @@ /* * Jail-related sysctls. */ -static SYSCTL_NODE(_security, OID_AUTO, jail, CTLFLAG_RW, 0, - "Jails"); +SYSCTL_NODE(_security, OID_AUTO, jail, CTLFLAG_RW, 0, "Jails"); static int sysctl_jail_list(SYSCTL_HANDLER_ARGS) Index: sys/kern/kern_mib.c =========================================================================== --- sys/kern/kern_mib.c 2012/02/10 02:20:13 #62 +++ sys/kern/kern_mib.c 2012/02/10 02:20:13 @@ -144,6 +144,9 @@ SYSCTL_STRING(_kern, KERN_BOOTFILE, bootfile, CTLFLAG_RW, kernelname, sizeof kernelname, "Name of kernel file booted"); +SYSCTL_STRING(_kern, OID_AUTO, build_uuid, CTLFLAG_RD, + build_uuid, 0, "Unique kernel build identifier"); + SYSCTL_INT(_hw, HW_NCPU, ncpu, CTLFLAG_RD|CTLFLAG_CAPRD, &mp_ncpus, 0, "Number of active CPUs"); Index: sys/kern/kern_shutdown.c =========================================================================== --- sys/kern/kern_shutdown.c 2012/02/10 02:20:13 #122 +++ sys/kern/kern_shutdown.c 2012/02/10 02:20:13 @@ -69,6 +69,7 @@ #ifdef SW_WATCHDOG #include #endif +#include #include @@ -426,6 +427,9 @@ * unmount filesystems (thus forcing an fsck on reboot). */ printf("Giving up on %d buffers\n", nbusy); +#ifdef DDB_x + Debugger("busy buffers"); +#endif DELAY(5000000); /* 5 seconds */ } else { if (!first_buf_printf) @@ -610,6 +614,11 @@ newpanic = 1; } + printf("\n o _ _ _\n"); + printf(" _o /\\_ _ \\\\o (_)\\__/o (_)\n"); + printf(" _< \\_ _>(_) (_)/<_ \\_| \\ _|/' \\/\n"); + printf(" (_)>(_) (_) (_) (_) (_)' _\\o_\n\n"); + va_start(ap, fmt); if (newpanic) { (void)vsnprintf(buf, sizeof(buf), fmt, ap); @@ -753,7 +762,9 @@ mkdumpheader(struct kerneldumpheader *kdh, char *magic, uint32_t archver, uint64_t dumplen, uint32_t blksz) { + struct uuid u; + parse_uuid(build_uuid, &u); bzero(kdh, sizeof(*kdh)); strncpy(kdh->magic, magic, sizeof(kdh->magic)); strncpy(kdh->architecture, MACHINE_ARCH, sizeof(kdh->architecture)); @@ -766,5 +777,6 @@ strncpy(kdh->versionstring, version, sizeof(kdh->versionstring)); if (panicstr != NULL) strncpy(kdh->panicstring, panicstr, sizeof(kdh->panicstring)); + bcopy(&u, kdh->uuid, sizeof(kdh->uuid)); kdh->parity = kerneldump_parity(kdh); } Index: sys/kern/kern_sig.c =========================================================================== --- sys/kern/kern_sig.c 2012/02/10 02:20:13 #287 +++ sys/kern/kern_sig.c 2012/02/10 02:20:13 @@ -139,6 +139,10 @@ static SYSCTL_NODE(_kern, OID_AUTO, sigqueue, CTLFLAG_RW, 0, "POSIX real time signal"); +static int kern_do_sigsys = 1; +SYSCTL_INT(_kern, OID_AUTO, do_sigsys, CTLFLAG_RW, + &kern_do_sigsys, 0, "Have the kernel send SIGSYS on a bad syscall"); + static int max_pending_per_proc = 128; SYSCTL_INT(_kern_sigqueue, OID_AUTO, max_pending_per_proc, CTLFLAG_RW, &max_pending_per_proc, 0, "Max pending signals per proc"); @@ -3311,9 +3315,11 @@ { struct proc *p = td->td_proc; - PROC_LOCK(p); - kern_psignal(p, SIGSYS); - PROC_UNLOCK(p); + if (kern_do_sigsys) { + PROC_LOCK(p); + kern_psignal(p, SIGSYS); + PROC_UNLOCK(p); + } return (ENOSYS); } Index: sys/kern/kern_syscalls.c =========================================================================== --- sys/kern/kern_syscalls.c 2012/02/10 02:20:13 #11 +++ sys/kern/kern_syscalls.c 2012/02/10 02:20:13 @@ -27,6 +27,8 @@ #include __FBSDID("$FreeBSD: src/sys/kern/kern_syscalls.c,v 1.17 2010/10/21 20:31:50 delphij Exp $"); +#include "opt_compat.h" + #include #include #include @@ -38,6 +40,10 @@ #include #include +#ifdef COMPAT_IA32 +extern struct sysent freebsd32_sysent[]; +#endif + /* * Acts like "nosys" but can be identified in sysent for dynamic call * number assignment for a limited number of calls. Index: sys/kern/subr_kdb.c =========================================================================== --- sys/kern/subr_kdb.c 2012/02/10 02:20:13 #45 +++ sys/kern/subr_kdb.c 2012/02/10 02:20:13 @@ -308,6 +308,7 @@ } return (brk); } +#undef CTRL static int kdb_alt_break_internal(int key, int *state, int force_gdb) Index: sys/kern/sys_generic.c =========================================================================== --- sys/kern/sys_generic.c 2012/02/10 02:20:13 #109 +++ sys/kern/sys_generic.c 2012/02/10 02:20:13 @@ -190,6 +190,7 @@ return(error); } +#ifdef COMPAT_FREEBSD6 int freebsd6_pread(td, uap) struct thread *td; @@ -203,6 +204,7 @@ oargs.offset = uap->offset; return (sys_pread(td, &oargs)); } +#endif /* * Scatter read system call. @@ -399,6 +401,7 @@ return(error); } +#ifdef COMPAT_FREEBSD6 int freebsd6_pwrite(td, uap) struct thread *td; @@ -412,6 +415,7 @@ oargs.offset = uap->offset; return (sys_pwrite(td, &oargs)); } +#endif /* * Gather write system call. Index: sys/kern/syscalls.c =========================================================================== --- sys/kern/syscalls.c 2012/02/10 02:20:13 #159 +++ sys/kern/syscalls.c 2012/02/10 02:20:13 @@ -180,8 +180,8 @@ "msgsys", /* 170 = msgsys */ "shmsys", /* 171 = shmsys */ "#172", /* 172 = nosys */ - "freebsd6_pread", /* 173 = freebsd6_pread */ - "freebsd6_pwrite", /* 174 = freebsd6_pwrite */ + "compat6.pread", /* 173 = freebsd6 pread */ + "compat6.pwrite", /* 174 = freebsd6 pwrite */ "setfib", /* 175 = setfib */ "ntp_adjtime", /* 176 = ntp_adjtime */ "#177", /* 177 = sfork */ @@ -204,11 +204,11 @@ "getrlimit", /* 194 = getrlimit */ "setrlimit", /* 195 = setrlimit */ "getdirentries", /* 196 = getdirentries */ - "freebsd6_mmap", /* 197 = freebsd6_mmap */ + "compat6.mmap", /* 197 = freebsd6 mmap */ "__syscall", /* 198 = __syscall */ - "freebsd6_lseek", /* 199 = freebsd6_lseek */ - "freebsd6_truncate", /* 200 = freebsd6_truncate */ - "freebsd6_ftruncate", /* 201 = freebsd6_ftruncate */ + "compat6.lseek", /* 199 = freebsd6 lseek */ + "compat6.truncate", /* 200 = freebsd6 truncate */ + "compat6.ftruncate", /* 201 = freebsd6 ftruncate */ "__sysctl", /* 202 = __sysctl */ "mlock", /* 203 = mlock */ "munlock", /* 204 = munlock */ @@ -425,9 +425,9 @@ "__mac_execve", /* 415 = __mac_execve */ "sigaction", /* 416 = sigaction */ "sigreturn", /* 417 = sigreturn */ - "#418", /* 418 = __xstat */ - "#419", /* 419 = __xfstat */ - "#420", /* 420 = __xlstat */ + "__xstat", /* 418 = __xstat */ + "__xfstat", /* 419 = __xfstat */ + "__xlstat", /* 420 = __xlstat */ "getcontext", /* 421 = getcontext */ "setcontext", /* 422 = setcontext */ "swapcontext", /* 423 = swapcontext */ Index: sys/kern/syscalls.master =========================================================================== --- sys/kern/syscalls.master 2012/02/10 02:20:13 #181 +++ sys/kern/syscalls.master 2012/02/10 02:20:13 @@ -343,10 +343,9 @@ int a4); } ; XXX should be { int shmsys(int which, ...); } 172 AUE_NULL UNIMPL nosys -173 AUE_PREAD STD { ssize_t freebsd6_pread(int fd, void *buf, \ +173 AUE_PREAD COMPAT6 { ssize_t pread(int fd, void *buf, \ size_t nbyte, int pad, off_t offset); } -174 AUE_PWRITE STD { ssize_t freebsd6_pwrite(int fd, \ - const void *buf, \ +174 AUE_PWRITE COMPAT6 { ssize_t pwrite(int fd, const void *buf, \ size_t nbyte, int pad, off_t offset); } 175 AUE_NULL STD { int setfib(int fibnum); } 176 AUE_NTP_ADJTIME STD { int ntp_adjtime(struct timex *tp); } @@ -377,16 +376,16 @@ __setrlimit_args int 196 AUE_GETDIRENTRIES STD { int getdirentries(int fd, char *buf, \ u_int count, long *basep); } -197 AUE_MMAP STD { caddr_t freebsd6_mmap(caddr_t addr, \ - size_t len, int prot, int flags, int fd, \ - int pad, off_t pos); } +197 AUE_MMAP COMPAT6 { caddr_t mmap(caddr_t addr, size_t len, \ + int prot, int flags, int fd, int pad, \ + off_t pos); } 198 AUE_NULL NOPROTO { int nosys(void); } __syscall \ __syscall_args int -199 AUE_LSEEK STD { off_t freebsd6_lseek(int fd, int pad, \ - off_t offset, int whence); } -200 AUE_TRUNCATE STD { int freebsd6_truncate(char *path, int pad, \ +199 AUE_LSEEK COMPAT6 { off_t lseek(int fd, int pad, off_t offset, \ + int whence); } +200 AUE_TRUNCATE COMPAT6 { int truncate(char *path, int pad, \ off_t length); } -201 AUE_FTRUNCATE STD { int freebsd6_ftruncate(int fd, int pad, \ +201 AUE_FTRUNCATE COMPAT6 { int ftruncate(int fd, int pad, \ off_t length); } 202 AUE_SYSCTL STD { int __sysctl(int *name, u_int namelen, \ void *old, size_t *oldlenp, void *new, \ @@ -748,9 +747,12 @@ struct sigaction *oact); } 417 AUE_SIGRETURN STD { int sigreturn( \ const struct __ucontext *sigcntxp); } -418 AUE_NULL UNIMPL __xstat -419 AUE_NULL UNIMPL __xfstat -420 AUE_NULL UNIMPL __xlstat +418 AUE_STAT STD { int __xstat(int ver, char *path, \ + struct _new_stat *ub); } +419 AUE_FSTAT STD { int __xfstat(int ver, int fd, \ + struct _new_stat *sb); } +420 AUE_LSTAT STD { int __xlstat(int ver, char *path, \ + struct _new_stat *ub); } 421 AUE_NULL STD { int getcontext(struct __ucontext *ucp); } 422 AUE_NULL STD { int setcontext( \ const struct __ucontext *ucp); } Index: sys/kern/systrace_args.c =========================================================================== --- sys/kern/systrace_args.c 2012/02/10 02:20:13 #46 +++ sys/kern/systrace_args.c 2012/02/10 02:20:13 @@ -914,28 +914,6 @@ *n_args = 4; break; } - /* freebsd6_pread */ - case 173: { - struct freebsd6_pread_args *p = params; - iarg[0] = p->fd; /* int */ - uarg[1] = (intptr_t) p->buf; /* void * */ - uarg[2] = p->nbyte; /* size_t */ - iarg[3] = p->pad; /* int */ - iarg[4] = p->offset; /* off_t */ - *n_args = 5; - break; - } - /* freebsd6_pwrite */ - case 174: { - struct freebsd6_pwrite_args *p = params; - iarg[0] = p->fd; /* int */ - uarg[1] = (intptr_t) p->buf; /* const void * */ - uarg[2] = p->nbyte; /* size_t */ - iarg[3] = p->pad; /* int */ - iarg[4] = p->offset; /* off_t */ - *n_args = 5; - break; - } /* setfib */ case 175: { struct setfib_args *p = params; @@ -1037,52 +1015,11 @@ *n_args = 4; break; } - /* freebsd6_mmap */ - case 197: { - struct freebsd6_mmap_args *p = params; - uarg[0] = (intptr_t) p->addr; /* caddr_t */ - uarg[1] = p->len; /* size_t */ - iarg[2] = p->prot; /* int */ - iarg[3] = p->flags; /* int */ - iarg[4] = p->fd; /* int */ - iarg[5] = p->pad; /* int */ - iarg[6] = p->pos; /* off_t */ - *n_args = 7; - break; - } /* nosys */ case 198: { *n_args = 0; break; } - /* freebsd6_lseek */ - case 199: { - struct freebsd6_lseek_args *p = params; - iarg[0] = p->fd; /* int */ - iarg[1] = p->pad; /* int */ - iarg[2] = p->offset; /* off_t */ - iarg[3] = p->whence; /* int */ - *n_args = 4; - break; - } - /* freebsd6_truncate */ - case 200: { - struct freebsd6_truncate_args *p = params; - uarg[0] = (intptr_t) p->path; /* char * */ - iarg[1] = p->pad; /* int */ - iarg[2] = p->length; /* off_t */ - *n_args = 3; - break; - } - /* freebsd6_ftruncate */ - case 201: { - struct freebsd6_ftruncate_args *p = params; - iarg[0] = p->fd; /* int */ - iarg[1] = p->pad; /* int */ - iarg[2] = p->length; /* off_t */ - *n_args = 3; - break; - } /* __sysctl */ case 202: { struct sysctl_args *p = params; @@ -2342,6 +2279,33 @@ *n_args = 1; break; } + /* __xstat */ + case 418: { + struct __xstat_args *p = params; + iarg[0] = p->ver; /* int */ + uarg[1] = (intptr_t) p->path; /* char * */ + uarg[2] = (intptr_t) p->ub; /* struct _new_stat * */ + *n_args = 3; + break; + } + /* __xfstat */ + case 419: { + struct __xfstat_args *p = params; + iarg[0] = p->ver; /* int */ + iarg[1] = p->fd; /* int */ + uarg[2] = (intptr_t) p->sb; /* struct _new_stat * */ + *n_args = 3; + break; + } + /* __xlstat */ + case 420: { + struct __xlstat_args *p = params; + iarg[0] = p->ver; /* int */ + uarg[1] = (intptr_t) p->path; /* char * */ + uarg[2] = (intptr_t) p->ub; /* struct _new_stat * */ + *n_args = 3; + break; + } /* getcontext */ case 421: { struct getcontext_args *p = params; @@ -4738,50 +4702,6 @@ break; }; break; - /* freebsd6_pread */ - case 173: - switch(ndx) { - case 0: - p = "int"; - break; - case 1: - p = "void *"; - break; - case 2: - p = "size_t"; - break; - case 3: - p = "int"; - break; - case 4: - p = "off_t"; - break; - default: - break; - }; - break; - /* freebsd6_pwrite */ - case 174: - switch(ndx) { - case 0: - p = "int"; - break; - case 1: - p = "const void *"; - break; - case 2: - p = "size_t"; - break; - case 3: - p = "int"; - break; - case 4: - p = "off_t"; - break; - default: - break; - }; - break; /* setfib */ case 175: switch(ndx) { @@ -4942,88 +4862,9 @@ break; }; break; - /* freebsd6_mmap */ - case 197: - switch(ndx) { - case 0: - p = "caddr_t"; - break; - case 1: - p = "size_t"; - break; - case 2: - p = "int"; - break; - case 3: - p = "int"; - break; - case 4: - p = "int"; - break; - case 5: - p = "int"; - break; - case 6: - p = "off_t"; - break; - default: - break; - }; - break; /* nosys */ case 198: break; - /* freebsd6_lseek */ - case 199: - switch(ndx) { - case 0: - p = "int"; - break; - case 1: - p = "int"; - break; - case 2: - p = "off_t"; - break; - case 3: - p = "int"; - break; - default: - break; - }; - break; - /* freebsd6_truncate */ - case 200: - switch(ndx) { - case 0: - p = "char *"; - break; - case 1: - p = "int"; - break; - case 2: - p = "off_t"; - break; - default: - break; - }; - break; - /* freebsd6_ftruncate */ - case 201: - switch(ndx) { - case 0: - p = "int"; - break; - case 1: - p = "int"; - break; - case 2: - p = "off_t"; - break; - default: - break; - }; - break; /* __sysctl */ case 202: switch(ndx) { @@ -7070,6 +6911,54 @@ break; }; break; + /* __xstat */ + case 418: + switch(ndx) { + case 0: + p = "int"; + break; + case 1: + p = "char *"; + break; + case 2: + p = "struct _new_stat *"; + break; + default: + break; + }; + break; + /* __xfstat */ + case 419: + switch(ndx) { + case 0: + p = "int"; + break; + case 1: + p = "int"; + break; + case 2: + p = "struct _new_stat *"; + break; + default: + break; + }; + break; + /* __xlstat */ + case 420: + switch(ndx) { + case 0: + p = "int"; + break; + case 1: + p = "char *"; + break; + case 2: + p = "struct _new_stat *"; + break; + default: + break; + }; + break; /* getcontext */ case 421: switch(ndx) { @@ -9212,16 +9101,6 @@ if (ndx == 0 || ndx == 1) p = "int"; break; - /* freebsd6_pread */ - case 173: - if (ndx == 0 || ndx == 1) - p = "ssize_t"; - break; - /* freebsd6_pwrite */ - case 174: - if (ndx == 0 || ndx == 1) - p = "ssize_t"; - break; /* setfib */ case 175: if (ndx == 0 || ndx == 1) @@ -9287,28 +9166,8 @@ if (ndx == 0 || ndx == 1) p = "int"; break; - /* freebsd6_mmap */ - case 197: - if (ndx == 0 || ndx == 1) - p = "caddr_t"; - break; /* nosys */ case 198: - /* freebsd6_lseek */ - case 199: - if (ndx == 0 || ndx == 1) - p = "off_t"; - break; - /* freebsd6_truncate */ - case 200: - if (ndx == 0 || ndx == 1) - p = "int"; - break; - /* freebsd6_ftruncate */ - case 201: - if (ndx == 0 || ndx == 1) - p = "int"; - break; /* __sysctl */ case 202: if (ndx == 0 || ndx == 1) @@ -10044,6 +9903,21 @@ if (ndx == 0 || ndx == 1) p = "int"; break; + /* __xstat */ + case 418: + if (ndx == 0 || ndx == 1) + p = "int"; + break; + /* __xfstat */ + case 419: + if (ndx == 0 || ndx == 1) + p = "int"; + break; + /* __xlstat */ + case 420: + if (ndx == 0 || ndx == 1) + p = "int"; + break; /* getcontext */ case 421: if (ndx == 0 || ndx == 1) Index: sys/kern/vfs_aio.c =========================================================================== --- sys/kern/vfs_aio.c 2012/02/10 02:20:13 #154 +++ sys/kern/vfs_aio.c 2012/02/10 02:20:13 @@ -1102,11 +1102,10 @@ * Point to the new user address space, and * refer to it. */ - mycp->p_vmspace = userp->p_vmspace; - atomic_add_int(&mycp->p_vmspace->vm_refcnt, 1); + atomic_add_int(&userp->p_vmspace->vm_refcnt, 1); /* Activate the new mapping. */ - pmap_activate(FIRST_THREAD_IN_PROC(mycp)); + pmap_switch_vmspace(userp->p_vmspace); /* * If the old address space wasn't the daemons @@ -1148,11 +1147,8 @@ /* Get the user address space to disconnect from. */ tmpvm = mycp->p_vmspace; - /* Get original address space for daemon. */ - mycp->p_vmspace = myvm; - - /* Activate the daemon's address space. */ - pmap_activate(FIRST_THREAD_IN_PROC(mycp)); + /* Activate the daemon's original address space. */ + pmap_switch_vmspace(myvm); #ifdef DIAGNOSTIC if (tmpvm == myvm) { printf("AIOD: vmspace problem -- %d\n", Index: sys/kern/vfs_mount.c =========================================================================== --- sys/kern/vfs_mount.c 2012/02/10 02:20:13 #272 +++ sys/kern/vfs_mount.c 2012/02/10 02:20:13 @@ -80,6 +80,12 @@ SYSCTL_INT(_vfs, OID_AUTO, usermount, CTLFLAG_RW, &usermount, 0, "Unprivileged users may mount and unmount file systems"); +SYSCTL_DECL(_security_jail); +int jail_allow_mount_all = 0; +SYSCTL_INT(_security_jail, OID_AUTO, allow_mount_all, CTLFLAG_RW, + &jail_allow_mount_all, 0, + "Prison root can mount all filesystems"); + MALLOC_DEFINE(M_MOUNT, "mount", "vfs mount structure"); static MALLOC_DEFINE(M_VNODE_MARKER, "vnodemarker", "vnode marker"); static uma_zone_t mount_zone; @@ -1085,7 +1091,7 @@ vfsp = vfs_byname_kld(fstype, td, &error); if (vfsp == NULL) return (ENODEV); - if (jailed(td->td_ucred) && !(vfsp->vfc_flags & VFCF_JAIL)) + if (!jail_allow_mount_all && jailed(td->td_ucred) && !(vfsp->vfc_flags & VFCF_JAIL)) return (EPERM); } Index: sys/kern/vfs_subr.c =========================================================================== --- sys/kern/vfs_subr.c 2012/02/10 02:20:13 #500 +++ sys/kern/vfs_subr.c 2012/02/10 02:20:13 @@ -497,6 +497,7 @@ return ((struct mount *) 0); } +extern int jail_allow_mount_all; /* * Check if a user can access privileged mount options. */ @@ -509,7 +510,7 @@ * If the thread is jailed, but this is not a jail-friendly file * system, deny immediately. */ - if (!(mp->mnt_vfc->vfc_flags & VFCF_JAIL) && jailed(td->td_ucred)) + if (!jail_allow_mount_all && !(mp->mnt_vfc->vfc_flags & VFCF_JAIL) && jailed(td->td_ucred)) return (EPERM); /* Index: sys/kern/vfs_syscalls.c =========================================================================== --- sys/kern/vfs_syscalls.c 2012/02/10 02:20:13 #317 +++ sys/kern/vfs_syscalls.c 2012/02/10 02:20:13 @@ -2107,6 +2107,7 @@ } #endif /* COMPAT_43 */ +#if defined(COMPAT_FREEBSD6) /* Version with the 'pad' argument */ int freebsd6_lseek(td, uap) @@ -2120,6 +2121,7 @@ ouap.whence = uap->whence; return (sys_lseek(td, &ouap)); } +#endif /* * Check access permissions using passed credentials. @@ -2361,6 +2363,33 @@ #endif /* COMPAT_43 */ /* + * Convert from a current to new stat structure. + */ +void +cvtnewstat(st, nst) + struct stat *st; + struct _new_stat *nst; +{ + bzero(nst, sizeof *nst); + nst->st_dev = st->st_dev; + nst->st_ino = st->st_ino; + nst->st_mode = st->st_mode; + nst->st_nlink = st->st_nlink; + nst->st_uid = st->st_uid; + nst->st_gid = st->st_gid; + nst->st_rdev = st->st_rdev; + nst->st_atim = st->st_atim; + nst->st_mtim = st->st_mtim; + nst->st_ctim = st->st_ctim; + nst->st_size = st->st_size; + nst->st_blocks = st->st_blocks; + nst->st_blksize = st->st_blksize; + nst->st_flags = st->st_flags; + nst->st_gen = st->st_gen; + nst->st_birthtim = st->st_birthtim; +} + +/* * Get file status; this version follows links. */ #ifndef _SYS_SYSPROTO_H_ @@ -2387,6 +2416,31 @@ } #ifndef _SYS_SYSPROTO_H_ +struct __xstat_args { + int ver; + char *path; + struct _new_stat *ub; +}; +#endif + +int +sys___xstat(struct thread *td, struct __xstat_args *uap) +{ + struct stat sb; + struct _new_stat nsb; + int error; + + if (uap->ver != __STATVER) + return (EOPNOTSUPP); + error = kern_stat(td, uap->path, UIO_USERSPACE, &sb); + if (error == 0) { + cvtnewstat(&sb, &nsb); + error = copyout(&nsb, uap->ub, sizeof (nsb)); + } + return (error); +} + +#ifndef _SYS_SYSPROTO_H_ struct fstatat_args { int fd; char *path; @@ -2488,6 +2542,30 @@ return (error); } +#ifndef _SYS_SYSPROTO_H_ +struct __xlstat_args { + int ver; + char *path; + struct _new_stat *ub; +}; +#endif +int +sys___xlstat(struct thread *td, struct __xlstat_args *uap) +{ + struct stat sb; + struct _new_stat nsb; + int error; + + if (uap->ver != __STATVER) + return (EOPNOTSUPP); + error = kern_lstat(td, uap->path, UIO_USERSPACE, &sb); + if (error == 0) { + cvtnewstat(&sb, &nsb); + error = copyout(&nsb, uap->ub, sizeof (nsb)); + } + return (error); +} + int kern_lstat(struct thread *td, char *path, enum uio_seg pathseg, struct stat *sbp) { @@ -3532,6 +3610,7 @@ } #endif /* COMPAT_43 */ +#if defined(COMPAT_FREEBSD6) /* Versions with the pad argument */ int freebsd6_truncate(struct thread *td, struct freebsd6_truncate_args *uap) @@ -3552,7 +3631,10 @@ ouap.length = uap->length; return (sys_ftruncate(td, &ouap)); } +#endif +static int nofsync = 0; +SYSCTL_INT(_debug, OID_AUTO, nofsync, CTLFLAG_RW, &nofsync, 0, ""); /* * Sync an open file. */ @@ -3575,6 +3657,8 @@ int error, lock_flags; AUDIT_ARG_FD(uap->fd); + if (nofsync) + return (0); if ((error = getvnode(td->td_proc->p_fd, uap->fd, CAP_FSYNC, &fp)) != 0) return (error); Index: sys/sys/_types.h =========================================================================== --- sys/sys/_types.h 2012/02/10 02:20:13 #26 +++ sys/sys/_types.h 2012/02/10 02:20:13 @@ -67,6 +67,11 @@ typedef int __cpulevel_t; /* level parameter for cpuset. */ typedef int __cpusetid_t; /* cpuset identifier. */ +/* New types for 64 bit inode number support (forward compat only) */ +typedef __uint64_t __new_ino_t; /* inode number */ +typedef __uint32_t __new_mode_t; /* permissions */ +typedef __uint32_t __new_nlink_t; /* link count */ + /* * Unusual type definitions. */ Index: sys/sys/kerneldump.h =========================================================================== --- sys/sys/kerneldump.h 2012/02/10 02:20:13 #13 +++ sys/sys/kerneldump.h 2012/02/10 02:20:13 @@ -64,7 +64,7 @@ #define KERNELDUMPMAGIC_CLEARED "Cleared Kernel Dump" char architecture[12]; uint32_t version; -#define KERNELDUMPVERSION 1 +#define KERNELDUMPVERSION 2 uint32_t architectureversion; #define KERNELDUMP_ALPHA_VERSION 1 #define KERNELDUMP_AMD64_VERSION 2 @@ -80,6 +80,22 @@ uint32_t blocksize; char hostname[64]; char versionstring[192]; + char panicstring[176]; + u_char uuid[16]; + uint32_t parity; +}; + +struct kerneldumpheader_v1 { + char magic[20]; + char architecture[12]; +#define KERNELDUMPVERSION_V1 1 + uint32_t version; + uint32_t architectureversion; + uint64_t dumplength; /* excl headers */ + uint64_t dumptime; + uint32_t blocksize; + char hostname[64]; + char versionstring[192]; char panicstring[192]; uint32_t parity; }; Index: sys/sys/module.h =========================================================================== --- sys/sys/module.h 2012/02/10 02:20:13 #11 +++ sys/sys/module.h 2012/02/10 02:20:13 @@ -126,7 +126,7 @@ #define MODULE_KERNEL_MAXVER (roundup(__FreeBSD_version, 100000) - 1) #define DECLARE_MODULE_WITH_MAXVER(name, data, sub, order, maxver) \ - MODULE_DEPEND(name, kernel, __FreeBSD_version, \ + MODULE_DEPEND(name, kernel, 1, \ __FreeBSD_version, maxver); \ MODULE_METADATA(_md_##name, MDT_MODULE, &data, #name); \ SYSINIT(name##module, sub, order, module_register_init, &data); \ Index: sys/sys/param.h =========================================================================== --- sys/sys/param.h 2012/02/10 02:20:13 #401 +++ sys/sys/param.h 2012/02/10 02:20:13 @@ -148,7 +148,7 @@ #define MAXPHYS (128 * 1024) /* max raw I/O transfer size */ #endif #ifndef MAXDUMPPGS -#define MAXDUMPPGS (DFLTPHYS/PAGE_SIZE) +#define MAXDUMPPGS (MAXPHYS/PAGE_SIZE) #endif /* Index: sys/sys/pcpu.h =========================================================================== --- sys/sys/pcpu.h 2012/02/10 02:20:13 #57 +++ sys/sys/pcpu.h 2012/02/10 02:20:13 @@ -146,6 +146,10 @@ struct rm_queue* volatile rmq_prev; }; +#ifndef PCPU_MD_ALIGN +#define PCPU_MD_ALIGN +#endif + /* * This structure maps out the global data that needs to be kept on a * per-cpu basis. The members are accessed via the PCPU_GET/SET/PTR Index: sys/sys/stat.h =========================================================================== --- sys/sys/stat.h 2012/02/10 02:20:13 #27 +++ sys/sys/stat.h 2012/02/10 02:20:13 @@ -149,6 +149,29 @@ unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec)); }; +/* New 64 bit inode number support forward compatability */ +struct _new_stat { + __dev_t st_dev; /* inode's device */ + __dev_t st_rdev; /* device type */ + __new_mode_t st_mode; /* inode protection mode */ + __new_nlink_t st_nlink; /* number of hard links */ + uid_t st_uid; /* user ID of the file's owner */ + gid_t st_gid; /* group ID of the file's group */ + __new_ino_t st_ino; /* inode's number */ + struct timespec st_atim; /* time of last access */ + struct timespec st_mtim; /* time of last data modification */ + struct timespec st_ctim; /* time of last file status change */ + struct timespec st_birthtim; /* time of file creation */ + off_t st_size; /* file size, in bytes */ + __int64_t st_blocks; /* blocks allocated for file */ + __uint32_t st_blksize; /* optimal blocksize for I/O */ + fflags_t st_flags; /* user defined flags for file */ + __uint32_t st_gen; /* file generation number */ + __int32_t __pad2; /* pad to 64 bit alignment */ + __int64_t __pad3[4]; /* spare */ +}; +#define __STATVER 700 /* FreeBSD 7.0 */ + #if __BSD_VISIBLE struct nstat { __dev_t st_dev; /* inode's device */ Index: sys/sys/syscall.h =========================================================================== --- sys/sys/syscall.h 2012/02/10 02:20:13 #158 +++ sys/sys/syscall.h 2012/02/10 02:20:13 @@ -345,6 +345,9 @@ #define SYS___mac_execve 415 #define SYS_sigaction 416 #define SYS_sigreturn 417 +#define SYS___xstat 418 +#define SYS___xfstat 419 +#define SYS___xlstat 420 #define SYS_getcontext 421 #define SYS_setcontext 422 #define SYS_swapcontext 423 Index: sys/sys/syscall.mk =========================================================================== --- sys/sys/syscall.mk 2012/02/10 02:20:13 #159 +++ sys/sys/syscall.mk 2012/02/10 02:20:13 @@ -294,6 +294,9 @@ __mac_execve.o \ sigaction.o \ sigreturn.o \ + __xstat.o \ + __xfstat.o \ + __xlstat.o \ getcontext.o \ setcontext.o \ swapcontext.o \ Index: sys/sys/sysctl.h =========================================================================== --- sys/sys/sysctl.h 2012/02/10 02:20:13 #100 +++ sys/sys/sysctl.h 2012/02/10 02:20:13 @@ -750,6 +750,7 @@ extern char osrelease[]; extern char ostype[]; extern char kern_ident[]; +extern char build_uuid[]; /* Dynamic oid handling */ struct sysctl_oid *sysctl_add_oid(struct sysctl_ctx_list *clist, Index: sys/sys/sysproto.h =========================================================================== --- sys/sys/sysproto.h 2012/02/10 02:20:13 #176 +++ sys/sys/sysproto.h 2012/02/10 02:20:13 @@ -531,20 +531,6 @@ char a3_l_[PADL_(int)]; int a3; char a3_r_[PADR_(int)]; char a4_l_[PADL_(int)]; int a4; char a4_r_[PADR_(int)]; }; -struct freebsd6_pread_args { - char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)]; - char buf_l_[PADL_(void *)]; void * buf; char buf_r_[PADR_(void *)]; - char nbyte_l_[PADL_(size_t)]; size_t nbyte; char nbyte_r_[PADR_(size_t)]; - char pad_l_[PADL_(int)]; int pad; char pad_r_[PADR_(int)]; - char offset_l_[PADL_(off_t)]; off_t offset; char offset_r_[PADR_(off_t)]; -}; -struct freebsd6_pwrite_args { - char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)]; - char buf_l_[PADL_(const void *)]; const void * buf; char buf_r_[PADR_(const void *)]; - char nbyte_l_[PADL_(size_t)]; size_t nbyte; char nbyte_r_[PADR_(size_t)]; - char pad_l_[PADL_(int)]; int pad; char pad_r_[PADR_(int)]; - char offset_l_[PADL_(off_t)]; off_t offset; char offset_r_[PADR_(off_t)]; -}; struct setfib_args { char fibnum_l_[PADL_(int)]; int fibnum; char fibnum_r_[PADR_(int)]; }; @@ -594,31 +580,6 @@ char count_l_[PADL_(u_int)]; u_int count; char count_r_[PADR_(u_int)]; char basep_l_[PADL_(long *)]; long * basep; char basep_r_[PADR_(long *)]; }; -struct freebsd6_mmap_args { - char addr_l_[PADL_(caddr_t)]; caddr_t addr; char addr_r_[PADR_(caddr_t)]; - char len_l_[PADL_(size_t)]; size_t len; char len_r_[PADR_(size_t)]; - char prot_l_[PADL_(int)]; int prot; char prot_r_[PADR_(int)]; - char flags_l_[PADL_(int)]; int flags; char flags_r_[PADR_(int)]; - char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)]; - char pad_l_[PADL_(int)]; int pad; char pad_r_[PADR_(int)]; - char pos_l_[PADL_(off_t)]; off_t pos; char pos_r_[PADR_(off_t)]; -}; -struct freebsd6_lseek_args { - char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)]; - char pad_l_[PADL_(int)]; int pad; char pad_r_[PADR_(int)]; - char offset_l_[PADL_(off_t)]; off_t offset; char offset_r_[PADR_(off_t)]; - char whence_l_[PADL_(int)]; int whence; char whence_r_[PADR_(int)]; -}; -struct freebsd6_truncate_args { - char path_l_[PADL_(char *)]; char * path; char path_r_[PADR_(char *)]; - char pad_l_[PADL_(int)]; int pad; char pad_r_[PADR_(int)]; - char length_l_[PADL_(off_t)]; off_t length; char length_r_[PADR_(off_t)]; -}; -struct freebsd6_ftruncate_args { - char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)]; - char pad_l_[PADL_(int)]; int pad; char pad_r_[PADR_(int)]; - char length_l_[PADL_(off_t)]; off_t length; char length_r_[PADR_(off_t)]; -}; struct sysctl_args { char name_l_[PADL_(int *)]; int * name; char name_r_[PADR_(int *)]; char namelen_l_[PADL_(u_int)]; u_int namelen; char namelen_r_[PADR_(u_int)]; @@ -1244,6 +1205,21 @@ struct sigreturn_args { char sigcntxp_l_[PADL_(const struct __ucontext *)]; const struct __ucontext * sigcntxp; char sigcntxp_r_[PADR_(const struct __ucontext *)]; }; +struct __xstat_args { + char ver_l_[PADL_(int)]; int ver; char ver_r_[PADR_(int)]; + char path_l_[PADL_(char *)]; char * path; char path_r_[PADR_(char *)]; + char ub_l_[PADL_(struct _new_stat *)]; struct _new_stat * ub; char ub_r_[PADR_(struct _new_stat *)]; +}; +struct __xfstat_args { + char ver_l_[PADL_(int)]; int ver; char ver_r_[PADR_(int)]; + char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)]; + char sb_l_[PADL_(struct _new_stat *)]; struct _new_stat * sb; char sb_r_[PADR_(struct _new_stat *)]; +}; +struct __xlstat_args { + char ver_l_[PADL_(int)]; int ver; char ver_r_[PADR_(int)]; + char path_l_[PADL_(char *)]; char * path; char path_r_[PADR_(char *)]; + char ub_l_[PADL_(struct _new_stat *)]; struct _new_stat * ub; char ub_r_[PADR_(struct _new_stat *)]; +}; struct getcontext_args { char ucp_l_[PADL_(struct __ucontext *)]; struct __ucontext * ucp; char ucp_r_[PADR_(struct __ucontext *)]; }; @@ -1861,8 +1837,6 @@ int sys_semsys(struct thread *, struct semsys_args *); int sys_msgsys(struct thread *, struct msgsys_args *); int sys_shmsys(struct thread *, struct shmsys_args *); -int freebsd6_pread(struct thread *, struct freebsd6_pread_args *); -int freebsd6_pwrite(struct thread *, struct freebsd6_pwrite_args *); int sys_setfib(struct thread *, struct setfib_args *); int sys_ntp_adjtime(struct thread *, struct ntp_adjtime_args *); int sys_setgid(struct thread *, struct setgid_args *); @@ -1876,10 +1850,6 @@ int sys_getrlimit(struct thread *, struct __getrlimit_args *); int sys_setrlimit(struct thread *, struct __setrlimit_args *); int sys_getdirentries(struct thread *, struct getdirentries_args *); -int freebsd6_mmap(struct thread *, struct freebsd6_mmap_args *); -int freebsd6_lseek(struct thread *, struct freebsd6_lseek_args *); -int freebsd6_truncate(struct thread *, struct freebsd6_truncate_args *); -int freebsd6_ftruncate(struct thread *, struct freebsd6_ftruncate_args *); int sys___sysctl(struct thread *, struct sysctl_args *); int sys_mlock(struct thread *, struct mlock_args *); int sys_munlock(struct thread *, struct munlock_args *); @@ -2024,6 +1994,9 @@ int sys___mac_execve(struct thread *, struct __mac_execve_args *); int sys_sigaction(struct thread *, struct sigaction_args *); int sys_sigreturn(struct thread *, struct sigreturn_args *); +int sys___xstat(struct thread *, struct __xstat_args *); +int sys___xfstat(struct thread *, struct __xfstat_args *); +int sys___xlstat(struct thread *, struct __xlstat_args *); int sys_getcontext(struct thread *, struct getcontext_args *); int sys_setcontext(struct thread *, struct setcontext_args *); int sys_swapcontext(struct thread *, struct swapcontext_args *); @@ -2365,6 +2338,51 @@ #ifdef COMPAT_FREEBSD6 +struct freebsd6_pread_args { + char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)]; + char buf_l_[PADL_(void *)]; void * buf; char buf_r_[PADR_(void *)]; + char nbyte_l_[PADL_(size_t)]; size_t nbyte; char nbyte_r_[PADR_(size_t)]; + char pad_l_[PADL_(int)]; int pad; char pad_r_[PADR_(int)]; + char offset_l_[PADL_(off_t)]; off_t offset; char offset_r_[PADR_(off_t)]; +}; +struct freebsd6_pwrite_args { + char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)]; + char buf_l_[PADL_(const void *)]; const void * buf; char buf_r_[PADR_(const void *)]; + char nbyte_l_[PADL_(size_t)]; size_t nbyte; char nbyte_r_[PADR_(size_t)]; + char pad_l_[PADL_(int)]; int pad; char pad_r_[PADR_(int)]; + char offset_l_[PADL_(off_t)]; off_t offset; char offset_r_[PADR_(off_t)]; +}; +struct freebsd6_mmap_args { + char addr_l_[PADL_(caddr_t)]; caddr_t addr; char addr_r_[PADR_(caddr_t)]; + char len_l_[PADL_(size_t)]; size_t len; char len_r_[PADR_(size_t)]; + char prot_l_[PADL_(int)]; int prot; char prot_r_[PADR_(int)]; + char flags_l_[PADL_(int)]; int flags; char flags_r_[PADR_(int)]; + char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)]; + char pad_l_[PADL_(int)]; int pad; char pad_r_[PADR_(int)]; + char pos_l_[PADL_(off_t)]; off_t pos; char pos_r_[PADR_(off_t)]; +}; +struct freebsd6_lseek_args { + char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)]; + char pad_l_[PADL_(int)]; int pad; char pad_r_[PADR_(int)]; + char offset_l_[PADL_(off_t)]; off_t offset; char offset_r_[PADR_(off_t)]; + char whence_l_[PADL_(int)]; int whence; char whence_r_[PADR_(int)]; +}; +struct freebsd6_truncate_args { + char path_l_[PADL_(char *)]; char * path; char path_r_[PADR_(char *)]; + char pad_l_[PADL_(int)]; int pad; char pad_r_[PADR_(int)]; + char length_l_[PADL_(off_t)]; off_t length; char length_r_[PADR_(off_t)]; +}; +struct freebsd6_ftruncate_args { + char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)]; + char pad_l_[PADL_(int)]; int pad; char pad_r_[PADR_(int)]; + char length_l_[PADL_(off_t)]; off_t length; char length_r_[PADR_(off_t)]; +}; +int freebsd6_pread(struct thread *, struct freebsd6_pread_args *); +int freebsd6_pwrite(struct thread *, struct freebsd6_pwrite_args *); +int freebsd6_mmap(struct thread *, struct freebsd6_mmap_args *); +int freebsd6_lseek(struct thread *, struct freebsd6_lseek_args *); +int freebsd6_truncate(struct thread *, struct freebsd6_truncate_args *); +int freebsd6_ftruncate(struct thread *, struct freebsd6_ftruncate_args *); #endif /* COMPAT_FREEBSD6 */ @@ -2718,6 +2736,9 @@ #define SYS_AUE___mac_execve AUE_NULL #define SYS_AUE_sigaction AUE_SIGACTION #define SYS_AUE_sigreturn AUE_SIGRETURN +#define SYS_AUE___xstat AUE_STAT +#define SYS_AUE___xfstat AUE_FSTAT +#define SYS_AUE___xlstat AUE_LSTAT #define SYS_AUE_getcontext AUE_NULL #define SYS_AUE_setcontext AUE_NULL #define SYS_AUE_swapcontext AUE_NULL Index: sys/sys/ttydefaults.h =========================================================================== --- sys/sys/ttydefaults.h 2012/02/10 02:20:13 #9 +++ sys/sys/ttydefaults.h 2012/02/10 02:20:13 @@ -66,8 +66,8 @@ ((x) - 'a' + 1) : (((x) - 'A' + 1) & 0x7f)) #define CEOF CTRL('D') #define CEOL 0xff /* XXX avoid _POSIX_VDISABLE */ -#define CERASE CTRL('?') -#define CERASE2 CTRL('H') +#define CERASE CTRL('H') +#define CERASE2 CTRL('?') #define CINTR CTRL('C') #define CSTATUS CTRL('T') #define CKILL CTRL('U') Index: sys/sys/vnode.h =========================================================================== --- sys/sys/vnode.h 2012/02/10 02:20:13 #227 +++ sys/sys/vnode.h 2012/02/10 02:20:13 @@ -571,6 +571,7 @@ struct thread; struct proc; struct stat; +struct _new_stat; struct nstat; struct ucred; struct uio; @@ -592,6 +593,7 @@ int change_dir(struct vnode *vp, struct thread *td); int change_root(struct vnode *vp, struct thread *td); void cvtstat(struct stat *st, struct ostat *ost); +void cvtnewstat(struct stat *st, struct _new_stat *ost); void cvtnstat(struct stat *sb, struct nstat *nsb); int getnewvnode(const char *tag, struct mount *mp, struct vop_vector *vops, struct vnode **vpp); Index: sys/ufs/ffs/ffs_alloc.c =========================================================================== --- sys/ufs/ffs/ffs_alloc.c 2012/02/10 02:20:13 #100 +++ sys/ufs/ffs/ffs_alloc.c 2012/02/10 02:20:13 @@ -566,7 +566,7 @@ if (end_lvl == 0 || (idp = &end_ap[end_lvl - 1])->in_off + 1 >= len) { ssize = len; } else { -#ifdef INVARIANTS +#ifdef INVARIANTS_busted if (start_lvl > 0 && start_ap[start_lvl - 1].in_lbn == idp->in_lbn) panic("ffs_reallocblk: start == end"); @@ -774,7 +774,7 @@ if (end_lvl == 0 || (idp = &end_ap[end_lvl - 1])->in_off + 1 >= len) { ssize = len; } else { -#ifdef INVARIANTS +#ifdef INVARIANTS_busted if (start_lvl > 0 && start_ap[start_lvl - 1].in_lbn == idp->in_lbn) panic("ffs_reallocblk: start == end"); Index: sys/vm/pmap.h =========================================================================== --- sys/vm/pmap.h 2012/02/10 02:20:13 #52 +++ sys/vm/pmap.h 2012/02/10 02:20:13 @@ -90,6 +90,7 @@ #ifdef _KERNEL struct thread; +struct vmspace; /* * Updates to kernel_vm_end are synchronized by the kernel_map's system mutex. @@ -144,6 +145,7 @@ void pmap_zero_page(vm_page_t); void pmap_zero_page_area(vm_page_t, int off, int size); void pmap_zero_page_idle(vm_page_t); +void pmap_switch_vmspace(struct vmspace *vm); #define pmap_resident_count(pm) ((pm)->pm_stats.resident_count) #define pmap_wired_count(pm) ((pm)->pm_stats.wired_count) Index: sys/vm/vm_map.c =========================================================================== --- sys/vm/vm_map.c 2012/02/10 02:20:13 #241 +++ sys/vm/vm_map.c 2012/02/10 02:20:13 @@ -404,26 +404,17 @@ refcnt = vm->vm_refcnt; if (refcnt > 1 && p->p_vmspace != &vmspace0) { /* Switch now since other proc might free vmspace */ - PROC_VMSPACE_LOCK(p); - p->p_vmspace = &vmspace0; - PROC_VMSPACE_UNLOCK(p); - pmap_activate(td); + pmap_switch_vmspace(&vmspace0); } } while (!atomic_cmpset_int(&vm->vm_refcnt, refcnt, refcnt - 1)); if (refcnt == 1) { if (p->p_vmspace != vm) { /* vmspace not yet freed, switch back */ - PROC_VMSPACE_LOCK(p); - p->p_vmspace = vm; - PROC_VMSPACE_UNLOCK(p); - pmap_activate(td); + pmap_switch_vmspace(vm); } pmap_remove_pages(vmspace_pmap(vm)); /* Switch now since this proc will free vmspace */ - PROC_VMSPACE_LOCK(p); - p->p_vmspace = &vmspace0; - PROC_VMSPACE_UNLOCK(p); - pmap_activate(td); + pmap_switch_vmspace(&vmspace0); vmspace_dofree(vm); } vmspace_container_reset(p); @@ -3555,6 +3546,7 @@ struct vmspace *oldvmspace = p->p_vmspace; struct vmspace *newvmspace; + KASSERT(p == curthread->td_proc, ("vmspace_exec: not curthread")); newvmspace = vmspace_alloc(minuser, maxuser); if (newvmspace == NULL) return (ENOMEM); @@ -3566,11 +3558,7 @@ * run it down. Even though there is little or no chance of blocking * here, it is a good idea to keep this form for future mods. */ - PROC_VMSPACE_LOCK(p); - p->p_vmspace = newvmspace; - PROC_VMSPACE_UNLOCK(p); - if (p == curthread->td_proc) - pmap_activate(curthread); + pmap_switch_vmspace(newvmspace); vmspace_free(oldvmspace); return (0); } @@ -3589,6 +3577,7 @@ if (oldvmspace->vm_refcnt == 1) return (0); fork_charge = 0; + KASSERT(p == curthread->td_proc, ("vmspace_exec: not curthread")); newvmspace = vmspace_fork(oldvmspace, &fork_charge); if (newvmspace == NULL) return (ENOMEM); @@ -3596,11 +3585,7 @@ vmspace_free(newvmspace); return (ENOMEM); } - PROC_VMSPACE_LOCK(p); - p->p_vmspace = newvmspace; - PROC_VMSPACE_UNLOCK(p); - if (p == curthread->td_proc) - pmap_activate(curthread); + pmap_switch_vmspace(newvmspace); vmspace_free(oldvmspace); return (0); } Index: sys/vm/vm_map.h =========================================================================== --- sys/vm/vm_map.h 2012/02/10 02:20:13 #78 +++ sys/vm/vm_map.h 2012/02/10 02:20:13 @@ -253,6 +253,14 @@ { return &vmspace->vm_pmap; } + +/* + * PROC_VMSPACE_{UN,}LOCK() can be a noop as long as vmspaces are type + * stable. + */ +#define PROC_VMSPACE_LOCK(p) do { } while (0) +#define PROC_VMSPACE_UNLOCK(p) do { } while (0) + #endif /* _KERNEL */ #ifdef _KERNEL Index: sys/vm/vm_mmap.c =========================================================================== --- sys/vm/vm_mmap.c 2012/02/10 02:20:13 #134 +++ sys/vm/vm_mmap.c 2012/02/10 02:20:13 @@ -391,6 +391,7 @@ return (error); } +#ifdef COMPAT_FREEBSD6 int freebsd6_mmap(struct thread *td, struct freebsd6_mmap_args *uap) { @@ -404,6 +405,7 @@ oargs.pos = uap->pos; return (sys_mmap(td, &oargs)); } +#endif #ifdef COMPAT_43 #ifndef _SYS_SYSPROTO_H_ Index: tools/build/options/WITHOUT_PROFILE =========================================================================== --- tools/build/options/WITHOUT_PROFILE 2012/02/10 02:20:13 #3 +++ tools/build/options/WITHOUT_PROFILE 2012/02/10 02:20:13 Index: usr.bin/at/Makefile =========================================================================== --- usr.bin/at/Makefile 2012/02/10 02:20:13 #6 +++ usr.bin/at/Makefile 2012/02/10 02:20:13 @@ -3,7 +3,7 @@ .include "${.CURDIR}/Makefile.inc" PROG= at -SRCS= at.c panic.c parsetime.c perm.c +SRCS= at.c panic.c parsetime.c perm.c suntime.c LINKS= ${BINDIR}/at ${BINDIR}/atq \ ${BINDIR}/at ${BINDIR}/atrm \ ${BINDIR}/at ${BINDIR}/batch @@ -16,6 +16,8 @@ BINOWN= root BINMODE= 4555 CLEANFILES+= at.1 +LDADD+= -lm +DPADD+= ${LIBM} at.1: at.man @${ECHO} Making ${.TARGET:T} from ${.ALLSRC:T}; \ Index: usr.bin/at/parsetime.c =========================================================================== --- usr.bin/at/parsetime.c 2012/02/10 02:20:13 #9 +++ usr.bin/at/parsetime.c 2012/02/10 02:20:13 @@ -61,7 +61,7 @@ /* Structures and unions */ enum { /* symbols */ - MIDNIGHT, NOON, TEATIME, + MIDNIGHT, NOON, TEATIME, SUNRISE, SUNSET, PM, AM, TOMORROW, TODAY, NOW, MINUTES, HOURS, DAYS, WEEKS, MONTHS, YEARS, NUMBER, PLUS, DOT, SLASH, ID, JUNK, @@ -80,6 +80,8 @@ { "midnight", MIDNIGHT,0 }, /* 00:00:00 of today or tomorrow */ { "noon", NOON,0 }, /* 12:00:00 of today or tomorrow */ { "teatime", TEATIME,0 }, /* 16:00:00 of today or tomorrow */ + { "sunrise", SUNRISE, 0 }, /* Sunrise */ + { "sunset", SUNSET, 0 }, /* Sunset */ { "am", AM,0 }, /* morning times for 0-12 clock */ { "pm", PM,0 }, /* evening times for 0-12 clock */ { "tomorrow", TOMORROW,0 }, /* execute 24 hours from time */ @@ -230,7 +232,8 @@ /* then see what it is */ - if (isdigit(sc_token[0])) { + if (isdigit(sc_token[0]) || sc_token[0] == '-') { + sc_token[++idx] = *sct++; while (isdigit(*sct)) sc_token[++idx] = *sct++; sc_token[++idx] = 0; @@ -564,6 +567,11 @@ struct tm nowtime, runtime; int hr = 0; /* this MUST be initialized to zero for midnight/noon/teatime */ + int mn, r; + double lat, lon; + + lat = 37.798325; /* where I live, so there. */ + lon = -121.970223; nowtimer = time(NULL); nowtime = *localtime(&nowtimer); @@ -593,6 +601,26 @@ month(&runtime); break; + case SUNRISE: + r = sun_time(1, lat, lon, nowtime.tm_gmtoff / 3600, nowtime.tm_yday + 1, &hr, &mn); + if (r == -1) + panic("no sunrise!"); + runtime.tm_hour = hr; + runtime.tm_min = mn; + token(); + month(&runtime); + break; + + case SUNSET: + r = sun_time(0, lat, lon, nowtime.tm_gmtoff / 3600, nowtime.tm_yday + 1, &hr, &mn); + if (r == -1) + panic("no sunrise!"); + runtime.tm_hour = hr; + runtime.tm_min = mn; + token(); + month(&runtime); + break; + /* evil coding for TEATIME|NOON|MIDNIGHT - we've initialised * hr to zero up above, then fall into this case in such a * way so we add +12 +4 hours to it for teatime, +12 hours Index: usr.bin/at/parsetime.h =========================================================================== --- usr.bin/at/parsetime.h 2012/02/10 02:20:13 #1 +++ usr.bin/at/parsetime.h 2012/02/10 02:20:13 @@ -24,3 +24,4 @@ */ time_t parsetime(int argc, char **argv); +int sun_time(int rise, double lat, double lon, int tz, int yday, int *hr, int *mn); Index: usr.bin/at/suntime.c =========================================================================== *** /dev/null Fri Feb 10 02:19:45 2012 --- usr.bin/at/suntime.c Fri Feb 10 02:20:19 2012 *************** *** 0 **** --- 1,99 ---- + /* + * C version of algorithm from p5-Astro-SunTime. + */ + + /* Results can be -=checked with: http://aa.usno.navy.mil/AA/data/docs/RS_OneYear.html */ + + #include + #include + #include + #include + #include + #include + + #include "parsetime.h" + + int + sun_time(int rise, double latitude, double longitude, int time_zone, int yday, int *hh, int *mm) + { + double A, B, C, D, E, F, G, J, K, L, M, P, Q, R, S, T, U, V; + + /* + * eg: + * latitude 38.74274 - degrees north = positive + * longitude -90.560143 - degrees east = positive + * time_zone -6 - hours east = positive + */ + + A = 1.5708; + B = 3.14159; + C = 4.71239; + D = 6.28319; + /* Invert signs here to flip +/- of input ranges */ + E = 0.0174533 * latitude; + F = 0.0174533 * longitude; + G = 0.261799 * time_zone; + + /* + * For astronomical twilight, use R = -0.309017 + * For nautical twilight, use R = -0.207912 + * For civil twilight, use R = -0.104528 + * For sunrise or sunset, use R = -0.0145439 + */ + R = -0.0145439; + + if (rise) + J = A; + else + J = C; + K = yday + ((J - F) / D); + L = (K * 0.017202) - 0.0574039; /* Solar Mean Anomoly */ + M = L + 0.0334405 * sin(L); /* Solar True Longitude */ + M += 4.93289 + (3.49066E-04) * sin(2 * L); + /* Quadrant Determination */ + while (M < 0.0) + M += D; + while (M >= D) + M -= D; + if ((M / A) - ((int)(M / A)) == 0.0) + M += 4.84814E-06; + P = sin(M) / cos(M); /* Solar Right Ascension */ + P = atan2(0.91746 * P, 1); + + /* Quadrant Adjustment */ + if (M > C) + P += D; + else if (M > A) + P += B; + + Q = 0.39782 * sin(M); /* Solar Declination */ + Q = Q / sqrt(-Q * Q + 1); /* This is how the original author wrote it! */ + Q = atan2(Q, 1); + + S = R - (sin(Q) * sin(E)); + S = S / (cos(Q) * cos(E)); + + if (abs(S) > 1) { /* Null phenomenon */ + errno = ERANGE; /* No Sun{rise|set} */ + return (-1); + } + + S = S / sqrt(-S * S + 1); + S = A - atan2(S, 1); + if (rise) + S = D - S; + + T = S + P - 0.0172028 * K - 1.73364; /* Local apparent time */ + U = T - F; /* Universal timer */ + V = U + G; /* Wall clock time */ + while (V < 0.0) + V += D; + while (V >= D) + V -= D; + V = V * 3.81972; + + *hh = V; + *mm = (V - *hh) * 60 + 0.5; + + return (0); + } Index: usr.bin/gcore/Makefile =========================================================================== --- usr.bin/gcore/Makefile 2012/02/10 02:20:13 #7 +++ usr.bin/gcore/Makefile 2012/02/10 02:20:13 @@ -1,7 +1,7 @@ # @(#)Makefile 8.1 (Berkeley) 6/6/93 # $FreeBSD: src/usr.bin/gcore/Makefile,v 1.12 2010/02/25 20:24:19 ru Exp $ -PROG= gcore +PROG?= gcore SRCS= elfcore.c gcore.c DPADD= ${LIBUTIL} LDADD= -lutil Index: usr.bin/procstat/procstat.1 =========================================================================== --- usr.bin/procstat/procstat.1 2012/02/10 02:20:13 #16 +++ usr.bin/procstat/procstat.1 2012/02/10 02:20:13 @@ -388,6 +388,8 @@ mapping flags .It TP VM object type +.It OFFSET +mapping offset within VM object .El .Pp The following protection flags may be displayed: Index: usr.bin/procstat/procstat_vm.c =========================================================================== --- usr.bin/procstat/procstat_vm.c 2012/02/10 02:20:13 #11 +++ usr.bin/procstat/procstat_vm.c 2012/02/10 02:20:13 @@ -44,15 +44,16 @@ procstat_vm(struct kinfo_proc *kipp) { struct kinfo_vmentry *freep, *kve; - int ptrwidth; + int ptrwidth, offwidth; int i, cnt; const char *str; ptrwidth = 2*sizeof(void *) + 2; + offwidth = 2*sizeof(off_t) + 2; if (!hflag) - printf("%5s %*s %*s %3s %4s %4s %3s %3s %3s %-2s %-s\n", + printf("%5s %*s %*s %3s %4s %4s %3s %3s %3s %-2s %*s %8s %8s %-s\n", "PID", ptrwidth, "START", ptrwidth, "END", "PRT", "RES", - "PRES", "REF", "SHD", "FL", "TP", "PATH"); + "PRES", "REF", "SHD", "FL", "TP", offwidth, "OFFSET", "FSID", "FILEID", "PATH"); freep = kinfo_getvmmap(kipp->ki_pid, &cnt); if (freep == NULL) @@ -104,6 +105,9 @@ break; } printf("%-2s ", str); + printf("%#*llx ", offwidth, (unsigned long long)kve->kve_offset); + printf("%#8lx ", (unsigned long)kve->kve_vn_fsid); + printf("%8lld ", (unsigned long long)kve->kve_vn_fileid); printf("%-s\n", kve->kve_path); } free(freep); Index: usr.bin/tail/tail.c =========================================================================== --- usr.bin/tail/tail.c 2012/02/10 02:20:13 #18 +++ usr.bin/tail/tail.c 2012/02/10 02:20:13 @@ -111,7 +111,7 @@ obsolete(argv); style = NOTSET; off = 0; - while ((ch = getopt(argc, argv, "Fb:c:fn:qr")) != -1) + while ((ch = getopt(argc, argv, "Fb:c:fln:qr")) != -1) switch(ch) { case 'F': /* -F is superset of (and implies) -f */ Fflag = fflag = 1; @@ -125,6 +125,9 @@ case 'f': fflag = 1; break; + case 'l': + setlinebuf(stdout); + break; case 'n': ARG(1, FLINES, RLINES); break; Index: usr.sbin/sicontrol/sicontrol.c =========================================================================== --- usr.sbin/sicontrol/sicontrol.c 2012/02/10 02:20:13 #6 +++ usr.sbin/sicontrol/sicontrol.c 2012/02/10 02:20:13 @@ -119,8 +119,9 @@ #define U_MSTATE 4 #define U_STAT_CCB 5 #define U_STAT_PORT 6 +#define U_STAT_TTY 7 -#define U_MAX 7 +#define U_MAX 8 #define U_ALL -1 char *usage[] = { "debug [[add|del|set debug_levels] | [off]]\n", @@ -644,6 +645,56 @@ printf("\tsp_delta_overflows 0x%d\n", PRT.sp_delta_overflows); } +#if 0 +const char *pt_state(int ts) +{ + static char buf[200]; + + buf[0] = 0; + if (ts & TS_SO_OLOWAT) strcat(buf, "TS_SO_OLOWAT "); + if (ts & TS_ASYNC) strcat(buf, "TS_ASYNC "); + if (ts & TS_BUSY) strcat(buf, "TS_BUSY "); + if (ts & TS_CARR_ON) strcat(buf, "TS_CARR_ON "); + if (ts & TS_FLUSH) strcat(buf, "TS_FLUSH "); + if (ts & TS_ISOPEN) strcat(buf, "TS_ISOPEN "); + if (ts & TS_TBLOCK) strcat(buf, "TS_TBLOCK "); + if (ts & TS_TIMEOUT) strcat(buf, "TS_TIMEOUT "); + if (ts & TS_TTSTOP) strcat(buf, "TS_TTSTOP "); + if (ts & TS_XCLUDE) strcat(buf, "TS_XCLUDE "); + if (ts & TS_BKSL) strcat(buf, "TS_BKSL "); + if (ts & TS_CNTTB) strcat(buf, "TS_CNTTB "); + if (ts & TS_ERASE) strcat(buf, "TS_ERASE "); + if (ts & TS_TYPEN) strcat(buf, "TS_TYPEN "); + if (ts & TS_CAN_BYPASS_L_RINT) strcat(buf, "TS_CAN_BYPASS_L_RINT "); + if (ts & TS_CONNECTED) strcat(buf, "TS_CONNECTED "); + if (ts & TS_SNOOP) strcat(buf, "TS_SNOOP "); + if (ts & TS_SO_OCOMPLETE) strcat(buf, "TS_OCOMPLETE "); + if (ts & TS_ZOMBIE) strcat(buf, "TS_ZOMBIE "); + if (ts & TS_CAR_OFLOW) strcat(buf, "TS_CAR_OFLOW "); + if (ts & TS_DTR_WAIT) strcat(buf, "TS_DTR_WAIT "); + if (ts & TS_GONE) strcat(buf, "TS_GONE "); + if (ts & TS_CALLOUT) strcat(buf, "TS_CALLOUT "); + return (buf); +} +void +{ + struct si_pstat sip; +#define PRT sip.tc_siport + + if (ac != 0) + prusage(U_STAT_PORT, 1); + sip.tc_dev = tc.tc_dev; + if (ioctl(ctlfd, TCSI_PORT, &sip) < 0) + err(1, "TCSI_PORT on %s", Devname); + printf("%s: ", Devname); + + printf("\tsp_pend 0x%x %s\n", PRT.sp_pend, s_stat(PRT.sp_pend)); + printf("\tsp_last_hi_ip 0x%x %s\n", PRT.sp_last_hi_ip, s_ip(PRT.sp_last_hi_ip)); + printf("\tsp_state 0x%x %s\n", PRT.sp_state, sp_state(PRT.sp_state)); + printf("\tsp_delta_overflows 0x%d\n", PRT.sp_delta_overflows); +} +#endif + int islevel(char *tk) {