Re: svn commit: r279206 - head/sys/kern
On Mon, Feb 23, 2015 at 01:41:36PM +, Andrey V. Elsukov wrote: Author: ae Date: Mon Feb 23 13:41:35 2015 New Revision: 279206 URL: https://svnweb.freebsd.org/changeset/base/279206 Log: In some cases soreceive_dgram() can return no data, but has control message. This can happen when application is sending packets too big for the path MTU and recvmsg() will return zero (indicating no data) but there will be a cmsghdr with cmsg_type set to IPV6_PATHMTU. Remove KASSERT() which does NULL pointer dereference in such case. Also call m_freem() only when m isn't NULL. PR: 197882 MFC after: 1 week Sponsored by: Yandex LLC Modified: head/sys/kern/uipc_socket.c Modified: head/sys/kern/uipc_socket.c == --- head/sys/kern/uipc_socket.c Mon Feb 23 12:54:46 2015 (r279205) +++ head/sys/kern/uipc_socket.c Mon Feb 23 13:41:35 2015 (r279206) @@ -2255,7 +2255,8 @@ soreceive_dgram(struct socket *so, struc * Process one or more MT_CONTROL mbufs present before any data mbufs * in the first mbuf chain on the socket buffer. We call into the * protocol to perform externalization (or freeing if controlp == - * NULL). + * NULL). In some cases there can be only MT_CONTROL mbufs without + * MT_DATA mbufs. */ if (m-m_type == MT_CONTROL) { struct mbuf *cm = NULL, *cmn; @@ -2285,8 +2286,6 @@ soreceive_dgram(struct socket *so, struc cm = cmn; } } - KASSERT(m-m_type == MT_DATA, (soreceive_dgram: !data)); - Should this be changed to m == NULL || m-m_type == MT_DATA ? while (m != NULL uio-uio_resid 0) { len = uio-uio_resid; if (len m-m_len) @@ -2303,9 +2302,10 @@ soreceive_dgram(struct socket *so, struc m-m_len -= len; } } - if (m != NULL) + if (m != NULL) { flags |= MSG_TRUNC; - m_freem(m); + m_freem(m); + } if (flagsp != NULL) *flagsp |= flags; return (0); ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org
svn commit: r279205 - head/sys/ofed/include/linux
Author: hselasky Date: Mon Feb 23 12:54:46 2015 New Revision: 279205 URL: https://svnweb.freebsd.org/changeset/base/279205 Log: Macro fixes: - Add missing order_base_2() macro. - Fix BUILD_BUG_ON() macro. MFC after:1 month Sponsored by: Mellanox Technologies Modified: head/sys/ofed/include/linux/kernel.h head/sys/ofed/include/linux/log2.h Modified: head/sys/ofed/include/linux/kernel.h == --- head/sys/ofed/include/linux/kernel.hMon Feb 23 09:40:59 2015 (r279204) +++ head/sys/ofed/include/linux/kernel.hMon Feb 23 12:54:46 2015 (r279205) @@ -59,7 +59,7 @@ #defineKERN_INFO 6 #defineKERN_DEBUG 7 -#defineBUILD_BUG_ON(x) CTASSERT(x) +#defineBUILD_BUG_ON(x) CTASSERT(!(x)) #define BUG() panic(BUG) #define BUG_ON(condition) do { if (condition) BUG(); } while(0) Modified: head/sys/ofed/include/linux/log2.h == --- head/sys/ofed/include/linux/log2.h Mon Feb 23 09:40:59 2015 (r279204) +++ head/sys/ofed/include/linux/log2.h Mon Feb 23 12:54:46 2015 (r279205) @@ -167,4 +167,6 @@ int __ilog2_u64(u64 n) __ilog2_u64(n) \ ) +#defineorder_base_2(x) ilog2(roundup_pow_of_two(x)) + #endif /* _LINUX_LOG2_H_ */ ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org
svn commit: r279206 - head/sys/kern
Author: ae Date: Mon Feb 23 13:41:35 2015 New Revision: 279206 URL: https://svnweb.freebsd.org/changeset/base/279206 Log: In some cases soreceive_dgram() can return no data, but has control message. This can happen when application is sending packets too big for the path MTU and recvmsg() will return zero (indicating no data) but there will be a cmsghdr with cmsg_type set to IPV6_PATHMTU. Remove KASSERT() which does NULL pointer dereference in such case. Also call m_freem() only when m isn't NULL. PR: 197882 MFC after:1 week Sponsored by: Yandex LLC Modified: head/sys/kern/uipc_socket.c Modified: head/sys/kern/uipc_socket.c == --- head/sys/kern/uipc_socket.c Mon Feb 23 12:54:46 2015(r279205) +++ head/sys/kern/uipc_socket.c Mon Feb 23 13:41:35 2015(r279206) @@ -2255,7 +2255,8 @@ soreceive_dgram(struct socket *so, struc * Process one or more MT_CONTROL mbufs present before any data mbufs * in the first mbuf chain on the socket buffer. We call into the * protocol to perform externalization (or freeing if controlp == -* NULL). +* NULL). In some cases there can be only MT_CONTROL mbufs without +* MT_DATA mbufs. */ if (m-m_type == MT_CONTROL) { struct mbuf *cm = NULL, *cmn; @@ -2285,8 +2286,6 @@ soreceive_dgram(struct socket *so, struc cm = cmn; } } - KASSERT(m-m_type == MT_DATA, (soreceive_dgram: !data)); - while (m != NULL uio-uio_resid 0) { len = uio-uio_resid; if (len m-m_len) @@ -2303,9 +2302,10 @@ soreceive_dgram(struct socket *so, struc m-m_len -= len; } } - if (m != NULL) + if (m != NULL) { flags |= MSG_TRUNC; - m_freem(m); + m_freem(m); + } if (flagsp != NULL) *flagsp |= flags; return (0); ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org
Re: svn commit: r279189 - in head/sys/powerpc: aim fpu include powerpc
On Sunday, February 22, 2015 07:30:14 PM Nathan Whitehorn wrote: On 02/22/15 17:21, Konstantin Belousov wrote: On Sun, Feb 22, 2015 at 09:40:28PM +, Nathan Whitehorn wrote: Author: nwhitehorn Date: Sun Feb 22 21:40:27 2015 New Revision: 279189 URL: https://svnweb.freebsd.org/changeset/base/279189 Log: Kernel support for the Vector-Scalar eXtension (VSX) found on the POWER7 and POWER8. This instruction set unifies the 32 64-bit scalar floating point registers with the 32 128-bit vector registers into a single bank of 64 128-bit registers. Kernel support mostly amounts to saving and restoring the wider version of the floating point registers and making sure that both scalar FP and vector registers are enabled once a VSX instruction is executed. get_mcontext() and friends currently cannot see the high bits, which will require a little more work. As the system compiler (GCC 4.2) does not support VSX, making use of this from userland requires either newer GCC or clang. Handling the similar issue (exploding of the machine state size) for x86 resulted in the creation of the getcontextx(3) API. It is both get/set context(2) syscalls and signal handling which require modifications. For signal handlers and sigreturn(2), it is possible to make it transparent for the consumers, but not for *context(2), since mcontext_t is explicit type allocated by callers. Thanks! I had forgotten about the signal handling issue. Will look into this tomorrow. Don't forget to include the info in cores as well so debuggers can see them (as well as ptrace access if that needs changes). -- John Baldwin ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org
svn commit: r279209 - head/sys/kern
Author: ae Date: Mon Feb 23 15:24:43 2015 New Revision: 279209 URL: https://svnweb.freebsd.org/changeset/base/279209 Log: soreceive_generic() still has similar KASSERT(), therefore instead of remove KASSERT(), change it to check mbuf isn't NULL. Suggested by: kib MFC after:1 week Modified: head/sys/kern/uipc_socket.c Modified: head/sys/kern/uipc_socket.c == --- head/sys/kern/uipc_socket.c Mon Feb 23 15:05:39 2015(r279208) +++ head/sys/kern/uipc_socket.c Mon Feb 23 15:24:43 2015(r279209) @@ -2286,6 +2286,8 @@ soreceive_dgram(struct socket *so, struc cm = cmn; } } + KASSERT(m == NULL || m-m_type == MT_DATA, + (soreceive_dgram: !data)); while (m != NULL uio-uio_resid 0) { len = uio-uio_resid; if (len m-m_len) ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org
Re: svn commit: r279210 - head/sys/dev/usb/controller
On Mon, Feb 23, 2015 at 05:01:39PM +, Hans Petter Selasky wrote: Author: hselasky Date: Mon Feb 23 17:01:38 2015 New Revision: 279210 URL: https://svnweb.freebsd.org/changeset/base/279210 Log: Add support for the DWC OTG v2 chipset found in the STM32F4 series of processors. Make sure we pullup the data lines in device mode when we power on the port. Sounds interesting. STM32F4 is a M4 microcontroller right ? so how this driver works ? Ruslan ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org
svn commit: r279210 - head/sys/dev/usb/controller
Author: hselasky Date: Mon Feb 23 17:01:38 2015 New Revision: 279210 URL: https://svnweb.freebsd.org/changeset/base/279210 Log: Add support for the DWC OTG v2 chipset found in the STM32F4 series of processors. Make sure we pullup the data lines in device mode when we power on the port. MFC after:1 week Modified: head/sys/dev/usb/controller/dwc_otg.c head/sys/dev/usb/controller/dwc_otgreg.h Modified: head/sys/dev/usb/controller/dwc_otg.c == --- head/sys/dev/usb/controller/dwc_otg.c Mon Feb 23 15:24:43 2015 (r279209) +++ head/sys/dev/usb/controller/dwc_otg.c Mon Feb 23 17:01:38 2015 (r279210) @@ -108,12 +108,19 @@ GINTSTS_WKUPINT | GINTSTS_USBSUSP | GINTMSK_OTGINTMSK | \ GINTSTS_SESSREQINT) -static int dwc_otg_use_hsic; +#defineDWC_OTG_PHY_ULPI 0 +#defineDWC_OTG_PHY_HSIC 1 +#defineDWC_OTG_PHY_INTERNAL 2 -static SYSCTL_NODE(_hw_usb, OID_AUTO, dwc_otg, CTLFLAG_RW, 0, USB DWC OTG); +#ifndef DWC_OTG_PHY_DEFAULT +#defineDWC_OTG_PHY_DEFAULT DWC_OTG_PHY_ULPI +#endif + +static int dwc_otg_phy_type = DWC_OTG_PHY_DEFAULT; -SYSCTL_INT(_hw_usb_dwc_otg, OID_AUTO, use_hsic, CTLFLAG_RDTUN, -dwc_otg_use_hsic, 0, DWC OTG uses HSIC interface); +static SYSCTL_NODE(_hw_usb, OID_AUTO, dwc_otg, CTLFLAG_RW, 0, USB DWC OTG); +SYSCTL_INT(_hw_usb_dwc_otg, OID_AUTO, phy_type, CTLFLAG_RDTUN, +dwc_otg_phy_type, 0, DWC OTG PHY TYPE - 0/1/2 - ULPI/HSIC/INTERNAL); #ifdef USB_DEBUG static int dwc_otg_debug; @@ -3766,8 +3773,9 @@ dwc_otg_init(struct dwc_otg_softc *sc) break; } - /* select HSIC or non-HSIC mode */ - if (dwc_otg_use_hsic) { + /* select HSIC, ULPI or internal PHY mode */ + switch (dwc_otg_phy_type) { + case DWC_OTG_PHY_HSIC: DWC_OTG_WRITE_4(sc, DOTG_GUSBCFG, GUSBCFG_PHYIF | GUSBCFG_TRD_TIM_SET(5) | temp); @@ -3779,7 +3787,8 @@ dwc_otg_init(struct dwc_otg_softc *sc) temp ~GLPMCFG_HSIC_CONN); DWC_OTG_WRITE_4(sc, DOTG_GLPMCFG, temp | GLPMCFG_HSIC_CONN); - } else { + break; + case DWC_OTG_PHY_ULPI: DWC_OTG_WRITE_4(sc, DOTG_GUSBCFG, GUSBCFG_ULPI_UTMI_SEL | GUSBCFG_TRD_TIM_SET(5) | temp); @@ -3788,6 +3797,25 @@ dwc_otg_init(struct dwc_otg_softc *sc) temp = DWC_OTG_READ_4(sc, DOTG_GLPMCFG); DWC_OTG_WRITE_4(sc, DOTG_GLPMCFG, temp ~GLPMCFG_HSIC_CONN); + break; + case DWC_OTG_PHY_INTERNAL: + DWC_OTG_WRITE_4(sc, DOTG_GUSBCFG, + GUSBCFG_PHYSEL | + GUSBCFG_TRD_TIM_SET(5) | temp); + DWC_OTG_WRITE_4(sc, DOTG_GOTGCTL, 0); + + temp = DWC_OTG_READ_4(sc, DOTG_GLPMCFG); + DWC_OTG_WRITE_4(sc, DOTG_GLPMCFG, + temp ~GLPMCFG_HSIC_CONN); + + temp = DWC_OTG_READ_4(sc, DOTG_GGPIO); + temp = ~(DOTG_GGPIO_NOVBUSSENS | DOTG_GGPIO_I2CPADEN); + temp |= (DOTG_GGPIO_VBUSASEN | DOTG_GGPIO_VBUSBSEN | + DOTG_GGPIO_PWRDWN); + DWC_OTG_WRITE_4(sc, DOTG_GGPIO, temp); + break; + default: + break; } /* clear global nak */ @@ -3807,9 +3835,6 @@ dwc_otg_init(struct dwc_otg_softc *sc) /* wait 10ms */ usb_pause_mtx(sc-sc_bus.bus_mtx, hz / 100); - /* pull up D+ */ - dwc_otg_pull_up(sc); - temp = DWC_OTG_READ_4(sc, DOTG_GHWCFG3); sc-sc_fifo_size = 4 * GHWCFG3_DFIFODEPTH_GET(temp); @@ -4548,11 +4573,15 @@ tr_handle_set_port_feature: /* nops */ break; case UHF_PORT_POWER: + sc-sc_flags.port_powered = 1; if (sc-sc_mode == DWC_MODE_HOST || sc-sc_mode == DWC_MODE_OTG) { sc-sc_hprt_val |= HPRT_PRTPWR; DWC_OTG_WRITE_4(sc, DOTG_HPRT, sc-sc_hprt_val); } - sc-sc_flags.port_powered = 1; + if (sc-sc_mode == DWC_MODE_DEVICE || sc-sc_mode == DWC_MODE_OTG) { + /* pull up D+, if any */ + dwc_otg_pull_up(sc); + } break; default: err = USB_ERR_IOERROR; Modified: head/sys/dev/usb/controller/dwc_otgreg.h == --- head/sys/dev/usb/controller/dwc_otgreg.hMon Feb 23 15:24:43 2015 (r279209) +++ head/sys/dev/usb/controller/dwc_otgreg.hMon Feb 23 17:01:38 2015 (r279210) @@ -196,6 +196,14 @@ #defineGUSBCFG_TOUTCAL_MASK0x0007 #defineGUSBCFG_TOUTCAL_SHIFT 0 +/* STM32F4 */ +#defineDOTG_GGPIO_NOVBUSSENS (1
Re: svn commit: r279206 - head/sys/kern
On Mon, Feb 23, 2015 at 01:41:36PM +, Andrey V. Elsukov wrote: A Author: ae A Date: Mon Feb 23 13:41:35 2015 A New Revision: 279206 A URL: https://svnweb.freebsd.org/changeset/base/279206 A A Log: A In some cases soreceive_dgram() can return no data, but has control A message. This can happen when application is sending packets too big A for the path MTU and recvmsg() will return zero (indicating no data) A but there will be a cmsghdr with cmsg_type set to IPV6_PATHMTU. A Remove KASSERT() which does NULL pointer dereference in such case. A Also call m_freem() only when m isn't NULL. A A PR:197882 A MFC after: 1 week A Sponsored by: Yandex LLC All this code is so entangled, due to historical decision to have code to handle dgram and stream sockets, data messages and control messages. Now that dgram and stream are almost[1] split, splitting data and control would finish un-entangling. This would require introducing extra pr_ methods, not a big deal. [1] Struct sockbuf is still the same. -- Totus tuus, Glebius. ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org
svn commit: r279213 - head/sys/sys
Author: glebius Date: Mon Feb 23 18:57:09 2015 New Revision: 279213 URL: https://svnweb.freebsd.org/changeset/base/279213 Log: A lot of current code in network stack expects mbufs not having m_nextpkt pointer, assuming that if there is one, then this is a packet batch. Thus, mbufq_dequeue() needs to clear it on mbuf that is being returned. Modified: head/sys/sys/mbuf.h Modified: head/sys/sys/mbuf.h == --- head/sys/sys/mbuf.h Mon Feb 23 18:55:26 2015(r279212) +++ head/sys/sys/mbuf.h Mon Feb 23 18:57:09 2015(r279213) @@ -1282,6 +1282,7 @@ mbufq_dequeue(struct mbufq *mq) m = STAILQ_FIRST(mq-mq_head); if (m) { STAILQ_REMOVE_HEAD(mq-mq_head, m_stailqpkt); + m-m_nextpkt = NULL; mq-mq_len--; } return (m); ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org
Re: svn commit: r279210 - head/sys/dev/usb/controller
On 02/23/15 18:10, Ruslan Bukin wrote: On Mon, Feb 23, 2015 at 05:01:39PM +, Hans Petter Selasky wrote: Author: hselasky Date: Mon Feb 23 17:01:38 2015 New Revision: 279210 URL: https://svnweb.freebsd.org/changeset/base/279210 Log: Add support for the DWC OTG v2 chipset found in the STM32F4 series of processors. Make sure we pullup the data lines in device mode when we power on the port. Sounds interesting. STM32F4 is a M4 microcontroller right ? so how this driver works ? Ruslan This is for an embedded project which is using a port of the FreeBSD USB stack :-) --HPS ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org
svn commit: r279215 - head/sys/arm/arm
Author: ian Date: Mon Feb 23 20:09:05 2015 New Revision: 279215 URL: https://svnweb.freebsd.org/changeset/base/279215 Log: There is no reason to do i+dcache writeback and invalidate when changing the translation table (this may be left over from armv5 days). It's especially bad to do so using a cache operation that isn't coherent on SMP systems. Submitted by: Michal Meloun Modified: head/sys/arm/arm/cpufunc_asm_armv7.S Modified: head/sys/arm/arm/cpufunc_asm_armv7.S == --- head/sys/arm/arm/cpufunc_asm_armv7.SMon Feb 23 19:36:31 2015 (r279214) +++ head/sys/arm/arm/cpufunc_asm_armv7.SMon Feb 23 20:09:05 2015 (r279215) @@ -72,11 +72,7 @@ __FBSDID($FreeBSD$); #endif ENTRY(armv7_setttb) - stmdb sp!, {r0, lr} - bl _C_LABEL(armv7_idcache_wbinv_all) /* clean the D cache */ - ldmia sp!, {r0, lr} dsb - orr r0, r0, #PT_ATTR mcr CP15_TTBR0(r0) isb ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org
svn commit: r279217 - head/sys/powerpc/pseries
Author: nwhitehorn Date: Mon Feb 23 20:38:00 2015 New Revision: 279217 URL: https://svnweb.freebsd.org/changeset/base/279217 Log: Fix race in interrupt handling that could cause IO to hang up under heavy load. Modified: head/sys/powerpc/pseries/phyp_vscsi.c Modified: head/sys/powerpc/pseries/phyp_vscsi.c == --- head/sys/powerpc/pseries/phyp_vscsi.c Mon Feb 23 20:36:07 2015 (r279216) +++ head/sys/powerpc/pseries/phyp_vscsi.c Mon Feb 23 20:38:00 2015 (r279217) @@ -931,10 +931,11 @@ vscsi_check_response_queue(struct vscsi_ mtx_assert(sc-io_lock, MA_OWNED); - phyp_hcall(H_VIO_SIGNAL, sc-unit, 0); - bus_dmamap_sync(sc-crq_tag, sc-crq_map, BUS_DMASYNC_POSTREAD); - while (sc-crq_queue[sc-cur_crq].valid != 0) { + /* The hypercalls at both ends of this are not optimal */ + phyp_hcall(H_VIO_SIGNAL, sc-unit, 0); + bus_dmamap_sync(sc-crq_tag, sc-crq_map, BUS_DMASYNC_POSTREAD); + crq = sc-crq_queue[sc-cur_crq]; switch (crq-valid) { @@ -983,9 +984,9 @@ vscsi_check_response_queue(struct vscsi_ crq-valid = 0; sc-cur_crq = (sc-cur_crq + 1) % sc-n_crqs; - }; - bus_dmamap_sync(sc-crq_tag, sc-crq_map, BUS_DMASYNC_PREWRITE); - phyp_hcall(H_VIO_SIGNAL, sc-unit, 1); + bus_dmamap_sync(sc-crq_tag, sc-crq_map, BUS_DMASYNC_PREWRITE); + phyp_hcall(H_VIO_SIGNAL, sc-unit, 1); + } } ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org
svn commit: r279221 - head/sys/sys
Author: ken Date: Mon Feb 23 22:50:43 2015 New Revision: 279221 URL: https://svnweb.freebsd.org/changeset/base/279221 Log: Bump __FreeBSD_version for the mtio(4) / sa(4) ioctl and API additions in revision 279219. Sponsored by: Spectra Logic MFC after:1 month Modified: head/sys/sys/param.h Modified: head/sys/sys/param.h == --- head/sys/sys/param.hMon Feb 23 22:31:39 2015(r279220) +++ head/sys/sys/param.hMon Feb 23 22:50:43 2015(r279221) @@ -58,7 +58,7 @@ * in the range 5 to 9. */ #undef __FreeBSD_version -#define __FreeBSD_version 1100061 /* Master, propagated to newvers */ +#define __FreeBSD_version 1100062 /* Master, propagated to newvers */ /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org
svn commit: r279222 - head/sys/boot/i386/libi386
Author: grembo (ports committer) Date: Mon Feb 23 22:58:51 2015 New Revision: 279222 URL: https://svnweb.freebsd.org/changeset/base/279222 Log: Improve memory detection in biosmem.c - Add a quirk to allow ignoring e820 extended memory detection. - Improve memory detection through e801. - Add bootloader command biosmem. See differential revision for more details. Reviewed by: jhb, adrian Approved by: adrian Differential Revision: https://reviews.freebsd.org/D1741 Modified: head/sys/boot/i386/libi386/biosmem.c Modified: head/sys/boot/i386/libi386/biosmem.c == --- head/sys/boot/i386/libi386/biosmem.cMon Feb 23 22:50:43 2015 (r279221) +++ head/sys/boot/i386/libi386/biosmem.cMon Feb 23 22:58:51 2015 (r279222) @@ -32,19 +32,63 @@ __FBSDID($FreeBSD$); */ #include stand.h #include machine/pc/bios.h +#include bootstrap.h #include libi386.h #include btxv86.h vm_offset_tmemtop, memtop_copyin, high_heap_base; uint32_t bios_basemem, bios_extmem, high_heap_size; -static struct bios_smap smap; +static struct bios_smap_xattr smap; + +/* + * Used to track which method was used to set BIOS memory + * regions. + */ +static uint8_t b_bios_probed; +#defineB_BASEMEM_E820 0x1 +#defineB_BASEMEM_120x2 +#defineB_EXTMEM_E820 0x4 +#defineB_EXTMEM_E801 0x8 +#defineB_EXTMEM_8800 0x10 /* * The minimum amount of memory to reserve in bios_extmem for the heap. */ #defineHEAP_MIN(3 * 1024 * 1024) +/* + * Products in this list need quirks to detect + * memory correctly. You need both maker and product as + * reported by smbios. + */ +#define BQ_DISTRUST_E820_EXTMEM0x1 /* e820 might not return useful + extended memory */ +struct bios_getmem_quirks { +const char* bios_vendor; +const char*maker; +const char*product; +intquirk; +}; + +static struct bios_getmem_quirks quirks[] = { +{coreboot, Acer, Peppy, BQ_DISTRUST_E820_EXTMEM}, +{NULL, NULL, NULL, 0} +}; + +static int +bios_getquirks(void) +{ +int i; + +for (i=0; quirks[i].quirk != 0; ++i) + if (smbios_match(quirks[i].bios_vendor, quirks[i].maker, + quirks[i].product)) + return (quirks[i].quirk); + +return (0); +} + void bios_getmem(void) { @@ -56,7 +100,7 @@ bios_getmem(void) v86.ctl = V86_FLAGS; v86.addr = 0x15;/* int 0x15 function 0xe820*/ v86.eax = 0xe820; - v86.ecx = sizeof(struct bios_smap); + v86.ecx = sizeof(struct bios_smap_xattr); v86.edx = SMAP_SIG; v86.es = VTOPSEG(smap); v86.edi = VTOPOFF(smap); @@ -65,11 +109,16 @@ bios_getmem(void) break; /* look for a low-memory segment that's large enough */ if ((smap.type == SMAP_TYPE_MEMORY) (smap.base == 0) - (smap.length = (512 * 1024))) + (smap.length = (512 * 1024))) { bios_basemem = smap.length; + b_bios_probed |= B_BASEMEM_E820; + } + /* look for the first segment in 'extended' memory */ - if ((smap.type == SMAP_TYPE_MEMORY) (smap.base == 0x10)) { + if ((smap.type == SMAP_TYPE_MEMORY) (smap.base == 0x10) + !(bios_getquirks() BQ_DISTRUST_E820_EXTMEM)) { bios_extmem = smap.length; + b_bios_probed |= B_EXTMEM_E820; } /* @@ -100,6 +149,7 @@ bios_getmem(void) v86int(); bios_basemem = (v86.eax 0x) * 1024; + b_bios_probed |= B_BASEMEM_12; } /* Fall back through several compatibility functions for extended memory */ @@ -109,7 +159,30 @@ bios_getmem(void) v86.eax = 0xe801; v86int(); if (!(V86_CY(v86.efl))) { - bios_extmem = ((v86.ecx 0x) + ((v86.edx 0x) * 64)) * 1024; + /* +* Clear high_heap; it may end up overlapping +* with the segment we're determining here. +* Let the default steal stuff from top of +* bios_extmem code below pick up on it. +*/ + high_heap_size = 0; + high_heap_base = 0; + + /* +* %cx is the number of 1KiB blocks between 1..16MiB. +* It can only be up to 0x3c00; if it's smaller then +* there's a PC AT memory hole so we can't treat +* it as contiguous. +*/ + bios_extmem = (v86.ecx 0x) * 1024; + if (bios_extmem == (1024 * 0x3c00)) + bios_extmem += (v86.edx 0x) * 64 * 1024; + + /* truncate bios_extmem */ + if (bios_extmem 0x3ff0) + bios_extmem = 0x3ff0; + + b_bios_probed |= B_EXTMEM_E801; } } if (bios_extmem == 0) { @@ -118,6 +191,7 @@
svn commit: r279219 - in head: contrib/groff/tmac lib lib/libmt rescue/rescue share/man/man4 share/mk sys/cam/scsi sys/sys usr.bin/mt
Author: ken Date: Mon Feb 23 21:59:30 2015 New Revision: 279219 URL: https://svnweb.freebsd.org/changeset/base/279219 Log: Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape
svn commit: r279220 - head/usr.sbin/bhyve
Author: grehan Date: Mon Feb 23 22:31:39 2015 New Revision: 279220 URL: https://svnweb.freebsd.org/changeset/base/279220 Log: Don't close a block context if it couldn't be opened, for example if the backing file doesn't exist, avoiding a null deref. Reviewed by: neel MFC after:1 week. Modified: head/usr.sbin/bhyve/pci_ahci.c Modified: head/usr.sbin/bhyve/pci_ahci.c == --- head/usr.sbin/bhyve/pci_ahci.c Mon Feb 23 21:59:30 2015 (r279219) +++ head/usr.sbin/bhyve/pci_ahci.c Mon Feb 23 22:31:39 2015 (r279220) @@ -1968,7 +1968,8 @@ pci_ahci_init(struct vmctx *ctx, struct open_fail: if (ret) { - blockif_close(sc-port[0].bctx); + if (sc-port[0].bctx != NULL) + blockif_close(sc-port[0].bctx); free(sc); } ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org
svn commit: r279231 - head/sys/dev/sfxge
Author: arybchik Date: Tue Feb 24 06:09:31 2015 New Revision: 279231 URL: https://svnweb.freebsd.org/changeset/base/279231 Log: sfxge: add put-list high watermark It is interesting to know how long put-list grows. Sponsored by: Solarflare Communications, Inc. Approved by:gnn (mentor) Modified: head/sys/dev/sfxge/sfxge_tx.c head/sys/dev/sfxge/sfxge_tx.h Modified: head/sys/dev/sfxge/sfxge_tx.c == --- head/sys/dev/sfxge/sfxge_tx.c Tue Feb 24 06:08:55 2015 (r279230) +++ head/sys/dev/sfxge/sfxge_tx.c Tue Feb 24 06:09:31 2015 (r279231) @@ -214,6 +214,9 @@ sfxge_tx_qdpl_swizzle(struct sfxge_txq * count++; } while (mbuf != NULL); + if (count stdp-std_put_hiwat) + stdp-std_put_hiwat = count; + /* Append the reversed put list to the get list. */ KASSERT(*get_tailp == NULL, (*get_tailp != NULL)); *stdp-std_getp = get_next; @@ -1485,6 +1488,10 @@ sfxge_tx_qinit(struct sfxge_softc *sc, u SYSCTL_CHILDREN(txq_node), OID_AUTO, dpl_get_hiwat, CTLFLAG_RD | CTLFLAG_STATS, stdp-std_get_hiwat, 0, ); + SYSCTL_ADD_UINT(device_get_sysctl_ctx(sc-dev), + SYSCTL_CHILDREN(txq_node), OID_AUTO, + dpl_put_hiwat, CTLFLAG_RD | CTLFLAG_STATS, + stdp-std_put_hiwat, 0, ); #endif txq-type = type; Modified: head/sys/dev/sfxge/sfxge_tx.h == --- head/sys/dev/sfxge/sfxge_tx.h Tue Feb 24 06:08:55 2015 (r279230) +++ head/sys/dev/sfxge/sfxge_tx.h Tue Feb 24 06:09:31 2015 (r279231) @@ -102,6 +102,8 @@ struct sfxge_tx_dpl { * in get list */ unsigned intstd_get_hiwat; /* Packets in get list * high watermark */ + unsigned intstd_put_hiwat; /* Packets in put list +* high watermark */ }; ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org
svn commit: r279230 - head/sys/dev/sfxge
Author: arybchik Date: Tue Feb 24 06:08:55 2015 New Revision: 279230 URL: https://svnweb.freebsd.org/changeset/base/279230 Log: sfxge: use goto to cleanup to avoid duplicate cleanup code Sponsored by: Solarflare Communications, Inc. Approved by:gnn (mentor) Modified: head/sys/dev/sfxge/sfxge_dma.c Modified: head/sys/dev/sfxge/sfxge_dma.c == --- head/sys/dev/sfxge/sfxge_dma.c Tue Feb 24 05:43:16 2015 (r279229) +++ head/sys/dev/sfxge/sfxge_dma.c Tue Feb 24 06:08:55 2015 (r279230) @@ -141,7 +141,7 @@ sfxge_dma_alloc(struct sfxge_softc *sc, MIN(0x3FFFUL, BUS_SPACE_MAXADDR), BUS_SPACE_MAXADDR, NULL, NULL, len, 1, len, 0, NULL, NULL, esmp-esm_tag) != 0) { device_printf(sc-dev, Couldn't allocate txq DMA tag\n); - return (ENOMEM); + goto fail_tag_create; } /* Allocate kernel memory. */ @@ -149,17 +149,14 @@ sfxge_dma_alloc(struct sfxge_softc *sc, BUS_DMA_WAITOK | BUS_DMA_COHERENT | BUS_DMA_ZERO, esmp-esm_map) != 0) { device_printf(sc-dev, Couldn't allocate DMA memory\n); - bus_dma_tag_destroy(esmp-esm_tag); - return (ENOMEM); + goto fail_alloc; } /* Load map into device memory. */ if (bus_dmamap_load(esmp-esm_tag, esmp-esm_map, vaddr, len, sfxge_dma_cb, esmp-esm_addr, 0) != 0) { device_printf(sc-dev, Couldn't load DMA mapping\n); - bus_dmamem_free(esmp-esm_tag, vaddr, esmp-esm_map); - bus_dma_tag_destroy(esmp-esm_tag); - return (ENOMEM); + goto fail_load; } /* @@ -167,15 +164,20 @@ sfxge_dma_alloc(struct sfxge_softc *sc, * and will have set esm_addr to 0 if something went * wrong. */ - if (esmp-esm_addr == 0) { - bus_dmamem_free(esmp-esm_tag, vaddr, esmp-esm_map); - bus_dma_tag_destroy(esmp-esm_tag); - return (ENOMEM); - } + if (esmp-esm_addr == 0) + goto fail_load_check; esmp-esm_base = vaddr; return (0); + +fail_load_check: +fail_load: + bus_dmamem_free(esmp-esm_tag, vaddr, esmp-esm_map); +fail_alloc: + bus_dma_tag_destroy(esmp-esm_tag); +fail_tag_create: + return (ENOMEM); } void ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org
svn commit: r279223 - head/sys/dev/bce
Author: yongari Date: Tue Feb 24 01:00:46 2015 New Revision: 279223 URL: https://svnweb.freebsd.org/changeset/base/279223 Log: Correct a typo. Reported by: jmg Modified: head/sys/dev/bce/if_bcereg.h Modified: head/sys/dev/bce/if_bcereg.h == --- head/sys/dev/bce/if_bcereg.hMon Feb 23 22:58:51 2015 (r279222) +++ head/sys/dev/bce/if_bcereg.hTue Feb 24 01:00:46 2015 (r279223) @@ -419,7 +419,7 @@ /* Returns FALSE in defects per 2^31 - 1 calls, otherwise returns TRUE. */ #define DB_RANDOMFALSE(defects)(random() defects) #define DB_OR_RANDOMFALSE(defects) || (random() defects) -#define DB_AND_RANDOMFALSE(defects) (random() ddfects) +#define DB_AND_RANDOMFALSE(defects) (random() defects) /* Returns TRUE in defects per 2^31 - 1 calls, otherwise returns FALSE. */ #define DB_RANDOMTRUE(defects) (random() defects) ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org
svn commit: r279227 - head/usr.sbin/bhyve
Author: neel Date: Tue Feb 24 05:15:40 2015 New Revision: 279227 URL: https://svnweb.freebsd.org/changeset/base/279227 Log: Emulate MSR 0xC0011024 when running on AMD processors. OpenBSD guests test bit 0 of this MSR to detect whether the workaround for erratum 721 has been applied. Reported by: Jason Tubnor (ja...@tubnor.net) MFC after:1 week Modified: head/usr.sbin/bhyve/xmsr.c Modified: head/usr.sbin/bhyve/xmsr.c == --- head/usr.sbin/bhyve/xmsr.c Tue Feb 24 04:05:32 2015(r279226) +++ head/usr.sbin/bhyve/xmsr.c Tue Feb 24 05:15:40 2015(r279227) @@ -185,6 +185,15 @@ emulate_rdmsr(struct vmctx *ctx, int vcp *val = 0; break; + /* +* OpenBSD guests test bit 0 of this MSR to detect if the +* workaround for erratum 721 is already applied. +* http://support.amd.com/TechDocs/41322_10h_Rev_Gd.pdf +*/ + case 0xC0011029: + *val = 1; + break; + default: error = -1; break; ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org
svn commit: r279229 - head/sys/cam/scsi
Author: ken Date: Tue Feb 24 05:43:16 2015 New Revision: 279229 URL: https://svnweb.freebsd.org/changeset/base/279229 Log: Fix printf format warnings on sparc64 and mips. Sponsored by: Spectra Logic MFC after:1 month Modified: head/sys/cam/scsi/scsi_sa.c Modified: head/sys/cam/scsi/scsi_sa.c == --- head/sys/cam/scsi/scsi_sa.c Tue Feb 24 05:35:15 2015(r279228) +++ head/sys/cam/scsi/scsi_sa.c Tue Feb 24 05:43:16 2015(r279229) @@ -4432,7 +4432,7 @@ saextget(struct cdev *dev, struct cam_pe ts2_len); SASBADDVARSTRDESC(sb, indent, tmpstr2, %s, serial_num, - cgd.serial_num_len + 1, Serial Number); + (ssize_t)cgd.serial_num_len + 1, Serial Number); if (ts2_malloc != 0) free(tmpstr2, M_SCSISA); } else { @@ -4441,8 +4441,8 @@ saextget(struct cdev *dev, struct cam_pe * be empty if the device has no serial number. */ tmpstr[0] = '\0'; - SASBADDVARSTRDESC(sb, indent, tmpstr, %s, serial_num, 0, - Serial Number); + SASBADDVARSTRDESC(sb, indent, tmpstr, %s, serial_num, + (ssize_t)0, Serial Number); } SASBADDUINTDESC(sb, indent, softc-maxio, %u, maxio, ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org
svn commit: r279225 - head/usr.sbin/bhyve
Author: neel Date: Tue Feb 24 02:04:16 2015 New Revision: 279225 URL: https://svnweb.freebsd.org/changeset/base/279225 Log: Add -u option to bhyve(8) to indicate that the RTC should maintain UTC time. The default remains localtime for compatibility with the original device model in bhyve(8). This is required for OpenBSD guests which assume that the RTC keeps UTC time. Reviewed by: grehan Pointed out by: Jason Tubnor (ja...@tubnor.net) MFC after:2 weeks Modified: head/usr.sbin/bhyve/bhyve.8 head/usr.sbin/bhyve/bhyverun.c head/usr.sbin/bhyve/rtc.c head/usr.sbin/bhyve/rtc.h Modified: head/usr.sbin/bhyve/bhyve.8 == --- head/usr.sbin/bhyve/bhyve.8 Tue Feb 24 01:46:43 2015(r279224) +++ head/usr.sbin/bhyve/bhyve.8 Tue Feb 24 02:04:16 2015(r279225) @@ -32,7 +32,7 @@ .Nd run a guest operating system inside a virtual machine .Sh SYNOPSIS .Nm -.Op Fl abehwxACHPWY +.Op Fl abehuwxACHPWY .Op Fl c Ar numcpus .Op Fl g Ar gdbport .Op Fl l Ar lpcdev Ns Op , Ns Ar conf @@ -239,6 +239,8 @@ The host device must have been reserved loader variable as described in .Xr vmm 4 . .El +.It Fl u +RTC keeps UTC time. .It Fl U Ar uuid Set the universally unique identifier .Pq UUID Modified: head/usr.sbin/bhyve/bhyverun.c == --- head/usr.sbin/bhyve/bhyverun.c Tue Feb 24 01:46:43 2015 (r279224) +++ head/usr.sbin/bhyve/bhyverun.c Tue Feb 24 02:04:16 2015 (r279225) @@ -122,7 +122,7 @@ usage(int code) { fprintf(stderr, -Usage: %s [-abehwxACHPWY] [-c vcpus] [-g gdb port] [-l lpc]\n +Usage: %s [-abehuwxACHPWY] [-c vcpus] [-g gdb port] [-l lpc]\n %*s [-m mem] [-p vcpu:hostcpu] [-s pci] [-U uuid] vm\n -a: local apic is in xAPIC mode (deprecated)\n -A: create ACPI tables\n @@ -137,6 +137,7 @@ usage(int code) -p: pin 'vcpu' to 'hostcpu'\n -P: vmexit from the guest on pause\n -s: slot,driver,configinfo PCI slot config\n + -u: RTC keeps UTC time\n -U: uuid\n -w: ignore unimplemented MSRs\n -W: force virtio to use single-vector MSI\n @@ -685,6 +686,7 @@ main(int argc, char *argv[]) { int c, error, gdb_port, err, bvmcons; int dump_guest_memory, max_vcpus, mptgen; + int rtc_localtime; struct vmctx *ctx; uint64_t rip; size_t memsize; @@ -696,8 +698,9 @@ main(int argc, char *argv[]) guest_ncpus = 1; memsize = 256 * MB; mptgen = 1; + rtc_localtime = 1; - while ((c = getopt(argc, argv, abehwxACHIPWYp:g:c:s:m:l:U:)) != -1) { + while ((c = getopt(argc, argv, abehuwxACHIPWYp:g:c:s:m:l:U:)) != -1) { switch (c) { case 'a': x2apic_mode = 0; @@ -757,6 +760,9 @@ main(int argc, char *argv[]) case 'e': strictio = 1; break; + case 'u': + rtc_localtime = 0; + break; case 'U': guest_uuid_str = optarg; break; @@ -820,7 +826,7 @@ main(int argc, char *argv[]) pci_irq_init(ctx); ioapic_init(ctx); - rtc_init(ctx); + rtc_init(ctx, rtc_localtime); sci_init(ctx); /* Modified: head/usr.sbin/bhyve/rtc.c == --- head/usr.sbin/bhyve/rtc.c Tue Feb 24 01:46:43 2015(r279224) +++ head/usr.sbin/bhyve/rtc.c Tue Feb 24 02:04:16 2015(r279225) @@ -55,23 +55,23 @@ __FBSDID($FreeBSD$); /* * Returns the current RTC time as number of seconds since 00:00:00 Jan 1, 1970 - * - * XXX this always returns localtime to maintain compatibility with the - * original device model. */ static time_t -rtc_time(struct vmctx *ctx) +rtc_time(struct vmctx *ctx, int use_localtime) { struct tm tm; time_t t; time(t); - localtime_r(t, tm); - return (timegm(tm)); + if (use_localtime) { + localtime_r(t, tm); + t = timegm(tm); + } + return (t); } void -rtc_init(struct vmctx *ctx) +rtc_init(struct vmctx *ctx, int use_localtime) { size_t himem; size_t lomem; @@ -99,7 +99,7 @@ rtc_init(struct vmctx *ctx) err = vm_rtc_write(ctx, RTC_HMEM_MSB, himem 16); assert(err == 0); - err = vm_rtc_settime(ctx, rtc_time(ctx)); + err = vm_rtc_settime(ctx, rtc_time(ctx, use_localtime)); assert(err == 0); } Modified: head/usr.sbin/bhyve/rtc.h
svn commit: r279228 - head/sys/amd64/vmm/intel
Author: neel Date: Tue Feb 24 05:35:15 2015 New Revision: 279228 URL: https://svnweb.freebsd.org/changeset/base/279228 Log: Always emulate MSR_PAT on Intel processors and don't rely on PAT save/restore capability of VT-x. This lets bhyve run nested in older VMware versions that don't support the PAT save/restore capability. Note that the actual value programmed by the guest in MSR_PAT is irrelevant because bhyve sets the 'Ignore PAT' bit in the nested PTE. Reported by: marcel Tested by:Leon Dang (ld...@nahannisys.com) Sponsored by: Nahanni Systems MFC after:2 weeks Modified: head/sys/amd64/vmm/intel/vmcs.c head/sys/amd64/vmm/intel/vmx.c head/sys/amd64/vmm/intel/vmx.h head/sys/amd64/vmm/intel/vmx_msr.c Modified: head/sys/amd64/vmm/intel/vmcs.c == --- head/sys/amd64/vmm/intel/vmcs.c Tue Feb 24 05:15:40 2015 (r279227) +++ head/sys/amd64/vmm/intel/vmcs.c Tue Feb 24 05:35:15 2015 (r279228) @@ -342,18 +342,6 @@ vmcs_init(struct vmcs *vmcs) */ VMPTRLD(vmcs); - /* Initialize guest IA32_PAT MSR with the default value */ - pat = PAT_VALUE(0, PAT_WRITE_BACK) | - PAT_VALUE(1, PAT_WRITE_THROUGH) | - PAT_VALUE(2, PAT_UNCACHED)| - PAT_VALUE(3, PAT_UNCACHEABLE) | - PAT_VALUE(4, PAT_WRITE_BACK) | - PAT_VALUE(5, PAT_WRITE_THROUGH) | - PAT_VALUE(6, PAT_UNCACHED)| - PAT_VALUE(7, PAT_UNCACHEABLE); - if ((error = vmwrite(VMCS_GUEST_IA32_PAT, pat)) != 0) - goto done; - /* Host state */ /* Initialize host IA32_PAT MSR */ Modified: head/sys/amd64/vmm/intel/vmx.c == --- head/sys/amd64/vmm/intel/vmx.c Tue Feb 24 05:15:40 2015 (r279227) +++ head/sys/amd64/vmm/intel/vmx.c Tue Feb 24 05:35:15 2015 (r279228) @@ -100,13 +100,11 @@ __FBSDID($FreeBSD$); (VM_EXIT_HOST_LMA | \ VM_EXIT_SAVE_EFER | \ VM_EXIT_LOAD_EFER | \ - VM_EXIT_ACKNOWLEDGE_INTERRUPT | \ - VM_EXIT_SAVE_PAT| \ - VM_EXIT_LOAD_PAT) + VM_EXIT_ACKNOWLEDGE_INTERRUPT) #defineVM_EXIT_CTLS_ZERO_SETTING VM_EXIT_SAVE_DEBUG_CONTROLS -#defineVM_ENTRY_CTLS_ONE_SETTING (VM_ENTRY_LOAD_EFER | VM_ENTRY_LOAD_PAT) +#defineVM_ENTRY_CTLS_ONE_SETTING (VM_ENTRY_LOAD_EFER) #defineVM_ENTRY_CTLS_ZERO_SETTING \ (VM_ENTRY_LOAD_DEBUG_CONTROLS | \ @@ -859,10 +857,6 @@ vmx_vminit(struct vm *vm, pmap_t pmap) * VM exit and entry respectively. It is also restored from the * host VMCS area on a VM exit. * -* MSR_PAT is saved and restored in the guest VMCS are on a VM exit -* and entry respectively. It is also restored from the host VMCS -* area on a VM exit. -* * The TSC MSR is exposed read-only. Writes are disallowed as that * will impact the host TSC. * XXX Writes would be implemented with a wrmsr trap, and @@ -874,7 +868,6 @@ vmx_vminit(struct vm *vm, pmap_t pmap) guest_msr_rw(vmx, MSR_SYSENTER_ESP_MSR) || guest_msr_rw(vmx, MSR_SYSENTER_EIP_MSR) || guest_msr_rw(vmx, MSR_EFER) || - guest_msr_rw(vmx, MSR_PAT) || guest_msr_ro(vmx, MSR_TSC)) panic(vmx_vminit: error setting guest msr access); Modified: head/sys/amd64/vmm/intel/vmx.h == --- head/sys/amd64/vmm/intel/vmx.h Tue Feb 24 05:15:40 2015 (r279227) +++ head/sys/amd64/vmm/intel/vmx.h Tue Feb 24 05:35:15 2015 (r279228) @@ -103,6 +103,7 @@ enum { IDX_MSR_STAR, IDX_MSR_SF_MASK, IDX_MSR_KGSBASE, + IDX_MSR_PAT, GUEST_MSR_NUM /* must be the last enumeration */ }; Modified: head/sys/amd64/vmm/intel/vmx_msr.c == --- head/sys/amd64/vmm/intel/vmx_msr.c Tue Feb 24 05:15:40 2015 (r279227) +++ head/sys/amd64/vmm/intel/vmx_msr.c Tue Feb 24 05:35:15 2015 (r279228) @@ -230,6 +230,25 @@ westmere_cpu(void) return (false); } +static bool +pat_valid(uint64_t val) +{ + int i, pa; + + /* +* From Intel SDM: Table Memory Types That Can Be Encoded With PAT +* +* Extract PA0 through PA7 and validate that each one encodes a +* valid memory type. +*/ + for (i = 0; i 8; i++) { + pa =
svn commit: r279232 - in head/sys/dev: ixl netmap
Author: luigi Date: Tue Feb 24 06:20:50 2015 New Revision: 279232 URL: https://svnweb.freebsd.org/changeset/base/279232 Log: Add native netmap support to ixl. Preliminary tests indicate 32 Mpps on tx, 24 Mpps on rx with source and receiver on two different ports of the same 40G card. Optimizations are likely possible. The code follows closely the one for ixgbe so i do not expect stability issues. Hardware kindly supplied by Intel. Reviewed by: Jack Vogel MFC after:1 week Added: head/sys/dev/netmap/if_ixl_netmap.h (contents, props changed) Modified: head/sys/dev/ixl/if_ixl.c head/sys/dev/ixl/ixl_txrx.c Modified: head/sys/dev/ixl/if_ixl.c == --- head/sys/dev/ixl/if_ixl.c Tue Feb 24 06:09:31 2015(r279231) +++ head/sys/dev/ixl/if_ixl.c Tue Feb 24 06:20:50 2015(r279232) @@ -213,6 +213,9 @@ DRIVER_MODULE(ixl, pci, ixl_driver, ixl_ MODULE_DEPEND(ixl, pci, 1, 1, 1); MODULE_DEPEND(ixl, ether, 1, 1, 1); +#ifdef DEV_NETMAP +MODULE_DEPEND(ixl, netmap, 1, 1, 1); +#endif /* DEV_NETMAP */ /* ** Global reset mutex @@ -287,6 +290,10 @@ int ixl_atr_rate = 20; TUNABLE_INT(hw.ixl.atr_rate, ixl_atr_rate); #endif +#ifdef DEV_NETMAP +#define NETMAP_IXL_MAIN /* only bring in one part of the netmap code */ +#include dev/netmap/if_ixl_netmap.h +#endif /* DEV_NETMAP */ static char *ixl_fc_string[6] = { None, @@ -647,6 +654,9 @@ ixl_attach(device_t dev) ixl_unregister_vlan, vsi, EVENTHANDLER_PRI_FIRST); +#ifdef DEV_NETMAP + ixl_netmap_attach(vsi); +#endif /* DEV_NETMAP */ INIT_DEBUGOUT(ixl_attach: end); return (0); @@ -725,6 +735,9 @@ ixl_detach(device_t dev) EVENTHANDLER_DEREGISTER(vlan_unconfig, vsi-vlan_detach); callout_drain(pf-timer); +#ifdef DEV_NETMAP + netmap_detach(vsi-ifp); +#endif /* DEV_NETMAP */ ixl_free_pci_resources(pf); @@ -2662,6 +2675,15 @@ ixl_initialize_vsi(struct ixl_vsi *vsi) break; } wr32(vsi-hw, I40E_QRX_TAIL(que-me), 0); +#ifdef DEV_NETMAP + /* preserve queue */ + if (vsi-ifp-if_capenable IFCAP_NETMAP) { + struct netmap_adapter *na = NA(vsi-ifp); + struct netmap_kring *kring = na-rx_rings[i]; + int t = na-num_rx_desc - 1 - nm_kr_rxspace(kring); + wr32(vsi-hw, I40E_QRX_TAIL(que-me), t); + } else +#endif /* DEV_NETMAP */ wr32(vsi-hw, I40E_QRX_TAIL(que-me), que-num_desc - 1); } return (err); Modified: head/sys/dev/ixl/ixl_txrx.c == --- head/sys/dev/ixl/ixl_txrx.c Tue Feb 24 06:09:31 2015(r279231) +++ head/sys/dev/ixl/ixl_txrx.c Tue Feb 24 06:20:50 2015(r279232) @@ -62,6 +62,10 @@ static __inline void ixl_rx_discard(stru static __inline void ixl_rx_input(struct rx_ring *, struct ifnet *, struct mbuf *, u8); +#ifdef DEV_NETMAP +#include dev/netmap/if_ixl_netmap.h +#endif /* DEV_NETMAP */ + /* ** Multiqueue Transmit driver ** @@ -486,9 +490,21 @@ ixl_init_tx_ring(struct ixl_queue *que) { struct tx_ring *txr = que-txr; struct ixl_tx_buf *buf; +#ifdef DEV_NETMAP + struct netmap_adapter *na = NA(que-vsi-ifp); + struct netmap_slot *slot; +#endif /* DEV_NETMAP */ /* Clear the old ring contents */ IXL_TX_LOCK(txr); +#ifdef DEV_NETMAP + /* +* (under lock): if in netmap mode, do some consistency +* checks and set slot to entry 0 of the netmap ring. +*/ + slot = netmap_reset(na, NR_TX, que-me, 0); +#endif /* DEV_NETMAP */ + bzero((void *)txr-base, (sizeof(struct i40e_tx_desc)) * que-num_desc); @@ -512,6 +528,19 @@ ixl_init_tx_ring(struct ixl_queue *que) m_freem(buf-m_head); buf-m_head = NULL; } +#ifdef DEV_NETMAP + /* +* In netmap mode, set the map for the packet buffer. +* NOTE: Some drivers (not this one) also need to set +* the physical buffer address in the NIC ring. +* netmap_idx_n2k() maps a nic index, i, into the corresponding +* netmap slot index, si +*/ + if (slot) { + int si = netmap_idx_n2k(na-tx_rings[que-me], i); + netmap_load_map(na, buf-tag, buf-map, NMB(na, slot + si)); + } +#endif /* DEV_NETMAP */ /* Clear the EOP index */ buf-eop_index = -1; } @@ -823,6 +852,11 @@ ixl_txeof(struct ixl_queue *que) mtx_assert(txr-mtx, MA_OWNED); +#ifdef DEV_NETMAP + // XXX todo: implement moderation + if (netmap_tx_irq(que-vsi-ifp, que-me)) +