diff options
author | mm <mm@FreeBSD.org> | 2013-03-19 11:09:15 +0000 |
---|---|---|
committer | mm <mm@FreeBSD.org> | 2013-03-19 11:09:15 +0000 |
commit | c94cc27299ba2ab2acf00ca31ec90c92a37b16f7 (patch) | |
tree | dc4e31348d425160553b7ff6655e986ab941fff5 | |
parent | 3a10a36ee8940816a53ed53f8b1ca562b85b68a9 (diff) | |
parent | 38b46fc64e9af0a68fc5ac1ff070b5b90a466812 (diff) | |
download | FreeBSD-src-c94cc27299ba2ab2acf00ca31ec90c92a37b16f7.zip FreeBSD-src-c94cc27299ba2ab2acf00ca31ec90c92a37b16f7.tar.gz |
MFC @248493
43 files changed, 738 insertions, 264 deletions
diff --git a/contrib/binutils/gas/config/tc-arm.c b/contrib/binutils/gas/config/tc-arm.c index c8f3149..b41ce60 100644 --- a/contrib/binutils/gas/config/tc-arm.c +++ b/contrib/binutils/gas/config/tc-arm.c @@ -7097,7 +7097,7 @@ do_vfp_nsyn_msr (void) return SUCCESS; } -static int +static void do_vfp_vmrs (void) { int rt; @@ -7106,21 +7106,21 @@ do_vfp_vmrs (void) if (inst.operands[0].reg > 14) { inst.error = BAD_PC; - return FAIL; + return; } /* If the destination is r13 and not in ARM mode then unprefictable */ if (thumb_mode && inst.operands[0].reg == REG_SP) { inst.error = BAD_SP; - return FAIL; + return; } /* If the destination is APSR_nzcv */ if (inst.operands[0].isvec && inst.operands[1].reg != 1) { inst.error = BAD_VMRS; - return FAIL; + return; } if (inst.operands[0].isvec) @@ -7131,32 +7131,28 @@ do_vfp_vmrs (void) /* Or in the registers to use */ inst.instruction |= rt << 12; inst.instruction |= inst.operands[1].reg << 16; - - return SUCCESS; } -static int +static void do_vfp_vmsr (void) { /* The destination register can be r0-r14 or APSR_nzcv */ if (inst.operands[1].reg > 14) { inst.error = BAD_PC; - return FAIL; + return; } /* If the destination is r13 and not in ARM mode then unprefictable */ if (thumb_mode && inst.operands[0].reg == REG_SP) { inst.error = BAD_SP; - return FAIL; + return; } /* Or in the registers to use */ inst.instruction |= inst.operands[1].reg << 12; inst.instruction |= inst.operands[0].reg << 16; - - return SUCCESS; } static void diff --git a/crypto/openssh/sshd_config b/crypto/openssh/sshd_config index 48345f5..437424d 100644 --- a/crypto/openssh/sshd_config +++ b/crypto/openssh/sshd_config @@ -50,8 +50,7 @@ #PubkeyAuthentication yes # The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2 -# but this is overridden so installations will only check .ssh/authorized_keys -AuthorizedKeysFile .ssh/authorized_keys +#AuthorizedKeysFile .ssh/authorized_keys .ssh/authorized_keys2 #AuthorizedPrincipalsFile none diff --git a/etc/mtree/BSD.usr.dist b/etc/mtree/BSD.usr.dist index 89ec940..299389f 100644 --- a/etc/mtree/BSD.usr.dist +++ b/etc/mtree/BSD.usr.dist @@ -217,6 +217,8 @@ .. atf .. + bhyve + .. bootforth .. csh diff --git a/etc/rc.d/savecore b/etc/rc.d/savecore index 3e61adc..a39d5ba 100755 --- a/etc/rc.d/savecore +++ b/etc/rc.d/savecore @@ -23,6 +23,9 @@ savecore_prestart() return 1 ;; [Aa][Uu][Tt][Oo]) + if [ ! -L /dev/dumpdev ]; then + return 1 + fi dumpdev=`/bin/realpath /dev/dumpdev` ;; esac diff --git a/lib/libc/sys/mlock.2 b/lib/libc/sys/mlock.2 index 0e5fef8..42acc97 100644 --- a/lib/libc/sys/mlock.2 +++ b/lib/libc/sys/mlock.2 @@ -28,7 +28,7 @@ .\" @(#)mlock.2 8.2 (Berkeley) 12/11/93 .\" $FreeBSD$ .\" -.Dd December 25, 2012 +.Dd March 18, 2013 .Dt MLOCK 2 .Os .Sh NAME @@ -138,7 +138,12 @@ is set to 0 and the caller is not the super-user. .It Bq Er EINVAL The address given is not page aligned or the length is negative. .It Bq Er ENOMEM -Some portion of the indicated address range is not allocated. +Some or all of the address range specified by the addr and len +arguments does not correspond to valid mapped pages in the address space +of the process. +.It Bq Er ENOMEM +Locking the pages mapped by the specified range would exceed a limit on +the amount of memory that the process may lock. .El .Sh "SEE ALSO" .Xr fork 2 , diff --git a/lib/libvmmapi/vmmapi.c b/lib/libvmmapi/vmmapi.c index 6a368b3..6982ba3 100644 --- a/lib/libvmmapi/vmmapi.c +++ b/lib/libvmmapi/vmmapi.c @@ -48,8 +48,16 @@ __FBSDID("$FreeBSD$"); #include "vmmapi.h" +#define GB (1024 * 1024 * 1024UL) + struct vmctx { int fd; + uint32_t lowmem_limit; + enum vm_mmap_style vms; + size_t lowmem; + char *lowmem_addr; + size_t highmem; + char *highmem_addr; char *name; }; @@ -90,6 +98,7 @@ vm_open(const char *name) assert(vm != NULL); vm->fd = -1; + vm->lowmem_limit = 3 * GB; vm->name = (char *)(vm + 1); strcpy(vm->name, name); @@ -151,8 +160,22 @@ vm_get_memory_seg(struct vmctx *ctx, vm_paddr_t gpa, size_t *ret_len) return (error); } -int -vm_setup_memory(struct vmctx *ctx, vm_paddr_t gpa, size_t len, char **mapaddr) +uint32_t +vm_get_lowmem_limit(struct vmctx *ctx) +{ + + return (ctx->lowmem_limit); +} + +void +vm_set_lowmem_limit(struct vmctx *ctx, uint32_t limit) +{ + + ctx->lowmem_limit = limit; +} + +static int +setup_memory_segment(struct vmctx *ctx, vm_paddr_t gpa, size_t len, char **addr) { int error; struct vm_memory_segment seg; @@ -165,20 +188,69 @@ vm_setup_memory(struct vmctx *ctx, vm_paddr_t gpa, size_t len, char **mapaddr) seg.gpa = gpa; seg.len = len; error = ioctl(ctx->fd, VM_MAP_MEMORY, &seg); - if (error == 0 && mapaddr != NULL) { - *mapaddr = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_SHARED, + if (error == 0 && addr != NULL) { + *addr = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_SHARED, ctx->fd, gpa); } return (error); } -char * -vm_map_memory(struct vmctx *ctx, vm_paddr_t gpa, size_t len) +int +vm_setup_memory(struct vmctx *ctx, size_t memsize, enum vm_mmap_style vms) +{ + char **addr; + int error; + + /* XXX VM_MMAP_SPARSE not implemented yet */ + assert(vms == VM_MMAP_NONE || vms == VM_MMAP_ALL); + ctx->vms = vms; + + /* + * If 'memsize' cannot fit entirely in the 'lowmem' segment then + * create another 'highmem' segment above 4GB for the remainder. + */ + if (memsize > ctx->lowmem_limit) { + ctx->lowmem = ctx->lowmem_limit; + ctx->highmem = memsize - ctx->lowmem; + } else { + ctx->lowmem = memsize; + ctx->highmem = 0; + } + + if (ctx->lowmem > 0) { + addr = (vms == VM_MMAP_ALL) ? &ctx->lowmem_addr : NULL; + error = setup_memory_segment(ctx, 0, ctx->lowmem, addr); + if (error) + return (error); + } + + if (ctx->highmem > 0) { + addr = (vms == VM_MMAP_ALL) ? &ctx->highmem_addr : NULL; + error = setup_memory_segment(ctx, 4*GB, ctx->highmem, addr); + if (error) + return (error); + } + + return (0); +} + +void * +vm_map_gpa(struct vmctx *ctx, vm_paddr_t gaddr, size_t len) { - /* Map 'len' bytes of memory at guest physical address 'gpa' */ - return ((char *)mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_SHARED, - ctx->fd, gpa)); + /* XXX VM_MMAP_SPARSE not implemented yet */ + assert(ctx->vms == VM_MMAP_ALL); + + if (gaddr < ctx->lowmem && gaddr + len <= ctx->lowmem) + return ((void *)(ctx->lowmem_addr + gaddr)); + + if (gaddr >= 4*GB) { + gaddr -= 4*GB; + if (gaddr < ctx->highmem && gaddr + len <= ctx->highmem) + return ((void *)(ctx->highmem_addr + gaddr)); + } + + return (NULL); } int diff --git a/lib/libvmmapi/vmmapi.h b/lib/libvmmapi/vmmapi.h index e8cc8ba..f066c50 100644 --- a/lib/libvmmapi/vmmapi.h +++ b/lib/libvmmapi/vmmapi.h @@ -32,24 +32,26 @@ struct vmctx; enum x2apic_state; +/* + * Different styles of mapping the memory assigned to a VM into the address + * space of the controlling process. + */ +enum vm_mmap_style { + VM_MMAP_NONE, /* no mapping */ + VM_MMAP_ALL, /* fully and statically mapped */ + VM_MMAP_SPARSE, /* mappings created on-demand */ +}; + int vm_create(const char *name); struct vmctx *vm_open(const char *name); void vm_destroy(struct vmctx *ctx); size_t vmm_get_mem_total(void); size_t vmm_get_mem_free(void); int vm_get_memory_seg(struct vmctx *ctx, vm_paddr_t gpa, size_t *ret_len); -/* - * Create a memory segment of 'len' bytes in the guest physical address space - * at offset 'gpa'. - * - * If 'mapaddr' is not NULL then this region is mmap'ed into the address - * space of the calling process. If there is an mmap error then *mapaddr - * will be set to MAP_FAILED. - */ - -int vm_setup_memory(struct vmctx *ctx, vm_paddr_t gpa, size_t len, - char **mapaddr); -char * vm_map_memory(struct vmctx *ctx, vm_paddr_t gpa, size_t len); +int vm_setup_memory(struct vmctx *ctx, size_t len, enum vm_mmap_style s); +void *vm_map_gpa(struct vmctx *ctx, vm_paddr_t gaddr, size_t len); +uint32_t vm_get_lowmem_limit(struct vmctx *ctx); +void vm_set_lowmem_limit(struct vmctx *ctx, uint32_t limit); int vm_set_desc(struct vmctx *ctx, int vcpu, int reg, uint64_t base, uint32_t limit, uint32_t access); int vm_get_desc(struct vmctx *ctx, int vcpu, int reg, diff --git a/sbin/geom/class/eli/geom_eli.c b/sbin/geom/class/eli/geom_eli.c index 1ed72b11..3eee6f2 100644 --- a/sbin/geom/class/eli/geom_eli.c +++ b/sbin/geom/class/eli/geom_eli.c @@ -259,6 +259,8 @@ struct g_command class_commands[] = { static int verbose = 0; +#define BUFSIZE 1024 + static int eli_protect(struct gctl_req *req) { @@ -344,7 +346,7 @@ static int eli_genkey_files(struct gctl_req *req, bool new, const char *type, struct hmac_ctx *ctxp, char *passbuf, size_t passbufsize) { - char *p, buf[MAXPHYS], argname[16]; + char *p, buf[BUFSIZE], argname[16]; const char *file; int error, fd, i; ssize_t done; @@ -431,7 +433,7 @@ eli_genkey_passphrase_prompt(struct gctl_req *req, bool new, char *passbuf, } if (new) { - char tmpbuf[BUFSIZ]; + char tmpbuf[BUFSIZE]; p = readpassphrase("Reenter new passphrase: ", tmpbuf, sizeof(tmpbuf), @@ -460,7 +462,7 @@ static int eli_genkey_passphrase(struct gctl_req *req, struct g_eli_metadata *md, bool new, struct hmac_ctx *ctxp) { - char passbuf[MAXPHYS]; + char passbuf[BUFSIZE]; bool nopassphrase; int nfiles; diff --git a/share/examples/Makefile b/share/examples/Makefile index a3be98c..90bef45 100644 --- a/share/examples/Makefile +++ b/share/examples/Makefile @@ -7,6 +7,7 @@ LDIRS= BSD_daemon \ FreeBSD_version \ IPv6 \ + bhyve \ bootforth \ csh \ cvsup \ @@ -42,6 +43,7 @@ XFILES= BSD_daemon/FreeBSD.pfa \ FreeBSD_version/Makefile \ FreeBSD_version/README \ IPv6/USAGE \ + bhyve/vmrun.sh \ bootforth/README \ bootforth/boot.4th \ bootforth/frames.4th \ diff --git a/share/examples/bhyve/vmrun.sh b/share/examples/bhyve/vmrun.sh new file mode 100755 index 0000000..870c4dd --- /dev/null +++ b/share/examples/bhyve/vmrun.sh @@ -0,0 +1,179 @@ +#!/bin/sh +# +# Copyright (c) 2013 NetApp, Inc. +# 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$ +# + +LOADER=/usr/sbin/bhyveload +BHYVECTL=/usr/sbin/bhyvectl +FBSDRUN=/usr/sbin/bhyve + +DEFAULT_MEMSIZE=512 +DEFAULT_CPUS=2 +DEFAULT_TAPDEV=tap0 + +DEFAULT_VIRTIO_DISK="./diskdev" +DEFAULT_ISOFILE="./release.iso" + +usage() { + echo "Usage: vmrun.sh [-hai][-m <memsize>][-d <disk file>][-I <location of installation iso>][-t <tapdev>] <vmname>" + echo " -h: display this help message" + echo " -a: force memory mapped local apic access" + echo " -c: number of virtual cpus (default is ${DEFAULT_CPUS})" + echo " -d: virtio diskdev file (default is ${DEFAULT_VIRTIO_DISK})" + echo " -i: force boot of the Installation CDROM image" + echo " -I: Installation CDROM image location (default is ${DEFAULT_ISOFILE})" + echo " -m: memory size in MB (default is ${DEFAULT_MEMSIZE}MB)" + echo " -t: tap device for virtio-net (default is $DEFAULT_TAPDEV)" + echo "" + echo " This script needs to be executed with superuser privileges" + echo "" + exit 1 +} + +if [ `id -u` -ne 0 ]; then + usage +fi + +kldstat -n vmm > /dev/null 2>&1 +if [ $? -ne 0 ]; then + echo "vmm.ko is not loaded!" + exit 1 +fi + +force_install=0 +isofile=${DEFAULT_ISOFILE} +memsize=${DEFAULT_MEMSIZE} +cpus=${DEFAULT_CPUS} +virtio_diskdev=${DEFAULT_VIRTIO_DISK} +tapdev=${DEFAULT_TAPDEV} +apic_opt="" + +while getopts haic:I:m:d:t: c ; do + case $c in + h) + usage + ;; + a) + apic_opt="-a" + ;; + d) + virtio_diskdev=${OPTARG} + ;; + i) + force_install=1 + ;; + I) + isofile=${OPTARG} + ;; + c) + cpus=${OPTARG} + ;; + m) + memsize=${OPTARG} + ;; + t) + tapdev=${OPTARG} + ;; + \?) + usage + ;; + esac +done + +shift $((${OPTIND} - 1)) + +if [ $# -ne 1 ]; then + usage +fi + +vmname="$1" + +# Create the virtio diskdev file if needed +if [ ! -f ${virtio_diskdev} ]; then + echo "virtio disk device file \"${virtio_diskdev}\" does not exist." + echo "Creating it ..." + truncate -s 8G ${virtio_diskdev} > /dev/null +fi + +if [ ! -r ${virtio_diskdev} ]; then + echo "virtio disk device file \"${virtio_diskdev}\" is not readable" + exit 1 +fi + +if [ ! -w ${virtio_diskdev} ]; then + echo "virtio disk device file \"${virtio_diskdev}\" is not writable" + exit 1 +fi + +echo "Launching virtual machine \"$vmname\" ..." + +while [ 1 ]; do + ${BHYVECTL} --vm=${vmname} --destroy > /dev/null 2>&1 + + file ${virtio_diskdev} | grep ": x86 boot sector" > /dev/null + rc=$? + if [ $rc -ne 0 ]; then + file ${virtio_diskdev} | grep ": Unix Fast File sys" > /dev/null + rc=$? + fi + if [ $rc -ne 0 ]; then + need_install=1 + else + need_install=0 + fi + + if [ $force_install -eq 1 -o $need_install -eq 1 ]; then + if [ ! -r ${isofile} ]; then + echo -n "Installation CDROM image \"${isofile}\" " + echo "is not readable" + exit 1 + fi + BOOTDISK=${isofile} + installer_opt="-s 3:0,virtio-blk,${BOOTDISK}" + else + BOOTDISK=${virtio_diskdev} + installer_opt="" + fi + + ${LOADER} -m ${memsize} -d ${BOOTDISK} ${vmname} + if [ $? -ne 0 ]; then + break + fi + + ${FBSDRUN} -c ${cpus} -m ${memsize} ${apic_opt} -AI -H -P -g 0 \ + -s 0:0,hostbridge \ + -s 1:0,virtio-net,${tapdev} \ + -s 2:0,virtio-blk,${virtio_diskdev} \ + ${installer_opt} \ + -S 31,uart,stdio \ + ${vmname} + if [ $? -ne 0 ]; then + break + fi +done + +exit 99 diff --git a/share/man/man4/psm.4 b/share/man/man4/psm.4 index ffcd1d5..99835fb 100644 --- a/share/man/man4/psm.4 +++ b/share/man/man4/psm.4 @@ -26,7 +26,7 @@ .\" .\" $FreeBSD$ .\" -.Dd March 27, 2012 +.Dd March 18, 2013 .Dt PSM 4 .Os .Sh NAME @@ -339,6 +339,12 @@ at boot-time. This will enable .Nm to handle packets from guest devices (sticks) and extra buttons. +Similarly, extended support for IBM/Lenovo TrackPoint can be enabled +by setting +.Va hw.psm.trackpoint_support +to +.Em 1 +at boot-time. .Pp Tap and drag gestures can be disabled by setting .Va hw.psm.tap_enabled @@ -832,8 +838,8 @@ In contrast, some pad products, e.g.\& some versions of ALPS GlidePoint and Interlink VersaPad, treat the tapping action as fourth button events. .Pp -It is reported that ALPS GlidePoint, Synaptics Touchpad, and -Interlink VersaPad require +It is reported that ALPS GlidePoint, Synaptics Touchpad, IBM/Lenovo +TrackPoint, and Interlink VersaPad require .Em INITAFTERSUSPEND flag in order to recover from suspended state. This flag is automatically set when one of these devices is detected by the diff --git a/sys/arm/include/bus.h b/sys/arm/include/bus.h index ce8f5ad..0749838 100644 --- a/sys/arm/include/bus.h +++ b/sys/arm/include/bus.h @@ -731,6 +731,6 @@ bs_c_8_proto(f); * designed. It also serves to mark the locations needing that fix. */ #define BUS_SPACE_PHYSADDR(res, offs) \ - (vtophys(rman_get_start(res)+(offs))) + ((u_int)(rman_get_start(res)+(offs))) #endif /* _MACHINE_BUS_H_ */ diff --git a/sys/cddl/compat/opensolaris/sys/sig.h b/sys/cddl/compat/opensolaris/sys/sig.h index 5053797..985896e 100644 --- a/sys/cddl/compat/opensolaris/sys/sig.h +++ b/sys/cddl/compat/opensolaris/sys/sig.h @@ -55,7 +55,7 @@ issig(int why) p = td->td_proc; PROC_LOCK(p); mtx_lock(&p->p_sigacts->ps_mtx); - sig = cursig(td, SIG_STOP_ALLOWED); + sig = cursig(td); mtx_unlock(&p->p_sigacts->ps_mtx); PROC_UNLOCK(p); if (sig != 0) diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c index b866202..71c749c 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c @@ -919,7 +919,8 @@ dsl_check_snap_cb(const char *name, void *arg) char *dsname; dsname = kmem_asprintf("%s@%s", name, da->snapname); - VERIFY(nvlist_add_boolean(da->nvl, dsname) == 0); + fnvlist_add_boolean(da->nvl, dsname); + kmem_free(dsname, strlen(dsname) + 1); return (0); } diff --git a/sys/dev/atkbdc/psm.c b/sys/dev/atkbdc/psm.c index 7cf6508..95d3f63 100644 --- a/sys/dev/atkbdc/psm.c +++ b/sys/dev/atkbdc/psm.c @@ -260,6 +260,38 @@ typedef struct synapticsaction { int in_vscroll; } synapticsaction_t; +enum { + TRACKPOINT_SYSCTL_SENSITIVITY, + TRACKPOINT_SYSCTL_NEGATIVE_INERTIA, + TRACKPOINT_SYSCTL_UPPER_PLATEAU, + TRACKPOINT_SYSCTL_BACKUP_RANGE, + TRACKPOINT_SYSCTL_DRAG_HYSTERESIS, + TRACKPOINT_SYSCTL_MINIMUM_DRAG, + TRACKPOINT_SYSCTL_UP_THRESHOLD, + TRACKPOINT_SYSCTL_THRESHOLD, + TRACKPOINT_SYSCTL_JENKS_CURVATURE, + TRACKPOINT_SYSCTL_Z_TIME, + TRACKPOINT_SYSCTL_PRESS_TO_SELECT, + TRACKPOINT_SYSCTL_SKIP_BACKUPS +}; + +typedef struct trackpointinfo { + struct sysctl_ctx_list sysctl_ctx; + struct sysctl_oid *sysctl_tree; + int sensitivity; + int inertia; + int uplateau; + int reach; + int draghys; + int mindrag; + int upthresh; + int threshold; + int jenks; + int ztime; + int pts; + int skipback; +} trackpointinfo_t; + /* driver control block */ struct psm_softc { /* Driver status information */ int unit; @@ -274,6 +306,8 @@ struct psm_softc { /* Driver status information */ synapticshw_t synhw; /* Synaptics hardware information */ synapticsinfo_t syninfo; /* Synaptics configuration */ synapticsaction_t synaction; /* Synaptics action context */ + int tphw; /* TrackPoint hardware information */ + trackpointinfo_t tpinfo; /* TrackPoint configuration */ mousemode_t mode; /* operation mode */ mousemode_t dflt_mode; /* default operation mode */ mousestatus_t status; /* accumulated mouse movement */ @@ -344,6 +378,9 @@ TUNABLE_INT("hw.psm.tap_enabled", &tap_enabled); static int synaptics_support = 0; TUNABLE_INT("hw.psm.synaptics_support", &synaptics_support); +static int trackpoint_support = 0; +TUNABLE_INT("hw.psm.trackpoint_support", &trackpoint_support); + static int verbose = PSM_DEBUG; TUNABLE_INT("debug.psm.loglevel", &verbose); @@ -432,6 +469,7 @@ static probefunc_t enable_4dmouse; static probefunc_t enable_4dplus; static probefunc_t enable_mmanplus; static probefunc_t enable_synaptics; +static probefunc_t enable_trackpoint; static probefunc_t enable_versapad; static struct { @@ -466,6 +504,8 @@ static struct { 0x80, MOUSE_PS2_PACKETSIZE, enable_kmouse }, { MOUSE_MODEL_VERSAPAD, /* Interlink electronics VersaPad */ 0xe8, MOUSE_PS2VERSA_PACKETSIZE, enable_versapad }, + { MOUSE_MODEL_TRACKPOINT, /* IBM/Lenovo TrackPoint */ + 0xc0, MOUSE_PS2_PACKETSIZE, enable_trackpoint }, { MOUSE_MODEL_GENERIC, 0xc0, MOUSE_PS2_PACKETSIZE, NULL }, }; @@ -707,6 +747,7 @@ model_name(int model) { MOUSE_MODEL_4D, "4D Mouse" }, { MOUSE_MODEL_4DPLUS, "4D+ Mouse" }, { MOUSE_MODEL_SYNAPTICS, "Synaptics Touchpad" }, + { MOUSE_MODEL_TRACKPOINT, "IBM/Lenovo TrackPoint" }, { MOUSE_MODEL_GENERIC, "Generic PS/2 mouse" }, { MOUSE_MODEL_UNKNOWN, "Unknown" }, }; @@ -1452,7 +1493,7 @@ psmattach(device_t dev) sc->config |= PSM_CONFIG_INITAFTERSUSPEND; break; default: - if (sc->synhw.infoMajor >= 4) + if (sc->synhw.infoMajor >= 4 || sc->tphw > 0) sc->config |= PSM_CONFIG_INITAFTERSUSPEND; break; } @@ -3442,6 +3483,7 @@ psmsoftintr(void *arg) goto next; break; + case MOUSE_MODEL_TRACKPOINT: case MOUSE_MODEL_GENERIC: default: break; @@ -4474,6 +4516,233 @@ enable_synaptics(KBDC kbdc, struct psm_softc *sc) return (TRUE); } +/* IBM/Lenovo TrackPoint */ +static int +trackpoint_command(KBDC kbdc, int cmd, int loc, int val) +{ + const int seq[] = { 0xe2, cmd, loc, val }; + int i; + + for (i = 0; i < nitems(seq); i++) + if (send_aux_command(kbdc, seq[i]) != PSM_ACK) + return (EIO); + return (0); +} + +#define PSM_TPINFO(x) offsetof(struct psm_softc, tpinfo.x) +#define TPMASK 0 +#define TPLOC 1 +#define TPINFO 2 + +static int +trackpoint_sysctl(SYSCTL_HANDLER_ARGS) +{ + static const int data[][3] = { + { 0x00, 0x4a, PSM_TPINFO(sensitivity) }, + { 0x00, 0x4d, PSM_TPINFO(inertia) }, + { 0x00, 0x60, PSM_TPINFO(uplateau) }, + { 0x00, 0x57, PSM_TPINFO(reach) }, + { 0x00, 0x58, PSM_TPINFO(draghys) }, + { 0x00, 0x59, PSM_TPINFO(mindrag) }, + { 0x00, 0x5a, PSM_TPINFO(upthresh) }, + { 0x00, 0x5c, PSM_TPINFO(threshold) }, + { 0x00, 0x5d, PSM_TPINFO(jenks) }, + { 0x00, 0x5e, PSM_TPINFO(ztime) }, + { 0x01, 0x2c, PSM_TPINFO(pts) }, + { 0x08, 0x2d, PSM_TPINFO(skipback) } + }; + struct psm_softc *sc; + int error, newval, *oldvalp; + const int *tp; + + if (arg1 == NULL || arg2 < 0 || arg2 >= nitems(data)) + return (EINVAL); + sc = arg1; + tp = data[arg2]; + oldvalp = (int *)((intptr_t)sc + tp[TPINFO]); + newval = *oldvalp; + error = sysctl_handle_int(oidp, &newval, 0, req); + if (error != 0) + return (error); + if (newval == *oldvalp) + return (0); + if (newval < 0 || newval > (tp[TPMASK] == 0 ? 255 : 1)) + return (EINVAL); + error = trackpoint_command(sc->kbdc, tp[TPMASK] == 0 ? 0x81 : 0x47, + tp[TPLOC], tp[TPMASK] == 0 ? newval : tp[TPMASK]); + if (error != 0) + return (error); + *oldvalp = newval; + + return (0); +} + +static void +trackpoint_sysctl_create_tree(struct psm_softc *sc) +{ + + if (sc->tpinfo.sysctl_tree != NULL) + return; + + /* Attach extra trackpoint sysctl nodes under hw.psm.trackpoint */ + sysctl_ctx_init(&sc->tpinfo.sysctl_ctx); + sc->tpinfo.sysctl_tree = SYSCTL_ADD_NODE(&sc->tpinfo.sysctl_ctx, + SYSCTL_STATIC_CHILDREN(_hw_psm), OID_AUTO, "trackpoint", CTLFLAG_RD, + 0, "IBM/Lenovo TrackPoint"); + + /* hw.psm.trackpoint.sensitivity */ + sc->tpinfo.sensitivity = 0x64; + SYSCTL_ADD_PROC(&sc->tpinfo.sysctl_ctx, + SYSCTL_CHILDREN(sc->tpinfo.sysctl_tree), OID_AUTO, + "sensitivity", CTLTYPE_INT|CTLFLAG_RW|CTLFLAG_ANYBODY, + sc, TRACKPOINT_SYSCTL_SENSITIVITY, + trackpoint_sysctl, "I", + "Sensitivity"); + + /* hw.psm.trackpoint.negative_inertia */ + sc->tpinfo.inertia = 0x06; + SYSCTL_ADD_PROC(&sc->tpinfo.sysctl_ctx, + SYSCTL_CHILDREN(sc->tpinfo.sysctl_tree), OID_AUTO, + "negative_inertia", CTLTYPE_INT|CTLFLAG_RW|CTLFLAG_ANYBODY, + sc, TRACKPOINT_SYSCTL_NEGATIVE_INERTIA, + trackpoint_sysctl, "I", + "Negative inertia factor"); + + /* hw.psm.trackpoint.upper_plateau */ + sc->tpinfo.uplateau = 0x61; + SYSCTL_ADD_PROC(&sc->tpinfo.sysctl_ctx, + SYSCTL_CHILDREN(sc->tpinfo.sysctl_tree), OID_AUTO, + "upper_plateau", CTLTYPE_INT|CTLFLAG_RW|CTLFLAG_ANYBODY, + sc, TRACKPOINT_SYSCTL_UPPER_PLATEAU, + trackpoint_sysctl, "I", + "Transfer function upper plateau speed"); + + /* hw.psm.trackpoint.backup_range */ + sc->tpinfo.reach = 0x0a; + SYSCTL_ADD_PROC(&sc->tpinfo.sysctl_ctx, + SYSCTL_CHILDREN(sc->tpinfo.sysctl_tree), OID_AUTO, + "backup_range", CTLTYPE_INT|CTLFLAG_RW|CTLFLAG_ANYBODY, + sc, TRACKPOINT_SYSCTL_BACKUP_RANGE, + trackpoint_sysctl, "I", + "Backup range"); + + /* hw.psm.trackpoint.drag_hysteresis */ + sc->tpinfo.draghys = 0xff; + SYSCTL_ADD_PROC(&sc->tpinfo.sysctl_ctx, + SYSCTL_CHILDREN(sc->tpinfo.sysctl_tree), OID_AUTO, + "drag_hysteresis", CTLTYPE_INT|CTLFLAG_RW|CTLFLAG_ANYBODY, + sc, TRACKPOINT_SYSCTL_DRAG_HYSTERESIS, + trackpoint_sysctl, "I", + "Drag hysteresis"); + + /* hw.psm.trackpoint.minimum_drag */ + sc->tpinfo.mindrag = 0x14; + SYSCTL_ADD_PROC(&sc->tpinfo.sysctl_ctx, + SYSCTL_CHILDREN(sc->tpinfo.sysctl_tree), OID_AUTO, + "minimum_drag", CTLTYPE_INT|CTLFLAG_RW|CTLFLAG_ANYBODY, + sc, TRACKPOINT_SYSCTL_MINIMUM_DRAG, + trackpoint_sysctl, "I", + "Minimum drag"); + + /* hw.psm.trackpoint.up_threshold */ + sc->tpinfo.upthresh = 0xff; + SYSCTL_ADD_PROC(&sc->tpinfo.sysctl_ctx, + SYSCTL_CHILDREN(sc->tpinfo.sysctl_tree), OID_AUTO, + "up_threshold", CTLTYPE_INT|CTLFLAG_RW|CTLFLAG_ANYBODY, + sc, TRACKPOINT_SYSCTL_UP_THRESHOLD, + trackpoint_sysctl, "I", + "Up threshold for release"); + + /* hw.psm.trackpoint.threshold */ + sc->tpinfo.threshold = 0x08; + SYSCTL_ADD_PROC(&sc->tpinfo.sysctl_ctx, + SYSCTL_CHILDREN(sc->tpinfo.sysctl_tree), OID_AUTO, + "threshold", CTLTYPE_INT|CTLFLAG_RW|CTLFLAG_ANYBODY, + sc, TRACKPOINT_SYSCTL_THRESHOLD, + trackpoint_sysctl, "I", + "Threshold"); + + /* hw.psm.trackpoint.jenks_curvature */ + sc->tpinfo.jenks = 0x87; + SYSCTL_ADD_PROC(&sc->tpinfo.sysctl_ctx, + SYSCTL_CHILDREN(sc->tpinfo.sysctl_tree), OID_AUTO, + "jenks_curvature", CTLTYPE_INT|CTLFLAG_RW|CTLFLAG_ANYBODY, + sc, TRACKPOINT_SYSCTL_JENKS_CURVATURE, + trackpoint_sysctl, "I", + "Jenks curvature"); + + /* hw.psm.trackpoint.z_time */ + sc->tpinfo.ztime = 0x26; + SYSCTL_ADD_PROC(&sc->tpinfo.sysctl_ctx, + SYSCTL_CHILDREN(sc->tpinfo.sysctl_tree), OID_AUTO, + "z_time", CTLTYPE_INT|CTLFLAG_RW|CTLFLAG_ANYBODY, + sc, TRACKPOINT_SYSCTL_Z_TIME, + trackpoint_sysctl, "I", + "Z time constant"); + + /* hw.psm.trackpoint.press_to_select */ + sc->tpinfo.pts = 0x00; + SYSCTL_ADD_PROC(&sc->tpinfo.sysctl_ctx, + SYSCTL_CHILDREN(sc->tpinfo.sysctl_tree), OID_AUTO, + "press_to_select", CTLTYPE_INT|CTLFLAG_RW|CTLFLAG_ANYBODY, + sc, TRACKPOINT_SYSCTL_PRESS_TO_SELECT, + trackpoint_sysctl, "I", + "Press to Select"); + + /* hw.psm.trackpoint.skip_backups */ + sc->tpinfo.skipback = 0x00; + SYSCTL_ADD_PROC(&sc->tpinfo.sysctl_ctx, + SYSCTL_CHILDREN(sc->tpinfo.sysctl_tree), OID_AUTO, + "skip_backups", CTLTYPE_INT|CTLFLAG_RW|CTLFLAG_ANYBODY, + sc, TRACKPOINT_SYSCTL_SKIP_BACKUPS, + trackpoint_sysctl, "I", + "Skip backups from drags"); +} + +static int +enable_trackpoint(KBDC kbdc, struct psm_softc *sc) +{ + int id; + + kbdc = sc->kbdc; + + if (send_aux_command(kbdc, 0xe1) != PSM_ACK || + read_aux_data(kbdc) != 0x01) + return (FALSE); + id = read_aux_data(kbdc); + if (id < 0x01) + return (FALSE); + if (sc != NULL) + sc->tphw = id; + if (!trackpoint_support) + return (FALSE); + + if (sc != NULL) { + /* Create sysctl tree. */ + trackpoint_sysctl_create_tree(sc); + + trackpoint_command(kbdc, 0x81, 0x4a, sc->tpinfo.sensitivity); + trackpoint_command(kbdc, 0x81, 0x4d, sc->tpinfo.inertia); + trackpoint_command(kbdc, 0x81, 0x60, sc->tpinfo.uplateau); + trackpoint_command(kbdc, 0x81, 0x57, sc->tpinfo.reach); + trackpoint_command(kbdc, 0x81, 0x58, sc->tpinfo.draghys); + trackpoint_command(kbdc, 0x81, 0x59, sc->tpinfo.mindrag); + trackpoint_command(kbdc, 0x81, 0x5a, sc->tpinfo.upthresh); + trackpoint_command(kbdc, 0x81, 0x5c, sc->tpinfo.threshold); + trackpoint_command(kbdc, 0x81, 0x5d, sc->tpinfo.jenks); + trackpoint_command(kbdc, 0x81, 0x5e, sc->tpinfo.ztime); + if (sc->tpinfo.pts == 0x01) + trackpoint_command(kbdc, 0x47, 0x2c, 0x01); + if (sc->tpinfo.skipback == 0x01) + trackpoint_command(kbdc, 0x47, 0x2d, 0x08); + + sc->hw.hwid = id; + sc->hw.buttons = 3; + } + + return (TRUE); +} + /* Interlink electronics VersaPad */ static int enable_versapad(KBDC kbdc, struct psm_softc *sc) diff --git a/sys/dev/fdt/fdt_common.c b/sys/dev/fdt/fdt_common.c index e1913c1..e953051 100644 --- a/sys/dev/fdt/fdt_common.c +++ b/sys/dev/fdt/fdt_common.c @@ -421,12 +421,12 @@ fdt_regsize(phandle_t node, u_long *base, u_long *size) int fdt_reg_to_rl(phandle_t node, struct resource_list *rl) { - u_long start, end, count; + u_long count; pcell_t *reg, *regptr; pcell_t addr_cells, size_cells; int tuple_size, tuples; int i, rv; - bus_space_handle_t vaddr; + bus_space_handle_t start, end; long busaddr, bussize; if (fdt_addrsize_cells(OF_parent(node), &addr_cells, &size_cells) != 0) @@ -457,14 +457,12 @@ fdt_reg_to_rl(phandle_t node, struct resource_list *rl) /* Calculate address range relative to base. */ start += busaddr; - if (bus_space_map(fdtbus_bs_tag, start, count, 0, &vaddr) != 0) - panic("Couldn't map the device memory"); - end = vaddr + count - 1; + end = start + count - 1; - debugf("reg addr start = %lx, end = %lx, count = %lx\n", vaddr, + debugf("reg addr start = %lx, end = %lx, count = %lx\n", start, end, count); - resource_list_add(rl, SYS_RES_MEMORY, i, vaddr, end, + resource_list_add(rl, SYS_RES_MEMORY, i, start, end, count); } rv = 0; diff --git a/sys/dev/fdt/fdtbus.c b/sys/dev/fdt/fdtbus.c index 770c4c8..38f8a9a 100644 --- a/sys/dev/fdt/fdtbus.c +++ b/sys/dev/fdt/fdtbus.c @@ -617,6 +617,16 @@ static int fdtbus_activate_resource(device_t bus, device_t child, int type, int rid, struct resource *res) { + bus_space_handle_t p; + int error; + + if (type == SYS_RES_MEMORY || type == SYS_RES_IOPORT) { + error = bus_space_map(rman_get_bustag(res), + rman_get_bushandle(res), rman_get_size(res), 0, &p); + if (error) + return (error); + rman_set_bushandle(res, p); + } return (rman_activate_resource(res)); } diff --git a/sys/dev/fdt/simplebus.c b/sys/dev/fdt/simplebus.c index db9ade0..b4e7bfb 100644 --- a/sys/dev/fdt/simplebus.c +++ b/sys/dev/fdt/simplebus.c @@ -129,17 +129,19 @@ static driver_t simplebus_driver = { devclass_t simplebus_devclass; DRIVER_MODULE(simplebus, fdtbus, simplebus_driver, simplebus_devclass, 0, 0); +DRIVER_MODULE(simplebus, simplebus, simplebus_driver, simplebus_devclass, 0, + 0); static int simplebus_probe(device_t dev) { - if (!ofw_bus_is_compatible_strict(dev, "simple-bus")) + if (!ofw_bus_is_compatible(dev, "simple-bus")) return (ENXIO); device_set_desc(dev, "Flattened device tree simple bus"); - return (BUS_PROBE_DEFAULT); + return (BUS_PROBE_GENERIC); } static int @@ -179,7 +181,6 @@ simplebus_attach(device_t dev) device_printf(dev, "%s: could not process 'reg' " "property\n", di->di_ofw.obd_name); - /* XXX should unmap */ ofw_bus_gen_destroy_devinfo(&di->di_ofw); free(di, M_SIMPLEBUS); continue; @@ -189,7 +190,6 @@ simplebus_attach(device_t dev) device_printf(dev, "%s: could not process " "'interrupts' property\n", di->di_ofw.obd_name); resource_list_free(&di->di_res); - /* XXX should unmap */ ofw_bus_gen_destroy_devinfo(&di->di_ofw); free(di, M_SIMPLEBUS); continue; @@ -201,7 +201,6 @@ simplebus_attach(device_t dev) device_printf(dev, "could not add child: %s\n", di->di_ofw.obd_name); resource_list_free(&di->di_res); - /* XXX should unmap */ ofw_bus_gen_destroy_devinfo(&di->di_ofw); free(di, M_SIMPLEBUS); continue; @@ -254,8 +253,9 @@ simplebus_alloc_resource(device_t bus, device_t child, int type, int *rid, rle = resource_list_find(&di->di_res, type, *rid); if (rle == NULL) { - device_printf(bus, "no default resources for " - "rid = %d, type = %d\n", *rid, type); + if (bootverbose) + device_printf(bus, "no default resources for " + "rid = %d, type = %d\n", *rid, type); return (NULL); } start = rle->start; @@ -286,9 +286,6 @@ simplebus_setup_intr(device_t bus, device_t child, struct resource *res, enum intr_polarity pol; int error, rid; - if (device_get_parent(child) != bus) - return (ECHILD); - di = device_get_ivars(child); if (di == NULL) return (ENXIO); diff --git a/sys/dev/puc/pucdata.c b/sys/dev/puc/pucdata.c index d82f031..ddf9282 100644 --- a/sys/dev/puc/pucdata.c +++ b/sys/dev/puc/pucdata.c @@ -629,6 +629,7 @@ const struct puc_cfg puc_pci_devices[] = { "Exar XR17V258IV", DEFAULT_RCLK * 8, PUC_PORT_8S, 0x10, 0, -1, + .config_function = puc_config_exar }, /* The XR17V358 uses the 125MHz PCIe clock as its reference clock. */ diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index e1dbedc..6407edf 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -108,7 +108,7 @@ SDT_PROBE_ARGTYPE(proc, kernel, , signal_discard, 2, "int"); static int coredump(struct thread *); static int killpg1(struct thread *td, int sig, int pgid, int all, ksiginfo_t *ksi); -static int issignal(struct thread *td, int stop_allowed); +static int issignal(struct thread *td); static int sigprop(int sig); static void tdsigwakeup(struct thread *, int, sig_t, int); static void sig_suspend_threads(struct thread *, struct proc *, int); @@ -560,19 +560,17 @@ sigqueue_delete_stopmask_proc(struct proc *p) } /* - * Determine signal that should be delivered to process p, the current - * process, 0 if none. If there is a pending stop signal with default + * Determine signal that should be delivered to thread td, the current + * thread, 0 if none. If there is a pending stop signal with default * action, the process stops in issignal(). */ int -cursig(struct thread *td, int stop_allowed) +cursig(struct thread *td) { PROC_LOCK_ASSERT(td->td_proc, MA_OWNED); - KASSERT(stop_allowed == SIG_STOP_ALLOWED || - stop_allowed == SIG_STOP_NOT_ALLOWED, ("cursig: stop_allowed")); mtx_assert(&td->td_proc->p_sigacts->ps_mtx, MA_OWNED); THREAD_LOCK_ASSERT(td, MA_NOTOWNED); - return (SIGPENDING(td) ? issignal(td, stop_allowed) : 0); + return (SIGPENDING(td) ? issignal(td) : 0); } /* @@ -1202,7 +1200,7 @@ kern_sigtimedwait(struct thread *td, sigset_t waitset, ksiginfo_t *ksi, SIGSETNAND(td->td_sigmask, waitset); for (;;) { mtx_lock(&ps->ps_mtx); - sig = cursig(td, SIG_STOP_ALLOWED); + sig = cursig(td); mtx_unlock(&ps->ps_mtx); if (sig != 0 && SIGISMEMBER(waitset, sig)) { if (sigqueue_get(&td->td_sigqueue, sig, ksi) != 0 || @@ -1465,7 +1463,7 @@ kern_sigsuspend(struct thread *td, sigset_t mask) /* void */; thread_suspend_check(0); mtx_lock(&p->p_sigacts->ps_mtx); - while ((sig = cursig(td, SIG_STOP_ALLOWED)) != 0) + while ((sig = cursig(td)) != 0) has_sig += postsig(sig); mtx_unlock(&p->p_sigacts->ps_mtx); } @@ -2150,9 +2148,9 @@ tdsendsignal(struct proc *p, struct thread *td, int sig, ksiginfo_t *ksi) * Some signals have a process-wide effect and a per-thread * component. Most processing occurs when the process next * tries to cross the user boundary, however there are some - * times when processing needs to be done immediatly, such as + * times when processing needs to be done immediately, such as * waking up threads so that they can cross the user boundary. - * We try do the per-process part here. + * We try to do the per-process part here. */ if (P_SHOULDSTOP(p)) { KASSERT(!(p->p_flag & P_WEXIT), @@ -2399,12 +2397,10 @@ static void sig_suspend_threads(struct thread *td, struct proc *p, int sending) { struct thread *td2; - int wakeup_swapper; PROC_LOCK_ASSERT(p, MA_OWNED); PROC_SLOCK_ASSERT(p, MA_OWNED); - wakeup_swapper = 0; FOREACH_THREAD_IN_PROC(p, td2) { thread_lock(td2); td2->td_flags |= TDF_ASTPENDING | TDF_NEEDSUSPCHK; @@ -2431,8 +2427,6 @@ sig_suspend_threads(struct thread *td, struct proc *p, int sending) } thread_unlock(td2); } - if (wakeup_swapper) - kick_proc0(); } int @@ -2584,7 +2578,7 @@ sigallowstop() * postsig(sig); */ static int -issignal(struct thread *td, int stop_allowed) +issignal(struct thread *td) { struct proc *p; struct sigacts *ps; diff --git a/sys/kern/kern_synch.c b/sys/kern/kern_synch.c index 81471ca..33d2db5 100644 --- a/sys/kern/kern_synch.c +++ b/sys/kern/kern_synch.c @@ -205,8 +205,6 @@ _sleep(void *ident, struct lock_object *lock, int priority, sleepq_flags = SLEEPQ_SLEEP; if (catch) sleepq_flags |= SLEEPQ_INTERRUPTIBLE; - if (priority & PBDRY) - sleepq_flags |= SLEEPQ_STOP_ON_BDRY; sleepq_lock(ident); CTR5(KTR_PROC, "sleep: thread %ld (pid %ld, %s) on %s (%p)", diff --git a/sys/kern/subr_sleepqueue.c b/sys/kern/subr_sleepqueue.c index 1e1e263..92b5147 100644 --- a/sys/kern/subr_sleepqueue.c +++ b/sys/kern/subr_sleepqueue.c @@ -405,7 +405,7 @@ sleepq_catch_signals(void *wchan, int pri) struct thread *td; struct proc *p; struct sigacts *ps; - int sig, ret, stop_allowed; + int sig, ret; td = curthread; p = curproc; @@ -429,8 +429,6 @@ sleepq_catch_signals(void *wchan, int pri) sleepq_switch(wchan, pri); return (0); } - stop_allowed = (td->td_flags & TDF_SBDRY) ? SIG_STOP_NOT_ALLOWED : - SIG_STOP_ALLOWED; thread_unlock(td); mtx_unlock_spin(&sc->sc_lock); CTR3(KTR_PROC, "sleepq catching signals: thread %p (pid %ld, %s)", @@ -438,7 +436,7 @@ sleepq_catch_signals(void *wchan, int pri) PROC_LOCK(p); ps = p->p_sigacts; mtx_lock(&ps->ps_mtx); - sig = cursig(td, stop_allowed); + sig = cursig(td); if (sig == 0) { mtx_unlock(&ps->ps_mtx); ret = thread_suspend_check(1); diff --git a/sys/kern/subr_trap.c b/sys/kern/subr_trap.c index 11a4bc4..19729a4 100644 --- a/sys/kern/subr_trap.c +++ b/sys/kern/subr_trap.c @@ -267,7 +267,7 @@ ast(struct trapframe *framep) !SIGISEMPTY(p->p_siglist)) { PROC_LOCK(p); mtx_lock(&p->p_sigacts->ps_mtx); - while ((sig = cursig(td, SIG_STOP_ALLOWED)) != 0) + while ((sig = cursig(td)) != 0) postsig(sig); mtx_unlock(&p->p_sigacts->ps_mtx); PROC_UNLOCK(p); diff --git a/sys/modules/dtrace/fbt/Makefile b/sys/modules/dtrace/fbt/Makefile index acc10eb..8b00148 100644 --- a/sys/modules/dtrace/fbt/Makefile +++ b/sys/modules/dtrace/fbt/Makefile @@ -3,7 +3,7 @@ .PATH: ${.CURDIR}/../../../cddl/dev/fbt KMOD= fbt -.if ${MACHINE_ARCH} == "powerpc" +.if ${MACHINE_CPUARCH} == "powerpc" SRCS= fbt_powerpc.c .else SRCS= fbt.c diff --git a/sys/net/pfil.c b/sys/net/pfil.c index 06da0be..9939d72 100644 --- a/sys/net/pfil.c +++ b/sys/net/pfil.c @@ -94,12 +94,13 @@ pfil_run_hooks(struct pfil_head *ph, struct mbuf **mp, struct ifnet *ifp, /* * pfil_try_rlock() acquires rm reader lock for specified head - * if this is immediately possible, + * if this is immediately possible. */ int pfil_try_rlock(struct pfil_head *ph, struct rm_priotracker *tracker) { - return PFIL_TRY_RLOCK(ph, tracker); + + return (PFIL_TRY_RLOCK(ph, tracker)); } /* @@ -108,6 +109,7 @@ pfil_try_rlock(struct pfil_head *ph, struct rm_priotracker *tracker) void pfil_rlock(struct pfil_head *ph, struct rm_priotracker *tracker) { + PFIL_RLOCK(ph, tracker); } @@ -117,6 +119,7 @@ pfil_rlock(struct pfil_head *ph, struct rm_priotracker *tracker) void pfil_runlock(struct pfil_head *ph, struct rm_priotracker *tracker) { + PFIL_RUNLOCK(ph, tracker); } @@ -126,6 +129,7 @@ pfil_runlock(struct pfil_head *ph, struct rm_priotracker *tracker) void pfil_wlock(struct pfil_head *ph) { + PFIL_WLOCK(ph); } @@ -135,16 +139,19 @@ pfil_wlock(struct pfil_head *ph) void pfil_wunlock(struct pfil_head *ph) { + PFIL_WUNLOCK(ph); } /* - * pfil_wowned() releases writer lock for specified head. + * pfil_wowned() returns a non-zero value if the current thread owns + * an exclusive lock. */ int pfil_wowned(struct pfil_head *ph) { - return PFIL_WOWNED(ph); + + return (PFIL_WOWNED(ph)); } /* * pfil_head_register() registers a pfil_head with the packet filter hook diff --git a/sys/net/pfil.h b/sys/net/pfil.h index fabfe9a..9cdb422 100644 --- a/sys/net/pfil.h +++ b/sys/net/pfil.h @@ -123,14 +123,14 @@ struct pfil_head *pfil_head_get(int, u_long); if ((p)->flags & PFIL_FLAG_PRIVATE_LOCK) \ PFIL_LOCK_DESTROY_REAL((p)->ph_plock); \ } while (0) -#define PFIL_TRY_RLOCK(p, t) rm_try_rlock((p)->ph_plock, (t)) -#define PFIL_RLOCK(p, t) rm_rlock((p)->ph_plock, (t)) -#define PFIL_WLOCK(p) rm_wlock((p)->ph_plock) -#define PFIL_RUNLOCK(p, t) rm_runlock((p)->ph_plock, (t)) -#define PFIL_WUNLOCK(p) rm_wunlock((p)->ph_plock) -#define PFIL_WOWNED(p) rm_wowned((p)->ph_plock) -#define PFIL_LIST_LOCK() mtx_lock(&pfil_global_lock) -#define PFIL_LIST_UNLOCK() mtx_unlock(&pfil_global_lock) +#define PFIL_TRY_RLOCK(p, t) rm_try_rlock((p)->ph_plock, (t)) +#define PFIL_RLOCK(p, t) rm_rlock((p)->ph_plock, (t)) +#define PFIL_WLOCK(p) rm_wlock((p)->ph_plock) +#define PFIL_RUNLOCK(p, t) rm_runlock((p)->ph_plock, (t)) +#define PFIL_WUNLOCK(p) rm_wunlock((p)->ph_plock) +#define PFIL_WOWNED(p) rm_wowned((p)->ph_plock) +#define PFIL_LIST_LOCK() mtx_lock(&pfil_global_lock) +#define PFIL_LIST_UNLOCK() mtx_unlock(&pfil_global_lock) static __inline struct packet_filter_hook * pfil_hook_get(int dir, struct pfil_head *ph) diff --git a/sys/netpfil/ipfw/ip_fw2.c b/sys/netpfil/ipfw/ip_fw2.c index a542ffe..1c096d9 100644 --- a/sys/netpfil/ipfw/ip_fw2.c +++ b/sys/netpfil/ipfw/ip_fw2.c @@ -1203,9 +1203,9 @@ do { \ args->f_id.dst_port = dst_port = ntohs(dst_port); } - IPFW_RLOCK(chain); + IPFW_PF_RLOCK(chain); if (! V_ipfw_vnet_ready) { /* shutting down, leave NOW. */ - IPFW_RUNLOCK(chain); + IPFW_PF_RUNLOCK(chain); return (IP_FW_PASS); /* accept */ } if (args->rule.slot) { @@ -2459,7 +2459,7 @@ do { \ retval = IP_FW_DENY; printf("ipfw: ouch!, skip past end of rules, denying packet\n"); } - IPFW_RUNLOCK(chain); + IPFW_PF_RUNLOCK(chain); #ifdef __FreeBSD__ if (ucred_cache != NULL) crfree(ucred_cache); diff --git a/sys/netpfil/ipfw/ip_fw_private.h b/sys/netpfil/ipfw/ip_fw_private.h index 3ae1165..a41cdf5 100644 --- a/sys/netpfil/ipfw/ip_fw_private.h +++ b/sys/netpfil/ipfw/ip_fw_private.h @@ -278,10 +278,12 @@ struct sockopt; /* used by tcp_var.h */ #define IPFW_RLOCK_ASSERT(_chain) rw_assert(&(_chain)->rwmtx, RA_RLOCKED) #define IPFW_WLOCK_ASSERT(_chain) rw_assert(&(_chain)->rwmtx, RA_WLOCKED) -#define IPFW_RLOCK(p) rw_rlock(&(p)->rwmtx) -#define IPFW_RUNLOCK(p) rw_runlock(&(p)->rwmtx) -#define IPFW_WLOCK(p) rw_wlock(&(p)->rwmtx) -#define IPFW_WUNLOCK(p) rw_wunlock(&(p)->rwmtx) +#define IPFW_RLOCK(p) rw_rlock(&(p)->rwmtx) +#define IPFW_RUNLOCK(p) rw_runlock(&(p)->rwmtx) +#define IPFW_WLOCK(p) rw_wlock(&(p)->rwmtx) +#define IPFW_WUNLOCK(p) rw_wunlock(&(p)->rwmtx) +#define IPFW_PF_RLOCK(p) IPFW_RLOCK(p) +#define IPFW_PF_RUNLOCK(p) IPFW_RUNLOCK(p) #define IPFW_UH_RLOCK_ASSERT(_chain) rw_assert(&(_chain)->uh_lock, RA_RLOCKED) #define IPFW_UH_WLOCK_ASSERT(_chain) rw_assert(&(_chain)->uh_lock, RA_WLOCKED) diff --git a/sys/sys/mouse.h b/sys/sys/mouse.h index f8039ae..e0b70ff 100644 --- a/sys/sys/mouse.h +++ b/sys/sys/mouse.h @@ -141,6 +141,7 @@ typedef struct synapticshw { #define MOUSE_MODEL_4D 11 #define MOUSE_MODEL_4DPLUS 12 #define MOUSE_MODEL_SYNAPTICS 13 +#define MOUSE_MODEL_TRACKPOINT 14 typedef struct mousemode { int protocol; /* MOUSE_PROTO_XXX */ diff --git a/sys/sys/param.h b/sys/sys/param.h index 996d47c..2be2e25 100644 --- a/sys/sys/param.h +++ b/sys/sys/param.h @@ -211,7 +211,6 @@ #define PRIMASK 0x0ff #define PCATCH 0x100 /* OR'd with pri for tsleep to check signals */ #define PDROP 0x200 /* OR'd with pri to stop re-entry of interlock mutex */ -#define PBDRY 0x400 /* for PCATCH stop is done on the user boundary */ #define NZERO 0 /* default "nice" */ diff --git a/sys/sys/signalvar.h b/sys/sys/signalvar.h index fcf25ad..c784cfa 100644 --- a/sys/sys/signalvar.h +++ b/sys/sys/signalvar.h @@ -318,16 +318,12 @@ struct thread; extern struct mtx sigio_lock; -/* Values for stop_allowed parameter for cursig(). */ -#define SIG_STOP_ALLOWED 100 -#define SIG_STOP_NOT_ALLOWED 101 - /* Flags for kern_sigprocmask(). */ #define SIGPROCMASK_OLD 0x0001 #define SIGPROCMASK_PROC_LOCKED 0x0002 #define SIGPROCMASK_PS_LOCKED 0x0004 -int cursig(struct thread *td, int stop_allowed); +int cursig(struct thread *td); int sigdeferstop(void); void sigallowstop(void); void execsigs(struct proc *p); diff --git a/sys/sys/sleepqueue.h b/sys/sys/sleepqueue.h index 1c34636..05386a9 100644 --- a/sys/sys/sleepqueue.h +++ b/sys/sys/sleepqueue.h @@ -93,8 +93,6 @@ struct thread; #define SLEEPQ_SX 0x03 /* Used by an sx lock. */ #define SLEEPQ_LK 0x04 /* Used by a lockmgr. */ #define SLEEPQ_INTERRUPTIBLE 0x100 /* Sleep is interruptible. */ -#define SLEEPQ_STOP_ON_BDRY 0x200 /* Stop sleeping thread on - user mode boundary */ void init_sleepqueues(void); int sleepq_abort(struct thread *td, int intrval); diff --git a/usr.sbin/bhyve/acpi.c b/usr.sbin/bhyve/acpi.c index f9504f8..ed0c545 100644 --- a/usr.sbin/bhyve/acpi.c +++ b/usr.sbin/bhyve/acpi.c @@ -680,29 +680,26 @@ basl_end(struct basl_fio *in, struct basl_fio *out) } static int -basl_load(int fd, uint64_t off) +basl_load(struct vmctx *ctx, int fd, uint64_t off) { - struct stat sb; + struct stat sb; void *gaddr; - int err; - err = 0; - if (fstat(fd, &sb) < 0) { - err = errno; - } else { - gaddr = paddr_guest2host(basl_acpi_base + off, sb.st_size); - if (gaddr != NULL) { - if (read(fd, gaddr, sb.st_size) < 0) - err = errno; - } else - err = EFAULT; - } + if (fstat(fd, &sb) < 0) + return (errno); + + gaddr = paddr_guest2host(ctx, basl_acpi_base + off, sb.st_size); + if (gaddr == NULL) + return (EFAULT); - return (err); + if (read(fd, gaddr, sb.st_size) < 0) + return (errno); + + return (0); } static int -basl_compile(int (*fwrite_section)(FILE *fp), uint64_t offset) +basl_compile(struct vmctx *ctx, int (*fwrite_section)(FILE *), uint64_t offset) { struct basl_fio io[2]; static char iaslbuf[3*MAXPATHLEN + 10]; @@ -736,7 +733,7 @@ basl_compile(int (*fwrite_section)(FILE *fp), uint64_t offset) * Copy the aml output file into guest * memory at the specified location */ - err = basl_load(io[1].fd, offset); + err = basl_load(ctx, io[1].fd, offset); } } basl_end(&io[0], &io[1]); @@ -842,7 +839,7 @@ acpi_build(struct vmctx *ctx, int ncpu, int ioapic) * copying them into guest memory */ while (!err && basl_ftables[i].wsect != NULL) { - err = basl_compile(basl_ftables[i].wsect, + err = basl_compile(ctx, basl_ftables[i].wsect, basl_ftables[i].offset); i++; } diff --git a/usr.sbin/bhyve/bhyverun.c b/usr.sbin/bhyve/bhyverun.c index 17d60d6..5794b39 100644 --- a/usr.sbin/bhyve/bhyverun.c +++ b/usr.sbin/bhyve/bhyverun.c @@ -80,9 +80,6 @@ int guest_tslice = DEFAULT_GUEST_TSLICE; int guest_hz = DEFAULT_GUEST_HZ; char *vmname; -u_long lomem_sz; -u_long himem_sz; - int guest_ncpus; static int pincpu = -1; @@ -95,9 +92,6 @@ static int strictio; static int acpi; -static char *lomem_addr; -static char *himem_addr; - static char *progname; static const int BSP = 0; @@ -147,8 +141,7 @@ usage(int code) " -z: guest hz (default is %d)\n" " -s: <slot,driver,configinfo> PCI slot config\n" " -S: <slot,driver,configinfo> legacy PCI slot config\n" - " -m: lowmem in MB\n" - " -M: highmem in MB\n" + " -m: memory size in MB\n" " -x: mux vcpus to 1 hcpu\n" " -t: mux vcpu timeslice hz (default %d)\n", progname, DEFAULT_GDB_PORT, DEFAULT_GUEST_HZ, @@ -157,19 +150,10 @@ usage(int code) } void * -paddr_guest2host(uintptr_t gaddr, size_t len) +paddr_guest2host(struct vmctx *ctx, uintptr_t gaddr, size_t len) { - if (gaddr < lomem_sz && gaddr + len <= lomem_sz) - return ((void *)(lomem_addr + gaddr)); - - if (gaddr >= 4*GB) { - gaddr -= 4*GB; - if (gaddr < himem_sz && gaddr + len <= himem_sz) - return ((void *)(himem_addr + gaddr)); - } - - return (NULL); + return (vm_map_gpa(ctx, gaddr, len)); } int @@ -604,6 +588,7 @@ main(int argc, char *argv[]) int max_vcpus; struct vmctx *ctx; uint64_t rip; + size_t memsize; bvmcons = 0; inject_bkpt = 0; @@ -611,8 +596,9 @@ main(int argc, char *argv[]) gdb_port = DEFAULT_GDB_PORT; guest_ncpus = 1; ioapic = 0; + memsize = 256 * MB; - while ((c = getopt(argc, argv, "abehABHIPxp:g:c:z:s:S:n:m:M:")) != -1) { + while ((c = getopt(argc, argv, "abehABHIPxp:g:c:z:s:S:n:m:")) != -1) { switch (c) { case 'a': disable_x2apic = 1; @@ -651,10 +637,7 @@ main(int argc, char *argv[]) pci_parse_slot(optarg, 1); break; case 'm': - lomem_sz = strtoul(optarg, NULL, 0) * MB; - break; - case 'M': - himem_sz = strtoul(optarg, NULL, 0) * MB; + memsize = strtoul(optarg, NULL, 0) * MB; break; case 'H': guest_vmexit_on_hlt = 1; @@ -739,17 +722,10 @@ main(int argc, char *argv[]) exit(1); } - if (lomem_sz != 0) { - lomem_addr = vm_map_memory(ctx, 0, lomem_sz); - if (lomem_addr == (char *) MAP_FAILED) { - lomem_sz = 0; - } else if (himem_sz != 0) { - himem_addr = vm_map_memory(ctx, 4*GB, himem_sz); - if (himem_addr == (char *) MAP_FAILED) { - lomem_sz = 0; - himem_sz = 0; - } - } + err = vm_setup_memory(ctx, memsize, VM_MMAP_ALL); + if (err) { + fprintf(stderr, "Unable to setup memory (%d)\n", err); + exit(1); } init_inout(); diff --git a/usr.sbin/bhyve/bhyverun.h b/usr.sbin/bhyve/bhyverun.h index 70455bf..ffe3018 100644 --- a/usr.sbin/bhyve/bhyverun.h +++ b/usr.sbin/bhyve/bhyverun.h @@ -41,9 +41,7 @@ extern int guest_tslice; extern int guest_ncpus; extern char *vmname; -extern u_long lomem_sz, himem_sz; - -void *paddr_guest2host(uintptr_t addr, size_t len); +void *paddr_guest2host(struct vmctx *ctx, uintptr_t addr, size_t len); void fbsdrun_addcpu(struct vmctx *ctx, int cpu, uint64_t rip); int fbsdrun_muxed(void); diff --git a/usr.sbin/bhyve/mptbl.c b/usr.sbin/bhyve/mptbl.c index 9c68b3d..ece71cd 100644 --- a/usr.sbin/bhyve/mptbl.c +++ b/usr.sbin/bhyve/mptbl.c @@ -349,7 +349,7 @@ mptable_build(struct vmctx *ctx, int ncpu, int ioapic) char *curraddr; char *startaddr; - startaddr = paddr_guest2host(MPTABLE_BASE, MPTABLE_MAX_LENGTH); + startaddr = paddr_guest2host(ctx, MPTABLE_BASE, MPTABLE_MAX_LENGTH); if (startaddr == NULL) { printf("mptable requires mapped mem\n"); return (ENOMEM); diff --git a/usr.sbin/bhyve/pci_emul.c b/usr.sbin/bhyve/pci_emul.c index cb09b7c..b5e923c 100644 --- a/usr.sbin/bhyve/pci_emul.c +++ b/usr.sbin/bhyve/pci_emul.c @@ -86,6 +86,8 @@ static struct lirqinfo { SET_DECLARE(pci_devemu_set, struct pci_devemu); +static uint32_t pci_hole_startaddr; + static uint64_t pci_emul_iobase; static uint64_t pci_emul_membase32; static uint64_t pci_emul_membase64; @@ -93,7 +95,6 @@ static uint64_t pci_emul_membase64; #define PCI_EMUL_IOBASE 0x2000 #define PCI_EMUL_IOLIMIT 0x10000 -#define PCI_EMUL_MEMBASE32 (lomem_sz) #define PCI_EMUL_MEMLIMIT32 0xE0000000 /* 3.5GB */ #define PCI_EMUL_MEMBASE64 0xD000000000UL @@ -870,8 +871,10 @@ init_pci(struct vmctx *ctx) int slot, func; int error; + pci_hole_startaddr = vm_get_lowmem_limit(ctx); + pci_emul_iobase = PCI_EMUL_IOBASE; - pci_emul_membase32 = PCI_EMUL_MEMBASE32; + pci_emul_membase32 = pci_hole_startaddr; pci_emul_membase64 = PCI_EMUL_MEMBASE64; for (slot = 0; slot < MAXSLOTS; slot++) { @@ -904,8 +907,8 @@ init_pci(struct vmctx *ctx) memset(&memp, 0, sizeof(struct mem_range)); memp.name = "PCI hole"; memp.flags = MEM_F_RW; - memp.base = lomem_sz; - memp.size = (4ULL * 1024 * 1024 * 1024) - lomem_sz; + memp.base = pci_hole_startaddr; + memp.size = (4ULL * 1024 * 1024 * 1024) - pci_hole_startaddr; memp.handler = pci_emul_fallback_handler; error = register_mem_fallback(&memp); diff --git a/usr.sbin/bhyve/pci_virtio_block.c b/usr.sbin/bhyve/pci_virtio_block.c index 0c34666..a325e97 100644 --- a/usr.sbin/bhyve/pci_virtio_block.c +++ b/usr.sbin/bhyve/pci_virtio_block.c @@ -141,6 +141,7 @@ struct pci_vtblk_softc { uint16_t msix_table_idx_req; uint16_t msix_table_idx_cfg; }; +#define vtblk_ctx(sc) ((sc)->vbsc_pi->pi_vmctx) /* * Return the size of IO BAR that maps virtio header and device specific @@ -227,13 +228,14 @@ pci_vtblk_proc(struct pci_vtblk_softc *sc, struct vring_hqueue *hq) assert(nsegs >= 3); assert(nsegs < VTBLK_MAXSEGS + 2); - vid = paddr_guest2host(vd->vd_addr, vd->vd_len); + vid = paddr_guest2host(vtblk_ctx(sc), vd->vd_addr, vd->vd_len); assert((vid->vd_flags & VRING_DESC_F_INDIRECT) == 0); /* * The first descriptor will be the read-only fixed header */ - vbh = paddr_guest2host(vid[0].vd_addr, sizeof(struct virtio_blk_hdr)); + vbh = paddr_guest2host(vtblk_ctx(sc), vid[0].vd_addr, + sizeof(struct virtio_blk_hdr)); assert(vid[0].vd_len == sizeof(struct virtio_blk_hdr)); assert(vid[0].vd_flags & VRING_DESC_F_NEXT); assert((vid[0].vd_flags & VRING_DESC_F_WRITE) == 0); @@ -252,8 +254,8 @@ pci_vtblk_proc(struct pci_vtblk_softc *sc, struct vring_hqueue *hq) * Build up the iovec based on the guest's data descriptors */ for (i = 1, iolen = 0; i < nsegs - 1; i++) { - iov[i-1].iov_base = paddr_guest2host(vid[i].vd_addr, - vid[i].vd_len); + iov[i-1].iov_base = paddr_guest2host(vtblk_ctx(sc), + vid[i].vd_addr, vid[i].vd_len); iov[i-1].iov_len = vid[i].vd_len; iolen += vid[i].vd_len; @@ -271,7 +273,7 @@ pci_vtblk_proc(struct pci_vtblk_softc *sc, struct vring_hqueue *hq) } /* Lastly, get the address of the status byte */ - status = paddr_guest2host(vid[nsegs - 1].vd_addr, 1); + status = paddr_guest2host(vtblk_ctx(sc), vid[nsegs - 1].vd_addr, 1); assert(vid[nsegs - 1].vd_len == 1); assert((vid[nsegs - 1].vd_flags & VRING_DESC_F_NEXT) == 0); assert(vid[nsegs - 1].vd_flags & VRING_DESC_F_WRITE); @@ -347,7 +349,7 @@ pci_vtblk_ring_init(struct pci_vtblk_softc *sc, uint64_t pfn) hq = &sc->vbsc_q; hq->hq_size = VTBLK_RINGSZ; - hq->hq_dtable = paddr_guest2host(pfn << VRING_PFN, + hq->hq_dtable = paddr_guest2host(vtblk_ctx(sc), pfn << VRING_PFN, vring_size(VTBLK_RINGSZ)); hq->hq_avail_flags = (uint16_t *)(hq->hq_dtable + hq->hq_size); hq->hq_avail_idx = hq->hq_avail_flags + 1; diff --git a/usr.sbin/bhyve/pci_virtio_net.c b/usr.sbin/bhyve/pci_virtio_net.c index 7129f6b..783c45e 100644 --- a/usr.sbin/bhyve/pci_virtio_net.c +++ b/usr.sbin/bhyve/pci_virtio_net.c @@ -148,6 +148,7 @@ struct pci_vtnet_softc { struct vring_hqueue vsc_hq[VTNET_MAXQ]; uint16_t vsc_msix_table_idx[VTNET_MAXQ]; }; +#define vtnet_ctx(sc) ((sc)->vsc_pi->pi_vmctx) /* * Return the size of IO BAR that maps virtio header and device specific @@ -331,7 +332,7 @@ pci_vtnet_tap_rx(struct pci_vtnet_softc *sc) * Get a pointer to the rx header, and use the * data immediately following it for the packet buffer. */ - vrx = paddr_guest2host(vd->vd_addr, vd->vd_len); + vrx = paddr_guest2host(vtnet_ctx(sc), vd->vd_addr, vd->vd_len); buf = (uint8_t *)(vrx + 1); len = read(sc->vsc_tapfd, buf, @@ -439,7 +440,8 @@ pci_vtnet_proctx(struct pci_vtnet_softc *sc, struct vring_hqueue *hq) for (i = 0, plen = 0; i < VTNET_MAXSEGS; i++, vd = &hq->hq_dtable[vd->vd_next]) { - iov[i].iov_base = paddr_guest2host(vd->vd_addr, vd->vd_len); + iov[i].iov_base = paddr_guest2host(vtnet_ctx(sc), + vd->vd_addr, vd->vd_len); iov[i].iov_len = vd->vd_len; plen += vd->vd_len; tlen += vd->vd_len; @@ -522,7 +524,7 @@ pci_vtnet_ring_init(struct pci_vtnet_softc *sc, uint64_t pfn) hq = &sc->vsc_hq[qnum]; hq->hq_size = pci_vtnet_qsize(qnum); - hq->hq_dtable = paddr_guest2host(pfn << VRING_PFN, + hq->hq_dtable = paddr_guest2host(vtnet_ctx(sc), pfn << VRING_PFN, vring_size(hq->hq_size)); hq->hq_avail_flags = (uint16_t *)(hq->hq_dtable + hq->hq_size); hq->hq_avail_idx = hq->hq_avail_flags + 1; diff --git a/usr.sbin/bhyvectl/bhyvectl.c b/usr.sbin/bhyvectl/bhyvectl.c index 26c6c92..cf673d1 100644 --- a/usr.sbin/bhyvectl/bhyvectl.c +++ b/usr.sbin/bhyvectl/bhyvectl.c @@ -186,9 +186,8 @@ usage(void) " [--set-x2apic-state=<state>]\n" " [--get-x2apic-state]\n" " [--unassign-pptdev=<bus/slot/func>]\n" - " [--set-lowmem=<memory below 4GB in units of MB>]\n" + " [--set-mem=<memory in units of MB>]\n" " [--get-lowmem]\n" - " [--set-highmem=<memory above 4GB in units of MB>]\n" " [--get-highmem]\n", progname); exit(1); @@ -197,7 +196,7 @@ usage(void) static int get_stats, getcap, setcap, capval; static const char *capname; static int create, destroy, get_lowmem, get_highmem; -static uint64_t lowmem, highmem; +static uint64_t memsize; static int set_cr0, get_cr0, set_cr3, get_cr3, set_cr4, get_cr4; static int set_efer, get_efer; static int set_dr7, get_dr7; @@ -351,8 +350,7 @@ vm_set_vmcs_field(struct vmctx *ctx, int vcpu, int field, uint64_t val) enum { VMNAME = 1000, /* avoid collision with return values from getopt */ VCPU, - SET_LOWMEM, - SET_HIGHMEM, + SET_MEM, SET_EFER, SET_CR0, SET_CR3, @@ -400,8 +398,7 @@ main(int argc, char *argv[]) struct option opts[] = { { "vm", REQ_ARG, 0, VMNAME }, { "cpu", REQ_ARG, 0, VCPU }, - { "set-lowmem", REQ_ARG, 0, SET_LOWMEM }, - { "set-highmem",REQ_ARG, 0, SET_HIGHMEM }, + { "set-mem", REQ_ARG, 0, SET_MEM }, { "set-efer", REQ_ARG, 0, SET_EFER }, { "set-cr0", REQ_ARG, 0, SET_CR0 }, { "set-cr3", REQ_ARG, 0, SET_CR3 }, @@ -572,13 +569,9 @@ main(int argc, char *argv[]) case VCPU: vcpu = atoi(optarg); break; - case SET_LOWMEM: - lowmem = atoi(optarg) * MB; - lowmem = roundup(lowmem, 2 * MB); - break; - case SET_HIGHMEM: - highmem = atoi(optarg) * MB; - highmem = roundup(highmem, 2 * MB); + case SET_MEM: + memsize = atoi(optarg) * MB; + memsize = roundup(memsize, 2 * MB); break; case SET_EFER: efer = strtoul(optarg, NULL, 0); @@ -702,11 +695,8 @@ main(int argc, char *argv[]) error = -1; } - if (!error && lowmem) - error = vm_setup_memory(ctx, 0, lowmem, NULL); - - if (!error && highmem) - error = vm_setup_memory(ctx, 4 * GB, highmem, NULL); + if (!error && memsize) + error = vm_setup_memory(ctx, memsize, VM_MMAP_NONE); if (!error && set_efer) error = vm_set_register(ctx, vcpu, VM_REG_GUEST_EFER, efer); diff --git a/usr.sbin/bhyveload/bhyveload.8 b/usr.sbin/bhyveload/bhyveload.8 index 4a05116..f2e5e35 100644 --- a/usr.sbin/bhyveload/bhyveload.8 +++ b/usr.sbin/bhyveload/bhyveload.8 @@ -35,8 +35,7 @@ guest inside a bhyve virtual machine .Sh SYNOPSIS .Nm -.Op Fl m Ar lowmem -.Op Fl M Ar highmem +.Op Fl m Ar mem-size .Op Fl d Ar disk-path .Op Fl h Ar host-path .Ar vmname @@ -61,22 +60,13 @@ and will be created if it does not already exist. .Sh OPTIONS The following options are available: .Bl -tag -width indent -.It Fl m Ar lowmem -.Ar lowmem -is the amount of memory allocated below 4GB in the guest's physical address -space. +.It Fl m Ar mem-size +.Ar mem-size +is the amount of memory allocated to the guest in units of megabytes. .Pp The default value of -.Ar lowmem -is 256MB. -.It Fl M Ar highmem -.Ar highmem -is the amount of memory allocated above 4GB in the guest's physical address -space. -.Pp -The default value of -.Ar highmem -is 0MB. +.Ar mem-size +is 256. .It Fl d Ar disk-path The .Ar disk-path @@ -93,16 +83,7 @@ that boots off the ISO image .Pa /freebsd/release.iso and has 1GB memory allocated to it: .Pp -.Dl "bhyveload -m 256 -M 768 -d /freebsd/release.iso freebsd-vm" -.Pp -In the example above the 1GB allocation is split in two segments: -.Pp -.Bl -dash -compact -.It -256MB below the 4GB boundary (0MB - 256MB) -.It -768MB above the 4GB boundary (4096MB - 4864MB) -.El +.Dl "bhyveload -m 1024 -d /freebsd/release.iso freebsd-vm" .Sh SEE ALSO .Xr bhyve 4 , .Xr bhyve 8 , diff --git a/usr.sbin/bhyveload/bhyveload.c b/usr.sbin/bhyveload/bhyveload.c index ef12d9f..4cd280c 100644 --- a/usr.sbin/bhyveload/bhyveload.c +++ b/usr.sbin/bhyveload/bhyveload.c @@ -88,8 +88,7 @@ static char *host_base = "/"; static struct termios term, oldterm; static int disk_fd = -1; -static char *vmname, *progname, *membase; -static uint64_t lowmem, highmem; +static char *vmname, *progname; static struct vmctx *ctx; static uint64_t gdtbase, cr3, rsp; @@ -323,30 +322,30 @@ cb_diskioctl(void *arg, int unit, u_long cmd, void *data) static int cb_copyin(void *arg, const void *from, uint64_t to, size_t size) { + char *ptr; to &= 0x7fffffff; - if (to > lowmem) - return (EFAULT); - if (to + size > lowmem) - size = lowmem - to; - memcpy(&membase[to], from, size); + ptr = vm_map_gpa(ctx, to, size); + if (ptr == NULL) + return (EFAULT); + memcpy(ptr, from, size); return (0); } static int cb_copyout(void *arg, uint64_t from, void *to, size_t size) { + char *ptr; from &= 0x7fffffff; - if (from > lowmem) - return (EFAULT); - if (from + size > lowmem) - size = lowmem - from; - memcpy(to, &membase[from], size); + ptr = vm_map_gpa(ctx, from, size); + if (ptr == NULL) + return (EFAULT); + memcpy(to, ptr, size); return (0); } @@ -493,8 +492,8 @@ static void cb_getmem(void *arg, uint64_t *ret_lowmem, uint64_t *ret_highmem) { - *ret_lowmem = lowmem; - *ret_highmem = highmem; + vm_get_memory_seg(ctx, 0, ret_lowmem); + vm_get_memory_seg(ctx, 4 * GB, ret_highmem); } static const char * @@ -551,9 +550,9 @@ static void usage(void) { - printf("usage: %s [-d <disk image path>] [-h <host filesystem path>] " - "[-m <lowmem>][-M <highmem>] " - "<vmname>\n", progname); + fprintf(stderr, + "usage: %s [-m mem-size][-d <disk-path>] [-h <host-path>] " + "<vmname>\n", progname); exit(1); } @@ -562,16 +561,16 @@ main(int argc, char** argv) { void *h; void (*func)(struct loader_callbacks *, void *, int, int); + uint64_t mem_size; int opt, error; char *disk_image; progname = argv[0]; - lowmem = 128 * MB; - highmem = 0; + mem_size = 256 * MB; disk_image = NULL; - while ((opt = getopt(argc, argv, "d:h:m:M:")) != -1) { + while ((opt = getopt(argc, argv, "d:h:m:")) != -1) { switch (opt) { case 'd': disk_image = optarg; @@ -582,13 +581,9 @@ main(int argc, char** argv) break; case 'm': - lowmem = strtoul(optarg, NULL, 0) * MB; + mem_size = strtoul(optarg, NULL, 0) * MB; break; - case 'M': - highmem = strtoul(optarg, NULL, 0) * MB; - break; - case '?': usage(); } @@ -615,20 +610,12 @@ main(int argc, char** argv) exit(1); } - error = vm_setup_memory(ctx, 0, lowmem, &membase); + error = vm_setup_memory(ctx, mem_size, VM_MMAP_ALL); if (error) { - perror("vm_setup_memory(lowmem)"); + perror("vm_setup_memory"); exit(1); } - if (highmem != 0) { - error = vm_setup_memory(ctx, 4 * GB, highmem, NULL); - if (error) { - perror("vm_setup_memory(highmem)"); - exit(1); - } - } - tcgetattr(0, &term); oldterm = term; term.c_lflag &= ~(ICANON|ECHO); diff --git a/usr.sbin/moused/moused.c b/usr.sbin/moused/moused.c index 93eec99..0e278c4 100644 --- a/usr.sbin/moused/moused.c +++ b/usr.sbin/moused/moused.c @@ -245,6 +245,7 @@ static symtab_t rmodels[] = { { "4D Mouse", MOUSE_MODEL_4D, 0 }, { "4D+ Mouse", MOUSE_MODEL_4DPLUS, 0 }, { "Synaptics Touchpad", MOUSE_MODEL_SYNAPTICS, 0 }, + { "TrackPoint", MOUSE_MODEL_TRACKPOINT, 0 }, { "generic", MOUSE_MODEL_GENERIC, 0 }, { NULL, MOUSE_MODEL_UNKNOWN, 0 }, }; |