svn commit: r261433 - in user/ae/inet6: bin/df cddl/contrib/opensolaris/cmd/zdb contrib/gcc/cp gnu/lib/libgcc lib/libc libexec/rtld-elf release release/amd64 release/i386 release/pkg_repos release/...
Andrey V. Elsukov
ae at FreeBSD.org
Mon Feb 3 10:31:50 UTC 2014
Author: ae
Date: Mon Feb 3 10:31:43 2014
New Revision: 261433
URL: http://svnweb.freebsd.org/changeset/base/261433
Log:
Merge from head/ up to r260851.
Added:
user/ae/inet6/release/pkg_repos/
- copied from r260851, head/release/pkg_repos/
user/ae/inet6/share/man/man4/virtio_random.4
- copied unchanged from r260851, head/share/man/man4/virtio_random.4
user/ae/inet6/sys/dev/virtio/random/
- copied from r260851, head/sys/dev/virtio/random/
user/ae/inet6/sys/modules/virtio/random/
- copied from r260851, head/sys/modules/virtio/random/
Deleted:
user/ae/inet6/release/amd64/pkg-stage.conf
user/ae/inet6/release/i386/pkg-stage.conf
Modified:
user/ae/inet6/bin/df/df.1
user/ae/inet6/cddl/contrib/opensolaris/cmd/zdb/zdb.c
user/ae/inet6/contrib/gcc/cp/ChangeLog.apple
user/ae/inet6/contrib/gcc/cp/parser.c
user/ae/inet6/gnu/lib/libgcc/Makefile
user/ae/inet6/lib/libc/Makefile
user/ae/inet6/libexec/rtld-elf/Makefile
user/ae/inet6/release/Makefile
user/ae/inet6/release/scripts/pkg-stage.sh
user/ae/inet6/share/man/man4/Makefile
user/ae/inet6/share/mk/bsd.libnames.mk
user/ae/inet6/sys/amd64/conf/NOTES
user/ae/inet6/sys/amd64/vmm/intel/vmcs.h
user/ae/inet6/sys/amd64/vmm/intel/vmx.c
user/ae/inet6/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
user/ae/inet6/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_traverse.c
user/ae/inet6/sys/compat/freebsd32/freebsd32_misc.c
user/ae/inet6/sys/conf/files.amd64
user/ae/inet6/sys/conf/files.i386
user/ae/inet6/sys/dev/ahci/ahci.c
user/ae/inet6/sys/dev/usb/usb_dev.c
user/ae/inet6/sys/dev/usb/usb_device.c
user/ae/inet6/sys/i386/conf/NOTES
user/ae/inet6/sys/kern/kern_event.c
user/ae/inet6/sys/kern/uipc_sockbuf.c
user/ae/inet6/sys/kern/uipc_syscalls.c
user/ae/inet6/sys/mips/cavium/ciu.c
user/ae/inet6/sys/modules/virtio/Makefile
user/ae/inet6/sys/net/netmap_user.h
user/ae/inet6/sys/netinet/in_mcast.c
user/ae/inet6/sys/netinet6/in6.c
user/ae/inet6/sys/netinet6/ip6_fastfwd.c
user/ae/inet6/sys/sys/random.h
user/ae/inet6/sys/sys/sf_base.h
user/ae/inet6/sys/sys/sf_sync.h
user/ae/inet6/sys/sys/socket.h
user/ae/inet6/tools/tools/mcgrab/mcgrab.cc
user/ae/inet6/usr.bin/killall/killall.c
user/ae/inet6/usr.bin/ktrdump/ktrdump.c
user/ae/inet6/usr.bin/script/script.c
Directory Properties:
user/ae/inet6/ (props changed)
user/ae/inet6/cddl/ (props changed)
user/ae/inet6/cddl/contrib/opensolaris/ (props changed)
user/ae/inet6/contrib/gcc/ (props changed)
user/ae/inet6/gnu/lib/ (props changed)
user/ae/inet6/lib/libc/ (props changed)
user/ae/inet6/share/man/man4/ (props changed)
user/ae/inet6/sys/ (props changed)
user/ae/inet6/sys/amd64/vmm/ (props changed)
user/ae/inet6/sys/cddl/contrib/opensolaris/ (props changed)
user/ae/inet6/sys/conf/ (props changed)
Modified: user/ae/inet6/bin/df/df.1
==============================================================================
--- user/ae/inet6/bin/df/df.1 Mon Feb 3 08:15:09 2014 (r261432)
+++ user/ae/inet6/bin/df/df.1 Mon Feb 3 10:31:43 2014 (r261433)
@@ -29,7 +29,7 @@
.\" @(#)df.1 8.3 (Berkeley) 5/8/95
.\" $FreeBSD$
.\"
-.Dd January 24, 2013
+.Dd January 16, 2014
.Dt DF 1
.Os
.Sh NAME
@@ -83,13 +83,13 @@ Use 1073741824 byte (1 Gibibyte) blocks
This overrides any
.Ev BLOCKSIZE
specification from the environment.
-.It Fl H
+.It Fl h
.Dq Human-readable
output.
Use unit suffixes: Byte, Kibibyte, Mebibyte, Gibibyte, Tebibyte and
Pebibyte (based on powers of 1024) in order to reduce the number of
digits to four or fewer.
-.It Fl h
+.It Fl H
.Dq Human-readable
output.
Use unit suffixes: Byte, Kilobyte, Megabyte,
Modified: user/ae/inet6/cddl/contrib/opensolaris/cmd/zdb/zdb.c
==============================================================================
--- user/ae/inet6/cddl/contrib/opensolaris/cmd/zdb/zdb.c Mon Feb 3 08:15:09 2014 (r261432)
+++ user/ae/inet6/cddl/contrib/opensolaris/cmd/zdb/zdb.c Mon Feb 3 10:31:43 2014 (r261433)
@@ -3012,6 +3012,7 @@ zdb_read_block(char *thing, spa_t *spa)
free(dup);
return;
}
+ i += p - &flagstr[i + 1]; /* skip over the number */
}
}
Modified: user/ae/inet6/contrib/gcc/cp/ChangeLog.apple
==============================================================================
--- user/ae/inet6/contrib/gcc/cp/ChangeLog.apple Mon Feb 3 08:15:09 2014 (r261432)
+++ user/ae/inet6/contrib/gcc/cp/ChangeLog.apple Mon Feb 3 10:31:43 2014 (r261433)
@@ -302,15 +302,6 @@
(cp_parser_objc_declaration): Parses attribute list and passes it down
to cp_parser_objc_class_interface/cp_parser_objc_protocol_declaration.
-2007-07-24 Fariborz Jahanian <fjahanian at apple.com>
-
- Radar 5355344
- * cp-tree.h (cp_objc_protocol_id_list): New declaration
- * cp-lang.c (cp_objc_protocol_id_list): New stub
- * parser.c (cp_parser_type_name): Added code to disambiguate
- conditional from a protocol type.
- (cp_parser_objc_tentative_protocol_refs_opt): New
-
2007-07-13 Fariborz Jahanian <fjahanian at apple.com>
Radar 5277239
Modified: user/ae/inet6/contrib/gcc/cp/parser.c
==============================================================================
--- user/ae/inet6/contrib/gcc/cp/parser.c Mon Feb 3 08:15:09 2014 (r261432)
+++ user/ae/inet6/contrib/gcc/cp/parser.c Mon Feb 3 10:31:43 2014 (r261433)
@@ -1827,10 +1827,6 @@ static tree cp_parser_objc_identifier_li
/* APPLE LOCAL end radar 3803157 - objc attribute */
static tree cp_parser_objc_protocol_refs_opt
(cp_parser *);
-/* APPLE LOCAL begin radar 5355344 */
-static bool cp_parser_objc_tentative_protocol_refs_opt
- (cp_parser *, tree *);
-/* APPLE LOCAL end radar 5355344 */
static void cp_parser_objc_declaration
(cp_parser *);
static tree cp_parser_objc_statement
@@ -17873,32 +17869,6 @@ cp_parser_objc_protocol_refs_opt (cp_par
return protorefs;
}
-/* APPLE LOCAL begin radar 5355344 */
-/* This routine also parses a list of Objective-C protocol references; except that
- if list is not valid, it returns FALSE and back-tracks parsing. */
-
-static bool
-cp_parser_objc_tentative_protocol_refs_opt (cp_parser* parser, tree *protorefs)
-{
- *protorefs = NULL_TREE;
- if(cp_lexer_next_token_is (parser->lexer, CPP_LESS))
- {
- cp_parser_parse_tentatively (parser);
- cp_lexer_consume_token (parser->lexer); /* Eat '<'. */
- *protorefs = cp_parser_objc_identifier_list (parser);
- if (!cp_objc_protocol_id_list (*protorefs))
- {
- cp_parser_abort_tentative_parse (parser);
- return false;
- }
- if (cp_parser_parse_definitely (parser))
- cp_parser_require (parser, CPP_GREATER, "`>'");
- }
-
- return true;
-}
-/* APPLE LOCAL end radar 5355344 */
-
/* Parse a Objective-C visibility specification. */
static void
Modified: user/ae/inet6/gnu/lib/libgcc/Makefile
==============================================================================
--- user/ae/inet6/gnu/lib/libgcc/Makefile Mon Feb 3 08:15:09 2014 (r261432)
+++ user/ae/inet6/gnu/lib/libgcc/Makefile Mon Feb 3 10:31:43 2014 (r261433)
@@ -119,8 +119,8 @@ LIB1ASMFUNCS = _dvmd_tls _bb_init_func
.if ${MK_ARM_EABI} != "no"
LIB2ADDEH = unwind-arm.c libunwind.S pr-support.c unwind-c.c
# Some compilers generate __aeabi_ functions libgcc_s is missing
-DPADD+= ${LIBGCC}
-LDADD+= -lgcc
+DPADD+= ${LIBCOMPILER_RT}
+LDADD+= -lcompiler_rt
.else
LIB2FUNCS_EXTRA = floatunsidf.c floatunsisf.c
.endif
@@ -145,6 +145,7 @@ LIB1ASMFUNCS = __divxf3 __divdf3 __divsf
__divsi3 __modsi3 __udivsi3 __umodsi3 __save_stack_nonlocal \
__nonlocal_goto __restore_stack_nonlocal __trampoline \
_fixtfdi _fixunstfdi _floatditf
+LIB2FUNCS += _bswapsi2 _bswapdi2
LIB2ADDEH = unwind-ia64.c unwind-sjlj.c unwind-c.c
.endif
Modified: user/ae/inet6/lib/libc/Makefile
==============================================================================
--- user/ae/inet6/lib/libc/Makefile Mon Feb 3 08:15:09 2014 (r261432)
+++ user/ae/inet6/lib/libc/Makefile Mon Feb 3 10:31:43 2014 (r261433)
@@ -40,11 +40,11 @@ CFLAGS+=${CANCELPOINTS_CFLAGS}
.endif
#
-# Only link with static libgcc.a (no libgcc_eh.a).
+# Link with static libcompiler_rt.a.
#
-DPADD+= ${LIBGCC}
+DPADD+= ${LIBCOMPILER_RT}
LDFLAGS+= -nodefaultlibs
-LDADD+= -lgcc
+LDADD+= -lcompiler_rt
.if ${MK_SSP} != "no"
LDADD+= -lssp_nonshared
Modified: user/ae/inet6/libexec/rtld-elf/Makefile
==============================================================================
--- user/ae/inet6/libexec/rtld-elf/Makefile Mon Feb 3 08:15:09 2014 (r261432)
+++ user/ae/inet6/libexec/rtld-elf/Makefile Mon Feb 3 10:31:43 2014 (r261433)
@@ -43,11 +43,12 @@ DPADD= ${LIBC_PIC}
LDADD= -lc_pic
.if ${MACHINE_CPUARCH} == "arm" && ${MK_ARM_EABI} != "no"
-# Some of the required math functions (div & mod) are implemented in libgcc
-# on ARM. The library also needs to be placed first to be correctly linked.
-# As some of the functions are used before we have shared libraries.
-DPADD+= ${LIBGCC}
-LDADD+= -lgcc
+# Some of the required math functions (div & mod) are implemented in
+# libcompiler_rt on ARM. The library also needs to be placed first to be
+# correctly linked. As some of the functions are used before we have
+# shared libraries.
+DPADD+= ${LIBCOMPILER_RT}
+LDADD+= -lcompiler_rt
.endif
Modified: user/ae/inet6/release/Makefile
==============================================================================
--- user/ae/inet6/release/Makefile Mon Feb 3 08:15:09 2014 (r261432)
+++ user/ae/inet6/release/Makefile Mon Feb 3 10:31:43 2014 (r261433)
@@ -224,9 +224,9 @@ packagesystem: base.txz kernel.txz ${EXT
touch ${.TARGET}
pkg-stage:
-.if !defined(NOPKG) && exists(${.CURDIR}/${TARGET}/pkg-stage.conf)
- sh ${.CURDIR}/scripts/pkg-stage.sh ${.CURDIR}/${TARGET}/pkg-stage.conf \
- ${REVISION}
+.if !defined(NOPKG)
+ env REPOS_DIR=${.CURDIR}/pkg_repos/ \
+ sh ${.CURDIR}/scripts/pkg-stage.sh
mkdir -p ${.OBJDIR}/dvd/packages/repos/
cp ${.CURDIR}/scripts/FreeBSD_install_cdrom.conf \
${.OBJDIR}/dvd/packages/repos/
Modified: user/ae/inet6/release/scripts/pkg-stage.sh
==============================================================================
--- user/ae/inet6/release/scripts/pkg-stage.sh Mon Feb 3 08:15:09 2014 (r261432)
+++ user/ae/inet6/release/scripts/pkg-stage.sh Mon Feb 3 10:31:43 2014 (r261433)
@@ -5,24 +5,31 @@
set -e
-usage() {
- echo "$(basename ${0}) /path/to/pkg-stage.conf revision"
- exit 1
-}
-
-if [ ! -e "${1}" ]; then
- echo "Configuration file not specified."
- echo
- usage
-fi
-
-if [ "$#" -lt 2 ]; then
- usage
-fi
-
-# Source config file for this architecture.
-REVISION="${2}"
-. "${1}" || exit 1
+export ASSUME_ALWAYS_YES=1
+export PKG_DBDIR="/tmp/pkg"
+export PERMISSIVE="YES"
+export REPO_AUTOUPDATE="NO"
+export PKGCMD="/usr/sbin/pkg -d"
+
+DVD_PACKAGES="archivers/unzip
+devel/subversion
+devel/subversion-static
+emulators/linux_base-f10
+misc/freebsd-doc-all
+net/mpd5
+net/rsync
+ports-mgmt/pkg
+ports-mgmt/portmaster
+shells/bash
+shells/zsh
+security/sudo
+sysutils/screen
+www/firefox
+www/links
+x11-drivers/xf86-video-vmware
+x11/gnome2
+x11/kde4
+x11/xorg"
# If NOPORTS is set for the release, do not attempt to build pkg(8).
if [ ! -f /usr/ports/Makefile ]; then
@@ -33,8 +40,13 @@ if [ ! -x /usr/local/sbin/pkg ]; then
/usr/bin/make -C /usr/ports/ports-mgmt/pkg install clean
fi
+export PKG_ABI=$(pkg -vv | grep ^ABI | awk '{print $3}')
+export PKG_CACHEDIR="dvd/packages/${PKG_ABI}"
+
/bin/mkdir -p ${PKG_CACHEDIR}
+# Print pkg(8) information to make debugging easier.
+${PKGCMD} -vv
${PKGCMD} update -f
${PKGCMD} fetch -d ${DVD_PACKAGES}
Modified: user/ae/inet6/share/man/man4/Makefile
==============================================================================
--- user/ae/inet6/share/man/man4/Makefile Mon Feb 3 08:15:09 2014 (r261432)
+++ user/ae/inet6/share/man/man4/Makefile Mon Feb 3 10:31:43 2014 (r261433)
@@ -543,6 +543,7 @@ MAN= aac.4 \
${_virtio.4} \
${_virtio_balloon.4} \
${_virtio_blk.4} \
+ ${_virtio_random.4} \
${_virtio_scsi.4} \
vkbd.4 \
vlan.4 \
@@ -787,6 +788,7 @@ _nxge.4= nxge.4
_virtio.4= virtio.4
_virtio_balloon.4=virtio_balloon.4
_virtio_blk.4= virtio_blk.4
+_virtio_random.4= virtio_random.4
_virtio_scsi.4= virtio_scsi.4
_vmx.4= vmx.4
_vtnet.4= vtnet.4
Copied: user/ae/inet6/share/man/man4/virtio_random.4 (from r260851, head/share/man/man4/virtio_random.4)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ user/ae/inet6/share/man/man4/virtio_random.4 Mon Feb 3 10:31:43 2014 (r261433, copy of r260851, head/share/man/man4/virtio_random.4)
@@ -0,0 +1,61 @@
+.\" Copyright (c) 2013 Bryan Venteicher
+.\" 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$
+.\"
+.Dd December 28, 2013
+.Dt VIRTIO_RANDOM 4
+.Os
+.Sh NAME
+.Nm virtio_random
+.Nd VirtIO Entropy driver
+.Sh SYNOPSIS
+To compile this driver into the kernel,
+place the following lines in your
+kernel configuration file:
+.Bd -ragged -offset indent
+.Cd "device virtio_random"
+.Ed
+.Pp
+Alternatively, to load the driver as a
+module at boot time, place the following line in
+.Xr loader.conf 5 :
+.Bd -literal -offset indent
+virtio_random_load="YES"
+.Ed
+.Sh DESCRIPTION
+The
+.Nm
+device driver provides support for VirtIO entropy devices.
+.Pp
+The entropy device supplies high-quality randomness from the
+hypervisor to the guest.
+.Sh SEE ALSO
+.Xr random 4
+.Xr virtio 4
+.Sh HISTORY
+The
+.Nm
+driver was written by
+.An Bryan Venteicher Aq bryanv at FreeBSD.org .
Modified: user/ae/inet6/share/mk/bsd.libnames.mk
==============================================================================
--- user/ae/inet6/share/mk/bsd.libnames.mk Mon Feb 3 08:15:09 2014 (r261432)
+++ user/ae/inet6/share/mk/bsd.libnames.mk Mon Feb 3 10:31:43 2014 (r261433)
@@ -36,6 +36,7 @@ LIBCAPSICUM?= ${DESTDIR}${LIBDIR}/libcap
LIBCASPER?= ${DESTDIR}${LIBDIR}/libcasper.a
LIBCOM_ERR?= ${DESTDIR}${LIBDIR}/libcom_err.a
LIBCOMPAT?= ${DESTDIR}${LIBDIR}/libcompat.a
+LIBCOMPILER_RT?=${DESTDIR}${LIBDIR}/libcompiler_rt.a
LIBCRYPT?= ${DESTDIR}${LIBDIR}/libcrypt.a
LIBCRYPTO?= ${DESTDIR}${LIBDIR}/libcrypto.a
LIBCTF?= ${DESTDIR}${LIBDIR}/libctf.a
@@ -53,8 +54,6 @@ LIBFETCH?= ${DESTDIR}${LIBDIR}/libfetch.
LIBFL?= "don't use LIBFL, use LIBL"
LIBFORM?= ${DESTDIR}${LIBDIR}/libform.a
LIBG2C?= ${DESTDIR}${LIBDIR}/libg2c.a
-LIBGCC?= ${DESTDIR}${LIBDIR}/libgcc.a
-LIBGCC_PIC?= ${DESTDIR}${LIBDIR}/libgcc_pic.a
LIBGEOM?= ${DESTDIR}${LIBDIR}/libgeom.a
LIBGNUREGEX?= ${DESTDIR}${LIBDIR}/libgnuregex.a
LIBGSSAPI?= ${DESTDIR}${LIBDIR}/libgssapi.a
Modified: user/ae/inet6/sys/amd64/conf/NOTES
==============================================================================
--- user/ae/inet6/sys/amd64/conf/NOTES Mon Feb 3 08:15:09 2014 (r261432)
+++ user/ae/inet6/sys/amd64/conf/NOTES Mon Feb 3 10:31:43 2014 (r261433)
@@ -472,6 +472,7 @@ device vtnet # VirtIO Ethernet device
device virtio_blk # VirtIO Block device
device virtio_scsi # VirtIO SCSI device
device virtio_balloon # VirtIO Memory Balloon device
+device virtio_random # VirtIO Entropy device
device hyperv # HyperV drivers
Modified: user/ae/inet6/sys/amd64/vmm/intel/vmcs.h
==============================================================================
--- user/ae/inet6/sys/amd64/vmm/intel/vmcs.h Mon Feb 3 08:15:09 2014 (r261432)
+++ user/ae/inet6/sys/amd64/vmm/intel/vmcs.h Mon Feb 3 10:31:43 2014 (r261433)
@@ -331,12 +331,18 @@ vmcs_write(uint32_t encoding, uint64_t v
#define EXIT_REASON_APIC_WRITE 56
/*
+ * NMI unblocking due to IRET.
+ *
+ * Applies to VM-exits due to hardware exception or EPT fault.
+ */
+#define EXIT_QUAL_NMIUDTI (1 << 12)
+/*
* VMCS interrupt information fields
*/
-#define VMCS_INTR_INFO_VALID (1U << 31)
-#define VMCS_INTR_INFO_TYPE(info) (((info) >> 8) & 0x7)
-#define VMCS_INTR_INFO_HW_INTR (0 << 8)
-#define VMCS_INTR_INFO_NMI (2 << 8)
+#define VMCS_INTR_VALID (1U << 31)
+#define VMCS_INTR_T_MASK 0x700 /* Interruption-info type */
+#define VMCS_INTR_T_HWINTR (0 << 8)
+#define VMCS_INTR_T_NMI (2 << 8)
/*
* VMCS IDT-Vectoring information fields
Modified: user/ae/inet6/sys/amd64/vmm/intel/vmx.c
==============================================================================
--- user/ae/inet6/sys/amd64/vmm/intel/vmx.c Mon Feb 3 08:15:09 2014 (r261432)
+++ user/ae/inet6/sys/amd64/vmm/intel/vmx.c Mon Feb 3 10:31:43 2014 (r261433)
@@ -1065,7 +1065,7 @@ vmx_inject_nmi(struct vmx *vmx, int vcpu
* Inject the virtual NMI. The vector must be the NMI IDT entry
* or the VMCS entry check will fail.
*/
- info = VMCS_INTR_INFO_NMI | VMCS_INTR_INFO_VALID;
+ info = VMCS_INTR_T_NMI | VMCS_INTR_VALID;
info |= IDT_NMI;
vmcs_write(VMCS_ENTRY_INTR_INFO, info);
@@ -1103,7 +1103,7 @@ vmx_inject_interrupts(struct vmx *vmx, i
* because of a pending AST.
*/
info = vmcs_read(VMCS_ENTRY_INTR_INFO);
- if (info & VMCS_INTR_INFO_VALID)
+ if (info & VMCS_INTR_VALID)
return;
/*
@@ -1134,7 +1134,7 @@ vmx_inject_interrupts(struct vmx *vmx, i
goto cantinject;
/* Inject the interrupt */
- info = VMCS_INTR_INFO_HW_INTR | VMCS_INTR_INFO_VALID;
+ info = VMCS_INTR_T_HWINTR | VMCS_INTR_VALID;
info |= vector;
vmcs_write(VMCS_ENTRY_INTR_INFO, info);
@@ -1155,6 +1155,37 @@ cantinject:
VCPU_CTR0(vmx->vm, vcpu, "Enabling interrupt window exiting");
}
+/*
+ * If the Virtual NMIs execution control is '1' then the logical processor
+ * tracks virtual-NMI blocking in the Guest Interruptibility-state field of
+ * the VMCS. An IRET instruction in VMX non-root operation will remove any
+ * virtual-NMI blocking.
+ *
+ * This unblocking occurs even if the IRET causes a fault. In this case the
+ * hypervisor needs to restore virtual-NMI blocking before resuming the guest.
+ */
+static void
+vmx_restore_nmi_blocking(struct vmx *vmx, int vcpuid)
+{
+ uint32_t gi;
+
+ VCPU_CTR0(vmx->vm, vcpuid, "Restore Virtual-NMI blocking");
+ gi = vmcs_read(VMCS_GUEST_INTERRUPTIBILITY);
+ gi |= VMCS_INTERRUPTIBILITY_NMI_BLOCKING;
+ vmcs_write(VMCS_GUEST_INTERRUPTIBILITY, gi);
+}
+
+static void
+vmx_clear_nmi_blocking(struct vmx *vmx, int vcpuid)
+{
+ uint32_t gi;
+
+ VCPU_CTR0(vmx->vm, vcpuid, "Clear Virtual-NMI blocking");
+ gi = vmcs_read(VMCS_GUEST_INTERRUPTIBILITY);
+ gi &= ~VMCS_INTERRUPTIBILITY_NMI_BLOCKING;
+ vmcs_write(VMCS_GUEST_INTERRUPTIBILITY, gi);
+}
+
static int
vmx_emulate_cr_access(struct vmx *vmx, int vcpu, uint64_t exitqual)
{
@@ -1448,6 +1479,8 @@ vmx_exit_process(struct vmx *vmx, int vc
uint64_t qual, gpa;
bool retu;
+ CTASSERT((PINBASED_CTLS_ONE_SETTING & PINBASED_VIRTUAL_NMI) != 0);
+
handled = 0;
vmxctx = &vmx->ctx[vcpu];
@@ -1480,9 +1513,20 @@ vmx_exit_process(struct vmx *vmx, int vc
vmcs_write(VMCS_ENTRY_EXCEPTION_ERROR,
idtvec_err);
}
+ /*
+ * If 'virtual NMIs' are being used and the VM-exit
+ * happened while injecting an NMI during the previous
+ * VM-entry, then clear "blocking by NMI" in the Guest
+ * Interruptibility-state.
+ */
+ if ((idtvec_info & VMCS_INTR_T_MASK) ==
+ VMCS_INTR_T_NMI) {
+ vmx_clear_nmi_blocking(vmx, vcpu);
+ }
vmcs_write(VMCS_ENTRY_INST_LENGTH, vmexit->inst_length);
}
default:
+ idtvec_info = 0;
break;
}
@@ -1556,8 +1600,8 @@ vmx_exit_process(struct vmx *vmx, int vc
* this virtual interrupt during the subsequent VM enter.
*/
intr_info = vmcs_read(VMCS_EXIT_INTR_INFO);
- KASSERT((intr_info & VMCS_INTR_INFO_VALID) != 0 &&
- VMCS_INTR_INFO_TYPE(intr_info) == 0,
+ KASSERT((intr_info & VMCS_INTR_VALID) != 0 &&
+ (intr_info & VMCS_INTR_T_MASK) == VMCS_INTR_T_HWINTR,
("VM exit interruption info invalid: %#x", intr_info));
vmx_trigger_hostintr(intr_info & 0xff);
@@ -1587,6 +1631,23 @@ vmx_exit_process(struct vmx *vmx, int vc
vmm_stat_incr(vmx->vm, vcpu, VMEXIT_CPUID, 1);
handled = vmx_handle_cpuid(vmx->vm, vcpu, vmxctx);
break;
+ case EXIT_REASON_EXCEPTION:
+ intr_info = vmcs_read(VMCS_EXIT_INTR_INFO);
+ KASSERT((intr_info & VMCS_INTR_VALID) != 0,
+ ("VM exit interruption info invalid: %#x", intr_info));
+ /*
+ * If Virtual NMIs control is 1 and the VM-exit is due to a
+ * fault encountered during the execution of IRET then we must
+ * restore the state of "virtual-NMI blocking" before resuming
+ * the guest.
+ *
+ * See "Resuming Guest Software after Handling an Exception".
+ */
+ if ((idtvec_info & VMCS_IDT_VEC_VALID) == 0 &&
+ (intr_info & 0xff) != IDT_DF &&
+ (intr_info & EXIT_QUAL_NMIUDTI) != 0)
+ vmx_restore_nmi_blocking(vmx, vcpu);
+ break;
case EXIT_REASON_EPT_FAULT:
vmm_stat_incr(vmx->vm, vcpu, VMEXIT_EPT_FAULT, 1);
/*
@@ -1605,6 +1666,17 @@ vmx_exit_process(struct vmx *vmx, int vc
vmexit->u.inst_emul.gla = vmcs_gla();
vmexit->u.inst_emul.cr3 = vmcs_guest_cr3();
}
+ /*
+ * If Virtual NMIs control is 1 and the VM-exit is due to an
+ * EPT fault during the execution of IRET then we must restore
+ * the state of "virtual-NMI blocking" before resuming.
+ *
+ * See description of "NMI unblocking due to IRET" in
+ * "Exit Qualification for EPT Violations".
+ */
+ if ((idtvec_info & VMCS_IDT_VEC_VALID) == 0 &&
+ (qual & EXIT_QUAL_NMIUDTI) != 0)
+ vmx_restore_nmi_blocking(vmx, vcpu);
break;
case EXIT_REASON_APIC_ACCESS:
handled = vmx_handle_apic_access(vmx, vcpu, vmexit);
@@ -2039,11 +2111,11 @@ vmx_inject(void *arg, int vcpu, int type
if (error)
return (error);
- if (info & VMCS_INTR_INFO_VALID)
+ if (info & VMCS_INTR_VALID)
return (EAGAIN);
info = vector | (type_map[type] << 8) | (code_valid ? 1 << 11 : 0);
- info |= VMCS_INTR_INFO_VALID;
+ info |= VMCS_INTR_VALID;
error = vmcs_setreg(vmcs, 0, VMCS_IDENT(VMCS_ENTRY_INTR_INFO), info);
if (error != 0)
return (error);
Modified: user/ae/inet6/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
==============================================================================
--- user/ae/inet6/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Mon Feb 3 08:15:09 2014 (r261432)
+++ user/ae/inet6/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Mon Feb 3 10:31:43 2014 (r261433)
@@ -21,7 +21,7 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013 by Delphix. All rights reserved.
- * Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
+ * Copyright (c) 2014 by Saso Kiselkov. All rights reserved.
* Copyright 2013 Nexenta Systems, Inc. All rights reserved.
*/
@@ -4597,6 +4597,13 @@ l2arc_write_done(zio_t *zio)
*/
for (ab = list_prev(buflist, head); ab; ab = ab_prev) {
ab_prev = list_prev(buflist, ab);
+ abl2 = ab->b_l2hdr;
+
+ /*
+ * Release the temporary compressed buffer as soon as possible.
+ */
+ if (abl2->b_compress != ZIO_COMPRESS_OFF)
+ l2arc_release_cdata_buf(ab);
hash_lock = HDR_LOCK(ab);
if (!mutex_tryenter(hash_lock)) {
@@ -4609,14 +4616,6 @@ l2arc_write_done(zio_t *zio)
continue;
}
- abl2 = ab->b_l2hdr;
-
- /*
- * Release the temporary compressed buffer as soon as possible.
- */
- if (abl2->b_compress != ZIO_COMPRESS_OFF)
- l2arc_release_cdata_buf(ab);
-
if (zio->io_error != 0) {
/*
* Error - drop L2ARC entry.
Modified: user/ae/inet6/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_traverse.c
==============================================================================
--- user/ae/inet6/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_traverse.c Mon Feb 3 08:15:09 2014 (r261432)
+++ user/ae/inet6/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_traverse.c Mon Feb 3 10:31:43 2014 (r261433)
@@ -351,9 +351,9 @@ traverse_visitbp(traverse_data_t *td, co
prefetch_dnode_metadata(td, dnp, zb->zb_objset,
DMU_META_DNODE_OBJECT);
if (arc_buf_size(buf) >= sizeof (objset_phys_t)) {
- prefetch_dnode_metadata(td, &osp->os_userused_dnode,
- zb->zb_objset, DMU_USERUSED_OBJECT);
prefetch_dnode_metadata(td, &osp->os_groupused_dnode,
+ zb->zb_objset, DMU_GROUPUSED_OBJECT);
+ prefetch_dnode_metadata(td, &osp->os_userused_dnode,
zb->zb_objset, DMU_USERUSED_OBJECT);
}
@@ -364,18 +364,18 @@ traverse_visitbp(traverse_data_t *td, co
err = 0;
}
if (err == 0 && arc_buf_size(buf) >= sizeof (objset_phys_t)) {
- dnp = &osp->os_userused_dnode;
+ dnp = &osp->os_groupused_dnode;
err = traverse_dnode(td, dnp, zb->zb_objset,
- DMU_USERUSED_OBJECT);
+ DMU_GROUPUSED_OBJECT);
}
if (err && hard) {
lasterr = err;
err = 0;
}
if (err == 0 && arc_buf_size(buf) >= sizeof (objset_phys_t)) {
- dnp = &osp->os_groupused_dnode;
+ dnp = &osp->os_userused_dnode;
err = traverse_dnode(td, dnp, zb->zb_objset,
- DMU_GROUPUSED_OBJECT);
+ DMU_USERUSED_OBJECT);
}
}
Modified: user/ae/inet6/sys/compat/freebsd32/freebsd32_misc.c
==============================================================================
--- user/ae/inet6/sys/compat/freebsd32/freebsd32_misc.c Mon Feb 3 08:15:09 2014 (r261432)
+++ user/ae/inet6/sys/compat/freebsd32/freebsd32_misc.c Mon Feb 3 10:31:43 2014 (r261433)
@@ -1644,18 +1644,28 @@ struct sf_hdtr32 {
int trl_cnt;
};
+struct sf_hdtr_kq32 {
+ int kq_fd;
+ uint32_t kq_flags;
+ uint32_t kq_udata; /* 32-bit void ptr */
+ uint32_t kq_ident; /* 32-bit uintptr_t */
+};
+
static int
freebsd32_do_sendfile(struct thread *td,
struct freebsd32_sendfile_args *uap, int compat)
{
struct sf_hdtr32 hdtr32;
struct sf_hdtr hdtr;
+ struct sf_hdtr_kq32 hdtr_kq32;
+ struct sf_hdtr_kq hdtr_kq;
struct uio *hdr_uio, *trl_uio;
struct iovec32 *iov32;
off_t offset;
int error;
off_t sbytes;
struct sendfile_sync *sfs;
+ int do_kqueue = 0;
offset = PAIR32TO64(off_t, uap->offset);
if (offset < 0)
@@ -1687,10 +1697,32 @@ freebsd32_do_sendfile(struct thread *td,
if (error)
goto out;
}
+
+ /*
+ * If SF_KQUEUE is set, then we need to also copy in
+ * the kqueue data after the normal hdtr set and set do_kqueue=1.
+ */
+ if (uap->flags & SF_KQUEUE) {
+ error = copyin(((char *) uap->hdtr) + sizeof(hdtr32),
+ &hdtr_kq32,
+ sizeof(hdtr_kq32));
+ if (error != 0)
+ goto out;
+
+ /* 32->64 bit fields */
+ CP(hdtr_kq32, hdtr_kq, kq_fd);
+ CP(hdtr_kq32, hdtr_kq, kq_flags);
+ PTRIN_CP(hdtr_kq32, hdtr_kq, kq_udata);
+ CP(hdtr_kq32, hdtr_kq, kq_ident);
+ do_kqueue = 1;
+ }
}
+
+ /* Call sendfile */
+ /* XXX stack depth! */
error = _do_sendfile(td, uap->fd, uap->s, uap->flags, compat,
- offset, uap->nbytes, &sbytes, hdr_uio, trl_uio);
+ offset, uap->nbytes, &sbytes, hdr_uio, trl_uio, &hdtr_kq);
if (uap->sbytes != NULL)
copyout(&sbytes, uap->sbytes, sizeof(off_t));
Modified: user/ae/inet6/sys/conf/files.amd64
==============================================================================
--- user/ae/inet6/sys/conf/files.amd64 Mon Feb 3 08:15:09 2014 (r261432)
+++ user/ae/inet6/sys/conf/files.amd64 Mon Feb 3 10:31:43 2014 (r261433)
@@ -448,6 +448,7 @@ dev/virtio/network/if_vtnet.c optional
dev/virtio/block/virtio_blk.c optional virtio_blk
dev/virtio/balloon/virtio_balloon.c optional virtio_balloon
dev/virtio/scsi/virtio_scsi.c optional virtio_scsi
+dev/virtio/random/virtio_random.c optional virtio_random
isa/syscons_isa.c optional sc
isa/vga_isa.c optional vga
kern/kern_clocksource.c standard
Modified: user/ae/inet6/sys/conf/files.i386
==============================================================================
--- user/ae/inet6/sys/conf/files.i386 Mon Feb 3 08:15:09 2014 (r261432)
+++ user/ae/inet6/sys/conf/files.i386 Mon Feb 3 10:31:43 2014 (r261433)
@@ -414,6 +414,7 @@ dev/virtio/network/if_vtnet.c optional
dev/virtio/block/virtio_blk.c optional virtio_blk
dev/virtio/balloon/virtio_balloon.c optional virtio_balloon
dev/virtio/scsi/virtio_scsi.c optional virtio_scsi
+dev/virtio/random/virtio_random.c optional virtio_random
i386/acpica/acpi_machdep.c optional acpi
acpi_wakecode.o optional acpi \
dependency "$S/i386/acpica/acpi_wakecode.S assym.s" \
Modified: user/ae/inet6/sys/dev/ahci/ahci.c
==============================================================================
--- user/ae/inet6/sys/dev/ahci/ahci.c Mon Feb 3 08:15:09 2014 (r261432)
+++ user/ae/inet6/sys/dev/ahci/ahci.c Mon Feb 3 10:31:43 2014 (r261433)
@@ -146,6 +146,7 @@ static struct {
{0x78021022, 0x00, "AMD Hudson-2", 0},
{0x78031022, 0x00, "AMD Hudson-2", 0},
{0x78041022, 0x00, "AMD Hudson-2", 0},
+ {0x06111b21, 0x00, "ASMedia ASM2106", 0},
{0x06121b21, 0x00, "ASMedia ASM1061", 0},
{0x26528086, 0x00, "Intel ICH6", AHCI_Q_NOFORCE},
{0x26538086, 0x00, "Intel ICH6M", AHCI_Q_NOFORCE},
Modified: user/ae/inet6/sys/dev/usb/usb_dev.c
==============================================================================
--- user/ae/inet6/sys/dev/usb/usb_dev.c Mon Feb 3 08:15:09 2014 (r261432)
+++ user/ae/inet6/sys/dev/usb/usb_dev.c Mon Feb 3 10:31:43 2014 (r261433)
@@ -207,6 +207,11 @@ usb_ref_device(struct usb_cdev_privdata
DPRINTFN(2, "no device at %u\n", cpd->dev_index);
goto error;
}
+ if (cpd->udev->state == USB_STATE_DETACHED &&
+ (need_uref != 2)) {
+ DPRINTFN(2, "device is detached\n");
+ goto error;
+ }
if (cpd->udev->refcount == USB_DEV_REF_MAX) {
DPRINTFN(2, "no dev ref\n");
goto error;
@@ -597,6 +602,13 @@ usb_fifo_free(struct usb_fifo *f)
mtx_unlock(f->priv_mtx);
mtx_lock(&usb_ref_lock);
+ /*
+ * Check if the "f->refcount" variable reached zero
+ * during the unlocked time before entering wait:
+ */
+ if (f->refcount == 0)
+ break;
+
/* wait for sync */
cv_wait(&f->cv_drain, &usb_ref_lock);
}
@@ -915,23 +927,12 @@ usb_close(void *arg)
DPRINTFN(2, "cpd=%p\n", cpd);
- err = usb_ref_device(cpd, &refs, 0);
- if (err)
+ err = usb_ref_device(cpd, &refs,
+ 2 /* uref and allow detached state */);
+ if (err) {
+ DPRINTFN(0, "Cannot grab USB reference when "
+ "closing USB file handle\n");
goto done;
-
- /*
- * If this function is not called directly from the root HUB
- * thread, there is usually a need to lock the enumeration
- * lock. Check this.
- */
- if (!usbd_enum_is_locked(cpd->udev)) {
-
- DPRINTFN(2, "Locking enumeration\n");
-
- /* reference device */
- err = usb_usb_ref_device(cpd, &refs);
- if (err)
- goto done;
}
if (cpd->fflags & FREAD) {
usb_fifo_close(refs.rxfifo, cpd->fflags);
Modified: user/ae/inet6/sys/dev/usb/usb_device.c
==============================================================================
--- user/ae/inet6/sys/dev/usb/usb_device.c Mon Feb 3 08:15:09 2014 (r261432)
+++ user/ae/inet6/sys/dev/usb/usb_device.c Mon Feb 3 10:31:43 2014 (r261433)
@@ -2070,6 +2070,8 @@ usb_free_device(struct usb_device *udev,
DPRINTFN(4, "udev=%p port=%d\n", udev, udev->port_no);
bus = udev->bus;
+
+ /* set DETACHED state to prevent any further references */
usb_set_device_state(udev, USB_STATE_DETACHED);
#if USB_HAVE_DEVCTL
@@ -2085,16 +2087,7 @@ usb_free_device(struct usb_device *udev,
usb_free_symlink(udev->ugen_symlink);
udev->ugen_symlink = NULL;
}
-#endif
- /*
- * Unregister our device first which will prevent any further
- * references:
- */
- usb_bus_port_set_device(bus, udev->parent_hub ?
- udev->parent_hub->hub->ports + udev->port_index : NULL,
- NULL, USB_ROOT_HUB_ADDR);
-#if USB_HAVE_UGEN
/* wait for all pending references to go away: */
mtx_lock(&usb_ref_lock);
udev->refcount--;
@@ -2114,6 +2107,11 @@ usb_free_device(struct usb_device *udev,
/* the following will get the device unconfigured in software */
usb_unconfigure(udev, USB_UNCFG_FLAG_FREE_EP0);
+ /* final device unregister after all character devices are closed */
+ usb_bus_port_set_device(bus, udev->parent_hub ?
+ udev->parent_hub->hub->ports + udev->port_index : NULL,
+ NULL, USB_ROOT_HUB_ADDR);
+
/* unsetup any leftover default USB transfers */
usbd_transfer_unsetup(udev->ctrl_xfer, USB_CTRL_XFER_MAX);
@@ -2647,8 +2645,14 @@ usb_set_device_state(struct usb_device *
DPRINTF("udev %p state %s -> %s\n", udev,
usb_statestr(udev->state), usb_statestr(state));
- udev->state = state;
+#if USB_HAVE_UGEN
+ mtx_lock(&usb_ref_lock);
+#endif
+ udev->state = state;
+#if USB_HAVE_UGEN
+ mtx_unlock(&usb_ref_lock);
+#endif
if (udev->bus->methods->device_state_change != NULL)
(udev->bus->methods->device_state_change) (udev);
}
Modified: user/ae/inet6/sys/i386/conf/NOTES
==============================================================================
--- user/ae/inet6/sys/i386/conf/NOTES Mon Feb 3 08:15:09 2014 (r261432)
+++ user/ae/inet6/sys/i386/conf/NOTES Mon Feb 3 10:31:43 2014 (r261433)
@@ -800,6 +800,7 @@ device vtnet # VirtIO Ethernet device
device virtio_blk # VirtIO Block device
device virtio_scsi # VirtIO SCSI device
device virtio_balloon # VirtIO Memory Balloon device
+device virtio_random # VirtIO Entropy device
device hyperv # HyperV drivers
Modified: user/ae/inet6/sys/kern/kern_event.c
==============================================================================
--- user/ae/inet6/sys/kern/kern_event.c Mon Feb 3 08:15:09 2014 (r261432)
+++ user/ae/inet6/sys/kern/kern_event.c Mon Feb 3 10:31:43 2014 (r261433)
@@ -294,6 +294,7 @@ static struct {
{ &fs_filtops }, /* EVFILT_FS */
{ &null_filtops }, /* EVFILT_LIO */
{ &user_filtops }, /* EVFILT_USER */
+ { &null_filtops }, /* EVFILT_SENDFILE */
};
/*
Modified: user/ae/inet6/sys/kern/uipc_sockbuf.c
==============================================================================
--- user/ae/inet6/sys/kern/uipc_sockbuf.c Mon Feb 3 08:15:09 2014 (r261432)
+++ user/ae/inet6/sys/kern/uipc_sockbuf.c Mon Feb 3 10:31:43 2014 (r261433)
@@ -813,7 +813,7 @@ sbflush_internal(struct sockbuf *sb)
while (sb->sb_mbcnt) {
/*
- * Don't call sbdrop(sb, 0) if the leading mbuf is non-empty:
+ * Don't call sbcut(sb, 0) if the leading mbuf is non-empty:
* we would loop forever. Panic instead.
*/
if (!sb->sb_cc && (sb->sb_mb == NULL || sb->sb_mb->m_len))
Modified: user/ae/inet6/sys/kern/uipc_syscalls.c
==============================================================================
--- user/ae/inet6/sys/kern/uipc_syscalls.c Mon Feb 3 08:15:09 2014 (r261432)
+++ user/ae/inet6/sys/kern/uipc_syscalls.c Mon Feb 3 10:31:43 2014 (r261433)
@@ -123,6 +123,10 @@ static int getpeername1(struct thread *t
counter_u64_t sfstat[sizeof(struct sfstat) / sizeof(uint64_t)];
+static int filt_sfsync_attach(struct knote *kn);
+static void filt_sfsync_detach(struct knote *kn);
+static int filt_sfsync(struct knote *kn, long hint);
+
/*
* sendfile(2)-related variables and associated sysctls
*/
@@ -132,8 +136,28 @@ static int sfreadahead = 1;
SYSCTL_INT(_kern_ipc_sendfile, OID_AUTO, readahead, CTLFLAG_RW,
&sfreadahead, 0, "Number of sendfile(2) read-ahead MAXBSIZE blocks");
+#ifdef SFSYNC_DEBUG
+static int sf_sync_debug = 0;
+SYSCTL_INT(_debug, OID_AUTO, sf_sync_debug, CTLFLAG_RW,
+ &sf_sync_debug, 0, "Output debugging during sf_sync lifecycle");
+#define SFSYNC_DPRINTF(s, ...) \
+ do { \
+ if (sf_sync_debug) \
+ printf((s), ##__VA_ARGS__); \
+ } while (0)
+#else
+#define SFSYNC_DPRINTF(c, ...)
+#endif
+
static uma_zone_t zone_sfsync;
+static struct filterops sendfile_filtops = {
+ .f_isfd = 0,
+ .f_attach = filt_sfsync_attach,
+ .f_detach = filt_sfsync_detach,
+ .f_event = filt_sfsync,
+};
+
static void
sfstat_init(const void *unused)
{
@@ -152,6 +176,7 @@ sf_sync_init(const void *unused)
NULL, NULL,
UMA_ALIGN_CACHE,
0);
+ kqueue_add_filteropts(EVFILT_SENDFILE, &sendfile_filtops);
}
SYSINIT(sf_sync, SI_SUB_MBUF, SI_ORDER_FIRST, sf_sync_init, NULL);
@@ -1860,6 +1885,118 @@ getsockaddr(namp, uaddr, len)
return (error);
}
+static int
+filt_sfsync_attach(struct knote *kn)
+{
+ struct sendfile_sync *sfs = (struct sendfile_sync *) kn->kn_sdata;
+ struct knlist *knl = &sfs->klist;
+
+ SFSYNC_DPRINTF("%s: kn=%p, sfs=%p\n", __func__, kn, sfs);
+
+ /*
+ * Validate that we actually received this via the kernel API.
+ */
+ if ((kn->kn_flags & EV_FLAG1) == 0)
+ return (EPERM);
+
+ kn->kn_ptr.p_v = sfs;
+ kn->kn_flags &= ~EV_FLAG1;
+
+ knl->kl_lock(knl->kl_lockarg);
+ /*
+ * If we're in the "freeing" state,
+ * don't allow the add. That way we don't
+ * end up racing with some other thread that
+ * is trying to finish some setup.
+ */
+ if (sfs->state == SF_STATE_FREEING) {
+ knl->kl_unlock(knl->kl_lockarg);
+ return (EINVAL);
+ }
+ knlist_add(&sfs->klist, kn, 1);
+ knl->kl_unlock(knl->kl_lockarg);
+
+ return (0);
+}
+
+/*
+ * Called when a knote is being detached.
+ */
+static void
+filt_sfsync_detach(struct knote *kn)
+{
+ struct knlist *knl;
+ struct sendfile_sync *sfs;
+ int do_free = 0;
+
+ sfs = kn->kn_ptr.p_v;
+ knl = &sfs->klist;
+
+ SFSYNC_DPRINTF("%s: kn=%p, sfs=%p\n", __func__, kn, sfs);
+
+ knl->kl_lock(knl->kl_lockarg);
+ if (!knlist_empty(knl))
+ knlist_remove(knl, kn, 1);
+
+ /*
+ * If the list is empty _AND_ the refcount is 0
+ * _AND_ we've finished the setup phase and now
+ * we're in the running phase, we can free the
+ * underlying sendfile_sync.
+ *
+ * But we shouldn't do it before finishing the
+ * underlying divorce from the knote.
+ *
+ * So, we have the sfsync lock held; transition
+ * it to "freeing", then unlock, then free
+ * normally.
+ */
+ if (knlist_empty(knl)) {
+ if (sfs->state == SF_STATE_COMPLETED && sfs->count == 0) {
+ SFSYNC_DPRINTF("%s: (%llu) sfs=%p; completed, "
+ "count==0, empty list: time to free!\n",
+ __func__,
+ (unsigned long long) curthread->td_tid,
+ sfs);
+ sf_sync_set_state(sfs, SF_STATE_FREEING, 1);
+ do_free = 1;
+ }
+ }
+ knl->kl_unlock(knl->kl_lockarg);
+
+ /*
+ * Only call free if we're the one who has transitioned things
+ * to free. Otherwise we could race with another thread that
+ * is currently tearing things down.
+ */
+ if (do_free == 1) {
+ SFSYNC_DPRINTF("%s: (%llu) sfs=%p, %s:%d\n",
+ __func__,
+ (unsigned long long) curthread->td_tid,
+ sfs,
+ __FILE__,
*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
More information about the svn-src-user
mailing list