svn commit: r279972 - head/sys/mips/conf
Author: adrian Date: Sat Mar 14 07:59:54 2015 New Revision: 279972 URL: https://svnweb.freebsd.org/changeset/base/279972 Log: Add board support for the TP-Link TL-WR1043nd v2. This is a QCA9558 based design with on-chip 2GHz 3x3 11n wifi, AR8327N switch, 64MB RAM and 8MB flash. Of course, it runs FreeBSD. Added: head/sys/mips/conf/TL-WR1043NDv2 (contents, props changed) head/sys/mips/conf/TL-WR1043NDv2.hints (contents, props changed) Added: head/sys/mips/conf/TL-WR1043NDv2 == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/mips/conf/TL-WR1043NDv2Sat Mar 14 07:59:54 2015 (r279972) @@ -0,0 +1,51 @@ +# +# TP-Link TL-WR1043nd v2 - based on the AP135 reference design. +# +# This contains a QCA9558 MIPS74k SoC with on-board 3x3 2GHz wifi, +# 64MiB RAM and an AR8327 5-port gigabit ethernet switch. +# +# $FreeBSD$ +# + +# Include the default QCA955x parameters +include "QCA955X_BASE" + +ident TL-WR1043NDv2 + +# Override hints with board values +hints "TL-WR1043NDv2.hints" + +options AR71XX_REALMEM=(64*1024*1024) + +# Options required for miiproxy and mdiobus +optionsARGE_MDIO # Export an MDIO bus separate from arge +device miiproxy# MDIO bus <-> MII PHY rendezvous + +device etherswitch +device arswitch + +# read MSDOS formatted disks - USB +optionsMSDOSFS + +# Enable the uboot environment stuff rather then the +# redboot stuff. +optionsAR71XX_ENV_UBOOT + +# uzip - to boot natively from flash +device geom_uncompress +optionsGEOM_UNCOMPRESS + +# Used for the static uboot partition map +device geom_map + +# yes, this board has a PCI connected atheros device +#deviceath_pci +#options AR71XX_ATH_EEPROM +#devicefirmware# Used by the above +#options ATH_EEPROM_FIRMWARE + +# Boot off of the rootfs, as defined in the geom_map setup. +optionsROOTDEVNAME=\"ufs:map/rootfs.uncompress\" + +# Default to accept +optionsIPFIREWALL_DEFAULT_TO_ACCEPT Added: head/sys/mips/conf/TL-WR1043NDv2.hints == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/mips/conf/TL-WR1043NDv2.hints Sat Mar 14 07:59:54 2015 (r279972) @@ -0,0 +1,149 @@ +# The TP-Link 1043NDv2 is based on the AP135 with a couple of minor +# differences - well, besides having no 11ac. + +# $FreeBSD$ + +# QCA955X_ETH_CFG_RGMII_EN (1 << 0) +hint.qca955x_gmac.0.gmac_cfg=0x1 + +# mdiobus0 on arge0 +hint.argemdio.0.at="nexus0" +hint.argemdio.0.maddr=0x1900 +hint.argemdio.0.msize=0x1000 +hint.argemdio.0.order=0 + +# mdiobus1 on arge1 - required to bring up arge1? +hint.argemdio.1.at="nexus0" +hint.argemdio.1.maddr=0x1a00 +hint.argemdio.1.msize=0x1000 +hint.argemdio.1.order=0 + +# AR8327 - connected via mdiobus0 on arge0 +hint.arswitch.0.at="mdio0" +hint.arswitch.0.is_7240=0 # definitely not the internal switch! +hint.arswitch.0.is_9340=0 # not the internal switch! +hint.arswitch.0.numphys=5 # all ports are PHYs +hint.arswitch.0.phy4cpu=0 +hint.arswitch.0.is_rgmii=0 # not needed +hint.arswitch.0.is_gmii=0 # not needed + +# This is where it gets a bit odd. port 0 and port 6 are CPU ports. +# The current code only supports one CPU port. So hm, what should +# we do to hook PAD6 up to be RGMII but a PHY, not a MAC? + +# The other trick - how do we get arge1 (hooked up to GMAC0) to work? +# That's currently supposed to be hooked up to CPU port 0. + +# Other AR8327 configuration parameters + +# AP136-020 parameters + +# GMAC0 AR8327 -> GMAC1 (arge1) SoC, SGMII + +# AR8327_PAD_MAC_SGMII +hint.arswitch.0.pad.0.mode=3 +#hint.arswitch.0.pad.0.rxclk_delay_sel=0 +hint.arswitch.0.pad.0.sgmii_delay_en=1 + +# GMAC6 AR8327 -> GMAC0 (arge0) SoC, RGMII + +# AR8327_PAD_MAC_RGMII +hint.arswitch.0.pad.6.mode=6 +hint.arswitch.0.pad.6.txclk_delay_en=1 +hint.arswitch.0.pad.6.rxclk_delay_en=1 +# AR8327_CLK_DELAY_SEL1 +hint.arswitch.0.pad.6.txclk_delay_sel=1 +# AR8327_CLK_DELAY_SEL2 +hint.arswitch.0.pad.6.rxclk_delay_sel=2 + +hint.arswitch.0.led.ctrl0=0xcc35cc35 +hint.arswitch.0.led.ctrl1=0xca35ca35 +hint.arswitch.0.led.ctrl2=0xc935c935 +hint.arswitch.0.led.ctrl3=0x0300 +int.arswitch.0.led.open_drain=1 + +# force_link=1 is required for the rest of the parameters +# to be configured. +hint.arswitch.0.port.0.force_link=1 +hint.arswitch.0.port.0.speed=1000 +hint.arswitch.0.port.0.duplex=1 +hint.arswitch.0.port.0.txpause=1 +hint.arswitch.0.port.0.rxpause=1 + +# force_link=1 is required for the rest of the parameters +# to be configured. +hint.arswitch.0.port.6.force_link=1 +hint.arswitch.0.port.6.speed=1000 +hint.arswitch.0.port.6.duplex=1 +hint.arswitch.0.port.6.txpause=1 +hint.arswitch.0.port.6.rxpause=1 +
svn commit: r279973 - head/sys/mips/conf
Author: adrian Date: Sat Mar 14 08:29:03 2015 New Revision: 279973 URL: https://svnweb.freebsd.org/changeset/base/279973 Log: Compile some modules - I'm going to eventually just compile all the modules, but these are a subset of things that are worth playing with in deployed APs. (ipfw in particular is rather nice.) Modified: head/sys/mips/conf/QCA955X_BASE Modified: head/sys/mips/conf/QCA955X_BASE == --- head/sys/mips/conf/QCA955X_BASE Sat Mar 14 07:59:54 2015 (r279972) +++ head/sys/mips/conf/QCA955X_BASE Sat Mar 14 08:29:03 2015 (r279973) @@ -27,7 +27,7 @@ hints "QCA955X_BASE.hints" makeoptionsDEBUG=-g#Build kernel with gdb(1) debug symbols # makeoptions MODULES_OVERRIDE="random gpio ar71xx if_gif if_gre if_bridge bridgestp usb wlan wlan_xauth wlan_acl wlan_wep wlan_tkip wlan_ccmp wlan_rssadapt wlan_amrr ath ath_ahb hwpmc" -makeoptionsMODULES_OVERRIDE="" +makeoptionsMODULES_OVERRIDE="if_vlan ipfw if_gre if_gif if_bridge bridgestp hwpmc" optionsDDB optionsKDB ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r279974 - stable/10/sys/fs/fdescfs
Author: kib Date: Sat Mar 14 08:42:40 2015 New Revision: 279974 URL: https://svnweb.freebsd.org/changeset/base/279974 Log: MFC r279401: Some fixes for fdescfs lookup code Do not ever return doomed vnode from. lookup. Reuse the vn_vget_ino_gen() helper to handle parallel unmounts . Modified: stable/10/sys/fs/fdescfs/fdesc_vnops.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/fs/fdescfs/fdesc_vnops.c == --- stable/10/sys/fs/fdescfs/fdesc_vnops.c Sat Mar 14 08:29:03 2015 (r279973) +++ stable/10/sys/fs/fdescfs/fdesc_vnops.c Sat Mar 14 08:42:40 2015 (r279974) @@ -247,6 +247,28 @@ loop: return (0); } +struct fdesc_get_ino_args { + fdntype ftype; + unsigned fd_fd; + int ix; + struct file *fp; + struct thread *td; +}; + +static int +fdesc_get_ino_alloc(struct mount *mp, void *arg, int lkflags, +struct vnode **rvp) +{ + struct fdesc_get_ino_args *a; + int error; + + a = arg; + error = fdesc_allocvp(a->ftype, a->fd_fd, a->ix, mp, rvp); + fdrop(a->fp, a->td); + return (error); +} + + /* * vp is the current namei directory * ndp is the name to locate in that directory... @@ -265,6 +287,7 @@ fdesc_lookup(ap) char *pname = cnp->cn_nameptr; struct thread *td = cnp->cn_thread; struct file *fp; + struct fdesc_get_ino_args arg; int nlen = cnp->cn_namelen; u_int fd, fd1; int error; @@ -326,6 +349,8 @@ fdesc_lookup(ap) vn_lock(dvp, LK_RETRY | LK_EXCLUSIVE); vdrop(dvp); fvp = dvp; + if ((dvp->v_iflag & VI_DOOMED) != 0) + error = ENOENT; } else { /* * Unlock our root node (dvp) when doing this, since we might @@ -335,16 +360,13 @@ fdesc_lookup(ap) * opposite lock order. Vhold the root vnode first so we don't * lose it. */ - vhold(dvp); - VOP_UNLOCK(dvp, 0); - error = fdesc_allocvp(Fdesc, fd, FD_DESC + fd, dvp->v_mount, - &fvp); - fdrop(fp, td); - /* -* The root vnode must be locked last to prevent deadlock condition. -*/ - vn_lock(dvp, LK_RETRY | LK_EXCLUSIVE); - vdrop(dvp); + arg.ftype = Fdesc; + arg.fd_fd = fd; + arg.ix = FD_DESC + fd; + arg.fp = fp; + arg.td = td; + error = vn_vget_ino_gen(dvp, fdesc_get_ino_alloc, &arg, + LK_EXCLUSIVE, &fvp); } if (error) ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r279975 - head/usr.sbin/bhyve
Author: mav Date: Sat Mar 14 08:45:54 2015 New Revision: 279975 URL: https://svnweb.freebsd.org/changeset/base/279975 Log: Improve NCQ errors reporting for virtual AHCI disks. While this implementation is still not perfect, previous was just broken. MFC after:2 weeks Modified: head/usr.sbin/bhyve/pci_ahci.c Modified: head/usr.sbin/bhyve/pci_ahci.c == --- head/usr.sbin/bhyve/pci_ahci.c Sat Mar 14 08:42:40 2015 (r279974) +++ head/usr.sbin/bhyve/pci_ahci.c Sat Mar 14 08:45:54 2015 (r279975) @@ -134,6 +134,7 @@ struct ahci_port { int reset; int mult_sectors; uint8_t xfermode; + uint8_t err_cfis[20]; uint8_t sense_key; uint8_t asc; uint32_t pending; @@ -299,18 +300,27 @@ ahci_write_fis_piosetup(struct ahci_port } static void -ahci_write_fis_sdb(struct ahci_port *p, int slot, uint32_t tfd) +ahci_write_fis_sdb(struct ahci_port *p, int slot, uint8_t *cfis, uint32_t tfd) { uint8_t fis[8]; uint8_t error; error = (tfd >> 8) & 0xff; memset(fis, 0, sizeof(fis)); - fis[0] = error; + fis[0] = FIS_TYPE_SETDEVBITS; + fis[1] = (1 << 6); fis[2] = tfd & 0x77; - *(uint32_t *)(fis + 4) = (1 << slot); - if (fis[2] & ATA_S_ERROR) + fis[3] = error; + if (fis[2] & ATA_S_ERROR) { p->is |= AHCI_P_IX_TFE; + p->err_cfis[0] = slot; + p->err_cfis[2] = tfd & 0x77; + p->err_cfis[3] = error; + memcpy(&p->err_cfis[4], cfis + 4, 16); + } else { + *(uint32_t *)(fis + 4) = (1 << slot); + p->sact &= ~(1 << slot); + } p->tfd = tfd; ahci_write_fis(p, FIS_TYPE_SETDEVBITS, fis); } @@ -337,9 +347,13 @@ ahci_write_fis_d2h(struct ahci_port *p, fis[11] = cfis[11]; fis[12] = cfis[12]; fis[13] = cfis[13]; - if (fis[2] & ATA_S_ERROR) + if (fis[2] & ATA_S_ERROR) { p->is |= AHCI_P_IX_TFE; - else + p->err_cfis[0] = 0x80; + p->err_cfis[2] = tfd & 0xff; + p->err_cfis[3] = error; + memcpy(&p->err_cfis[4], cfis + 4, 16); + } else p->ci &= ~(1 << slot); p->tfd = tfd; ahci_write_fis(p, FIS_TYPE_REGD2H, fis); @@ -774,6 +788,29 @@ write_prdt(struct ahci_port *p, int slot } static void +ahci_handle_read_log(struct ahci_port *p, int slot, uint8_t *cfis) +{ + struct ahci_cmd_hdr *hdr; + uint8_t buf[512]; + + hdr = (struct ahci_cmd_hdr *)(p->cmd_lst + slot * AHCI_CL_SIZE); + if (p->atapi || hdr->prdtl == 0 || cfis[4] != 0x10 || + cfis[5] != 0 || cfis[9] != 0 || cfis[12] != 1 || cfis[13] != 0) { + ahci_write_fis_d2h(p, slot, cfis, + (ATA_E_ABORT << 8) | ATA_S_READY | ATA_S_ERROR); + return; + } + + memset(buf, 0, sizeof(buf)); + memcpy(buf, p->err_cfis, sizeof(p->err_cfis)); + + if (cfis[2] == ATA_READ_LOG_EXT) + ahci_write_fis_piosetup(p); + write_prdt(p, slot, cfis, (void *)buf, sizeof(buf)); + ahci_write_fis_d2h(p, slot, cfis, ATA_S_DSC | ATA_S_READY); +} + +static void handle_identify(struct ahci_port *p, int slot, uint8_t *cfis) { struct ahci_cmd_hdr *hdr; @@ -839,7 +876,7 @@ handle_identify(struct ahci_port *p, int buf[85] = (ATA_SUPPORT_POWERMGT | ATA_SUPPORT_WRITECACHE| ATA_SUPPORT_LOOKAHEAD | ATA_SUPPORT_NOP); buf[86] = (ATA_SUPPORT_ADDRESS48 | ATA_SUPPORT_FLUSHCACHE | - ATA_SUPPORT_FLUSHCACHE48); + ATA_SUPPORT_FLUSHCACHE48 | 1 << 15); buf[87] = (1 << 14); buf[88] = 0x7f; if (p->xfermode & ATA_UDMA0) @@ -866,6 +903,8 @@ handle_identify(struct ahci_port *p, int buf[117] = sectsz / 2; buf[118] = ((sectsz / 2) >> 16); } + buf[119] = (ATA_SUPPORT_RWLOGDMAEXT | 1 << 14); + buf[120] = (ATA_SUPPORT_RWLOGDMAEXT | 1 << 14); buf[222] = 0x1020; ahci_write_fis_piosetup(p); write_prdt(p, slot, cfis, (void *)buf, sizeof(buf)); @@ -1522,6 +1561,10 @@ ahci_handle_cmd(struct ahci_port *p, int ahci_write_fis_d2h(p, slot, cfis, (ATA_E_ABORT << 8) | ATA_S_READY | ATA_S_ERROR); break; + case ATA_READ_LOG_EXT: + case ATA_READ_LOG_DMA_EXT: + ahci_handle_read_log(p, slot, cfis); + break; case ATA_STANDBY_CMD: break; case ATA_NOP: @@ -1684,10 +1727,9 @@ ata_ioreq_cb(struct blockif_req *br, int tfd = (ATA_E_ABORT << 8) | ATA_S_READY | ATA_S_ERROR; } - if (ncq) { -
svn commit: r279976 - head/usr.sbin/bhyve
Author: mav Date: Sat Mar 14 09:46:43 2015 New Revision: 279976 URL: https://svnweb.freebsd.org/changeset/base/279976 Log: Add support for NCQ variant of DSM TRIM for virtual AHCI disks. The code is not really tested yet due to lack of initiator support. Requested by: imp MFC after:2 weeks Modified: head/usr.sbin/bhyve/pci_ahci.c Modified: head/usr.sbin/bhyve/pci_ahci.c == --- head/usr.sbin/bhyve/pci_ahci.c Sat Mar 14 08:45:54 2015 (r279975) +++ head/usr.sbin/bhyve/pci_ahci.c Sat Mar 14 09:46:43 2015 (r279976) @@ -703,8 +703,13 @@ ahci_handle_dsm_trim(struct ahci_port *p int err; uint8_t buf[512]; - len = (uint16_t)cfis[13] << 8 | cfis[12]; - len *= 512; + if (cfis[2] == ATA_DATA_SET_MANAGEMENT) { + len = (uint16_t)cfis[13] << 8 | cfis[12]; + len *= 512; + } else { /* ATA_SEND_FPDMA_QUEUED */ + len = (uint16_t)cfis[11] << 8 | cfis[3]; + len *= 512; + } read_prdt(p, slot, cfis, buf, sizeof(buf)); next: @@ -866,6 +871,8 @@ handle_identify(struct ahci_port *p, int buf[75] = 31; buf[76] = (ATA_SATA_GEN1 | ATA_SATA_GEN2 | ATA_SATA_GEN3 | ATA_SUPPORT_NCQ); + buf[77] = (ATA_SUPPORT_RCVSND_FPDMA_QUEUED | + (p->ssts & ATA_SS_SPD_MASK) >> 3); buf[80] = 0x1f0; buf[81] = 0x28; buf[82] = (ATA_SUPPORT_POWERMGT | ATA_SUPPORT_WRITECACHE| @@ -1561,6 +1568,16 @@ ahci_handle_cmd(struct ahci_port *p, int ahci_write_fis_d2h(p, slot, cfis, (ATA_E_ABORT << 8) | ATA_S_READY | ATA_S_ERROR); break; + case ATA_SEND_FPDMA_QUEUED: + if ((cfis[13] & 0x1f) == ATA_SFPDMA_DSM && + cfis[17] == 0 && cfis[16] == ATA_DSM_TRIM && + cfis[11] == 0 && cfis[13] == 1) { + ahci_handle_dsm_trim(p, slot, cfis, 0); + break; + } + ahci_write_fis_d2h(p, slot, cfis, + (ATA_E_ABORT << 8) | ATA_S_READY | ATA_S_ERROR); + break; case ATA_READ_LOG_EXT: case ATA_READ_LOG_DMA_EXT: ahci_handle_read_log(p, slot, cfis); @@ -1688,9 +1705,12 @@ ata_ioreq_cb(struct blockif_req *br, int hdr = (struct ahci_cmd_hdr *)(p->cmd_lst + slot * AHCI_CL_SIZE); if (cfis[2] == ATA_WRITE_FPDMA_QUEUED || - cfis[2] == ATA_READ_FPDMA_QUEUED) + cfis[2] == ATA_READ_FPDMA_QUEUED || + cfis[2] == ATA_SEND_FPDMA_QUEUED) ncq = 1; - if (cfis[2] == ATA_DATA_SET_MANAGEMENT) + if (cfis[2] == ATA_DATA_SET_MANAGEMENT || + (cfis[2] == ATA_SEND_FPDMA_QUEUED && +(cfis[13] & 0x1f) == ATA_SFPDMA_DSM)) dsm = 1; pthread_mutex_lock(&sc->mtx); ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r279977 - head/usr.sbin/bhyve
Author: mav Date: Sat Mar 14 10:38:25 2015 New Revision: 279977 URL: https://svnweb.freebsd.org/changeset/base/279977 Log: Fix NOP and IDLE commands for virtual AHCI disks. MFC after:2 weeks Modified: head/usr.sbin/bhyve/pci_ahci.c Modified: head/usr.sbin/bhyve/pci_ahci.c == --- head/usr.sbin/bhyve/pci_ahci.c Sat Mar 14 09:46:43 2015 (r279976) +++ head/usr.sbin/bhyve/pci_ahci.c Sat Mar 14 10:38:25 2015 (r279977) @@ -1582,10 +1582,13 @@ ahci_handle_cmd(struct ahci_port *p, int case ATA_READ_LOG_DMA_EXT: ahci_handle_read_log(p, slot, cfis); break; - case ATA_STANDBY_CMD: - break; case ATA_NOP: + ahci_write_fis_d2h(p, slot, cfis, + (ATA_E_ABORT << 8) | ATA_S_READY | ATA_S_ERROR); + break; + case ATA_STANDBY_CMD: case ATA_STANDBY_IMMEDIATE: + case ATA_IDLE_CMD: case ATA_IDLE_IMMEDIATE: case ATA_SLEEP: ahci_write_fis_d2h(p, slot, cfis, ATA_S_READY | ATA_S_DSC); ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r279978 - stable/10/sys/modules/drm2/i915kms
Author: kib Date: Sat Mar 14 11:36:47 2015 New Revision: 279978 URL: https://svnweb.freebsd.org/changeset/base/279978 Log: MFC r270571 (by dumbbell): drm/i915: Add opt_acpi.h and acpi_if.h to the source files Modified: stable/10/sys/modules/drm2/i915kms/Makefile Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/modules/drm2/i915kms/Makefile == --- stable/10/sys/modules/drm2/i915kms/Makefile Sat Mar 14 10:38:25 2015 (r279977) +++ stable/10/sys/modules/drm2/i915kms/Makefile Sat Mar 14 11:36:47 2015 (r279978) @@ -35,8 +35,18 @@ SRCS = \ SRCS += i915_ioc32.c .endif -SRCS += device_if.h fb_if.h bus_if.h pci_if.h iicbus_if.h iicbb_if.h \ -opt_drm.h opt_compat.h opt_syscons.h +SRCS += \ + opt_acpi.h \ + opt_compat.h\ + opt_drm.h \ + opt_syscons.h \ + acpi_if.h \ + bus_if.h\ + fb_if.h \ + device_if.h \ + iicbb_if.h \ + iicbus_if.h \ + pci_if.h .include ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r279979 - head/usr.sbin/bhyve
Author: mav Date: Sat Mar 14 12:18:26 2015 New Revision: 279979 URL: https://svnweb.freebsd.org/changeset/base/279979 Log: Slightly polish virtual AHCI CD reporting. MFC after:2 weeks Modified: head/usr.sbin/bhyve/pci_ahci.c Modified: head/usr.sbin/bhyve/pci_ahci.c == --- head/usr.sbin/bhyve/pci_ahci.c Sat Mar 14 11:36:47 2015 (r279978) +++ head/usr.sbin/bhyve/pci_ahci.c Sat Mar 14 12:18:26 2015 (r279979) @@ -86,6 +86,7 @@ enum sata_fis_type { #defineREAD_TOC0x43 #defineGET_EVENT_STATUS_NOTIFICATION 0x4A #defineMODE_SENSE_10 0x5A +#defineREPORT_LUNS 0xA0 #defineREAD_12 0xA8 #defineREAD_CD 0xBE @@ -873,7 +874,7 @@ handle_identify(struct ahci_port *p, int ATA_SUPPORT_NCQ); buf[77] = (ATA_SUPPORT_RCVSND_FPDMA_QUEUED | (p->ssts & ATA_SS_SPD_MASK) >> 3); - buf[80] = 0x1f0; + buf[80] = 0x3f0; buf[81] = 0x28; buf[82] = (ATA_SUPPORT_POWERMGT | ATA_SUPPORT_WRITECACHE| ATA_SUPPORT_LOOKAHEAD | ATA_SUPPORT_NOP); @@ -939,20 +940,28 @@ handle_atapi_identify(struct ahci_port * buf[53] = (1 << 2 | 1 << 1); buf[62] = 0x3f; buf[63] = 7; + if (p->xfermode & ATA_WDMA0) + buf[63] |= (1 << ((p->xfermode & 7) + 8)); buf[64] = 3; - buf[65] = 100; - buf[66] = 100; - buf[67] = 100; - buf[68] = 100; - buf[76] = (1 << 2 | 1 << 1); + buf[65] = 120; + buf[66] = 120; + buf[67] = 120; + buf[68] = 120; + buf[76] = (ATA_SATA_GEN1 | ATA_SATA_GEN2 | ATA_SATA_GEN3); + buf[77] = ((p->ssts & ATA_SS_SPD_MASK) >> 3); buf[78] = (1 << 5); - buf[80] = (0x1f << 4); - buf[82] = (1 << 4); + buf[80] = 0x3f0; + buf[82] = (ATA_SUPPORT_POWERMGT | ATA_SUPPORT_PACKET | + ATA_SUPPORT_RESET | ATA_SUPPORT_NOP); buf[83] = (1 << 14); buf[84] = (1 << 14); - buf[85] = (1 << 4); + buf[85] = (ATA_SUPPORT_POWERMGT | ATA_SUPPORT_PACKET | + ATA_SUPPORT_RESET | ATA_SUPPORT_NOP); buf[87] = (1 << 14); - buf[88] = (1 << 14 | 0x7f); + buf[88] = 0x7f; + if (p->xfermode & ATA_UDMA0) + buf[88] |= (1 << ((p->xfermode & 7) + 8)); + buf[222] = 0x1020; ahci_write_fis_piosetup(p); write_prdt(p, slot, cfis, (void *)buf, sizeof(buf)); ahci_write_fis_d2h(p, slot, cfis, ATA_S_DSC | ATA_S_READY); @@ -965,22 +974,41 @@ atapi_inquiry(struct ahci_port *p, int s uint8_t buf[36]; uint8_t *acmd; int len; + uint32_t tfd; acmd = cfis + 0x40; - buf[0] = 0x05; - buf[1] = 0x80; - buf[2] = 0x00; - buf[3] = 0x21; - buf[4] = 31; - buf[5] = 0; - buf[6] = 0; - buf[7] = 0; - atapi_string(buf + 8, "BHYVE", 8); - atapi_string(buf + 16, "BHYVE DVD-ROM", 16); - atapi_string(buf + 32, "001", 4); + if (acmd[1] & 1) { /* VPD */ + if (acmd[2] == 0) { /* Supported VPD pages */ + buf[0] = 0x05; + buf[1] = 0; + buf[2] = 0; + buf[3] = 1; + buf[4] = 0; + len = 4 + buf[3]; + } else { + p->sense_key = ATA_SENSE_ILLEGAL_REQUEST; + p->asc = 0x24; + tfd = (p->sense_key << 12) | ATA_S_READY | ATA_S_ERROR; + cfis[4] = (cfis[4] & ~7) | ATA_I_CMD | ATA_I_IN; + ahci_write_fis_d2h(p, slot, cfis, tfd); + return; + } + } else { + buf[0] = 0x05; + buf[1] = 0x80; + buf[2] = 0x00; + buf[3] = 0x21; + buf[4] = 31; + buf[5] = 0; + buf[6] = 0; + buf[7] = 0; + atapi_string(buf + 8, "BHYVE", 8); + atapi_string(buf + 16, "BHYVE DVD-ROM", 16); + atapi_string(buf + 32, "001", 4); + len = sizeof(buf); + } - len = sizeof(buf); if (len > acmd[4]) len = acmd[4]; cfis[4] = (cfis[4] & ~7) | ATA_I_CMD | ATA_I_IN; @@ -1184,6 +1212,19 @@ atapi_read_toc(struct ahci_port *p, int } static void +atapi_report_luns(struct ahci_port *p, int slot, ui
svn commit: r279980 - head/share/mk
Author: dim Date: Sat Mar 14 12:29:44 2015 New Revision: 279980 URL: https://svnweb.freebsd.org/changeset/base/279980 Log: Allow relative pathnames in SRCS, so as to enable building software which includes more than one file with the same name, in different directories. For example, setting: SRCS+=foo/foo.c bar/foo.c baz/foo.c will now create separate objdirs 'foo', 'bar' and 'baz' for each of the sources in the list, and use those objdirs for the corresponding object files. Reviewed by: brooks, imp MFC after:1 week Differential Revision: https://reviews.freebsd.org/D1984 Modified: head/share/mk/bsd.obj.mk head/share/mk/sys.mk Modified: head/share/mk/bsd.obj.mk == --- head/share/mk/bsd.obj.mkSat Mar 14 12:18:26 2015(r279979) +++ head/share/mk/bsd.obj.mkSat Mar 14 12:29:44 2015(r279980) @@ -89,6 +89,16 @@ obj: .PHONY fi; \ ${ECHO} "${CANONICALOBJDIR} created for ${.CURDIR}"; \ fi +.for dir in ${SRCS:H:O:u} + @if ! test -d ${CANONICALOBJDIR}/${dir}/; then \ + mkdir -p ${CANONICALOBJDIR}/${dir}; \ + if ! test -d ${CANONICALOBJDIR}/${dir}/; then \ + ${ECHO} "Unable to create ${CANONICALOBJDIR}/${dir}."; \ + exit 1; \ + fi; \ + ${ECHO} "${CANONICALOBJDIR}/${dir} created for ${.CURDIR}"; \ + fi +.endfor .endif .if !target(objlink) Modified: head/share/mk/sys.mk == --- head/share/mk/sys.mkSat Mar 14 12:18:26 2015(r279979) +++ head/share/mk/sys.mkSat Mar 14 12:29:44 2015(r279980) @@ -242,21 +242,21 @@ YFLAGS?= -d ${CTFCONVERT_CMD} .c.o: - ${CC} ${CFLAGS} -c ${.IMPSRC} + ${CC} ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET} ${CTFCONVERT_CMD} .cc .cpp .cxx .C: ${CXX} ${CXXFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET} .cc.o .cpp.o .cxx.o .C.o: - ${CXX} ${CXXFLAGS} -c ${.IMPSRC} + ${CXX} ${CXXFLAGS} -c ${.IMPSRC} -o ${.TARGET} .m.o: - ${OBJC} ${OBJCFLAGS} -c ${.IMPSRC} + ${OBJC} ${OBJCFLAGS} -c ${.IMPSRC} -o ${.TARGET} ${CTFCONVERT_CMD} .p.o: - ${PC} ${PFLAGS} -c ${.IMPSRC} + ${PC} ${PFLAGS} -c ${.IMPSRC} -o ${.TARGET} ${CTFCONVERT_CMD} .e .r .F .f: @@ -264,14 +264,15 @@ YFLAGS?= -d -o ${.TARGET} .e.o .r.o .F.o .f.o: - ${FC} ${RFLAGS} ${EFLAGS} ${FFLAGS} -c ${.IMPSRC} + ${FC} ${RFLAGS} ${EFLAGS} ${FFLAGS} -c ${.IMPSRC} -o ${.TARGET} .S.o: - ${CC} ${CFLAGS} ${ACFLAGS} -c ${.IMPSRC} + ${CC} ${CFLAGS} ${ACFLAGS} -c ${.IMPSRC} -o ${.TARGET} ${CTFCONVERT_CMD} .asm.o: - ${CC} -x assembler-with-cpp ${CFLAGS} ${ACFLAGS} -c ${.IMPSRC} + ${CC} -x assembler-with-cpp ${CFLAGS} ${ACFLAGS} -c ${.IMPSRC} \ + -o ${.TARGET} ${CTFCONVERT_CMD} .s.o: ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r279981 - in head: contrib/compiler-rt/lib/builtins lib/libcompiler_rt
Author: dim Date: Sat Mar 14 12:40:19 2015 New Revision: 279981 URL: https://svnweb.freebsd.org/changeset/base/279981 Log: Pull in r231965 from upstream compiler-rt trunk (by Jörg Sonnenberger): Refactor float to integer conversion to share the same code. 80bit Intel/PPC long double is excluded due to lacking support for the abstraction. Consistently provide saturation logic. Extend to long double on 128bit IEEE extended platforms. Initial patch with test cases from GuanHong Liu. Reviewed by Steve Canon. Differential Revision: http://reviews.llvm.org/D2804 Pull in r232107 from upstream compiler-rt trunk (by Ed Maste): Use signed int implementation for __fixint Requested by: emaste Added: head/contrib/compiler-rt/lib/builtins/fixtfdi.c (contents, props changed) head/contrib/compiler-rt/lib/builtins/fixtfsi.c (contents, props changed) head/contrib/compiler-rt/lib/builtins/fixtfti.c (contents, props changed) head/contrib/compiler-rt/lib/builtins/fixunstfdi.c (contents, props changed) head/contrib/compiler-rt/lib/builtins/fixunstfsi.c (contents, props changed) head/contrib/compiler-rt/lib/builtins/fixunstfti.c (contents, props changed) head/contrib/compiler-rt/lib/builtins/fp_fixint_impl.inc (contents, props changed) head/contrib/compiler-rt/lib/builtins/fp_fixuint_impl.inc (contents, props changed) Modified: head/contrib/compiler-rt/lib/builtins/fixdfdi.c head/contrib/compiler-rt/lib/builtins/fixdfsi.c head/contrib/compiler-rt/lib/builtins/fixdfti.c head/contrib/compiler-rt/lib/builtins/fixsfdi.c head/contrib/compiler-rt/lib/builtins/fixsfsi.c head/contrib/compiler-rt/lib/builtins/fixsfti.c head/contrib/compiler-rt/lib/builtins/fixunsdfdi.c head/contrib/compiler-rt/lib/builtins/fixunsdfsi.c head/contrib/compiler-rt/lib/builtins/fixunsdfti.c head/contrib/compiler-rt/lib/builtins/fixunssfdi.c head/contrib/compiler-rt/lib/builtins/fixunssfsi.c head/contrib/compiler-rt/lib/builtins/fixunssfti.c head/contrib/compiler-rt/lib/builtins/fixunsxfdi.c head/contrib/compiler-rt/lib/builtins/fixunsxfsi.c head/contrib/compiler-rt/lib/builtins/fixunsxfti.c head/contrib/compiler-rt/lib/builtins/fixxfdi.c head/contrib/compiler-rt/lib/builtins/fixxfti.c head/lib/libcompiler_rt/Makefile Modified: head/contrib/compiler-rt/lib/builtins/fixdfdi.c == --- head/contrib/compiler-rt/lib/builtins/fixdfdi.c Sat Mar 14 12:29:44 2015(r279980) +++ head/contrib/compiler-rt/lib/builtins/fixdfdi.c Sat Mar 14 12:40:19 2015(r279981) @@ -6,40 +6,17 @@ * Source Licenses. See LICENSE.TXT for details. * * ===--=== - * - * This file implements __fixdfdi for the compiler_rt library. - * - * ===--=== */ -#include "int_lib.h" - -/* Returns: convert a to a signed long long, rounding toward zero. */ - -/* Assumption: double is a IEEE 64 bit floating point type - *su_int is a 32 bit integral type - *value in double is representable in di_int (no range checking performed) - */ - -/* seee | */ - +#define DOUBLE_PRECISION +#include "fp_lib.h" ARM_EABI_FNALIAS(d2lz, fixdfdi) +typedef di_int fixint_t; +typedef du_int fixuint_t; +#include "fp_fixint_impl.inc" + COMPILER_RT_ABI di_int -__fixdfdi(double a) -{ -double_bits fb; -fb.f = a; -int e = ((fb.u.s.high & 0x7FF0) >> 20) - 1023; -if (e < 0) -return 0; -di_int s = (si_int)(fb.u.s.high & 0x8000) >> 31; -dwords r; -r.s.high = (fb.u.s.high & 0x000F) | 0x0010; -r.s.low = fb.u.s.low; -if (e > 52) -r.all <<= (e - 52); -else -r.all >>= (52 - e); -return (r.all ^ s) - s; -} +__fixdfdi(fp_t a) { +return __fixint(a); +} Modified: head/contrib/compiler-rt/lib/builtins/fixdfsi.c == --- head/contrib/compiler-rt/lib/builtins/fixdfsi.c Sat Mar 14 12:29:44 2015(r279980) +++ head/contrib/compiler-rt/lib/builtins/fixdfsi.c Sat Mar 14 12:40:19 2015(r279981) @@ -1,50 +1,22 @@ -//===-- lib/fixdfsi.c - Double-precision -> integer conversion *- C -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===--===// -// -// This file implements double-precision to integer conversion for the -// compiler-rt library. No range checking is performed; the behavior of this -// conversion is undefined for out of range values in the C standard. -// -//===--
svn commit: r279982 - head/sys/vm
Author: ian Date: Sat Mar 14 13:00:37 2015 New Revision: 279982 URL: https://svnweb.freebsd.org/changeset/base/279982 Log: Revert r279932; this is going to be fixed in the sbuf code instead. PR: 195668 Modified: head/sys/vm/vm_phys.c head/sys/vm/vm_reserv.c Modified: head/sys/vm/vm_phys.c == --- head/sys/vm/vm_phys.c Sat Mar 14 12:40:19 2015(r279981) +++ head/sys/vm/vm_phys.c Sat Mar 14 13:00:37 2015(r279982) @@ -263,7 +263,6 @@ sysctl_vm_phys_free(SYSCTL_HANDLER_ARGS) } } } - sbuf_putc(&sbuf, 0); /* nullterm */ error = sbuf_finish(&sbuf); sbuf_delete(&sbuf); return (error); @@ -293,7 +292,6 @@ sysctl_vm_phys_segs(SYSCTL_HANDLER_ARGS) sbuf_printf(&sbuf, "domain:%d\n", seg->domain); sbuf_printf(&sbuf, "free list: %p\n", seg->free_queues); } - sbuf_putc(&sbuf, 0); /* nullterm */ error = sbuf_finish(&sbuf); sbuf_delete(&sbuf); return (error); Modified: head/sys/vm/vm_reserv.c == --- head/sys/vm/vm_reserv.c Sat Mar 14 12:40:19 2015(r279981) +++ head/sys/vm/vm_reserv.c Sat Mar 14 13:00:37 2015(r279982) @@ -261,7 +261,6 @@ sysctl_vm_reserv_partpopq(SYSCTL_HANDLER sbuf_printf(&sbuf, "%5d: %6dK, %6d\n", level, unused_pages * ((int)PAGE_SIZE / 1024), counter); } - sbuf_putc(&sbuf, 0); /* nullterm */ error = sbuf_finish(&sbuf); sbuf_delete(&sbuf); return (error); ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r279983 - head/sys/dev/wbwd
Author: ian Date: Sat Mar 14 13:02:08 2015 New Revision: 279983 URL: https://svnweb.freebsd.org/changeset/base/279983 Log: Revert r279933; this is going to be fixed in sbuf instead. PR: 195668 Modified: head/sys/dev/wbwd/wbwd.c Modified: head/sys/dev/wbwd/wbwd.c == --- head/sys/dev/wbwd/wbwd.cSat Mar 14 13:00:37 2015(r279982) +++ head/sys/dev/wbwd/wbwd.cSat Mar 14 13:02:08 2015(r279983) @@ -252,7 +252,6 @@ sysctl_wb_debug(SYSCTL_HANDLER_ARGS) sbuf_printf(&sb, "CRF6 0x%02x ", sc->reg_timeout); sbuf_printf(&sb, "CRF7 0x%02x", sc->reg_2); - sbuf_putc(&sb, 0); /* nullterm */ error = sbuf_finish(&sb); sbuf_delete(&sb); return (error); ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r279984 - head/sys/dev/cxgbe
Author: ian Date: Sat Mar 14 13:04:39 2015 New Revision: 279984 URL: https://svnweb.freebsd.org/changeset/base/279984 Log: Revert r279934, r279938; this is going to be fixed in sbuf instead. PR: 195668 Modified: head/sys/dev/cxgbe/t4_l2t.c head/sys/dev/cxgbe/t4_main.c Modified: head/sys/dev/cxgbe/t4_l2t.c == --- head/sys/dev/cxgbe/t4_l2t.c Sat Mar 14 13:02:08 2015(r279983) +++ head/sys/dev/cxgbe/t4_l2t.c Sat Mar 14 13:04:39 2015(r279984) @@ -321,7 +321,6 @@ skip: mtx_unlock(&e->lock); } - sbuf_putc(sb, 0); /* nullterm */ rc = sbuf_finish(sb); sbuf_delete(sb); Modified: head/sys/dev/cxgbe/t4_main.c == --- head/sys/dev/cxgbe/t4_main.cSat Mar 14 13:02:08 2015 (r279983) +++ head/sys/dev/cxgbe/t4_main.cSat Mar 14 13:04:39 2015 (r279984) @@ -5087,7 +5087,6 @@ sysctl_int_array(SYSCTL_HANDLER_ARGS) for (i = arg1; arg2; arg2 -= sizeof(int), i++) sbuf_printf(&sb, "%d ", *i); sbuf_trim(&sb); - sbuf_putc(&sb, 0); /* nullterm */ sbuf_finish(&sb); rc = sysctl_handle_string(oidp, sbuf_data(&sb), sbuf_len(&sb), req); sbuf_delete(&sb); ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r279986 - head/sbin/restore
Author: jilles Date: Sat Mar 14 13:45:43 2015 New Revision: 279986 URL: https://svnweb.freebsd.org/changeset/base/279986 Log: restore: Preserve timestamps to the nanosecond. The restore utility already knows the full-resolution timestamps, so the only thing to do is to stop converting the timespecs to timevals and use futimens() and utimensat(). Differential Revision:https://reviews.freebsd.org/D2020 Reviewed by: jhb Modified: head/sbin/restore/dirs.c head/sbin/restore/tape.c Modified: head/sbin/restore/dirs.c == --- head/sbin/restore/dirs.cSat Mar 14 13:08:00 2015(r279985) +++ head/sbin/restore/dirs.cSat Mar 14 13:45:43 2015(r279986) @@ -80,8 +80,8 @@ static struct inotab *inotab[HASHSIZE]; */ struct modeinfo { ino_t ino; - struct timeval ctimep[2]; - struct timeval mtimep[2]; + struct timespec ctimep[2]; + struct timespec mtimep[2]; mode_t mode; uid_t uid; gid_t gid; @@ -656,8 +656,8 @@ setdirmodes(int flags) else (void) chown(cp, node.uid, node.gid); (void) chmod(cp, node.mode); - utimes(cp, node.ctimep); - utimes(cp, node.mtimep); + utimensat(AT_FDCWD, cp, node.ctimep, 0); + utimensat(AT_FDCWD, cp, node.mtimep, 0); (void) chflags(cp, node.flags); } ep->e_flags &= ~NEW; @@ -746,13 +746,13 @@ allocinotab(struct context *ctxp, long s return (itp); node.ino = ctxp->ino; node.mtimep[0].tv_sec = ctxp->atime_sec; - node.mtimep[0].tv_usec = ctxp->atime_nsec / 1000; + node.mtimep[0].tv_nsec = ctxp->atime_nsec; node.mtimep[1].tv_sec = ctxp->mtime_sec; - node.mtimep[1].tv_usec = ctxp->mtime_nsec / 1000; + node.mtimep[1].tv_nsec = ctxp->mtime_nsec; node.ctimep[0].tv_sec = ctxp->atime_sec; - node.ctimep[0].tv_usec = ctxp->atime_nsec / 1000; + node.ctimep[0].tv_nsec = ctxp->atime_nsec; node.ctimep[1].tv_sec = ctxp->birthtime_sec; - node.ctimep[1].tv_usec = ctxp->birthtime_nsec / 1000; + node.ctimep[1].tv_nsec = ctxp->birthtime_nsec; node.extsize = ctxp->extsize; node.mode = ctxp->mode; node.flags = ctxp->file_flags; Modified: head/sbin/restore/tape.c == --- head/sbin/restore/tape.cSat Mar 14 13:08:00 2015(r279985) +++ head/sbin/restore/tape.cSat Mar 14 13:45:43 2015(r279986) @@ -569,20 +569,20 @@ extractfile(char *name) gid_t gid; mode_t mode; int extsize; - struct timeval mtimep[2], ctimep[2]; + struct timespec mtimep[2], ctimep[2]; struct entry *ep; char *buf; curfile.name = name; curfile.action = USING; mtimep[0].tv_sec = curfile.atime_sec; - mtimep[0].tv_usec = curfile.atime_nsec / 1000; + mtimep[0].tv_nsec = curfile.atime_nsec; mtimep[1].tv_sec = curfile.mtime_sec; - mtimep[1].tv_usec = curfile.mtime_nsec / 1000; + mtimep[1].tv_nsec = curfile.mtime_nsec; ctimep[0].tv_sec = curfile.atime_sec; - ctimep[0].tv_usec = curfile.atime_nsec / 1000; + ctimep[0].tv_nsec = curfile.atime_nsec; ctimep[1].tv_sec = curfile.birthtime_sec; - ctimep[1].tv_usec = curfile.birthtime_nsec / 1000; + ctimep[1].tv_nsec = curfile.birthtime_nsec; extsize = curfile.extsize; uid = getuid(); if (uid == 0) @@ -628,8 +628,10 @@ extractfile(char *name) set_extattr_link(name, buf, extsize); (void) lchown(name, uid, gid); (void) lchmod(name, mode); - (void) lutimes(name, ctimep); - (void) lutimes(name, mtimep); + (void) utimensat(AT_FDCWD, name, ctimep, + AT_SYMLINK_NOFOLLOW); + (void) utimensat(AT_FDCWD, name, mtimep, + AT_SYMLINK_NOFOLLOW); (void) lchflags(name, flags); return (GOOD); } @@ -658,8 +660,8 @@ extractfile(char *name) } (void) chown(name, uid, gid); (void) chmod(name, mode); - (void) utimes(name, ctimep); - (void) utimes(name, mtimep); + (void) utimensat(AT_FDCWD, name, ctimep, 0); + (void) utimensat(AT_FDCWD, name, mtimep, 0); (void) chflags(name, flags); return (GOOD); @@ -688,8 +690,8 @@ extractfile(char *name) } (void) chown(name, uid, gid); (void) chmod(name, mod
svn commit: r279987 - head/usr.sbin/bhyve
Author: mav Date: Sat Mar 14 14:06:37 2015 New Revision: 279987 URL: https://svnweb.freebsd.org/changeset/base/279987 Log: Add checksums to identify data and NCQ command error log. MFC after:2 weeks Modified: head/usr.sbin/bhyve/pci_ahci.c Modified: head/usr.sbin/bhyve/pci_ahci.c == --- head/usr.sbin/bhyve/pci_ahci.c Sat Mar 14 13:45:43 2015 (r279986) +++ head/usr.sbin/bhyve/pci_ahci.c Sat Mar 14 14:06:37 2015 (r279987) @@ -794,6 +794,17 @@ write_prdt(struct ahci_port *p, int slot } static void +ahci_checksum(uint8_t *buf, int size) +{ + int i; + uint8_t sum = 0; + + for (i = 0; i < size - 1; i++) + sum += buf[i]; + buf[size - 1] = 0x100 - sum; +} + +static void ahci_handle_read_log(struct ahci_port *p, int slot, uint8_t *cfis) { struct ahci_cmd_hdr *hdr; @@ -809,6 +820,7 @@ ahci_handle_read_log(struct ahci_port *p memset(buf, 0, sizeof(buf)); memcpy(buf, p->err_cfis, sizeof(p->err_cfis)); + ahci_checksum(buf, sizeof(buf)); if (cfis[2] == ATA_READ_LOG_EXT) ahci_write_fis_piosetup(p); @@ -914,6 +926,8 @@ handle_identify(struct ahci_port *p, int buf[119] = (ATA_SUPPORT_RWLOGDMAEXT | 1 << 14); buf[120] = (ATA_SUPPORT_RWLOGDMAEXT | 1 << 14); buf[222] = 0x1020; + buf[255] = 0x00a5; + ahci_checksum((uint8_t *)buf, sizeof(buf)); ahci_write_fis_piosetup(p); write_prdt(p, slot, cfis, (void *)buf, sizeof(buf)); ahci_write_fis_d2h(p, slot, cfis, ATA_S_DSC | ATA_S_READY); @@ -962,6 +976,8 @@ handle_atapi_identify(struct ahci_port * if (p->xfermode & ATA_UDMA0) buf[88] |= (1 << ((p->xfermode & 7) + 8)); buf[222] = 0x1020; + buf[255] = 0x00a5; + ahci_checksum((uint8_t *)buf, sizeof(buf)); ahci_write_fis_piosetup(p); write_prdt(p, slot, cfis, (void *)buf, sizeof(buf)); ahci_write_fis_d2h(p, slot, cfis, ATA_S_DSC | ATA_S_READY); ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r279988 - stable/10/sys/netinet
Author: ae Date: Sat Mar 14 14:35:07 2015 New Revision: 279988 URL: https://svnweb.freebsd.org/changeset/base/279988 Log: MFC r279730: lla_lookup() can directly call llentry_free() for static entries and the last one requires to hold afdata's wlock. PR: 197096 Modified: stable/10/sys/netinet/if_ether.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/netinet/if_ether.c == --- stable/10/sys/netinet/if_ether.cSat Mar 14 14:06:37 2015 (r279987) +++ stable/10/sys/netinet/if_ether.cSat Mar 14 14:35:07 2015 (r279988) @@ -153,10 +153,10 @@ arp_ifscrub(struct ifnet *ifp, uint32_t addr4.sin_len= sizeof(addr4); addr4.sin_family = AF_INET; addr4.sin_addr.s_addr = addr; - IF_AFDATA_RLOCK(ifp); + IF_AFDATA_WLOCK(ifp); lla_lookup(LLTABLE(ifp), (LLE_DELETE | LLE_IFADDR), (struct sockaddr *)&addr4); - IF_AFDATA_RUNLOCK(ifp); + IF_AFDATA_WUNLOCK(ifp); } #endif ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r279989 - stable/10/sys/netipsec
Author: ae Date: Sat Mar 14 14:38:25 2015 New Revision: 279989 URL: https://svnweb.freebsd.org/changeset/base/279989 Log: MFC r279735: Remove extra '&'. sin6 is already a pointer. PR: 195011 Modified: stable/10/sys/netipsec/key.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/netipsec/key.c == --- stable/10/sys/netipsec/key.cSat Mar 14 14:35:07 2015 (r279988) +++ stable/10/sys/netipsec/key.cSat Mar 14 14:38:25 2015 (r279989) @@ -3940,7 +3940,7 @@ key_ismyaddr6(sin6) IN6_IFADDR_RLOCK(); TAILQ_FOREACH(ia, &V_in6_ifaddrhead, ia_link) { - if (key_sockaddrcmp((struct sockaddr *)&sin6, + if (key_sockaddrcmp((struct sockaddr *)sin6, (struct sockaddr *)&ia->ia_addr, 0) == 0) { IN6_IFADDR_RUNLOCK(); return 1; ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r279990 - stable/9/sys/netinet
Author: ae Date: Sat Mar 14 14:44:03 2015 New Revision: 279990 URL: https://svnweb.freebsd.org/changeset/base/279990 Log: MFC r279730: lla_lookup() can directly call llentry_free() for static entries and the last one requires to hold afdata's wlock. PR: 197096 Modified: stable/9/sys/netinet/if_ether.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/netinet/if_ether.c == --- stable/9/sys/netinet/if_ether.c Sat Mar 14 14:38:25 2015 (r279989) +++ stable/9/sys/netinet/if_ether.c Sat Mar 14 14:44:03 2015 (r279990) @@ -154,10 +154,10 @@ arp_ifscrub(struct ifnet *ifp, uint32_t addr4.sin_len= sizeof(addr4); addr4.sin_family = AF_INET; addr4.sin_addr.s_addr = addr; - IF_AFDATA_RLOCK(ifp); + IF_AFDATA_WLOCK(ifp); lla_lookup(LLTABLE(ifp), (LLE_DELETE | LLE_IFADDR), (struct sockaddr *)&addr4); - IF_AFDATA_RUNLOCK(ifp); + IF_AFDATA_WUNLOCK(ifp); } #endif ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r279991 - stable/9/sys/netipsec
Author: ae Date: Sat Mar 14 14:46:10 2015 New Revision: 279991 URL: https://svnweb.freebsd.org/changeset/base/279991 Log: MFC r279735: Remove extra '&'. sin6 is already a pointer. PR: 195011 Modified: stable/9/sys/netipsec/key.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/netipsec/key.c == --- stable/9/sys/netipsec/key.c Sat Mar 14 14:44:03 2015(r279990) +++ stable/9/sys/netipsec/key.c Sat Mar 14 14:46:10 2015(r279991) @@ -3965,7 +3965,7 @@ key_ismyaddr6(sin6) IN6_IFADDR_RLOCK(); TAILQ_FOREACH(ia, &V_in6_ifaddrhead, ia_link) { - if (key_sockaddrcmp((struct sockaddr *)&sin6, + if (key_sockaddrcmp((struct sockaddr *)sin6, (struct sockaddr *)&ia->ia_addr, 0) == 0) { IN6_IFADDR_RUNLOCK(); return 1; ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r279992 - in head: share/man/man9 sys/kern sys/sys
Author: ian Date: Sat Mar 14 16:02:11 2015 New Revision: 279992 URL: https://svnweb.freebsd.org/changeset/base/279992 Log: Add a new flag, SBUF_INCLUDENUL, and new get/set/clear functions for flags. The SBUF_INCLUDENUL flag causes the nulterm byte at the end of the string to be counted in the length of the data. If copying the data using the sbuf_data() and sbuf_len() functions, or if writing it automatically with a drain function, the net effect is that the nulterm byte is copied along with the rest of the data. Modified: head/share/man/man9/sbuf.9 head/sys/kern/subr_sbuf.c head/sys/sys/sbuf.h Modified: head/share/man/man9/sbuf.9 == --- head/share/man/man9/sbuf.9 Sat Mar 14 14:46:10 2015(r279991) +++ head/share/man/man9/sbuf.9 Sat Mar 14 16:02:11 2015(r279992) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd April 11, 2013 +.Dd March 14, 2015 .Dt SBUF 9 .Os .Sh NAME @@ -34,6 +34,9 @@ .Nm sbuf_new_auto , .Nm sbuf_new_for_sysctl , .Nm sbuf_clear , +.Nm sbuf_get_flags , +.Nm sbuf_set_flags , +.Nm sbuf_clear_flags , .Nm sbuf_setpos , .Nm sbuf_bcat , .Nm sbuf_bcopyin , @@ -67,6 +70,12 @@ .Ft void .Fn sbuf_clear "struct sbuf *s" .Ft int +.Fn sbuf_get_flags "struct sbuf *s" +.Ft void +.Fn sbuf_set_flags "struct sbuf *s" "int flags" +.Ft void +.Fn sbuf_clear_flags "struct sbuf *s" "int flags" +.Ft int .Fn sbuf_setpos "struct sbuf *s" "int pos" .Ft int .Fn sbuf_bcat "struct sbuf *s" "const void *buf" "size_t len" @@ -159,6 +168,8 @@ Attempting to extend the sbuf beyond thi .It Dv SBUF_AUTOEXTEND This indicates that the storage buffer may be extended as necessary, so long as resources allow, to hold additional data. +.It Dv SBUF_INCLUDENUL +This causes the final nulterm byte to be counted in the length of the data. .El .Pp Note that if @@ -211,6 +222,18 @@ function invalidates the contents of the and resets its position to zero. .Pp The +.Fn sbuf_get_flags +function returns the current user flags. +The +.Fn sbuf_set_flags +and +.Fn sbuf_get_flags +functions set or clear one or more user flags, respectively. +The user flags are described under the +.Fn sbuf_new +function. +.Pp +The .Fn sbuf_setpos function sets the .Fa sbuf Ns 's Modified: head/sys/kern/subr_sbuf.c == --- head/sys/kern/subr_sbuf.c Sat Mar 14 14:46:10 2015(r279991) +++ head/sys/kern/subr_sbuf.c Sat Mar 14 16:02:11 2015(r279992) @@ -262,6 +262,28 @@ sbuf_uionew(struct sbuf *s, struct uio * } #endif +int +sbuf_get_flags(struct sbuf *s) +{ + + return (s->s_flags & SBUF_USRFLAGMSK); +} + +void +sbuf_clear_flags(struct sbuf *s, int flags) +{ + + s->s_flags &= ~(flags & SBUF_USRFLAGMSK); +} + +void +sbuf_set_flags(struct sbuf *s, int flags) +{ + + + s->s_flags |= (flags & SBUF_USRFLAGMSK); +} + /* * Clear an sbuf and reset its position. */ @@ -697,11 +719,13 @@ sbuf_finish(struct sbuf *s) assert_sbuf_integrity(s); assert_sbuf_state(s, 0); + s->s_buf[s->s_len] = '\0'; + if (s->s_flags & SBUF_INCLUDENUL) + s->s_len++; if (s->s_drain_func != NULL) { while (s->s_len > 0 && s->s_error == 0) s->s_error = sbuf_drain(s); } - s->s_buf[s->s_len] = '\0'; SBUF_SETFLAG(s, SBUF_FINISHED); #ifdef _KERNEL return (s->s_error); @@ -743,6 +767,10 @@ sbuf_len(struct sbuf *s) if (s->s_error != 0) return (-1); + + /* If finished, nulterm is already in len, else add one. */ + if ((s->s_flags & (SBUF_INCLUDENUL | SBUF_FINISHED)) == SBUF_INCLUDENUL) + return (s->s_len + 1); return (s->s_len); } Modified: head/sys/sys/sbuf.h == --- head/sys/sys/sbuf.h Sat Mar 14 14:46:10 2015(r279991) +++ head/sys/sys/sbuf.h Sat Mar 14 16:02:11 2015(r279992) @@ -48,6 +48,7 @@ struct sbuf { ssize_t s_len; /* current length of string */ #defineSBUF_FIXEDLEN 0x /* fixed length buffer (default) */ #defineSBUF_AUTOEXTEND 0x0001 /* automatically extend buffer */ +#defineSBUF_INCLUDENUL 0x0002 /* nulterm byte is counted in len */ #defineSBUF_USRFLAGMSK 0x /* mask of flags the user may specify */ #defineSBUF_DYNAMIC0x0001 /* s_buf must be freed */ #defineSBUF_FINISHED 0x0002 /* set by sbuf_finish() */ @@ -64,6 +65,9 @@ __BEGIN_DECLS struct sbuf*sbuf_new(struct sbuf *, char *, int, int); #define sbuf_new_auto()\ sbuf_new(NULL, NULL, 0, SBUF_AUTOEXTEND) +int sbuf_get_flags(struct sbuf *); +voidsbuf_clear_flags(struct sbuf *, int); +void
svn commit: r279993 - in head/sys: dev/cxgb dev/cxgbe kern vm
Author: ian Date: Sat Mar 14 17:08:28 2015 New Revision: 279993 URL: https://svnweb.freebsd.org/changeset/base/279993 Log: Set the SBUF_INCLUDENUL flag in sbuf_new_for_sysctl() so that sysctl strings returned to userland include the nulterm byte. Some uses of sbuf_new_for_sysctl() write binary data rather than strings; clear the SBUF_INCLUDENUL flag after calling sbuf_new_for_sysctl() in those cases. (Note that the sbuf code still automatically adds a nulterm byte in sbuf_finish(), but since it's not included in the length it won't get copied to userland along with the binary data.) Remove explicit adding of a nulterm byte in a couple places now that it gets done automatically by the sbuf drain code. PR: 195668 Modified: head/sys/dev/cxgb/cxgb_sge.c head/sys/dev/cxgbe/t4_main.c head/sys/kern/kern_descrip.c head/sys/kern/kern_malloc.c head/sys/kern/kern_proc.c head/sys/kern/kern_sysctl.c head/sys/vm/uma_core.c Modified: head/sys/dev/cxgb/cxgb_sge.c == --- head/sys/dev/cxgb/cxgb_sge.cSat Mar 14 16:02:11 2015 (r279992) +++ head/sys/dev/cxgb/cxgb_sge.cSat Mar 14 17:08:28 2015 (r279993) @@ -3149,9 +3149,6 @@ t3_dump_rspq(SYSCTL_HANDLER_ARGS) } err = sbuf_finish(sb); - /* Output a trailing NUL. */ - if (err == 0) - err = SYSCTL_OUT(req, "", 1); sbuf_delete(sb); return (err); } @@ -3219,9 +3216,6 @@ t3_dump_txq_eth(SYSCTL_HANDLER_ARGS) } err = sbuf_finish(sb); - /* Output a trailing NUL. */ - if (err == 0) - err = SYSCTL_OUT(req, "", 1); sbuf_delete(sb); return (err); } @@ -3279,9 +3273,6 @@ t3_dump_txq_ctrl(SYSCTL_HANDLER_ARGS) } err = sbuf_finish(sb); - /* Output a trailing NUL. */ - if (err == 0) - err = SYSCTL_OUT(req, "", 1); sbuf_delete(sb); return (err); } Modified: head/sys/dev/cxgbe/t4_main.c == --- head/sys/dev/cxgbe/t4_main.cSat Mar 14 16:02:11 2015 (r279992) +++ head/sys/dev/cxgbe/t4_main.cSat Mar 14 17:08:28 2015 (r279993) @@ -5083,12 +5083,11 @@ sysctl_int_array(SYSCTL_HANDLER_ARGS) int rc, *i; struct sbuf sb; - sbuf_new(&sb, NULL, 32, SBUF_AUTOEXTEND); + sbuf_new_for_sysctl(&sb, NULL, 64, req); for (i = arg1; arg2; arg2 -= sizeof(int), i++) sbuf_printf(&sb, "%d ", *i); sbuf_trim(&sb); - sbuf_finish(&sb); - rc = sysctl_handle_string(oidp, sbuf_data(&sb), sbuf_len(&sb), req); + rc = sbuf_finish(&sb); sbuf_delete(&sb); return (rc); } Modified: head/sys/kern/kern_descrip.c == --- head/sys/kern/kern_descrip.cSat Mar 14 16:02:11 2015 (r279992) +++ head/sys/kern/kern_descrip.cSat Mar 14 17:08:28 2015 (r279993) @@ -3296,6 +3296,7 @@ sysctl_kern_proc_filedesc(SYSCTL_HANDLER name = (int *)arg1; sbuf_new_for_sysctl(&sb, NULL, FILEDESC_SBUF_SIZE, req); + sbuf_clear_flags(&sb, SBUF_INCLUDENUL); error = pget((pid_t)name[0], PGET_CANDEBUG | PGET_NOTWEXIT, &p); if (error != 0) { sbuf_delete(&sb); @@ -3490,6 +3491,7 @@ sysctl_kern_proc_cwd(SYSCTL_HANDLER_ARGS name = (int *)arg1; sbuf_new_for_sysctl(&sb, NULL, sizeof(struct kinfo_file), req); + sbuf_clear_flags(&sb, SBUF_INCLUDENUL); error = pget((pid_t)name[0], PGET_CANDEBUG | PGET_NOTWEXIT, &p); if (error != 0) { sbuf_delete(&sb); Modified: head/sys/kern/kern_malloc.c == --- head/sys/kern/kern_malloc.c Sat Mar 14 16:02:11 2015(r279992) +++ head/sys/kern/kern_malloc.c Sat Mar 14 17:08:28 2015(r279993) @@ -918,6 +918,7 @@ sysctl_kern_malloc_stats(SYSCTL_HANDLER_ if (error != 0) return (error); sbuf_new_for_sysctl(&sbuf, NULL, 128, req); + sbuf_clear_flags(&sbuf, SBUF_INCLUDENUL); mtx_lock(&malloc_mtx); /* Modified: head/sys/kern/kern_proc.c == --- head/sys/kern/kern_proc.c Sat Mar 14 16:02:11 2015(r279992) +++ head/sys/kern/kern_proc.c Sat Mar 14 17:08:28 2015(r279993) @@ -1273,6 +1273,7 @@ sysctl_out_proc(struct proc *p, struct s pid = p->p_pid; sbuf_new_for_sysctl(&sb, (char *)&ki, sizeof(ki), req); + sbuf_clear_flags(&sb, SBUF_INCLUDENUL); error = kern_proc_out(p, &sb, flags); error2 = sbuf_finish(&sb); sbuf_delete(&sb); @@ -1934,6 +1935,7 @@ sysctl_kern_proc_auxv(SYSCTL_HANDLER_ARG return (0)
svn commit: r279994 - head/sys/conf
Author: dim Date: Sat Mar 14 17:19:48 2015 New Revision: 279994 URL: https://svnweb.freebsd.org/changeset/base/279994 Log: Amend r277940, by also disabling -Wcast-qual warnings for a few specific aesni files on i386. Modified: head/sys/conf/files.i386 Modified: head/sys/conf/files.i386 == --- head/sys/conf/files.i386Sat Mar 14 17:08:28 2015(r279993) +++ head/sys/conf/files.i386Sat Mar 14 17:19:48 2015(r279994) @@ -118,12 +118,12 @@ crypto/aesni/aeskeys_i386.S optional aes crypto/aesni/aesni.c optional aesni aesni_ghash.o optional aesni \ dependency "$S/crypto/aesni/aesni_ghash.c" \ - compile-with"${CC} -c ${CFLAGS:C/^-O2$/-O3/:N-nostdinc} ${WERROR} ${PROF} -mmmx -msse -msse4 -maes -mpclmul ${.IMPSRC}" \ + compile-with"${CC} -c ${CFLAGS:C/^-O2$/-O3/:N-nostdinc} ${WERROR} ${NO_WCAST_QUAL} ${PROF} -mmmx -msse -msse4 -maes -mpclmul ${.IMPSRC}" \ no-implicit-rule\ clean "aesni_ghash.o" aesni_wrap.o optional aesni \ dependency "$S/crypto/aesni/aesni_wrap.c" \ - compile-with"${CC} -c ${CFLAGS:C/^-O2$/-O3/:N-nostdinc} ${WERROR} ${PROF} -mmmx -msse -msse4 -maes ${.IMPSRC}" \ + compile-with"${CC} -c ${CFLAGS:C/^-O2$/-O3/:N-nostdinc} ${WERROR} ${NO_WCAST_QUAL} ${PROF} -mmmx -msse -msse4 -maes ${.IMPSRC}" \ no-implicit-rule\ clean "aesni_wrap.o" crypto/des/arch/i386/des_enc.S optional crypto | ipsec | netsmb ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r279996 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs
Author: smh Date: Sat Mar 14 17:35:04 2015 New Revision: 279996 URL: https://svnweb.freebsd.org/changeset/base/279996 Log: Allow zvol_geom_worker to process BIO_DELETE's If zvol_geom_start is called with a BIO_DELETE from a thread which can sleep it queues it for later processing by the zvol_geom_worker. The zvol_geom_worker didn't have a delete case so would simply loose the bio hence preventing the original caller from every completing. In addition an other unknown types would suffer the same fate. Allow zvol_geom_worker to process BIO_DELETE's via zvol_strategy and return unsupported for all unknown bio types. MFC after:2 weeks Sponsored by: Multiplay Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c == --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c Sat Mar 14 17:25:17 2015(r279995) +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c Sat Mar 14 17:35:04 2015(r279996) @@ -2775,8 +2775,12 @@ zvol_geom_worker(void *arg) break; case BIO_READ: case BIO_WRITE: + case BIO_DELETE: zvol_strategy(bp); break; + default: + g_io_deliver(bp, EOPNOTSUPP); + break; } } } ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r279997 - head/sys/netinet
Author: ian Date: Sat Mar 14 18:11:24 2015 New Revision: 279997 URL: https://svnweb.freebsd.org/changeset/base/279997 Log: Use sbuf_new_for_sysctl() instead of plain sbuf_new() to ensure sysctl string returned to userland is nulterminated. PR: 195668 Modified: head/sys/netinet/tcp_hostcache.c Modified: head/sys/netinet/tcp_hostcache.c == --- head/sys/netinet/tcp_hostcache.cSat Mar 14 17:35:04 2015 (r279996) +++ head/sys/netinet/tcp_hostcache.cSat Mar 14 18:11:24 2015 (r279997) @@ -596,7 +596,7 @@ tcp_hc_update(struct in_conninfo *inc, s static int sysctl_tcp_hc_list(SYSCTL_HANDLER_ARGS) { - int linesize = 128; + const int linesize = 128; struct sbuf sb; int i, error; struct hc_metrics *hc_entry; @@ -604,8 +604,7 @@ sysctl_tcp_hc_list(SYSCTL_HANDLER_ARGS) char ip6buf[INET6_ADDRSTRLEN]; #endif - sbuf_new(&sb, NULL, linesize * (V_tcp_hostcache.cache_count + 1), - SBUF_FIXEDLEN); + sbuf_new_for_sysctl(&sb, NULL, linesize, req); sbuf_printf(&sb, "\nIP addressMTU SSTRESH RTT RTTVAR BANDWIDTH " @@ -642,8 +641,7 @@ sysctl_tcp_hc_list(SYSCTL_HANDLER_ARGS) THC_UNLOCK(&V_tcp_hostcache.hashbase[i].hch_mtx); } #undef msec - sbuf_finish(&sb); - error = SYSCTL_OUT(req, sbuf_data(&sb), sbuf_len(&sb)); + error = sbuf_finish(&sb); sbuf_delete(&sb); return(error); } ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r279999 - head/sys/kern
Author: ian Date: Sat Mar 14 18:42:30 2015 New Revision: 27 URL: https://svnweb.freebsd.org/changeset/base/27 Log: Use sbuf_new_for_sysctl() instead of plain sbuf_new() to ensure sysctl string returned to userland is nulterminated. PR: 195668 Modified: head/sys/kern/sched_ule.c Modified: head/sys/kern/sched_ule.c == --- head/sys/kern/sched_ule.c Sat Mar 14 18:38:07 2015(r279998) +++ head/sys/kern/sched_ule.c Sat Mar 14 18:42:30 2015(r27) @@ -2830,7 +2830,7 @@ sysctl_kern_sched_topology_spec(SYSCTL_H KASSERT(cpu_top != NULL, ("cpu_top isn't initialized")); - topo = sbuf_new(NULL, NULL, 500, SBUF_AUTOEXTEND); + topo = sbuf_new_for_sysctl(NULL, NULL, 512, req); if (topo == NULL) return (ENOMEM); @@ -2839,8 +2839,7 @@ sysctl_kern_sched_topology_spec(SYSCTL_H sbuf_printf(topo, "\n"); if (err == 0) { - sbuf_finish(topo); - err = SYSCTL_OUT(req, sbuf_data(topo), sbuf_len(topo)); + err = sbuf_finish(topo); } sbuf_delete(topo); return (err); ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r280000 - head/sys/kern
Author: ian Date: Sat Mar 14 18:46:33 2015 New Revision: 28 URL: https://svnweb.freebsd.org/changeset/base/28 Log: Use sbuf_new_for_sysctl() instead of plain sbuf_new() to ensure sysctl string returned to userland is nulterminated. PR: 195668 Modified: head/sys/kern/kern_fail.c Modified: head/sys/kern/kern_fail.c == --- head/sys/kern/kern_fail.c Sat Mar 14 18:42:30 2015(r27) +++ head/sys/kern/kern_fail.c Sat Mar 14 18:46:33 2015(r28) @@ -394,11 +394,10 @@ fail_point_sysctl(SYSCTL_HANDLER_ARGS) int error; /* Retrieving */ - sbuf_new(&sb, NULL, 128, SBUF_AUTOEXTEND); + sbuf_new_for_sysctl(&sb, NULL, 128, req); fail_point_get(fp, &sb); sbuf_trim(&sb); - sbuf_finish(&sb); - error = SYSCTL_OUT(req, sbuf_data(&sb), sbuf_len(&sb)); + error = sbuf_finish(&sb); sbuf_delete(&sb); /* Setting */ ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
Re: svn commit: r279981 - in head: contrib/compiler-rt/lib/builtins lib/libcompiler_rt
On Sat, 14 Mar 2015, Dimitry Andric wrote: Log: ???Pull in r231965 from upstream compiler-rt trunk (by J??rg Sonnenberger): Refactor float to integer conversion to share the same code. 80bit Intel/PPC long double is excluded due to lacking support for the abstraction. Consistently provide saturation logic. Extend to long double on 128bit IEEE extended platforms. I hoped that this would fix a longstanding conversion bug, but that bug is actually for integer to float conversion, and the conversion is inline. clang can't even convert integer 0 to floating point correctly (when the integer has type uintmax_t and is variable with value 0, and the rounding mode is downwards): X #include X #include X #include X X int X main(void) X { X volatile uintmax_t er = 0; X X fesetround(FE_DOWNWARD); X printf("%.4f\n", (double)er); X return (0); X } clang generates broken inline code giving a result of -0.. It does a magic conversion involving loading the variable as an integer, shuffling bits, subtracting a double and adding a double. The subtraction gives -0.0 when the rounding mode is downwards. gcc48 generates apparently-correct inline code. It does a less magic but slower conversion involving: - for values not exceeding INT64_MAX, just cvtsi2sdq - for values exceeding INT64_MAX, modify er to ((er >> 1) | (er & 1)), convert that using cvtsi2sdq, then double the result. Does this commit fix the differences between the runtime calculations and compile-time calculations for overflowing cases? Saturation logic should do this. My old test programs (previously last tested in 2004) show the differences. Compilers produced much the same garbage in 1994, 2004 and 2015. Before this commit, they do the following: - gcc48 saturates at compile time. Its runtime results are inconsistent except for some cases of converting negative values to unsigned: - generally, the result is 0x8000 in bits for 64-bit values and 0x8000 for 32-bit values. This is the corect x86 value since it is what is generated on overflow by the hardware. Call it IOV. gcc corrupts even this value: - overflowing u_long or long -> (u_long)IOV or (long)IOV, OK - overflowing u_long, positive value -> 0 - overflowing u_long, negative value -> (u_long)IOV, OK, but it is weird that negative values overflow to a larger value than positive values. - this is with 64-bit longs on amd64. For conversions to u_int and int, the results are the same (with the the 32-bit IOV), except for the weird last result. Now: - overflowing u_int, negative value -> 0. This is the one case for unsigned types where the runtime result is consistent with the compile time result. - clang gives identical results. gcc was much more inconsistent in 1994. Its typical behaviour was to handle u_int by storing an int64_t and discarding the top bits. uint64_t is harder to handle and was more broken. The behaviour is undefined on overflow, so these bugs are less serious than for converting 0. I prefer traps on overflow. Everyone is used to integer division trapping when the result would be infinite. x86 hardware makes the trap for this impossible to avoid (but the kernel could handle the trap and produce an in-band error result like IOV). Converting FP infinity to integer should do the same. Unfortunately, x86 hardware make this trap hard to get efficiently (traps for it would have to be enabled; then the kernel could produce a signal for the integer case and emulate the hardware trap handling for the FP case). Bruce___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r280002 - stable/10/tools/regression/usr.bin/env
Author: jilles Date: Sat Mar 14 20:40:04 2015 New Revision: 280002 URL: https://svnweb.freebsd.org/changeset/base/280002 Log: MFC r279722: env: Fix testsuite for additional variables set by sh. Modified: stable/10/tools/regression/usr.bin/env/regress-env.rgdata Directory Properties: stable/10/ (props changed) Modified: stable/10/tools/regression/usr.bin/env/regress-env.rgdata == --- stable/10/tools/regression/usr.bin/env/regress-env.rgdata Sat Mar 14 19:22:15 2015(r280001) +++ stable/10/tools/regression/usr.bin/env/regress-env.rgdata Sat Mar 14 20:40:04 2015(r280002) @@ -235,9 +235,9 @@ gblenv=OUTSIDEVAR=OutsideValue script:/bin/echo "=== set ===" script:# drop some environment variables that 'sh' itself sets, and script:# then have 'set' print out all remaining environment variables. - script:# (can't unset OPTIND, so we use grep to get rid of that) - script:unset -v IFS PS1 PS2 PPID - script:set | grep -v '^OPTIND=' | sort + script:# (can't unset OPTIND/PWD, so we use grep to get rid of those) + script:unset -v IFS PS1 PS2 PS4 PPID + script:set | grep -Ev '^(OPTIND|PWD)=' | sort stdout:=== set === stdout:PATH=/bin:/usr/bin:/Not stdout:TESTVAR=SbValue ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r280003 - stable/9/tools/regression/usr.bin/env
Author: jilles Date: Sat Mar 14 21:07:37 2015 New Revision: 280003 URL: https://svnweb.freebsd.org/changeset/base/280003 Log: MFC r279722: env: Fix testsuite for additional variables set by sh. Modified: stable/9/tools/regression/usr.bin/env/regress-env.rgdata Directory Properties: stable/9/tools/regression/usr.bin/env/ (props changed) Modified: stable/9/tools/regression/usr.bin/env/regress-env.rgdata == --- stable/9/tools/regression/usr.bin/env/regress-env.rgdataSat Mar 14 20:40:04 2015(r280002) +++ stable/9/tools/regression/usr.bin/env/regress-env.rgdataSat Mar 14 21:07:37 2015(r280003) @@ -235,9 +235,9 @@ gblenv=OUTSIDEVAR=OutsideValue script:/bin/echo "=== set ===" script:# drop some environment variables that 'sh' itself sets, and script:# then have 'set' print out all remaining environment variables. - script:# (can't unset OPTIND, so we use grep to get rid of that) - script:unset -v IFS PS1 PS2 PPID - script:set | grep -v '^OPTIND=' | sort + script:# (can't unset OPTIND/PWD, so we use grep to get rid of those) + script:unset -v IFS PS1 PS2 PS4 PPID + script:set | grep -Ev '^(OPTIND|PWD)=' | sort stdout:=== set === stdout:PATH=/bin:/usr/bin:/Not stdout:TESTVAR=SbValue ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r280004 - head/usr.sbin/bhyve
Author: mav Date: Sat Mar 14 21:15:45 2015 New Revision: 280004 URL: https://svnweb.freebsd.org/changeset/base/280004 Log: Give block I/O interface multiple (8) execution threads. On parallel random I/O this allows better utilize wide storage pools. To not confuse prefetcher on linear I/O, consecutive requests are executed sequentially, following the same logic as was earlier implemented in CTL. Benchmarks of virtual AHCI disk, backed by ZVOL on RAID10 pool of 4 HDDs, show ~3.5 times random read performance improvements, while no degradation on linear I/O. MFC after:2 weeks Modified: head/usr.sbin/bhyve/block_if.c Modified: head/usr.sbin/bhyve/block_if.c == --- head/usr.sbin/bhyve/block_if.c Sat Mar 14 21:07:37 2015 (r280003) +++ head/usr.sbin/bhyve/block_if.c Sat Mar 14 21:15:45 2015 (r280004) @@ -55,6 +55,7 @@ __FBSDID("$FreeBSD$"); #define BLOCKIF_SIG0xb109b109 #define BLOCKIF_MAXREQ 33 +#define BLOCKIF_NUMTHR 8 enum blockop { BOP_READ, @@ -65,6 +66,7 @@ enum blockop { enum blockstat { BST_FREE, + BST_BLOCK, BST_PEND, BST_BUSY, BST_DONE @@ -76,6 +78,7 @@ struct blockif_elem { enum blockop be_op; enum blockstat be_status; pthread_tbe_tid; + off_tbe_block; }; struct blockif_ctxt { @@ -88,16 +91,15 @@ struct blockif_ctxt { int bc_sectsz; int bc_psectsz; int bc_psectoff; - pthread_t bc_btid; + int bc_closing; + pthread_t bc_btid[BLOCKIF_NUMTHR]; pthread_mutex_tbc_mtx; pthread_cond_t bc_cond; - int bc_closing; /* Request elements and free/pending/busy queues */ TAILQ_HEAD(, blockif_elem) bc_freeq; TAILQ_HEAD(, blockif_elem) bc_pendq; TAILQ_HEAD(, blockif_elem) bc_busyq; - u_int bc_req_count; struct blockif_elem bc_reqs[BLOCKIF_MAXREQ]; }; @@ -116,58 +118,83 @@ static int blockif_enqueue(struct blockif_ctxt *bc, struct blockif_req *breq, enum blockop op) { - struct blockif_elem *be; - - assert(bc->bc_req_count < BLOCKIF_MAXREQ); + struct blockif_elem *be, *tbe; + off_t off; + int i; be = TAILQ_FIRST(&bc->bc_freeq); assert(be != NULL); assert(be->be_status == BST_FREE); - TAILQ_REMOVE(&bc->bc_freeq, be, be_link); - be->be_status = BST_PEND; be->be_req = breq; be->be_op = op; + switch (op) { + case BOP_READ: + case BOP_WRITE: + case BOP_DELETE: + off = breq->br_offset; + for (i = 0; i < breq->br_iovcnt; i++) + off += breq->br_iov[i].iov_len; + break; + default: + off = OFF_MAX; + } + be->be_block = off; + TAILQ_FOREACH(tbe, &bc->bc_pendq, be_link) { + if (tbe->be_block == breq->br_offset) + break; + } + if (tbe == NULL) { + TAILQ_FOREACH(tbe, &bc->bc_busyq, be_link) { + if (tbe->be_block == breq->br_offset) + break; + } + } + if (tbe == NULL) + be->be_status = BST_PEND; + else + be->be_status = BST_BLOCK; TAILQ_INSERT_TAIL(&bc->bc_pendq, be, be_link); - - bc->bc_req_count++; - - return (0); + return (be->be_status == BST_PEND); } static int -blockif_dequeue(struct blockif_ctxt *bc, struct blockif_elem **bep) +blockif_dequeue(struct blockif_ctxt *bc, pthread_t t, struct blockif_elem **bep) { struct blockif_elem *be; - if (bc->bc_req_count == 0) - return (ENOENT); - - be = TAILQ_FIRST(&bc->bc_pendq); - assert(be != NULL); - assert(be->be_status == BST_PEND); + TAILQ_FOREACH(be, &bc->bc_pendq, be_link) { + if (be->be_status == BST_PEND) + break; + assert(be->be_status == BST_BLOCK); + } + if (be == NULL) + return (0); TAILQ_REMOVE(&bc->bc_pendq, be, be_link); be->be_status = BST_BUSY; - be->be_tid = bc->bc_btid; + be->be_tid = t; TAILQ_INSERT_TAIL(&bc->bc_busyq, be, be_link); - *bep = be; - - return (0); + return (1); } static void blockif_complete(struct blockif_ctxt *bc, struct blockif_elem *be) { - assert(be->be_status == BST_DONE); + struct blockif_elem *tbe; - TAILQ_REMOVE(&bc->bc_busyq, be, be_link); + if (be->be_status == BST_DONE || be->be_status == BST_BUSY) + TAILQ_REMOVE(&bc->bc_busyq, be,
svn commit: r280005 - head/sys/sys
Author: ian Date: Sat Mar 14 21:38:51 2015 New Revision: 280005 URL: https://svnweb.freebsd.org/changeset/base/280005 Log: Define a convenience macro, SYSCTL_OUT_STR() for handling strings the standard way (including the nulterm byte in the data returned to userland). This augments the existing sysctl_handle_string() in that this can be used with const strings without ugly inappropriate casting. Modified: head/sys/sys/sysctl.h Modified: head/sys/sys/sysctl.h == --- head/sys/sys/sysctl.h Sat Mar 14 21:15:45 2015(r280004) +++ head/sys/sys/sysctl.h Sat Mar 14 21:38:51 2015(r280005) @@ -186,6 +186,7 @@ struct sysctl_oid { #defineSYSCTL_IN(r, p, l) (r->newfunc)(r, p, l) #defineSYSCTL_OUT(r, p, l) (r->oldfunc)(r, p, l) +#defineSYSCTL_OUT_STR(r, p)(r->oldfunc)(r, p, strlen(p) + 1) int sysctl_handle_int(SYSCTL_HANDLER_ARGS); int sysctl_msec_to_ticks(SYSCTL_HANDLER_ARGS); ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r280006 - head/sys/kern
Author: ian Date: Sat Mar 14 21:40:01 2015 New Revision: 280006 URL: https://svnweb.freebsd.org/changeset/base/280006 Log: Use SYSCTL_OUT_STR() to return strings. PR: 195668 Modified: head/sys/kern/subr_bus.c head/sys/kern/subr_param.c Modified: head/sys/kern/subr_bus.c == --- head/sys/kern/subr_bus.cSat Mar 14 21:38:51 2015(r280005) +++ head/sys/kern/subr_bus.cSat Mar 14 21:40:01 2015(r280006) @@ -212,7 +212,7 @@ devclass_sysctl_handler(SYSCTL_HANDLER_A default: return (EINVAL); } - return (SYSCTL_OUT(req, value, strlen(value))); + return (SYSCTL_OUT_STR(req, value)); } static void @@ -269,7 +269,7 @@ device_sysctl_handler(SYSCTL_HANDLER_ARG default: return (EINVAL); } - error = SYSCTL_OUT(req, value, strlen(value)); + error = SYSCTL_OUT_STR(req, value); if (buf != NULL) free(buf, M_BUS); return (error); Modified: head/sys/kern/subr_param.c == --- head/sys/kern/subr_param.c Sat Mar 14 21:38:51 2015(r280005) +++ head/sys/kern/subr_param.c Sat Mar 14 21:40:01 2015(r280006) @@ -300,6 +300,5 @@ init_param2(long physpages) static int sysctl_kern_vm_guest(SYSCTL_HANDLER_ARGS) { - return (SYSCTL_OUT(req, vm_guest_sysctl_names[vm_guest], - strlen(vm_guest_sysctl_names[vm_guest]))); + return (SYSCTL_OUT_STR(req, vm_guest_sysctl_names[vm_guest])); } ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r280009 - head/sys/mips/rmi/dev/iic
Author: ian Date: Sat Mar 14 21:40:51 2015 New Revision: 280009 URL: https://svnweb.freebsd.org/changeset/base/280009 Log: Use SYSCTL_OUT_STR() to return strings. PR: 195668 Modified: head/sys/mips/rmi/dev/iic/at24co2n.c Modified: head/sys/mips/rmi/dev/iic/at24co2n.c == --- head/sys/mips/rmi/dev/iic/at24co2n.cSat Mar 14 21:40:33 2015 (r280008) +++ head/sys/mips/rmi/dev/iic/at24co2n.cSat Mar 14 21:40:51 2015 (r280009) @@ -84,7 +84,7 @@ at24co2n_mac_sysctl(SYSCTL_HANDLER_ARGS) p = sc->sc_mac_addr; len = snprintf(buf, sizeof(buf), "%02x:%02x:%02x:%02x:%02x:%02x", p[0], p[1], p[2], p[3], p[4], p[5]); - return SYSCTL_OUT(req, buf, len); + return SYSCTL_OUT_STR(req, buf); } ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r280008 - head/sys/dev/usb/net
Author: ian Date: Sat Mar 14 21:40:33 2015 New Revision: 280008 URL: https://svnweb.freebsd.org/changeset/base/280008 Log: Use SYSCTL_OUT_STR() to return strings. PR: 195668 Modified: head/sys/dev/usb/net/usb_ethernet.c Modified: head/sys/dev/usb/net/usb_ethernet.c == --- head/sys/dev/usb/net/usb_ethernet.c Sat Mar 14 21:40:24 2015 (r280007) +++ head/sys/dev/usb/net/usb_ethernet.c Sat Mar 14 21:40:33 2015 (r280008) @@ -155,7 +155,7 @@ ue_sysctl_parent(SYSCTL_HANDLER_ARGS) const char *name; name = device_get_nameunit(ue->ue_dev); - return SYSCTL_OUT(req, name, strlen(name)); + return SYSCTL_OUT_STR(req, name); } int ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r280010 - head/sys/net80211
Author: ian Date: Sat Mar 14 21:41:00 2015 New Revision: 280010 URL: https://svnweb.freebsd.org/changeset/base/280010 Log: Use SYSCTL_OUT_STR() to return strings. PR: 195668 Modified: head/sys/net80211/ieee80211_freebsd.c Modified: head/sys/net80211/ieee80211_freebsd.c == --- head/sys/net80211/ieee80211_freebsd.c Sat Mar 14 21:40:51 2015 (r280009) +++ head/sys/net80211/ieee80211_freebsd.c Sat Mar 14 21:41:00 2015 (r280010) @@ -209,7 +209,7 @@ ieee80211_sysctl_parent(SYSCTL_HANDLER_A struct ieee80211com *ic = arg1; const char *name = ic->ic_ifp->if_xname; - return SYSCTL_OUT(req, name, strlen(name)); + return SYSCTL_OUT_STR(req, name); } static int ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r280007 - head/sys/xen/xenbus
Author: ian Date: Sat Mar 14 21:40:24 2015 New Revision: 280007 URL: https://svnweb.freebsd.org/changeset/base/280007 Log: Use SYSCTL_OUT_STR() to return strings. PR: 195668 Modified: head/sys/xen/xenbus/xenbusb.c Modified: head/sys/xen/xenbus/xenbusb.c == --- head/sys/xen/xenbus/xenbusb.c Sat Mar 14 21:40:01 2015 (r280006) +++ head/sys/xen/xenbus/xenbusb.c Sat Mar 14 21:40:24 2015 (r280007) @@ -330,7 +330,7 @@ xenbusb_device_sysctl_handler(SYSCTL_HAN default: return (EINVAL); } - return (SYSCTL_OUT(req, value, strlen(value))); + return (SYSCTL_OUT_STR(req, value)); } /** ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
Re: svn commit: r279997 - head/sys/netinet
On Saturday, March 14, 2015 06:11:25 PM Ian Lepore wrote: > Author: ian > Date: Sat Mar 14 18:11:24 2015 > New Revision: 279997 > URL: https://svnweb.freebsd.org/changeset/base/279997 > > Log: > Use sbuf_new_for_sysctl() instead of plain sbuf_new() to ensure sysctl > string returned to userland is nulterminated. > > PR: 195668 This is not safe. sbuf_printf() is invoked with a lock held, so it isn't safe for the sbuf code to do a drain here. With sbuf_new_for_sysctl(), any call to an sbuf routine is a potential page fault, so the handler must either use sysctl_wire_old_buffer(), or the contents need to be output in one go. For this case I would prefer to use sbuf_len(sb) + 1 (or add INCLUDENUL to the args when creating it) and leave the sole SYSCTL_OUT() at the end. You will want to check the one or two other places you converted for this same issue as well. -- John Baldwin ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r280011 - head/sys/dev/iscsi_initiator
Author: ian Date: Sat Mar 14 22:32:15 2015 New Revision: 280011 URL: https://svnweb.freebsd.org/changeset/base/280011 Log: Use sysctl_handle_string() and the sbuf printf routines instead of large stack-allocated buffers and snprintf(). PR: 195668 Modified: head/sys/dev/iscsi_initiator/isc_sm.c Modified: head/sys/dev/iscsi_initiator/isc_sm.c == --- head/sys/dev/iscsi_initiator/isc_sm.c Sat Mar 14 21:41:00 2015 (r280010) +++ head/sys/dev/iscsi_initiator/isc_sm.c Sat Mar 14 22:32:15 2015 (r280011) @@ -54,6 +54,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -586,14 +587,15 @@ isc_dump_options(SYSCTL_HANDLER_ARGS) { int error; isc_session_t *sp; - char buf[1024], *bp; + struct sbuf sb; + + sbuf_new_for_sysctl(&sb, NULL, 128, req); sp = (isc_session_t *)arg1; - bp = buf; - sprintf(bp, "targetname='%s'", sp->opt.targetName); - bp += strlen(bp); - sprintf(bp, " targetname='%s'", sp->opt.targetAddress); - error = SYSCTL_OUT(req, buf, strlen(buf)); + sbuf_printf(&sb, "targetname='%s'", sp->opt.targetName); + sbuf_printf(&sb, " targetaddress='%s'", sp->opt.targetAddress); + error = sbuf_finish(&sb); + sbuf_delete(&sb); return error; } #endif @@ -603,51 +605,24 @@ isc_dump_stats(SYSCTL_HANDLER_ARGS) { isc_session_t *sp; struct isc_softc *sc; - char buf[1024], *bp; - int error, n; - + int error; + struct sbuf sb; + sp = (isc_session_t *)arg1; sc = sp->isc; - bp = buf; - n = sizeof(buf); - snprintf(bp, n, "recv=%d sent=%d", sp->stats.nrecv, sp->stats.nsent); - bp += strlen(bp); - n -= strlen(bp); - snprintf(bp, n, " flags=0x%08x pdus-alloc=%d pdus-max=%d", - sp->flags, sc->npdu_alloc, sc->npdu_max); - bp += strlen(bp); - n -= strlen(bp); - snprintf(bp, n, " cws=%d cmd=%x exp=%x max=%x stat=%x itt=%x", - sp->cws, sp->sn.cmd, sp->sn.expCmd, sp->sn.maxCmd, sp->sn.stat, sp->sn.itt); - error = SYSCTL_OUT(req, buf, strlen(buf)); - return error; -} + sbuf_new_for_sysctl(&sb, NULL, 128, req); -static int -isc_sysctl_targetName(SYSCTL_HANDLER_ARGS) -{ - char buf[128], **cp; - int error; - - cp = (char **)arg1; - snprintf(buf, sizeof(buf), "%s", *cp); - error = SYSCTL_OUT(req, buf, strlen(buf)); + sbuf_printf(&sb, "recv=%d sent=%d", sp->stats.nrecv, sp->stats.nsent); + sbuf_printf(&sb, " flags=0x%08x pdus-alloc=%d pdus-max=%d", +sp->flags, sc->npdu_alloc, sc->npdu_max); + sbuf_printf(&sb, " cws=%d cmd=%x exp=%x max=%x stat=%x itt=%x", + sp->cws, sp->sn.cmd, sp->sn.expCmd, sp->sn.maxCmd, sp->sn.stat, sp->sn.itt); + error = sbuf_finish(&sb); + sbuf_delete(&sb); return error; } - -static int -isc_sysctl_targetAddress(SYSCTL_HANDLER_ARGS) -{ - char buf[128], **cp; - int error; - cp = (char **)arg1; - snprintf(buf, sizeof(buf), "%s", *cp); - error = SYSCTL_OUT(req, buf, strlen(buf)); - return error; -} - static void isc_add_sysctls(isc_session_t *sp) { @@ -668,7 +643,7 @@ isc_add_sysctls(isc_session_t *sp) "targetname", CTLTYPE_STRING | CTLFLAG_RD, (void *)&sp->opt.targetName, 0, -isc_sysctl_targetName, "A", "target name"); +sysctl_handle_string, "A", "target name"); SYSCTL_ADD_PROC(&sp->clist, SYSCTL_CHILDREN(sp->oid), @@ -676,7 +651,7 @@ isc_add_sysctls(isc_session_t *sp) "targeaddress", CTLTYPE_STRING | CTLFLAG_RD, (void *)&sp->opt.targetAddress, 0, -isc_sysctl_targetAddress, "A", "target address"); +sysctl_handle_string, "A", "target address"); SYSCTL_ADD_PROC(&sp->clist, SYSCTL_CHILDREN(sp->oid), ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r280012 - head/sys/kern
Author: ian Date: Sat Mar 14 23:16:12 2015 New Revision: 280012 URL: https://svnweb.freebsd.org/changeset/base/280012 Log: Use sbuf_printf() for sysctl strings instead of stack buffers and snprintf(). Modified: head/sys/kern/kern_et.c head/sys/kern/kern_tc.c Modified: head/sys/kern/kern_et.c == --- head/sys/kern/kern_et.c Sat Mar 14 22:32:15 2015(r280011) +++ head/sys/kern/kern_et.c Sat Mar 14 23:16:12 2015(r280012) @@ -29,6 +29,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -238,22 +239,24 @@ et_free(struct eventtimer *et) static int sysctl_kern_eventtimer_choice(SYSCTL_HANDLER_ARGS) { - char buf[512], *spc; + struct sbuf sb; struct eventtimer *et; - int error, off; + int error; + + if ((error = sysctl_wire_old_buffer(req, 0)) != 0) + return (error); + sbuf_new_for_sysctl(&sb, NULL, 0, req); - spc = ""; - error = 0; - buf[0] = 0; - off = 0; ET_LOCK(); SLIST_FOREACH(et, &eventtimers, et_all) { - off += snprintf(buf + off, sizeof(buf) - off, "%s%s(%d)", - spc, et->et_name, et->et_quality); - spc = " "; + if (et != SLIST_FIRST(&eventtimers)) + sbuf_putc(&sb, ' '); + sbuf_printf(&sb, "%s(%d)", et->et_name, et->et_quality); } ET_UNLOCK(); - error = SYSCTL_OUT(req, buf, strlen(buf)); + + error = sbuf_finish(&sb); + sbuf_delete(&sb); return (error); } SYSCTL_PROC(_kern_eventtimer, OID_AUTO, choice, Modified: head/sys/kern/kern_tc.c == --- head/sys/kern/kern_tc.c Sat Mar 14 22:32:15 2015(r280011) +++ head/sys/kern/kern_tc.c Sat Mar 14 23:16:12 2015(r280012) @@ -25,6 +25,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -1445,18 +1446,18 @@ SYSCTL_PROC(_kern_timecounter, OID_AUTO, static int sysctl_kern_timecounter_choice(SYSCTL_HANDLER_ARGS) { - char buf[32], *spc; + struct sbuf sb; struct timecounter *tc; int error; - spc = ""; - error = 0; - for (tc = timecounters; error == 0 && tc != NULL; tc = tc->tc_next) { - sprintf(buf, "%s%s(%d)", - spc, tc->tc_name, tc->tc_quality); - error = SYSCTL_OUT(req, buf, strlen(buf)); - spc = " "; + sbuf_new_for_sysctl(&sb, NULL, 0, req); + for (tc = timecounters; tc != NULL; tc = tc->tc_next) { + if (tc != timecounters) + sbuf_putc(&sb, ' '); + sbuf_printf(&sb, "%s(%d)", tc->tc_name, tc->tc_quality); } + error = sbuf_finish(&sb); + sbuf_delete(&sb); return (error); } ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r280013 - in head/sys/mips: nlm rmi
Author: ian Date: Sat Mar 14 23:30:03 2015 New Revision: 280013 URL: https://svnweb.freebsd.org/changeset/base/280013 Log: Use sbuf_printf() for sysctl strings instead of static buffers and snprintf. Modified: head/sys/mips/nlm/cms.c head/sys/mips/rmi/fmn.c Modified: head/sys/mips/nlm/cms.c == --- head/sys/mips/nlm/cms.c Sat Mar 14 23:16:12 2015(r280012) +++ head/sys/mips/nlm/cms.c Sat Mar 14 23:30:03 2015(r280013) @@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -473,27 +474,22 @@ SYSINIT(start_msgring_threads, SI_SUB_SM static int sys_print_debug(SYSCTL_HANDLER_ARGS) { - int error, nb, i, fs; - static char xprintb[4096], *buf; + struct sbuf sb; + int error, i; - buf = xprintb; - fs = sizeof(xprintb); - nb = snprintf(buf, fs, + sbuf_new_for_sysctl(&sb, NULL, 64, req); + sbuf_printf(&sb, "\nID vc0 vc1 vc2 vc3 loops\n"); - buf += nb; - fs -= nb; for (i = 0; i < 32; i++) { if ((xlp_hw_thread_mask & (1 << i)) == 0) continue; - nb = snprintf(buf, fs, - "%2d: %8d %8d %8d %8d %8d\n", i, + sbuf_printf(&sb, "%2d: %8d %8d %8d %8d %8d\n", i, fmn_msgcount[i][0], fmn_msgcount[i][1], fmn_msgcount[i][2], fmn_msgcount[i][3], fmn_loops[i]); - buf += nb; - fs -= nb; } - error = SYSCTL_OUT(req, xprintb, buf - xprintb); + error = sbuf_finish(&sb); + sbuf_delete(&sb); return (error); } Modified: head/sys/mips/rmi/fmn.c == --- head/sys/mips/rmi/fmn.c Sat Mar 14 23:16:12 2015(r280012) +++ head/sys/mips/rmi/fmn.c Sat Mar 14 23:30:03 2015(r280013) @@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -468,27 +469,22 @@ SYSINIT(start_msgring_threads, SI_SUB_SM static int sys_print_debug(SYSCTL_HANDLER_ARGS) { - int error, nb, i, fs; - static char xprintb[4096], *buf; + struct sbuf sb; + int error, i; - buf = xprintb; - fs = sizeof(xprintb); - nb = snprintf(buf, fs, + sbuf_new_for_sysctl(&sb, NULL, 64, req); + sbuf_printf(&sb, "\nID INTR ER WU-SLP WU-ERR MSGS\n"); - buf += nb; - fs -= nb; for (i = 0; i < 32; i++) { if ((xlr_hw_thread_mask & (1 << i)) == 0) continue; - nb = snprintf(buf, fs, - "%2d: %8d %4d %8d %8d %8d\n", i, + sbuf_printf(&sb, "%2d: %8d %4d %8d %8d %8d\n", i, msgring_nintr[i/4], msgring_badintr[i/4], msgring_wakeup_sleep[i], msgring_wakeup_nosleep[i], msgring_nmsgs[i]); - buf += nb; - fs -= nb; } - error = SYSCTL_OUT(req, xprintb, buf - xprintb); + error = sbuf_finish(&sb); + sbuf_delete(&sb); return (error); } ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r280014 - head/sys/netinet
Author: ian Date: Sat Mar 14 23:57:33 2015 New Revision: 280014 URL: https://svnweb.freebsd.org/changeset/base/280014 Log: Go back to using sbuf_new() with a preallocated large buffer, to avoid triggering an sbuf auto-drain copyout while holding a lock. Pointed out by: jhb Pointy hat: ian Modified: head/sys/netinet/tcp_hostcache.c Modified: head/sys/netinet/tcp_hostcache.c == --- head/sys/netinet/tcp_hostcache.cSat Mar 14 23:30:03 2015 (r280013) +++ head/sys/netinet/tcp_hostcache.cSat Mar 14 23:57:33 2015 (r280014) @@ -604,7 +604,8 @@ sysctl_tcp_hc_list(SYSCTL_HANDLER_ARGS) char ip6buf[INET6_ADDRSTRLEN]; #endif - sbuf_new_for_sysctl(&sb, NULL, linesize, req); + sbuf_new(&sb, NULL, linesize * (V_tcp_hostcache.cache_count + 1), + SBUF_INCLUDENUL); sbuf_printf(&sb, "\nIP addressMTU SSTRESH RTT RTTVAR BANDWIDTH " @@ -642,6 +643,8 @@ sysctl_tcp_hc_list(SYSCTL_HANDLER_ARGS) } #undef msec error = sbuf_finish(&sb); + if (error == 0) + error = SYSCTL_OUT(req, sbuf_data(&sb), sbuf_len(&sb)); sbuf_delete(&sb); return(error); } ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
Re: svn commit: r279997 - head/sys/netinet
On Sat, 2015-03-14 at 17:52 -0400, John Baldwin wrote: > On Saturday, March 14, 2015 06:11:25 PM Ian Lepore wrote: > > Author: ian > > Date: Sat Mar 14 18:11:24 2015 > > New Revision: 279997 > > URL: https://svnweb.freebsd.org/changeset/base/279997 > > > > Log: > > Use sbuf_new_for_sysctl() instead of plain sbuf_new() to ensure sysctl > > string returned to userland is nulterminated. > > > > PR: 195668 > > This is not safe. sbuf_printf() is invoked with a lock held, so it isn't > safe for the sbuf code to do a drain here. With sbuf_new_for_sysctl(), > any call to an sbuf routine is a potential page fault, so the handler must > either use sysctl_wire_old_buffer(), or the contents need to be output in > one go. For this case I would prefer to use sbuf_len(sb) + 1 (or add > INCLUDENUL to the args when creating it) and leave the sole SYSCTL_OUT() > at the end. > > You will want to check the one or two other places you converted for this > same issue as well. > Doh! I was trying to keep an eye out for locks, but I missed that one. Fixed in r280014. I'm at that point in a big maintenance task where I've looked at too much code in too short a time, thanks for keeping a watchful eye on all this. -- Ian ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r280015 - head/sys/kern
Author: ian Date: Sun Mar 15 00:36:08 2015 New Revision: 280015 URL: https://svnweb.freebsd.org/changeset/base/280015 Log: Include the nulterm byte in the sysctl string. PR: 195668 Modified: head/sys/kern/kern_cons.c Modified: head/sys/kern/kern_cons.c == --- head/sys/kern/kern_cons.c Sat Mar 14 23:57:33 2015(r280014) +++ head/sys/kern/kern_cons.c Sun Mar 15 00:36:08 2015(r280015) @@ -292,7 +292,8 @@ sysctl_kern_console(SYSCTL_HANDLER_ARGS) int delete, error; struct sbuf *sb; - sb = sbuf_new(NULL, NULL, CNDEVPATHMAX * 2, SBUF_AUTOEXTEND); + sb = sbuf_new(NULL, NULL, CNDEVPATHMAX * 2, SBUF_AUTOEXTEND | + SBUF_INCLUDENUL); if (sb == NULL) return (ENOMEM); sbuf_clear(sb); ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r280016 - head/sys/kern
Author: ian Date: Sun Mar 15 00:39:18 2015 New Revision: 280016 URL: https://svnweb.freebsd.org/changeset/base/280016 Log: Add a nulterm byte to the returned sysctl string. PR: 195668 Modified: head/sys/kern/subr_prf.c Modified: head/sys/kern/subr_prf.c == --- head/sys/kern/subr_prf.cSun Mar 15 00:36:08 2015(r280015) +++ head/sys/kern/subr_prf.cSun Mar 15 00:39:18 2015(r280016) @@ -1009,7 +1009,7 @@ sysctl_kern_msgbuf(SYSCTL_HANDLER_ARGS) len = msgbuf_peekbytes(msgbufp, buf, sizeof(buf), &seq); mtx_unlock(&msgbuf_lock); if (len == 0) - return (0); + return (SYSCTL_OUT(req, "", 1)); /* add nulterm */ error = sysctl_handle_opaque(oidp, buf, len, req); if (error) ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"