From owner-svn-src-projects@FreeBSD.ORG Mon Dec 27 00:12:58 2010 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0DE691065670; Mon, 27 Dec 2010 00:12:58 +0000 (UTC) (envelope-from jeff@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id F11148FC23; Mon, 27 Dec 2010 00:12:57 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id oBR0Cvsu004405; Mon, 27 Dec 2010 00:12:57 GMT (envelope-from jeff@svn.freebsd.org) Received: (from jeff@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oBR0CvuH004401; Mon, 27 Dec 2010 00:12:57 GMT (envelope-from jeff@svn.freebsd.org) Message-Id: <201012270012.oBR0CvuH004401@svn.freebsd.org> From: Jeff Roberson Date: Mon, 27 Dec 2010 00:12:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r216727 - projects/ofed/head/sys/ofed/drivers/infiniband/ulp/sdp X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 27 Dec 2010 00:12:58 -0000 Author: jeff Date: Mon Dec 27 00:12:57 2010 New Revision: 216727 URL: http://svn.freebsd.org/changeset/base/216727 Log: - Implement missing OOB support modeled after TCP. - Document and resolve some potential socket teardown races with rx. The rx path proceeds under a separate lock and ssk->socket may become NULL while it's operating. Sponsored by: Isilon Systems, iX Systems, and Panasas. Modified: projects/ofed/head/sys/ofed/drivers/infiniband/ulp/sdp/sdp.h projects/ofed/head/sys/ofed/drivers/infiniband/ulp/sdp/sdp_main.c projects/ofed/head/sys/ofed/drivers/infiniband/ulp/sdp/sdp_rx.c Modified: projects/ofed/head/sys/ofed/drivers/infiniband/ulp/sdp/sdp.h ============================================================================== --- projects/ofed/head/sys/ofed/drivers/infiniband/ulp/sdp/sdp.h Sun Dec 26 23:19:16 2010 (r216726) +++ projects/ofed/head/sys/ofed/drivers/infiniband/ulp/sdp/sdp.h Mon Dec 27 00:12:57 2010 (r216727) @@ -357,6 +357,7 @@ struct sdp_moderation { int moder_time; }; +/* These are flags fields. */ #define SDP_TIMEWAIT 0x0001 /* In ssk timewait state. */ #define SDP_DROPPED 0x0002 /* Socket has been dropped. */ #define SDP_SOCKREF 0x0004 /* Holding a sockref for close. */ @@ -364,8 +365,10 @@ struct sdp_moderation { #define SDP_NEEDFIN 0x0010 /* Send a fin on the next tx. */ #define SDP_DREQWAIT 0x0020 /* Waiting on DREQ. */ #define SDP_HAVEOOB 0x0040 /* Have OOB data. */ -#define SDP_HADOOB 0x0080 /* Had OOB data. */ -#define SDP_DESTROY 0x0100 /* Being destroyed. */ + +/* These are oobflags */ +#define SDP_HADOOB 0x0001 /* Had OOB data. */ +#define SDP_DESTROY 0x0002 /* Being destroyed. */ struct sdp_sock { LIST_ENTRY(sdp_sock) list; @@ -383,6 +386,7 @@ struct sdp_sock { in_port_t fport; in_addr_t faddr; int flags; + int oobflags; /* protected by rx lock. */ int state; int softerror; int recv_bytes; /* Bytes per recv. buf including header */ Modified: projects/ofed/head/sys/ofed/drivers/infiniband/ulp/sdp/sdp_main.c ============================================================================== --- projects/ofed/head/sys/ofed/drivers/infiniband/ulp/sdp/sdp_main.c Sun Dec 26 23:19:16 2010 (r216726) +++ projects/ofed/head/sys/ofed/drivers/infiniband/ulp/sdp/sdp_main.c Mon Dec 27 00:12:57 2010 (r216727) @@ -1391,6 +1391,10 @@ sdp_rcvoob(struct socket *so, struct mbu ssk = sdp_sk(so); SDP_WLOCK(ssk); + if (!rx_ring_trylock(&ssk->rx_ring)) { + SDP_WUNLOCK(ssk); + return (ECONNRESET); + } if (ssk->flags & (SDP_TIMEWAIT | SDP_DROPPED)) { error = ECONNRESET; goto out; @@ -1398,20 +1402,20 @@ sdp_rcvoob(struct socket *so, struct mbu if ((so->so_oobmark == 0 && (so->so_rcv.sb_state & SBS_RCVATMARK) == 0) || so->so_options & SO_OOBINLINE || - ssk->flags & SDP_HADOOB) { + ssk->oobflags & SDP_HADOOB) { error = EINVAL; goto out; } - if ((ssk->flags & SDP_HAVEOOB) == 0) { + if ((ssk->oobflags & SDP_HAVEOOB) == 0) { error = EWOULDBLOCK; goto out; } m->m_len = 1; *mtod(m, caddr_t) = ssk->iobc; if ((flags & MSG_PEEK) == 0) - ssk->flags ^= (SDP_HAVEOOB | SDP_HADOOB); - + ssk->oobflags ^= (SDP_HAVEOOB | SDP_HADOOB); out: + rx_ring_unlock(&ssk->rx_ring); SDP_WUNLOCK(ssk); return (error); } @@ -1425,6 +1429,28 @@ sdp_sock_init(void *mem, int size, int f return (0); } +void +sdp_urg(struct sdp_sock *ssk, struct mbuf *mb) +{ + struct mbuf *m; + struct socket *so; + + so = ssk->socket; + if (so == NULL) + return; + + so->so_oobmark = so->so_rcv.sb_cc + mb->m_pkthdr.len - 1; + sohasoutofband(so); + ssk->oobflags &= ~(SDP_HAVEOOB | SDP_HADOOB); + if (!(so->so_options & SO_OOBINLINE)) { + for (m = mb; m->m_next != NULL; m = m->m_next); + ssk->iobc = *(mtod(m, char *) + m->m_len - 1); + ssk->oobflags |= SDP_HAVEOOB; + m->m_len--; + mb->m_pkthdr.len--; + } +} + /* * Notify a sdp socket of an asynchronous error. * Modified: projects/ofed/head/sys/ofed/drivers/infiniband/ulp/sdp/sdp_rx.c ============================================================================== --- projects/ofed/head/sys/ofed/drivers/infiniband/ulp/sdp/sdp_rx.c Sun Dec 26 23:19:16 2010 (r216726) +++ projects/ofed/head/sys/ofed/drivers/infiniband/ulp/sdp/sdp_rx.c Mon Dec 27 00:12:57 2010 (r216727) @@ -166,7 +166,7 @@ sdp_post_recvs_needed(struct sdp_sock *s int buffer_size = ssk->recv_bytes; unsigned long max_bytes; - if (!ssk->qp_active) + if (!ssk->qp_active || !ssk->socket) return 0; max_bytes = ssk->socket->so_snd.sb_mbmax * scale; @@ -243,8 +243,8 @@ sdp_sock_queue_rcv_mb(struct socket *sk, m_adj(mb, SDP_HEAD_SIZE); SOCKBUF_LOCK(&sk->so_rcv); -/* if (unlikely(h->flags & SDP_OOB_PRES)) - sdp_urg(ssk, mb); XXX */ + if (unlikely(h->flags & SDP_OOB_PRES)) + sdp_urg(ssk, mb); sbappend_locked(&sk->so_rcv, mb); sorwakeup_locked(sk); return mb; @@ -327,9 +327,10 @@ static int sdp_process_rx_ctl_mb(struct sdp_sock *ssk, struct mbuf *mb) { struct sdp_bsdh *h; - struct socket *sk = ssk->socket; + struct socket *sk; SDP_WLOCK_ASSERT(ssk); + sk = ssk->socket; h = mtod(mb, struct sdp_bsdh *); switch (h->mid) { case SDP_MID_DATA: @@ -404,12 +405,23 @@ sdp_process_rx_ctl_mb(struct sdp_sock *s static int sdp_process_rx_mb(struct sdp_sock *ssk, struct mbuf *mb) { - struct socket *sk = ssk->socket; + struct socket *sk; struct sdp_bsdh *h; unsigned long mseq_ack; int credits_before; h = mtod(mb, struct sdp_bsdh *); + sk = ssk->socket; + /* + * If another thread is in so_pcbfree this may be partially torn + * down but no further synchronization is required as the destroying + * thread will wait for receive to shutdown before discarding the + * socket. + */ + if (sk == NULL) { + m_freem(mb); + return 0; + } SDPSTATS_HIST_LINEAR(credits_before_update, tx_credits(ssk)); @@ -481,7 +493,7 @@ sdp_process_rx_wc(struct sdp_sock *ssk, return NULL; if (unlikely(wc->status)) { - if (ssk->qp_active) { + if (ssk->qp_active && sk) { sdp_dbg(sk, "Recv completion with error. " "Status %d, vendor: %d\n", wc->status, wc->vendor_err); @@ -524,7 +536,7 @@ sdp_bzcopy_write_space(struct sdp_sock * { struct socket *sk = ssk->socket; - if (tx_credits(ssk) >= ssk->min_bufs) + if (tx_credits(ssk) >= ssk->min_bufs && sk) sowwakeup(sk); } From owner-svn-src-projects@FreeBSD.ORG Mon Dec 27 05:47:25 2010 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0DFEF106566C; Mon, 27 Dec 2010 05:47:25 +0000 (UTC) (envelope-from jeff@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id EF9D08FC13; Mon, 27 Dec 2010 05:47:24 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id oBR5lO0K012481; Mon, 27 Dec 2010 05:47:24 GMT (envelope-from jeff@svn.freebsd.org) Received: (from jeff@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oBR5lOhJ012472; Mon, 27 Dec 2010 05:47:24 GMT (envelope-from jeff@svn.freebsd.org) Message-Id: <201012270547.oBR5lOhJ012472@svn.freebsd.org> From: Jeff Roberson Date: Mon, 27 Dec 2010 05:47:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r216729 - in projects/ofed/head/sys/ofed: drivers/infiniband/hw/mthca drivers/net/mlx4 include/linux X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 27 Dec 2010 05:47:25 -0000 Author: jeff Date: Mon Dec 27 05:47:24 2010 New Revision: 216729 URL: http://svn.freebsd.org/changeset/base/216729 Log: - Implement Linux compatible support for msix, removing some diffs against driver sources. - Add plubming to find the device based on the irq to eliminate another linux incompatibility in request_irq(). - Implement free_irq() which was previously empty. Sponsored by: Isilon Systems, iX Systems, and Panasas. Modified: projects/ofed/head/sys/ofed/drivers/infiniband/hw/mthca/mthca_eq.c projects/ofed/head/sys/ofed/drivers/infiniband/hw/mthca/mthca_main.c projects/ofed/head/sys/ofed/drivers/net/mlx4/eq.c projects/ofed/head/sys/ofed/drivers/net/mlx4/main.c projects/ofed/head/sys/ofed/include/linux/device.h projects/ofed/head/sys/ofed/include/linux/interrupt.h projects/ofed/head/sys/ofed/include/linux/linux_compat.c projects/ofed/head/sys/ofed/include/linux/pci.h Modified: projects/ofed/head/sys/ofed/drivers/infiniband/hw/mthca/mthca_eq.c ============================================================================== --- projects/ofed/head/sys/ofed/drivers/infiniband/hw/mthca/mthca_eq.c Mon Dec 27 00:30:29 2010 (r216728) +++ projects/ofed/head/sys/ofed/drivers/infiniband/hw/mthca/mthca_eq.c Mon Dec 27 05:47:24 2010 (r216729) @@ -865,38 +865,21 @@ int mthca_init_eq_table(struct mthca_dev }; for (i = 0; i < MTHCA_NUM_EQ; ++i) { -#ifdef __linux__ err = request_irq(dev->eq_table.eq[i].msi_x_vector, mthca_is_memfree(dev) ? mthca_arbel_msi_x_interrupt : mthca_tavor_msi_x_interrupt, 0, eq_name[i], dev->eq_table.eq + i); -#else - err = request_irq(dev->eq_table.eq[i].msi_x_vector, - mthca_is_memfree(dev) ? - mthca_arbel_msi_x_interrupt : - mthca_tavor_msi_x_interrupt, - 0, eq_name[i], dev->eq_table.eq + i, - &dev->pdev->dev); -#endif if (err) goto err_out_cmd; dev->eq_table.eq[i].have_irq = 1; } } else { -#ifdef __linux__ err = request_irq(dev->pdev->irq, mthca_is_memfree(dev) ? mthca_arbel_interrupt : mthca_tavor_interrupt, IRQF_SHARED, DRV_NAME, dev); -#else - err = request_irq(dev->pdev->irq, - mthca_is_memfree(dev) ? - mthca_arbel_interrupt : - mthca_tavor_interrupt, - IRQF_SHARED, DRV_NAME, dev, &dev->pdev->dev); -#endif if (err) goto err_out_cmd; dev->eq_table.have_irq = 1; Modified: projects/ofed/head/sys/ofed/drivers/infiniband/hw/mthca/mthca_main.c ============================================================================== --- projects/ofed/head/sys/ofed/drivers/infiniband/hw/mthca/mthca_main.c Mon Dec 27 00:30:29 2010 (r216728) +++ projects/ofed/head/sys/ofed/drivers/infiniband/hw/mthca/mthca_main.c Mon Dec 27 05:47:24 2010 (r216729) @@ -932,7 +932,6 @@ err_uar_table_free: static int mthca_enable_msi_x(struct mthca_dev *mdev) { -#ifdef __linux__ struct msix_entry entries[3]; int err; @@ -953,9 +952,6 @@ static int mthca_enable_msi_x(struct mth mdev->eq_table.eq[MTHCA_EQ_CMD ].msi_x_vector = entries[2].vector; return 0; -#else - return -EINVAL; -#endif } /* Types of supported HCA */ Modified: projects/ofed/head/sys/ofed/drivers/net/mlx4/eq.c ============================================================================== --- projects/ofed/head/sys/ofed/drivers/net/mlx4/eq.c Mon Dec 27 00:30:29 2010 (r216728) +++ projects/ofed/head/sys/ofed/drivers/net/mlx4/eq.c Mon Dec 27 05:47:24 2010 (r216729) @@ -611,28 +611,17 @@ int mlx4_init_eq_table(struct mlx4_dev * } else eq_name = async_eq_name; -#ifdef __linux__ err = request_irq(priv->eq_table.eq[i].irq, mlx4_msi_x_interrupt, 0, eq_name, priv->eq_table.eq + i); -#else - err = request_irq(priv->eq_table.eq[i].irq, - mlx4_msi_x_interrupt, 0, eq_name, - priv->eq_table.eq + i, &dev->pdev->dev); -#endif if (err) goto err_out_async; priv->eq_table.eq[i].have_irq = 1; } } else { -#ifdef __linux__ err = request_irq(dev->pdev->irq, mlx4_interrupt, IRQF_SHARED, DRV_NAME, dev); -#else - err = request_irq(dev->pdev->irq, mlx4_interrupt, - IRQF_SHARED, DRV_NAME, dev, &dev->pdev->dev); -#endif if (err) goto err_out_async; Modified: projects/ofed/head/sys/ofed/drivers/net/mlx4/main.c ============================================================================== --- projects/ofed/head/sys/ofed/drivers/net/mlx4/main.c Mon Dec 27 00:30:29 2010 (r216728) +++ projects/ofed/head/sys/ofed/drivers/net/mlx4/main.c Mon Dec 27 05:47:24 2010 (r216729) @@ -1208,7 +1208,6 @@ err_uar_table_free: static void mlx4_enable_msi_x(struct mlx4_dev *dev) { -#ifdef __linux__ struct mlx4_priv *priv = mlx4_priv(dev); struct msix_entry *entries; int nreq; @@ -1255,15 +1254,6 @@ no_msi: for (i = 0; i < 2; ++i) priv->eq_table.eq[i].irq = dev->pdev->irq; -#else - struct mlx4_priv *priv = mlx4_priv(dev); - int i; - - dev->caps.num_comp_vectors = 1; - - for (i = 0; i < 2; ++i) - priv->eq_table.eq[i].irq = dev->pdev->irq; -#endif } static int mlx4_init_port_info(struct mlx4_dev *dev, int port) Modified: projects/ofed/head/sys/ofed/include/linux/device.h ============================================================================== --- projects/ofed/head/sys/ofed/include/linux/device.h Mon Dec 27 00:30:29 2010 (r216728) +++ projects/ofed/head/sys/ofed/include/linux/device.h Mon Dec 27 05:47:24 2010 (r216729) @@ -55,17 +55,17 @@ struct class { struct device { struct device *parent; + struct list_head irqents; device_t bsddev; dev_t devt; struct class *class; void (*release)(struct device *dev); - irqreturn_t (*irqhandler)(int, void *); - void *irqarg; - void *irqtag; struct kobject kobj; uint64_t *dma_mask; void *driver_data; - + unsigned int irq; + unsigned int msix; + unsigned int msix_max; }; extern struct device linux_rootdev; Modified: projects/ofed/head/sys/ofed/include/linux/interrupt.h ============================================================================== --- projects/ofed/head/sys/ofed/include/linux/interrupt.h Mon Dec 27 00:30:29 2010 (r216728) +++ projects/ofed/head/sys/ofed/include/linux/interrupt.h Mon Dec 27 05:47:24 2010 (r216729) @@ -30,6 +30,7 @@ #define _LINUX_INTERRUPT_H_ #include +#include #include #include @@ -40,34 +41,77 @@ typedef irqreturn_t (*irq_handler_t)(int #define IRQF_SHARED RF_SHAREABLE +struct irq_ent { + struct list_head links; + struct device *dev; + struct resource *res; + void *arg; + irqreturn_t (*handler)(int, void *); + void *tag; + int irq; +}; + +static inline int +_irq_rid(struct device *dev, int irq) +{ + if (irq == dev->irq) + return (0); + return irq - dev->msix + 1; +} + static void -_irq_handler(void *device) +_irq_handler(void *ent) { - struct device *dev; + struct irq_ent *irqe; - dev = device; - dev->irqhandler(0, dev->irqarg); + irqe = ent; + irqe->handler(irqe->irq, irqe->arg); +} + +static inline struct irq_ent * +_irq_ent(struct device *dev, int irq) +{ + struct irq_ent *irqe; + + list_for_each_entry(irqe, &dev->irqents, links) + if (irqe->irq == irq) + return (irqe); + + return (NULL); } static inline int request_irq(unsigned int irq, irq_handler_t handler, unsigned long flags, - const char *name, void *arg, struct device *dev) + const char *name, void *arg) { struct resource *res; + struct irq_ent *irqe; + struct device *dev; int error; int rid; - rid = 0; + dev = _pci_find_irq_dev(irq); + if (dev == NULL) + return -ENXIO; + rid = _irq_rid(dev, irq); res = bus_alloc_resource_any(dev->bsddev, SYS_RES_IRQ, &rid, flags | RF_ACTIVE); if (res == NULL) return (-ENXIO); + irqe = kmalloc(sizeof(*irqe), GFP_KERNEL); + irqe->dev = dev; + irqe->res = res; + irqe->arg = arg; + irqe->handler = handler; + irqe->irq = irq; error = bus_setup_intr(dev->bsddev, res, INTR_TYPE_NET | INTR_MPSAFE, - NULL, _irq_handler, dev, &dev->irqtag); - if (error) + NULL, _irq_handler, irqe, &irqe->tag); + if (error) { + bus_release_resource(dev->bsddev, SYS_RES_IRQ, rid, irqe->res); + kfree(irqe); return (-error); - dev->irqhandler = handler; - dev->irqarg = arg; + } + list_add(&irqe->links, &dev->irqents); return 0; } @@ -75,7 +119,21 @@ request_irq(unsigned int irq, irq_handle static inline void free_irq(unsigned int irq, void *device) { - /* XXX */ + struct irq_ent *irqe; + struct device *dev; + int rid; + + dev = _pci_find_irq_dev(irq); + if (dev == NULL) + return; + rid = _irq_rid(dev, irq); + irqe = _irq_ent(dev, irq); + if (irqe == NULL) + return; + bus_teardown_intr(dev->bsddev, irqe->res, irqe->tag); + bus_release_resource(dev->bsddev, SYS_RES_IRQ, rid, irqe->res); + list_del(&irqe->links); + kfree(irqe); } #endif /* _LINUX_INTERRUPT_H_ */ Modified: projects/ofed/head/sys/ofed/include/linux/linux_compat.c ============================================================================== --- projects/ofed/head/sys/ofed/include/linux/linux_compat.c Mon Dec 27 00:30:29 2010 (r216728) +++ projects/ofed/head/sys/ofed/include/linux/linux_compat.c Mon Dec 27 05:47:24 2010 (r216729) @@ -61,6 +61,8 @@ struct kobject class_root; struct device linux_rootdev; struct class miscclass; struct list_head pci_drivers; +struct list_head pci_devices; +spinlock_t pci_lock; int panic_cmp(struct rb_node *one, struct rb_node *two) @@ -528,6 +530,8 @@ linux_compat_init(void) miscclass.name = "misc"; class_register(&miscclass); INIT_LIST_HEAD(&pci_drivers); + INIT_LIST_HEAD(&pci_devices); + spin_lock_init(&pci_lock); } SYSINIT(linux_compat, SI_SUB_DRIVERS, SI_ORDER_SECOND, linux_compat_init, NULL); Modified: projects/ofed/head/sys/ofed/include/linux/pci.h ============================================================================== --- projects/ofed/head/sys/ofed/include/linux/pci.h Mon Dec 27 00:30:29 2010 (r216728) +++ projects/ofed/head/sys/ofed/include/linux/pci.h Mon Dec 27 05:47:24 2010 (r216729) @@ -29,6 +29,8 @@ #ifndef _LINUX_PCI_H_ #define _LINUX_PCI_H_ +#define CONFIG_PCI_MSI + #include #include @@ -100,11 +102,14 @@ struct pci_driver { }; extern struct list_head pci_drivers; +extern struct list_head pci_devices; +extern spinlock_t pci_lock; #define __devexit_p(x) x struct pci_dev { struct device dev; + struct list_head links; struct pci_driver *pdrv; uint64_t dma_mask; uint16_t device; @@ -134,6 +139,24 @@ _pci_get_bar(struct pci_dev *pdev, int b return (rle); } +static inline struct device * +_pci_find_irq_dev(unsigned int irq) +{ + struct pci_dev *pdev; + + spin_lock(&pci_lock); + list_for_each_entry(pdev, &pci_devices, links) { + if (irq == pdev->dev.irq) + break; + if (irq >= pdev->dev.msix && irq < pdev->dev.msix_max) + break; + } + spin_unlock(&pci_lock); + if (pdev) + return &pdev->dev; + return (NULL); +} + static inline unsigned long pci_resource_start(struct pci_dev *pdev, int bar) { @@ -340,14 +363,17 @@ linux_pci_find(device_t dev, struct pci_ vendor = pci_get_vendor(dev); device = pci_get_device(dev); + spin_lock(&pci_lock); list_for_each_entry(pdrv, &pci_drivers, links) { for (id = pdrv->id_table; id->vendor != 0; id++) { if (vendor == id->vendor && device == id->device) { *idp = id; + spin_unlock(&pci_lock); return (pdrv); } } } + spin_unlock(&pci_lock); return (NULL); } @@ -378,6 +404,7 @@ linux_pci_attach(device_t dev) pdev = device_get_softc(dev); pdev->dev.parent = &linux_rootdev; pdev->dev.bsddev = dev; + INIT_LIST_HEAD(&pdev->dev.irqents); pdev->device = id->device; pdev->vendor = id->vendor; pdev->dev.dma_mask = &pdev->dma_mask; @@ -388,12 +415,22 @@ linux_pci_attach(device_t dev) kobject_name(&pdev->dev.kobj)); rle = _pci_get_rle(pdev, SYS_RES_IRQ, 0); if (rle) - pdev->irq = rle->start; + pdev->dev.irq = rle->start; + else + pdev->dev.irq = 0; + pdev->irq = pdev->dev.irq; mtx_unlock(&Giant); + spin_lock(&pci_lock); + list_add(&pdev->links, &pci_devices); + spin_unlock(&pci_lock); error = pdrv->probe(pdev, id); mtx_lock(&Giant); - if (error) + if (error) { + spin_lock(&pci_lock); + list_del(&pdev->links); + spin_unlock(&pci_lock); return (-error); + } return (0); } @@ -404,6 +441,9 @@ linux_pci_detach(device_t dev) pdev = device_get_softc(dev); pdev->pdrv->remove(pdev); + spin_lock(&pci_lock); + list_del(&pdev->links); + spin_unlock(&pci_lock); return (0); } @@ -420,7 +460,9 @@ pci_register_driver(struct pci_driver *p devclass_t bus; int error; + spin_lock(&pci_lock); list_add(&pdrv->links, &pci_drivers); + spin_unlock(&pci_lock); bus = devclass_find("pci"); pdrv->driver.name = pdrv->name; pdrv->driver.methods = pci_methods; @@ -444,6 +486,40 @@ pci_unregister_driver(struct pci_driver devclass_delete_driver(bus, &pdrv->driver); } +struct msix_entry { + int entry; + int vector; +}; + +/* + * Enable msix, positive errors indicate actual number of available + * vectors. Negative errors are failures. + */ +static inline int +pci_enable_msix(struct pci_dev *pdev, struct msix_entry *entries, int nreq) +{ + struct resource_list_entry *rle; + int error; + int avail; + int i; + + avail = pci_msix_count(pdev->dev.bsddev); + if (avail < nreq) { + if (avail == 0) + return -EINVAL; + return avail; + } + avail = nreq; + if ((error = -pci_alloc_msix(pdev->dev.bsddev, &avail)) != 0) + return error; + rle = _pci_get_rle(pdev, SYS_RES_IRQ, 1); + pdev->dev.msix = rle->start; + pdev->dev.msix_max = rle->start + avail; + for (i = 0; i < nreq; i++) + entries[i].vector = pdev->dev.msix + i; + return (0); +} + /* XXX This should not be necessary. */ #define pcix_set_mmrbc(d, v) 0 #define pcix_get_max_mmrbc(d) 0 From owner-svn-src-projects@FreeBSD.ORG Mon Dec 27 07:38:34 2010 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 07185106564A; Mon, 27 Dec 2010 07:38:34 +0000 (UTC) (envelope-from jeff@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E7E4A8FC12; Mon, 27 Dec 2010 07:38:33 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id oBR7cXoH015208; Mon, 27 Dec 2010 07:38:33 GMT (envelope-from jeff@svn.freebsd.org) Received: (from jeff@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oBR7cXbL015192; Mon, 27 Dec 2010 07:38:33 GMT (envelope-from jeff@svn.freebsd.org) Message-Id: <201012270738.oBR7cXbL015192@svn.freebsd.org> From: Jeff Roberson Date: Mon, 27 Dec 2010 07:38:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r216732 - in projects/ofed/head/sys/ofed: drivers/infiniband/hw/mlx4 drivers/infiniband/hw/mthca drivers/net/mlx4 include/linux X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 27 Dec 2010 07:38:34 -0000 Author: jeff Date: Mon Dec 27 07:38:33 2010 New Revision: 216732 URL: http://svn.freebsd.org/changeset/base/216732 Log: - Eliminate the laregest source of linux incompatibilities in drivers by supplying a compatible iounmap and ioremap. A hash of addresses and lenghts was necessary to remember the length for pmap_unmapdev. Sponsored by: Isilon Systems, iX Systems, and Panasas. Modified: projects/ofed/head/sys/ofed/drivers/infiniband/hw/mlx4/main.c projects/ofed/head/sys/ofed/drivers/infiniband/hw/mthca/mthca_av.c projects/ofed/head/sys/ofed/drivers/infiniband/hw/mthca/mthca_catas.c projects/ofed/head/sys/ofed/drivers/infiniband/hw/mthca/mthca_cmd.c projects/ofed/head/sys/ofed/drivers/infiniband/hw/mthca/mthca_eq.c projects/ofed/head/sys/ofed/drivers/infiniband/hw/mthca/mthca_main.c projects/ofed/head/sys/ofed/drivers/infiniband/hw/mthca/mthca_mr.c projects/ofed/head/sys/ofed/drivers/infiniband/hw/mthca/mthca_reset.c projects/ofed/head/sys/ofed/drivers/net/mlx4/catas.c projects/ofed/head/sys/ofed/drivers/net/mlx4/cmd.c projects/ofed/head/sys/ofed/drivers/net/mlx4/eq.c projects/ofed/head/sys/ofed/drivers/net/mlx4/main.c projects/ofed/head/sys/ofed/drivers/net/mlx4/reset.c projects/ofed/head/sys/ofed/include/linux/io.h projects/ofed/head/sys/ofed/include/linux/linux_compat.c Modified: projects/ofed/head/sys/ofed/drivers/infiniband/hw/mlx4/main.c ============================================================================== --- projects/ofed/head/sys/ofed/drivers/infiniband/hw/mlx4/main.c Mon Dec 27 07:12:22 2010 (r216731) +++ projects/ofed/head/sys/ofed/drivers/infiniband/hw/mlx4/main.c Mon Dec 27 07:38:33 2010 (r216732) @@ -1469,11 +1469,7 @@ err_counter: mlx4_counter_free(ibdev->dev, ibdev->counters[k - 1]); err_map: -#ifdef __linux__ iounmap(ibdev->uar_map); -#else - pmap_unmapdev((vm_offset_t)ibdev->uar_map, PAGE_SIZE); -#endif err_uar: mlx4_uar_free(dev, &ibdev->priv_uar); @@ -1507,11 +1503,7 @@ static void mlx4_ib_remove(struct mlx4_d flush_workqueue(wq); ibdev->iboe.nb.notifier_call = NULL; } -#ifdef __linux__ iounmap(ibdev->uar_map); -#else - pmap_unmapdev((vm_offset_t)ibdev->uar_map, PAGE_SIZE); -#endif mlx4_foreach_port(p, dev, MLX4_PORT_TYPE_IB) mlx4_CLOSE_PORT(dev, p); Modified: projects/ofed/head/sys/ofed/drivers/infiniband/hw/mthca/mthca_av.c ============================================================================== --- projects/ofed/head/sys/ofed/drivers/infiniband/hw/mthca/mthca_av.c Mon Dec 27 07:12:22 2010 (r216731) +++ projects/ofed/head/sys/ofed/drivers/infiniband/hw/mthca/mthca_av.c Mon Dec 27 07:38:33 2010 (r216732) @@ -370,11 +370,7 @@ void mthca_cleanup_av_table(struct mthca return; if (dev->av_table.av_map) -#ifdef __linux__ iounmap(dev->av_table.av_map); -#else - pmap_unmapdev((vm_offset_t)dev->av_table.av_map, MTHCA_AV_SIZE); -#endif pci_pool_destroy(dev->av_table.pool); mthca_alloc_cleanup(&dev->av_table.alloc); } Modified: projects/ofed/head/sys/ofed/drivers/infiniband/hw/mthca/mthca_catas.c ============================================================================== --- projects/ofed/head/sys/ofed/drivers/infiniband/hw/mthca/mthca_catas.c Mon Dec 27 07:12:22 2010 (r216731) +++ projects/ofed/head/sys/ofed/drivers/infiniband/hw/mthca/mthca_catas.c Mon Dec 27 07:38:33 2010 (r216732) @@ -174,12 +174,7 @@ void mthca_stop_catas_poll(struct mthca_ del_timer_sync(&dev->catas_err.timer); if (dev->catas_err.map) -#ifdef __linux__ iounmap(dev->catas_err.map); -#else - pmap_unmapdev((vm_offset_t)dev->catas_err.map, - dev->catas_err.size * 4); -#endif spin_lock_irq(&catas_lock); list_del(&dev->catas_err.list); Modified: projects/ofed/head/sys/ofed/drivers/infiniband/hw/mthca/mthca_cmd.c ============================================================================== --- projects/ofed/head/sys/ofed/drivers/infiniband/hw/mthca/mthca_cmd.c Mon Dec 27 07:12:22 2010 (r216731) +++ projects/ofed/head/sys/ofed/drivers/infiniband/hw/mthca/mthca_cmd.c Mon Dec 27 07:38:33 2010 (r216732) @@ -490,11 +490,7 @@ int mthca_cmd_init(struct mthca_dev *dev MTHCA_MAILBOX_SIZE, MTHCA_MAILBOX_SIZE, 0); if (!dev->cmd.pool) { -#ifdef __linux__ iounmap(dev->hcr); -#else - pmap_unmapdev((vm_offset_t)dev->hcr, MTHCA_HCR_SIZE); -#endif return -ENOMEM; } @@ -504,18 +500,9 @@ int mthca_cmd_init(struct mthca_dev *dev void mthca_cmd_cleanup(struct mthca_dev *dev) { pci_pool_destroy(dev->cmd.pool); -#ifdef __linux__ iounmap(dev->hcr); -#else - pmap_unmapdev((vm_offset_t)dev->hcr, MTHCA_HCR_SIZE); -#endif if (dev->cmd.flags & MTHCA_CMD_POST_DOORBELLS) -#ifdef __linux__ iounmap(dev->cmd.dbell_map); -#else - pmap_unmapdev((vm_offset_t)dev->cmd.dbell_map, - dev->cmd.dbell_size); -#endif } /* Modified: projects/ofed/head/sys/ofed/drivers/infiniband/hw/mthca/mthca_eq.c ============================================================================== --- projects/ofed/head/sys/ofed/drivers/infiniband/hw/mthca/mthca_eq.c Mon Dec 27 07:12:22 2010 (r216731) +++ projects/ofed/head/sys/ofed/drivers/infiniband/hw/mthca/mthca_eq.c Mon Dec 27 07:38:33 2010 (r216732) @@ -687,12 +687,7 @@ static int mthca_map_eq_regs(struct mthc dev->fw.arbel.eq_arm_base) + 4, 4, &dev->eq_regs.arbel.eq_arm)) { mthca_err(dev, "Couldn't map EQ arm register, aborting.\n"); -#ifdef __linux__ iounmap(dev->clr_base); -#else - pmap_unmapdev((vm_offset_t)dev->clr_base, - MTHCA_CLR_INT_SIZE); -#endif return -ENOMEM; } @@ -701,15 +696,8 @@ static int mthca_map_eq_regs(struct mthc MTHCA_EQ_SET_CI_SIZE, &dev->eq_regs.arbel.eq_set_ci_base)) { mthca_err(dev, "Couldn't map EQ CI register, aborting.\n"); -#ifdef __linux__ iounmap(dev->eq_regs.arbel.eq_arm); iounmap(dev->clr_base); -#else - pmap_unmapdev((vm_offset_t)dev->eq_regs.arbel.eq_arm, - 4); - pmap_unmapdev((vm_offset_t)dev->clr_base, - MTHCA_CLR_INT_SIZE); -#endif return -ENOMEM; } } else { @@ -725,12 +713,7 @@ static int mthca_map_eq_regs(struct mthc &dev->eq_regs.tavor.ecr_base)) { mthca_err(dev, "Couldn't map ecr register, " "aborting.\n"); -#ifdef __linux__ iounmap(dev->clr_base); -#else - pmap_unmapdev((vm_offset_t)dev->clr_base, - MTHCA_CLR_INT_SIZE); -#endif return -ENOMEM; } } @@ -742,25 +725,12 @@ static int mthca_map_eq_regs(struct mthc static void mthca_unmap_eq_regs(struct mthca_dev *dev) { if (mthca_is_memfree(dev)) { -#ifdef __linux__ iounmap(dev->eq_regs.arbel.eq_set_ci_base); iounmap(dev->eq_regs.arbel.eq_arm); iounmap(dev->clr_base); -#else - pmap_unmapdev((vm_offset_t)dev->eq_regs.arbel.eq_set_ci_base, - MTHCA_EQ_SET_CI_SIZE); - pmap_unmapdev((vm_offset_t)dev->eq_regs.arbel.eq_arm, 4); - pmap_unmapdev((vm_offset_t)dev->clr_base, MTHCA_CLR_INT_SIZE); -#endif } else { -#ifdef __linux__ iounmap(dev->eq_regs.tavor.ecr_base); iounmap(dev->clr_base); -#else - pmap_unmapdev((vm_offset_t)dev->eq_regs.tavor.ecr_base, - MTHCA_ECR_SIZE + MTHCA_ECR_CLR_SIZE); - pmap_unmapdev((vm_offset_t)dev->clr_base, MTHCA_CLR_INT_SIZE); -#endif } } Modified: projects/ofed/head/sys/ofed/drivers/infiniband/hw/mthca/mthca_main.c ============================================================================== --- projects/ofed/head/sys/ofed/drivers/infiniband/hw/mthca/mthca_main.c Mon Dec 27 07:12:22 2010 (r216731) +++ projects/ofed/head/sys/ofed/drivers/infiniband/hw/mthca/mthca_main.c Mon Dec 27 07:38:33 2010 (r216732) @@ -916,11 +916,7 @@ err_pd_table_free: mthca_cleanup_pd_table(dev); err_kar_unmap: -#ifdef __linux__ iounmap(dev->kar); -#else - pmap_unmapdev((vm_offset_t)dev->kar, PAGE_SIZE); -#endif err_uar_free: mthca_uar_free(dev, &dev->driver_uar); @@ -1189,11 +1185,7 @@ static void __mthca_remove_one(struct pc mthca_cleanup_mr_table(mdev); mthca_cleanup_pd_table(mdev); -#ifdef __linux__ iounmap(mdev->kar); -#else - pmap_unmapdev((vm_offset_t)mdev->kar, PAGE_SIZE); -#endif mthca_uar_free(mdev, &mdev->driver_uar); mthca_cleanup_uar_table(mdev); mthca_close_hca(mdev); Modified: projects/ofed/head/sys/ofed/drivers/infiniband/hw/mthca/mthca_mr.c ============================================================================== --- projects/ofed/head/sys/ofed/drivers/infiniband/hw/mthca/mthca_mr.c Mon Dec 27 07:12:22 2010 (r216731) +++ projects/ofed/head/sys/ofed/drivers/infiniband/hw/mthca/mthca_mr.c Mon Dec 27 07:38:33 2010 (r216732) @@ -955,22 +955,11 @@ err_reserve_fmr: err_fmr_mtt_buddy: if (dev->mr_table.tavor_fmr.mtt_base) -#ifdef __linux__ iounmap(dev->mr_table.tavor_fmr.mtt_base); -#else - pmap_unmapdev((vm_offset_t)dev->mr_table.tavor_fmr.mtt_base, - dev->mr_table.tavor_fmr.mtt_size); - -#endif err_fmr_mtt: if (dev->mr_table.tavor_fmr.mpt_base) -#ifdef __linux__ iounmap(dev->mr_table.tavor_fmr.mpt_base); -#else - pmap_unmapdev((vm_offset_t)dev->mr_table.tavor_fmr.mpt_base, - dev->mr_table.tavor_fmr.mpt_size); -#endif err_fmr_mpt: mthca_buddy_cleanup(&dev->mr_table.mtt_buddy); @@ -990,19 +979,9 @@ void mthca_cleanup_mr_table(struct mthca mthca_buddy_cleanup(&dev->mr_table.mtt_buddy); if (dev->mr_table.tavor_fmr.mtt_base) -#ifdef __linux__ iounmap(dev->mr_table.tavor_fmr.mtt_base); -#else - pmap_unmapdev((vm_offset_t)dev->mr_table.tavor_fmr.mtt_base, - dev->mr_table.tavor_fmr.mtt_size); -#endif if (dev->mr_table.tavor_fmr.mpt_base) -#ifdef __linux__ iounmap(dev->mr_table.tavor_fmr.mpt_base); -#else - pmap_unmapdev((vm_offset_t)dev->mr_table.tavor_fmr.mpt_base, - dev->mr_table.tavor_fmr.mpt_size); -#endif mthca_alloc_cleanup(&dev->mr_table.mpt_alloc); } Modified: projects/ofed/head/sys/ofed/drivers/infiniband/hw/mthca/mthca_reset.c ============================================================================== --- projects/ofed/head/sys/ofed/drivers/infiniband/hw/mthca/mthca_reset.c Mon Dec 27 07:12:22 2010 (r216731) +++ projects/ofed/head/sys/ofed/drivers/infiniband/hw/mthca/mthca_reset.c Mon Dec 27 07:38:33 2010 (r216732) @@ -164,11 +164,7 @@ int mthca_reset(struct mthca_dev *mdev) } writel(MTHCA_RESET_VALUE, reset); -#ifdef __linux__ iounmap(reset); -#else - pmap_unmapdev((vm_offset_t)reset, 4); -#endif } /* Docs say to wait one second before accessing device */ Modified: projects/ofed/head/sys/ofed/drivers/net/mlx4/catas.c ============================================================================== --- projects/ofed/head/sys/ofed/drivers/net/mlx4/catas.c Mon Dec 27 07:12:22 2010 (r216731) +++ projects/ofed/head/sys/ofed/drivers/net/mlx4/catas.c Mon Dec 27 07:38:33 2010 (r216732) @@ -145,12 +145,7 @@ void mlx4_stop_catas_poll(struct mlx4_de del_timer_sync(&priv->catas_err.timer); if (priv->catas_err.map) -#ifdef __linux__ iounmap(priv->catas_err.map); -#else - pmap_unmapdev((vm_offset_t)priv->catas_err.map, - priv->fw.catas_size * 4); -#endif spin_lock_irq(&catas_lock); list_del(&priv->catas_err.list); Modified: projects/ofed/head/sys/ofed/drivers/net/mlx4/cmd.c ============================================================================== --- projects/ofed/head/sys/ofed/drivers/net/mlx4/cmd.c Mon Dec 27 07:12:22 2010 (r216731) +++ projects/ofed/head/sys/ofed/drivers/net/mlx4/cmd.c Mon Dec 27 07:38:33 2010 (r216732) @@ -348,11 +348,7 @@ int mlx4_cmd_init(struct mlx4_dev *dev) MLX4_MAILBOX_SIZE, MLX4_MAILBOX_SIZE, 0); if (!priv->cmd.pool) { -#ifdef __linux__ iounmap(priv->cmd.hcr); -#else - pmap_unmapdev((vm_offset_t)priv->cmd.hcr, MLX4_HCR_SIZE); -#endif return -ENOMEM; } @@ -364,11 +360,7 @@ void mlx4_cmd_cleanup(struct mlx4_dev *d struct mlx4_priv *priv = mlx4_priv(dev); pci_pool_destroy(priv->cmd.pool); -#ifdef __linux__ iounmap(priv->cmd.hcr); -#else - pmap_unmapdev((vm_offset_t)priv->cmd.hcr, MLX4_HCR_SIZE); -#endif } /* Modified: projects/ofed/head/sys/ofed/drivers/net/mlx4/eq.c ============================================================================== --- projects/ofed/head/sys/ofed/drivers/net/mlx4/eq.c Mon Dec 27 07:12:22 2010 (r216731) +++ projects/ofed/head/sys/ofed/drivers/net/mlx4/eq.c Mon Dec 27 07:38:33 2010 (r216732) @@ -523,11 +523,7 @@ static void mlx4_unmap_clr_int(struct ml { struct mlx4_priv *priv = mlx4_priv(dev); -#ifdef __linux__ iounmap(priv->clr_base); -#else - pmap_unmapdev((vm_offset_t)priv->clr_base, MLX4_CLR_INT_SIZE); -#endif } int mlx4_alloc_eq_table(struct mlx4_dev *dev) @@ -679,12 +675,7 @@ void mlx4_cleanup_eq_table(struct mlx4_d for (i = 0; i < mlx4_num_eq_uar(dev); ++i) if (priv->eq_table.uar_map[i]) -#ifdef __linux__ iounmap(priv->eq_table.uar_map[i]); -#else - pmap_unmapdev((vm_offset_t)priv->eq_table.uar_map[i], - PAGE_SIZE); -#endif mlx4_bitmap_cleanup(&priv->eq_table.bitmap); Modified: projects/ofed/head/sys/ofed/drivers/net/mlx4/main.c ============================================================================== --- projects/ofed/head/sys/ofed/drivers/net/mlx4/main.c Mon Dec 27 07:12:22 2010 (r216731) +++ projects/ofed/head/sys/ofed/drivers/net/mlx4/main.c Mon Dec 27 07:38:33 2010 (r216732) @@ -1192,11 +1192,7 @@ err_pd_table_free: mlx4_cleanup_pd_table(dev); err_kar_unmap: -#ifdef __linux__ iounmap(priv->kar); -#else - pmap_unmapdev((vm_offset_t)priv->kar, PAGE_SIZE); -#endif err_uar_free: mlx4_uar_free(dev, &priv->driver_uar); @@ -1528,11 +1524,7 @@ static void mlx4_remove_one(struct pci_d mlx4_cleanup_xrcd_table(dev); mlx4_cleanup_pd_table(dev); -#ifdef __linux__ iounmap(priv->kar); -#else - pmap_unmapdev((vm_offset_t)priv->kar, PAGE_SIZE); -#endif mlx4_uar_free(dev, &priv->driver_uar); mlx4_cleanup_uar_table(dev); mlx4_free_eq_table(dev); Modified: projects/ofed/head/sys/ofed/drivers/net/mlx4/reset.c ============================================================================== --- projects/ofed/head/sys/ofed/drivers/net/mlx4/reset.c Mon Dec 27 07:12:22 2010 (r216731) +++ projects/ofed/head/sys/ofed/drivers/net/mlx4/reset.c Mon Dec 27 07:38:33 2010 (r216732) @@ -112,21 +112,13 @@ int mlx4_reset(struct mlx4_dev *dev) if (sem) { mlx4_err(dev, "Failed to obtain HW semaphore, aborting\n"); err = -EAGAIN; -#ifdef __linux__ iounmap(reset); -#else - pmap_unmapdev((vm_offset_t)reset, MLX4_RESET_SIZE); -#endif goto out; } /* actually hit reset */ writel(MLX4_RESET_VALUE, reset + MLX4_RESET_OFFSET); -#ifdef __linux__ iounmap(reset); -#else - pmap_unmapdev((vm_offset_t)reset, MLX4_RESET_SIZE); -#endif /* Docs say to wait one second before accessing device */ msleep(1000); Modified: projects/ofed/head/sys/ofed/include/linux/io.h ============================================================================== --- projects/ofed/head/sys/ofed/include/linux/io.h Mon Dec 27 07:12:22 2010 (r216731) +++ projects/ofed/head/sys/ofed/include/linux/io.h Mon Dec 27 07:38:33 2010 (r216732) @@ -29,10 +29,6 @@ #ifndef _LINUX_IO_H_ #define _LINUX_IO_H_ -#include -#include -#include - static inline uint32_t __raw_readl(const volatile void *addr) { @@ -90,15 +86,11 @@ writew(uint16_t b, void *addr) *(volatile uint16_t *)addr = b; } -#define ioremap pmap_mapdev +void *ioremap(vm_paddr_t phys_addr, unsigned long size); +void iounmap(void *addr); #define memset_io(a, b, c) memset((a), (b), (c)) #define memcpy_fromio(a, b, c) memcpy((a), (b), (c)) #define memcpy_toio(a, b, c) memcpy((a), (b), (c)) -/* - * iounmap is not defined as pmap_unmapdev requires a length that can - * not easily be determined on BSD. - */ - #endif /* _LINUX_IO_H_ */ Modified: projects/ofed/head/sys/ofed/include/linux/linux_compat.c ============================================================================== --- projects/ofed/head/sys/ofed/include/linux/linux_compat.c Mon Dec 27 07:12:22 2010 (r216731) +++ projects/ofed/head/sys/ofed/include/linux/linux_compat.c Mon Dec 27 07:38:33 2010 (r216732) @@ -35,7 +35,11 @@ #include #include +#include +#include + #include +#include #include #include @@ -45,6 +49,7 @@ #include #include #include +#include #include @@ -56,6 +61,12 @@ MALLOC_DEFINE(M_KMALLOC, "linux", "Linux #undef file #undef cdev #define RB_ROOT(head) (head)->rbh_root +#undef LIST_HEAD +/* From sys/queue.h */ +#define LIST_HEAD(name, type) \ +struct name { \ + struct type *lh_first; /* first element */ \ +} struct kobject class_root; struct device linux_rootdev; @@ -510,10 +521,67 @@ struct fileops linuxfileops = { .fo_close = linux_file_close }; +/* + * Hash of iomap addresses. This is infrequently accessed and does not + * need to be particularly large. This is done because we must store the + * caller's idea of the map size to properly unmap. + */ +struct iomap { + LIST_ENTRY(iomap) im_next; + void *im_addr; + unsigned long im_size; +}; + +LIST_HEAD(iomaphd, iomap); +#define IOMAP_HASH_SIZE 64 +#define IOMAP_HASH_MASK (IOMAP_HASH_SIZE - 1) +#define IO_HASH(addr) ((uintptr_t)(addr) >> PAGE_SHIFT) & IOMAP_HASH_MASK +static struct iomaphd iomaphead[IOMAP_HASH_SIZE]; +static struct mtx iomaplock; + +void * +ioremap(vm_paddr_t phys_addr, unsigned long size) +{ + struct iomap *iomap; + void *addr; + + addr = pmap_mapdev(phys_addr, size); + if (addr == NULL) + return (NULL); + iomap = kmalloc(sizeof(*iomap), GFP_KERNEL); + mtx_lock(&iomaplock); + iomap->im_size = size; + iomap->im_addr = addr; + LIST_INSERT_HEAD(&iomaphead[IO_HASH(addr)], iomap, im_next); + mtx_unlock(&iomaplock); + + return (addr); +} + +void +iounmap(void *addr) +{ + struct iomap *iomap; + + mtx_lock(&iomaplock); + LIST_FOREACH(iomap, &iomaphead[IO_HASH(addr)], im_next) + if (iomap->im_addr == addr) + break; + if (iomap) + LIST_REMOVE(iomap, im_next); + mtx_unlock(&iomaplock); + if (iomap == NULL) + return; + pmap_unmapdev((vm_offset_t)addr, iomap->im_size); + kfree(iomap); +} + + static void linux_compat_init(void) { struct sysctl_oid *rootoid; + int i; rootoid = SYSCTL_ADD_NODE(NULL, SYSCTL_STATIC_CHILDREN(), OID_AUTO, "sys", CTLFLAG_RD|CTLFLAG_MPSAFE, NULL, "sys"); @@ -532,6 +600,9 @@ linux_compat_init(void) INIT_LIST_HEAD(&pci_drivers); INIT_LIST_HEAD(&pci_devices); spin_lock_init(&pci_lock); + mtx_init(&iomaplock, "IO Map lock", NULL, MTX_DEF); + for (i = 0; i < IOMAP_HASH_SIZE; i++) + LIST_INIT(&iomaphead[i]); } SYSINIT(linux_compat, SI_SUB_DRIVERS, SI_ORDER_SECOND, linux_compat_init, NULL); From owner-svn-src-projects@FreeBSD.ORG Mon Dec 27 13:58:45 2010 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5891F1065672; Mon, 27 Dec 2010 13:58:45 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id 2A94F8FC18; Mon, 27 Dec 2010 13:58:45 +0000 (UTC) Received: from bigwig.baldwin.cx (66.111.2.69.static.nyinternet.net [66.111.2.69]) by cyrus.watson.org (Postfix) with ESMTPSA id D78D346B2E; Mon, 27 Dec 2010 08:58:44 -0500 (EST) Received: from John-Baldwins-Macbook-Pro.local (c-68-36-150-83.hsd1.nj.comcast.net [68.36.150.83]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id AE6B78A009; Mon, 27 Dec 2010 08:58:43 -0500 (EST) Message-ID: <4D189B93.3020204@FreeBSD.org> Date: Mon, 27 Dec 2010 08:58:43 -0500 From: John Baldwin User-Agent: Thunderbird 2.0.0.24 (Macintosh/20100228) MIME-Version: 1.0 To: Jeff Roberson References: <201012270547.oBR5lOhJ012472@svn.freebsd.org> In-Reply-To: <201012270547.oBR5lOhJ012472@svn.freebsd.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.6 (bigwig.baldwin.cx); Mon, 27 Dec 2010 08:58:44 -0500 (EST) X-Virus-Scanned: clamav-milter 0.96.3 at bigwig.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-0.9 required=4.2 tests=BAYES_00,RDNS_DYNAMIC autolearn=no version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on bigwig.baldwin.cx Cc: svn-src-projects@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r216729 - in projects/ofed/head/sys/ofed: drivers/infiniband/hw/mthca drivers/net/mlx4 include/linux X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 27 Dec 2010 13:58:45 -0000 Jeff Roberson wrote: > Author: jeff > Date: Mon Dec 27 05:47:24 2010 > New Revision: 216729 > URL: http://svn.freebsd.org/changeset/base/216729 > > Log: > - Implement Linux compatible support for msix, removing some diffs against > driver sources. > - Add plubming to find the device based on the irq to eliminate another > linux incompatibility in request_irq(). > - Implement free_irq() which was previously empty. > > Sponsored by: Isilon Systems, iX Systems, and Panasas. > > Modified: > projects/ofed/head/sys/ofed/drivers/infiniband/hw/mthca/mthca_eq.c > projects/ofed/head/sys/ofed/drivers/infiniband/hw/mthca/mthca_main.c > projects/ofed/head/sys/ofed/drivers/net/mlx4/eq.c > projects/ofed/head/sys/ofed/drivers/net/mlx4/main.c > projects/ofed/head/sys/ofed/include/linux/device.h > projects/ofed/head/sys/ofed/include/linux/interrupt.h > projects/ofed/head/sys/ofed/include/linux/linux_compat.c > projects/ofed/head/sys/ofed/include/linux/pci.h > > @@ -444,6 +486,40 @@ pci_unregister_driver(struct pci_driver > devclass_delete_driver(bus, &pdrv->driver); > } > > +struct msix_entry { > + int entry; > + int vector; > +}; > + > +/* > + * Enable msix, positive errors indicate actual number of available > + * vectors. Negative errors are failures. > + */ > +static inline int > +pci_enable_msix(struct pci_dev *pdev, struct msix_entry *entries, int nreq) > +{ > + struct resource_list_entry *rle; > + int error; > + int avail; > + int i; > + > + avail = pci_msix_count(pdev->dev.bsddev); > + if (avail < nreq) { > + if (avail == 0) > + return -EINVAL; > + return avail; > + } > + avail = nreq; > + if ((error = -pci_alloc_msix(pdev->dev.bsddev, &avail)) != 0) > + return error; > + rle = _pci_get_rle(pdev, SYS_RES_IRQ, 1); > + pdev->dev.msix = rle->start; > + pdev->dev.msix_max = rle->start + avail; MSI-X and MSI IRQs are not guaranteed to be a contiguous range. Only the RIDs are guaranteed to be 1...N. They usually are contiguous on x86 because there is not a lot of turnover in MSI IRQs, but this is not guaranteed. -- John Baldwin From owner-svn-src-projects@FreeBSD.ORG Tue Dec 28 21:40:20 2010 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5853D106566C; Tue, 28 Dec 2010 21:40:20 +0000 (UTC) (envelope-from marcel@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2CB588FC17; Tue, 28 Dec 2010 21:40:20 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id oBSLeKpj078035; Tue, 28 Dec 2010 21:40:20 GMT (envelope-from marcel@svn.freebsd.org) Received: (from marcel@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oBSLeKgJ078032; Tue, 28 Dec 2010 21:40:20 GMT (envelope-from marcel@svn.freebsd.org) Message-Id: <201012282140.oBSLeKgJ078032@svn.freebsd.org> From: Marcel Moolenaar Date: Tue, 28 Dec 2010 21:40:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r216779 - in projects/binutils-2.17/sys/boot/ia64: efi ski X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 28 Dec 2010 21:40:20 -0000 Author: marcel Date: Tue Dec 28 21:40:19 2010 New Revision: 216779 URL: http://svn.freebsd.org/changeset/base/216779 Log: Fix a misalignment trap under EFI caused by accessing the linker set. Modified: projects/binutils-2.17/sys/boot/ia64/efi/ldscript.ia64 projects/binutils-2.17/sys/boot/ia64/ski/ldscript.ia64 Modified: projects/binutils-2.17/sys/boot/ia64/efi/ldscript.ia64 ============================================================================== --- projects/binutils-2.17/sys/boot/ia64/efi/ldscript.ia64 Tue Dec 28 21:27:08 2010 (r216778) +++ projects/binutils-2.17/sys/boot/ia64/efi/ldscript.ia64 Tue Dec 28 21:40:19 2010 (r216779) @@ -16,15 +16,15 @@ SECTIONS *(.plt) } =0x00300000010070000002000001000400 . = ALIGN(4096); + __start_set_Xcommand_set = .; + set_Xcommand_set : { *(set_Xcommand_set) } + __stop_set_Xcommand_set = .; .data : { *(.rodata .rodata.* .gnu.linkonce.r.*) *(.rodata1) *(.sdata2 .sdata2.* .gnu.linkonce.s2.*) *(.sbss2 .sbss2.* .gnu.linkonce.sb2.*) *(.opd) - __start_set_Xcommand_set = .; - *(set_Xcommand_set) - __stop_set_Xcommand_set = .; *(.data .data.* .gnu.linkonce.d.*) *(.data1) *(.plabel) @@ -32,8 +32,8 @@ SECTIONS *(.bss .bss.* .gnu.linkonce.b.*) *(COMMON) } - .IA_64.unwind_info : { *(.IA_64.unwind_info* .gnu.linkonce.ia64unwi.*) } - .IA_64.unwind : { *(.IA_64.unwind* .gnu.linkonce.ia64unw.*) } + .IA_64.unwind_info : { *(.IA_64.unwind_info* .gnu.linkonce.ia64unwi.*) } + .IA_64.unwind : { *(.IA_64.unwind* .gnu.linkonce.ia64unw.*) } . = ALIGN(4096); __gp = .; .sdata : { Modified: projects/binutils-2.17/sys/boot/ia64/ski/ldscript.ia64 ============================================================================== --- projects/binutils-2.17/sys/boot/ia64/ski/ldscript.ia64 Tue Dec 28 21:27:08 2010 (r216778) +++ projects/binutils-2.17/sys/boot/ia64/ski/ldscript.ia64 Tue Dec 28 21:40:19 2010 (r216779) @@ -12,15 +12,15 @@ SECTIONS *(.gnu.warning) *(.plt) } =0x00300000010070000002000001000400 + __start_set_Xcommand_set = .; + set_Xcommand_set : { *(set_Xcommand_set) } + __stop_set_Xcommand_set = .; .data : { *(.rodata .rodata.* .gnu.linkonce.r.*) *(.rodata1) *(.sdata2 .sdata2.* .gnu.linkonce.s2.*) *(.sbss2 .sbss2.* .gnu.linkonce.sb2.*) *(.opd) - __start_set_Xcommand_set = .; - *(set_Xcommand_set) - __stop_set_Xcommand_set = .; *(.data .data.* .gnu.linkonce.d.*) *(.data1) *(.plabel) @@ -28,8 +28,8 @@ SECTIONS *(.bss .bss.* .gnu.linkonce.b.*) *(COMMON) } - .IA_64.unwind_info : { *(.IA_64.unwind_info* .gnu.linkonce.ia64unwi.*) } - .IA_64.unwind : { *(.IA_64.unwind* .gnu.linkonce.ia64unw.*) } + .IA_64.unwind_info : { *(.IA_64.unwind_info* .gnu.linkonce.ia64unwi.*) } + .IA_64.unwind : { *(.IA_64.unwind* .gnu.linkonce.ia64unw.*) } __gp = .; .sdata : { *(.got.plt .got) From owner-svn-src-projects@FreeBSD.ORG Wed Dec 29 02:24:43 2010 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D85F5106564A; Wed, 29 Dec 2010 02:24:43 +0000 (UTC) (envelope-from jeff@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C5DD58FC08; Wed, 29 Dec 2010 02:24:43 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id oBT2OhJm084174; Wed, 29 Dec 2010 02:24:43 GMT (envelope-from jeff@svn.freebsd.org) Received: (from jeff@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oBT2Oh3s084163; Wed, 29 Dec 2010 02:24:43 GMT (envelope-from jeff@svn.freebsd.org) Message-Id: <201012290224.oBT2Oh3s084163@svn.freebsd.org> From: Jeff Roberson Date: Wed, 29 Dec 2010 02:24:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r216785 - in projects/ofed/head/sys/ofed: drivers/infiniband/core drivers/infiniband/hw/mlx4 include/linux X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 29 Dec 2010 02:24:43 -0000 Author: jeff Date: Wed Dec 29 02:24:43 2010 New Revision: 216785 URL: http://svn.freebsd.org/changeset/base/216785 Log: - Eliminate file descriptor ifdefs related to get_unused_fd() and alloc_file() by providing compatible wrappers for these functions. - Add support for SIGIO based async file IO and the fasync() file operation entry. - Document a few cases that are missing compatibility shims and still require work. - Also document those ifdefs which do not require compatibility shims for various reasons. Sponsored by: Isilon Systems, iX Systems, and Panasas. Modified: projects/ofed/head/sys/ofed/drivers/infiniband/core/addr.c projects/ofed/head/sys/ofed/drivers/infiniband/core/cma.c projects/ofed/head/sys/ofed/drivers/infiniband/core/sysfs.c projects/ofed/head/sys/ofed/drivers/infiniband/core/ucma.c projects/ofed/head/sys/ofed/drivers/infiniband/core/umem.c projects/ofed/head/sys/ofed/drivers/infiniband/core/uverbs_main.c projects/ofed/head/sys/ofed/drivers/infiniband/hw/mlx4/main.c projects/ofed/head/sys/ofed/include/linux/file.h projects/ofed/head/sys/ofed/include/linux/fs.h projects/ofed/head/sys/ofed/include/linux/linux_compat.c Modified: projects/ofed/head/sys/ofed/drivers/infiniband/core/addr.c ============================================================================== --- projects/ofed/head/sys/ofed/drivers/infiniband/core/addr.c Tue Dec 28 23:50:13 2010 (r216784) +++ projects/ofed/head/sys/ofed/drivers/infiniband/core/addr.c Wed Dec 29 02:24:43 2010 (r216785) @@ -585,6 +585,7 @@ void rdma_addr_cancel(struct rdma_dev_ad EXPORT_SYMBOL(rdma_addr_cancel); #ifdef __linux__ +/* XXX Need this callback to reduce timeout time. */ static int netevent_callback(struct notifier_block *self, unsigned long event, void *ctx) { Modified: projects/ofed/head/sys/ofed/drivers/infiniband/core/cma.c ============================================================================== --- projects/ofed/head/sys/ofed/drivers/infiniband/core/cma.c Tue Dec 28 23:50:13 2010 (r216784) +++ projects/ofed/head/sys/ofed/drivers/infiniband/core/cma.c Wed Dec 29 02:24:43 2010 (r216785) @@ -1682,6 +1682,7 @@ out: } #ifdef __linux__ +/* XXX I need to add an EVENTHANDLER based system for handling these events. */ static void cma_ndev_work_handler(struct work_struct *_work) { struct cma_ndev_work *work = container_of(_work, struct cma_ndev_work, work); Modified: projects/ofed/head/sys/ofed/drivers/infiniband/core/sysfs.c ============================================================================== --- projects/ofed/head/sys/ofed/drivers/infiniband/core/sysfs.c Tue Dec 28 23:50:13 2010 (r216784) +++ projects/ofed/head/sys/ofed/drivers/infiniband/core/sysfs.c Wed Dec 29 02:24:43 2010 (r216785) @@ -444,6 +444,7 @@ static void ib_device_release(struct dev } #ifdef __linux__ +/* BSD supports this through devfs(5) and devd(8). */ static int ib_device_uevent(struct device *device, struct kobj_uevent_env *env) { Modified: projects/ofed/head/sys/ofed/drivers/infiniband/core/ucma.c ============================================================================== --- projects/ofed/head/sys/ofed/drivers/infiniband/core/ucma.c Tue Dec 28 23:50:13 2010 (r216784) +++ projects/ofed/head/sys/ofed/drivers/infiniband/core/ucma.c Wed Dec 29 02:24:43 2010 (r216785) @@ -596,6 +596,7 @@ static void ucma_copy_iboe_route(struct switch (route->num_paths) { case 0: dev_addr = &route->addr.dev_addr; + /* XXX Vlan missing. */ #if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE) dev = dev_get_by_index(&init_net, dev_addr->bound_dev_if); if (dev) { Modified: projects/ofed/head/sys/ofed/drivers/infiniband/core/umem.c ============================================================================== --- projects/ofed/head/sys/ofed/drivers/infiniband/core/umem.c Tue Dec 28 23:50:13 2010 (r216784) +++ projects/ofed/head/sys/ofed/drivers/infiniband/core/umem.c Wed Dec 29 02:24:43 2010 (r216785) @@ -120,6 +120,7 @@ static void __ib_umem_release(struct ib_ chunk->nents, DMA_BIDIRECTIONAL, &chunk->attrs); for (i = 0; i < chunk->nents; ++i) { #ifdef __linux__ + /* XXX I need to set the proper page flags here too. */ struct page *page = sg_page(&chunk->page_list[i]); if (umem->writable && dirty) set_page_dirty_lock(page); Modified: projects/ofed/head/sys/ofed/drivers/infiniband/core/uverbs_main.c ============================================================================== --- projects/ofed/head/sys/ofed/drivers/infiniband/core/uverbs_main.c Tue Dec 28 23:50:13 2010 (r216784) +++ projects/ofed/head/sys/ofed/drivers/infiniband/core/uverbs_main.c Wed Dec 29 02:24:43 2010 (r216785) @@ -121,6 +121,7 @@ static ssize_t (*uverbs_cmd_table[])(str }; #ifdef __linux__ +/* BSD Does not require a fake mountpoint for all files. */ static struct vfsmount *uverbs_event_mnt; #endif @@ -372,14 +373,12 @@ static unsigned int ib_uverbs_event_poll return pollflags; } -#ifdef __linux__ static int ib_uverbs_event_fasync(int fd, struct file *filp, int on) { struct ib_uverbs_event_file *file = filp->private_data; return fasync_helper(fd, filp, on, &file->async_queue); } -#endif static int ib_uverbs_event_close(struct inode *inode, struct file *filp) { @@ -409,9 +408,7 @@ static const struct file_operations uver .read = ib_uverbs_event_read, .poll = ib_uverbs_event_poll, .release = ib_uverbs_event_close, -#ifdef __linux__ .fasync = ib_uverbs_event_fasync -#endif }; void ib_uverbs_comp_handler(struct ib_cq *cq, void *cq_context) @@ -448,10 +445,7 @@ void ib_uverbs_comp_handler(struct ib_cq wake_up_interruptible(&file->poll_wait); if (file->filp) selwakeup(&file->filp->f_selinfo); -#ifdef __linux__ - /* funsetown ? */ kill_fasync(&file->async_queue, SIGIO, POLL_IN); -#endif } static void ib_uverbs_async_handler(struct ib_uverbs_file *file, @@ -486,10 +480,7 @@ static void ib_uverbs_async_handler(stru wake_up_interruptible(&file->async_file->poll_wait); if (file->async_file->filp) selwakeup(&file->async_file->filp->f_selinfo); -#ifdef __linux__ - /* funsetown? */ kill_fasync(&file->async_file->async_queue, SIGIO, POLL_IN); -#endif } void ib_uverbs_cq_event_handler(struct ib_event *event, void *context_ptr) @@ -563,7 +554,6 @@ struct file *ib_uverbs_alloc_event_file( ev_file->is_async = is_async; ev_file->is_closed = 0; -#ifdef __linux__ *fd = get_unused_fd(); if (*fd < 0) { ret = *fd; @@ -582,28 +572,12 @@ struct file *ib_uverbs_alloc_event_file( goto err_fd; } -#else - filp = kzalloc(sizeof(*filp), GFP_KERNEL); - if (filp == NULL) { - ret = -ENOMEM; - goto err; - } - filp->f_op = &uverbs_event_fops; - ret = falloc(curthread, &filp->_file, fd); - if (ret) { - ret = -ret; - goto err; - } - finit(filp->_file, FREAD, DTYPE_DEV, filp, &badfileops); -#endif filp->private_data = ev_file; return filp; -#ifdef __linux__ err_fd: put_unused_fd(*fd); -#endif err: kfree(ev_file); Modified: projects/ofed/head/sys/ofed/drivers/infiniband/hw/mlx4/main.c ============================================================================== --- projects/ofed/head/sys/ofed/drivers/infiniband/hw/mlx4/main.c Tue Dec 28 23:50:13 2010 (r216784) +++ projects/ofed/head/sys/ofed/drivers/infiniband/hw/mlx4/main.c Wed Dec 29 02:24:43 2010 (r216785) @@ -1135,6 +1135,7 @@ static int update_ipv6_gids(struct mlx4_ goto out; } + /* XXX vlan */ read_lock(&dev_base_lock); for_each_netdev(&init_net, tmp) { if (ndev && (tmp == ndev @@ -1195,7 +1196,6 @@ static int update_ipv6_gids(struct mlx4_ out: kfree(work); return ret; - return 0; } static void handle_en_event(struct mlx4_ib_dev *dev, int port, unsigned long event) @@ -1221,6 +1221,7 @@ static void netdev_removed(struct mlx4_i update_ipv6_gids(dev, port, 1); } +/* XXX netdev event needed. */ static int mlx4_ib_netdev_event(struct notifier_block *this, unsigned long event, void *ptr) { Modified: projects/ofed/head/sys/ofed/include/linux/file.h ============================================================================== --- projects/ofed/head/sys/ofed/include/linux/file.h Tue Dec 28 23:50:13 2010 (r216784) +++ projects/ofed/head/sys/ofed/include/linux/file.h Wed Dec 29 02:24:43 2010 (r216785) @@ -54,6 +54,10 @@ linux_fget(unsigned int fd) static inline void fput(struct linux_file *filp) { + if (filp->_file == NULL) { + kfree(filp); + return; + } if (refcount_release(&filp->_file->f_count)) { _fdrop(filp->_file, curthread); kfree(filp); @@ -63,21 +67,53 @@ fput(struct linux_file *filp) static inline void put_unused_fd(unsigned int fd) { - struct linux_file *file; + struct file *file; - file = linux_fget(fd); + file = fget_unlocked(curthread->td_proc->p_fd, fd); if (file == NULL) return; - if (file->_file) - fdclose(curthread->td_proc->p_fd, file->_file, fd, curthread); + fdclose(curthread->td_proc->p_fd, file, fd, curthread); } static inline void fd_install(unsigned int fd, struct linux_file *filp) { - filp->_file->f_ops = &linuxfileops; + struct file *file; + + file = fget_unlocked(curthread->td_proc->p_fd, fd); + filp->_file = file; + finit(file, filp->f_mode, DTYPE_DEV, filp, &linuxfileops); +} + +static inline int +get_unused_fd(void) +{ + struct file *file; + int error; + int fd; + + error = falloc(curthread, &file, &fd); + if (error) + return -error; + return fd; } +static inline struct linux_file * +_alloc_file(int mode, const struct file_operations *fops) +{ + struct linux_file *filp; + + filp = kzalloc(sizeof(*filp), GFP_KERNEL); + if (filp == NULL) + return (NULL); + filp->f_op = fops; + filp->f_mode = mode; + + return filp; +} + +#define alloc_file(mnt, root, mode, fops) _alloc_file((mode), (fops)) + #define file linux_file #define fget linux_fget Modified: projects/ofed/head/sys/ofed/include/linux/fs.h ============================================================================== --- projects/ofed/head/sys/ofed/include/linux/fs.h Tue Dec 28 23:50:13 2010 (r216784) +++ projects/ofed/head/sys/ofed/include/linux/fs.h Wed Dec 29 02:24:43 2010 (r216785) @@ -68,12 +68,30 @@ struct linux_file { const struct file_operations *f_op; void *private_data; int f_flags; + int f_mode; /* Just starting mode. */ struct dentry *f_dentry; struct dentry f_dentry_store; struct selinfo f_selinfo; + struct sigio *f_sigio; }; -#define file linux_file +#define file linux_file +#define fasync_struct sigio * + +#define fasync_helper(fd, filp, on, queue) \ +({ \ + if ((on)) \ + *(queue) = &(filp)->f_sigio; \ + else \ + *(queue) = NULL; \ + 0; \ +}) + +#define kill_fasync(queue, sig, pollstat) \ +do { \ + if (*(queue) != NULL) \ + pgsigio(*(queue), (sig), 0); \ +} while (0) typedef int (*filldir_t)(void *, const char *, int, loff_t, u64, unsigned); @@ -86,6 +104,7 @@ struct file_operations { int (*mmap)(struct file *, struct vm_area_struct *); int (*open)(struct inode *, struct file *); int (*release)(struct inode *, struct file *); + int (*fasync)(int, struct file *, int); #if 0 /* We do not support these methods. Don't permit them to compile. */ loff_t (*llseek)(struct file *, loff_t, int); @@ -100,7 +119,6 @@ struct file_operations { int (*flush)(struct file *, fl_owner_t id); int (*fsync)(struct file *, struct dentry *, int datasync); int (*aio_fsync)(struct kiocb *, int datasync); - int (*fasync)(int, struct file *, int); int (*lock)(struct file *, int, struct file_lock *); ssize_t (*sendpage)(struct file *, struct page *, int, size_t, loff_t *, int); @@ -115,6 +133,11 @@ struct file_operations { int (*setlease)(struct file *, long, struct file_lock **); #endif }; +#define fops_get(fops) (fops) + +#define FMODE_READ FREAD +#define FMODE_WRITE FWRITE +#define FMODE_EXEC FEXEC static inline int register_chrdev_region(dev_t dev, unsigned range, const char *name) Modified: projects/ofed/head/sys/ofed/include/linux/linux_compat.c ============================================================================== --- projects/ofed/head/sys/ofed/include/linux/linux_compat.c Tue Dec 28 23:50:13 2010 (r216784) +++ projects/ofed/head/sys/ofed/include/linux/linux_compat.c Wed Dec 29 02:24:43 2010 (r216785) @@ -34,6 +34,9 @@ #include #include #include +#include +#include +#include #include #include @@ -440,8 +443,6 @@ linux_dev_mmap_single(struct cdev *dev, return (error); } - - struct cdevsw linuxcdevsw = { .d_version = D_VERSION, .d_flags = D_TRACKCLOSE, @@ -510,15 +511,52 @@ linux_file_close(struct file *file, stru filp = (struct linux_file *)file->f_data; filp->f_flags = file->f_flag; error = -filp->f_op->release(NULL, filp); + funsetown(&filp->f_sigio); kfree(filp); return (error); } +static int +linux_file_ioctl(struct file *fp, u_long cmd, void *data, struct ucred *cred, + struct thread *td) +{ + struct linux_file *filp; + int error; + + filp = (struct linux_file *)fp->f_data; + filp->f_flags = fp->f_flag; + error = 0; + + switch (cmd) { + case FIONBIO: + break; + case FIOASYNC: + if (filp->f_op->fasync == NULL) + break; + error = filp->f_op->fasync(0, filp, fp->f_flag & FASYNC); + break; + case FIOSETOWN: + error = fsetown(*(int *)data, &filp->f_sigio); + if (error == 0) + error = filp->f_op->fasync(0, filp, + fp->f_flag & FASYNC); + break; + case FIOGETOWN: + *(int *)data = fgetown(&filp->f_sigio); + break; + default: + error = ENOTTY; + break; + } + return (error); +} + struct fileops linuxfileops = { .fo_read = linux_file_read, .fo_poll = linux_file_poll, - .fo_close = linux_file_close + .fo_close = linux_file_close, + .fo_ioctl = linux_file_ioctl }; /* From owner-svn-src-projects@FreeBSD.ORG Wed Dec 29 04:14:25 2010 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 34CB31065672; Wed, 29 Dec 2010 04:14:25 +0000 (UTC) (envelope-from jeff@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 099CB8FC15; Wed, 29 Dec 2010 04:14:25 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id oBT4EOBh086844; Wed, 29 Dec 2010 04:14:24 GMT (envelope-from jeff@svn.freebsd.org) Received: (from jeff@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oBT4EOfX086841; Wed, 29 Dec 2010 04:14:24 GMT (envelope-from jeff@svn.freebsd.org) Message-Id: <201012290414.oBT4EOfX086841@svn.freebsd.org> From: Jeff Roberson Date: Wed, 29 Dec 2010 04:14:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r216787 - in projects/ofed/head/sys: kern sys X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 29 Dec 2010 04:14:25 -0000 Author: jeff Date: Wed Dec 29 04:14:24 2010 New Revision: 216787 URL: http://svn.freebsd.org/changeset/base/216787 Log: - Add a wait argument to taskqueue_cancel() so it can be used for blocking and non-blocking operations. Sponsored by: Isilon Systems, iX Systems, and Panasas. Modified: projects/ofed/head/sys/kern/subr_taskqueue.c projects/ofed/head/sys/sys/taskqueue.h Modified: projects/ofed/head/sys/kern/subr_taskqueue.c ============================================================================== --- projects/ofed/head/sys/kern/subr_taskqueue.c Wed Dec 29 02:54:41 2010 (r216786) +++ projects/ofed/head/sys/kern/subr_taskqueue.c Wed Dec 29 04:14:24 2010 (r216787) @@ -251,10 +251,12 @@ taskqueue_run(struct taskqueue *queue) } int -taskqueue_cancel(struct taskqueue *queue, struct task *task) +taskqueue_cancel(struct taskqueue *queue, struct task *task, int wait) { int pending; + if (wait) + WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, __func__); if (queue->tq_spin) { /* XXX */ mtx_lock_spin(&queue->tq_mutex); pending = task->ta_pending; @@ -264,12 +266,11 @@ taskqueue_cancel(struct taskqueue *queue task, ta_link); task->ta_pending = 0; break; - } else + } else if (wait) msleep_spin(task, &queue->tq_mutex, "-", 0); } mtx_unlock_spin(&queue->tq_mutex); } else { - WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, __func__); mtx_lock(&queue->tq_mutex); pending = task->ta_pending; @@ -279,7 +280,7 @@ taskqueue_cancel(struct taskqueue *queue task, ta_link); task->ta_pending = 0; break; - } else + } else if (wait) msleep(task, &queue->tq_mutex, PWAIT, "-", 0); } mtx_unlock(&queue->tq_mutex); Modified: projects/ofed/head/sys/sys/taskqueue.h ============================================================================== --- projects/ofed/head/sys/sys/taskqueue.h Wed Dec 29 02:54:41 2010 (r216786) +++ projects/ofed/head/sys/sys/taskqueue.h Wed Dec 29 04:14:24 2010 (r216787) @@ -54,7 +54,7 @@ struct taskqueue *taskqueue_create(const int taskqueue_start_threads(struct taskqueue **tqp, int count, int pri, const char *name, ...) __printflike(4, 5); int taskqueue_enqueue(struct taskqueue *queue, struct task *task); -int taskqueue_cancel(struct taskqueue *queue, struct task *task); +int taskqueue_cancel(struct taskqueue *queue, struct task *task, int wait); void taskqueue_drain(struct taskqueue *queue, struct task *task); void taskqueue_free(struct taskqueue *queue); void taskqueue_run(struct taskqueue *queue); From owner-svn-src-projects@FreeBSD.ORG Wed Dec 29 04:16:12 2010 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 851B91065672; Wed, 29 Dec 2010 04:16:12 +0000 (UTC) (envelope-from jeff@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 747CB8FC15; Wed, 29 Dec 2010 04:16:12 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id oBT4GCkO086923; Wed, 29 Dec 2010 04:16:12 GMT (envelope-from jeff@svn.freebsd.org) Received: (from jeff@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oBT4GCY1086921; Wed, 29 Dec 2010 04:16:12 GMT (envelope-from jeff@svn.freebsd.org) Message-Id: <201012290416.oBT4GCY1086921@svn.freebsd.org> From: Jeff Roberson Date: Wed, 29 Dec 2010 04:16:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r216788 - projects/ofed/head/sys/ofed/include/linux X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 29 Dec 2010 04:16:12 -0000 Author: jeff Date: Wed Dec 29 04:16:12 2010 New Revision: 216788 URL: http://svn.freebsd.org/changeset/base/216788 Log: - cancel_delayed_work() is not expected to be perfect and may be called with locks held. Use the non-blocking callout_stop() and a non-blocking workqueue_cancel(). Sponsored by: Isilon Systems, iX Systems, and Panasas. Modified: projects/ofed/head/sys/ofed/include/linux/workqueue.h Modified: projects/ofed/head/sys/ofed/include/linux/workqueue.h ============================================================================== --- projects/ofed/head/sys/ofed/include/linux/workqueue.h Wed Dec 29 04:14:24 2010 (r216787) +++ projects/ofed/head/sys/ofed/include/linux/workqueue.h Wed Dec 29 04:16:12 2010 (r216788) @@ -167,17 +167,20 @@ flush_taskqueue(struct taskqueue *tq) #define cancel_work_sync(work) \ (work)->taskqueue ? \ - taskqueue_cancel((work)->taskqueue, &(work)->work_task) : 0 + taskqueue_cancel((work)->taskqueue, &(work)->work_task, 1) : 0 +/* + * This may leave work running on another CPU as it does on Linux. + */ static inline int cancel_delayed_work(struct delayed_work *work) { int error; - error = callout_drain(&work->timer); - if (error == 0 && work->work.taskqueue) + callout_stop(&work->timer); + if (work->work.taskqueue) error = taskqueue_cancel(work->work.taskqueue, - &work->work.work_task); + &work->work.work_task, 0); return error; } From owner-svn-src-projects@FreeBSD.ORG Wed Dec 29 04:17:50 2010 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5C069106564A; Wed, 29 Dec 2010 04:17:50 +0000 (UTC) (envelope-from jeff@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4A78B8FC0C; Wed, 29 Dec 2010 04:17:50 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id oBT4HoiI086989; Wed, 29 Dec 2010 04:17:50 GMT (envelope-from jeff@svn.freebsd.org) Received: (from jeff@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oBT4HoQ2086985; Wed, 29 Dec 2010 04:17:50 GMT (envelope-from jeff@svn.freebsd.org) Message-Id: <201012290417.oBT4HoQ2086985@svn.freebsd.org> From: Jeff Roberson Date: Wed, 29 Dec 2010 04:17:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r216789 - in projects/ofed/head/sys/ofed: drivers/infiniband/core include/linux include/net X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 29 Dec 2010 04:17:50 -0000 Author: jeff Date: Wed Dec 29 04:17:50 2010 New Revision: 216789 URL: http://svn.freebsd.org/changeset/base/216789 Log: - Solve a bug in addr.c where ifp could end up NULL. Reported/Tested by: gnn - Add support for Linux netevents via BSD eventhandlers. Sponsored by: Isilon Systems, iX Systems, and Panasas. Modified: projects/ofed/head/sys/ofed/drivers/infiniband/core/addr.c projects/ofed/head/sys/ofed/include/linux/notifier.h projects/ofed/head/sys/ofed/include/net/netevent.h Modified: projects/ofed/head/sys/ofed/drivers/infiniband/core/addr.c ============================================================================== --- projects/ofed/head/sys/ofed/drivers/infiniband/core/addr.c Wed Dec 29 04:16:12 2010 (r216788) +++ projects/ofed/head/sys/ofed/drivers/infiniband/core/addr.c Wed Dec 29 04:17:50 2010 (r216789) @@ -427,17 +427,21 @@ static int addr_resolve(struct sockaddr } /* * If it's not multicast or broadcast and the route doesn't match the - * requested interface return unreachable. + * requested interface return unreachable. Otherwise fetch the + * correct interface pointer and unlock the route. */ if (multi || bcast) { + if (ifp == NULL) + ifp = rte->rt_ifp; RTFREE_LOCKED(rte); } else if (ifp && ifp != rte->rt_ifp) { RTFREE_LOCKED(rte); return -ENETUNREACH; - } else + } else { + if (ifp == NULL) + ifp = rte->rt_ifp; RT_UNLOCK(rte); - if (ifp == NULL) - ifp = rte->rt_ifp; + } mcast: if (bcast) return rdma_copy_addr(addr, ifp, ifp->if_broadcastaddr); @@ -584,17 +588,19 @@ void rdma_addr_cancel(struct rdma_dev_ad } EXPORT_SYMBOL(rdma_addr_cancel); -#ifdef __linux__ -/* XXX Need this callback to reduce timeout time. */ static int netevent_callback(struct notifier_block *self, unsigned long event, void *ctx) { if (event == NETEVENT_NEIGH_UPDATE) { +#ifdef __linux__ struct neighbour *neigh = ctx; if (neigh->nud_state & NUD_VALID) { set_timeout(jiffies); } +#else + set_timeout(jiffies); +#endif } return 0; } @@ -602,7 +608,6 @@ static int netevent_callback(struct noti static struct notifier_block nb = { .notifier_call = netevent_callback }; -#endif static int addr_init(void) { @@ -611,17 +616,13 @@ static int addr_init(void) if (!addr_wq) return -ENOMEM; -#ifdef __linux__ register_netevent_notifier(&nb); -#endif return 0; } static void addr_cleanup(void) { -#ifdef __linux__ unregister_netevent_notifier(&nb); -#endif destroy_workqueue(addr_wq); } Modified: projects/ofed/head/sys/ofed/include/linux/notifier.h ============================================================================== --- projects/ofed/head/sys/ofed/include/linux/notifier.h Wed Dec 29 04:16:12 2010 (r216788) +++ projects/ofed/head/sys/ofed/include/linux/notifier.h Wed Dec 29 04:17:50 2010 (r216789) @@ -29,10 +29,18 @@ #ifndef _LINUX_NOTIFIER_H_ #define _LINUX_NOTIFIER_H_ +#include + +/* + * Max number of FreeBSD events to map to Linux events per notify type. + */ +#define NB_COUNT 5 + struct notifier_block { int (*notifier_call)(struct notifier_block *, unsigned long, void *); struct notifier_block *next; int priority; + eventhandler_tag tags[NB_COUNT]; }; #endif /* _LINUX_NOTIFIER_H_ */ Modified: projects/ofed/head/sys/ofed/include/net/netevent.h ============================================================================== --- projects/ofed/head/sys/ofed/include/net/netevent.h Wed Dec 29 04:16:12 2010 (r216788) +++ projects/ofed/head/sys/ofed/include/net/netevent.h Wed Dec 29 04:17:50 2010 (r216789) @@ -25,3 +25,47 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +#ifndef _LINUX_NET_NETEVENT_H_ +#define _LINUX_NET_NETEVENT_H_ + +#include + +enum netevent_notif_type { + NETEVENT_NEIGH_UPDATE = 0, +#if 0 /* Unsupported events. */ + NETEVENT_PMTU_UPDATE, + NETEVENT_REDIRECT, +#endif +}; + +struct llentry; + +static inline void +_handle_arp_update_event(void *arg, struct llentry *lle) +{ + struct notifier_block *nb; + + nb = arg; + nb->notifier_call(nb, NETEVENT_NEIGH_UPDATE, lle); +} + +static inline int +register_netevent_notifier(struct notifier_block *nb) +{ + nb->tags[NETEVENT_NEIGH_UPDATE] = EVENTHANDLER_REGISTER( + arp_update_event, _handle_arp_update_event, nb, 0); + return (0); +} + +static inline int +unregister_netevent_notifier(struct notifier_block *nb) +{ + + EVENTHANDLER_DEREGISTER(arp_update_event, + nb->tags[NETEVENT_NEIGH_UPDATE]); + + return (0); +} + +#endif /* _LINUX_NET_NETEVENT_H_ */ From owner-svn-src-projects@FreeBSD.ORG Thu Dec 30 23:35:24 2010 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3D18E1065679; Thu, 30 Dec 2010 23:35:24 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 289A78FC1D; Thu, 30 Dec 2010 23:35:24 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id oBUNZNdf054152; Thu, 30 Dec 2010 23:35:23 GMT (envelope-from dim@svn.freebsd.org) Received: (from dim@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oBUNZNvj054128; Thu, 30 Dec 2010 23:35:23 GMT (envelope-from dim@svn.freebsd.org) Message-Id: <201012302335.oBUNZNvj054128@svn.freebsd.org> From: Dimitry Andric Date: Thu, 30 Dec 2010 23:35:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r216827 - in projects/binutils-2.17: . bin/sh contrib/top etc etc/rc.d gnu/lib/libgcc lib/libc/locale lib/libc/rpc lib/libcompiler_rt lib/libkvm lib/libthr/thread libexec/rtld-elf libex... X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Dec 2010 23:35:24 -0000 Author: dim Date: Thu Dec 30 23:35:23 2010 New Revision: 216827 URL: http://svn.freebsd.org/changeset/base/216827 Log: Sync: merge r216683 through r216826 from ^/head. Added: projects/binutils-2.17/tools/regression/bin/sh/expansion/cmdsubst10.0 - copied unchanged from r216826, head/tools/regression/bin/sh/expansion/cmdsubst10.0 projects/binutils-2.17/tools/regression/bin/sh/expansion/cmdsubst4.0 - copied unchanged from r216826, head/tools/regression/bin/sh/expansion/cmdsubst4.0 projects/binutils-2.17/tools/regression/bin/sh/expansion/cmdsubst5.0 - copied unchanged from r216826, head/tools/regression/bin/sh/expansion/cmdsubst5.0 projects/binutils-2.17/tools/regression/bin/sh/expansion/cmdsubst6.0 - copied unchanged from r216826, head/tools/regression/bin/sh/expansion/cmdsubst6.0 projects/binutils-2.17/tools/regression/bin/sh/expansion/cmdsubst7.0 - copied unchanged from r216826, head/tools/regression/bin/sh/expansion/cmdsubst7.0 projects/binutils-2.17/tools/regression/bin/sh/expansion/cmdsubst8.0 - copied unchanged from r216826, head/tools/regression/bin/sh/expansion/cmdsubst8.0 projects/binutils-2.17/tools/regression/bin/sh/expansion/cmdsubst9.0 - copied unchanged from r216826, head/tools/regression/bin/sh/expansion/cmdsubst9.0 projects/binutils-2.17/tools/regression/bin/sh/expansion/plus-minus7.0 - copied unchanged from r216826, head/tools/regression/bin/sh/expansion/plus-minus7.0 Deleted: projects/binutils-2.17/sys/dev/cxgb/ulp/tom/cxgb_vm.c projects/binutils-2.17/sys/dev/cxgb/ulp/tom/cxgb_vm.h Modified: projects/binutils-2.17/Makefile projects/binutils-2.17/UPDATING projects/binutils-2.17/bin/sh/eval.c projects/binutils-2.17/bin/sh/exec.c projects/binutils-2.17/bin/sh/expand.c projects/binutils-2.17/bin/sh/expand.h projects/binutils-2.17/bin/sh/histedit.c projects/binutils-2.17/bin/sh/memalloc.c projects/binutils-2.17/bin/sh/memalloc.h projects/binutils-2.17/bin/sh/parser.c projects/binutils-2.17/etc/portsnap.conf projects/binutils-2.17/etc/rc.d/devd projects/binutils-2.17/gnu/lib/libgcc/Makefile projects/binutils-2.17/lib/libc/locale/mbrtowc.3 projects/binutils-2.17/lib/libc/rpc/publickey.3 projects/binutils-2.17/lib/libcompiler_rt/Makefile projects/binutils-2.17/lib/libkvm/kvm_getloadavg.3 projects/binutils-2.17/lib/libthr/thread/thr_mutex.c projects/binutils-2.17/libexec/rtld-elf/Makefile projects/binutils-2.17/libexec/rtld-elf/amd64/reloc.c projects/binutils-2.17/libexec/rtld-elf/arm/reloc.c projects/binutils-2.17/libexec/rtld-elf/i386/reloc.c projects/binutils-2.17/libexec/rtld-elf/ia64/reloc.c projects/binutils-2.17/libexec/rtld-elf/mips/reloc.c projects/binutils-2.17/libexec/rtld-elf/powerpc/reloc.c projects/binutils-2.17/libexec/rtld-elf/powerpc64/reloc.c projects/binutils-2.17/libexec/rtld-elf/powerpc64/rtld_start.S projects/binutils-2.17/libexec/rtld-elf/rtld.1 projects/binutils-2.17/libexec/rtld-elf/rtld.c projects/binutils-2.17/libexec/rtld-elf/rtld.h projects/binutils-2.17/libexec/rtld-elf/rtld_lock.c projects/binutils-2.17/libexec/rtld-elf/rtld_lock.h projects/binutils-2.17/libexec/rtld-elf/sparc64/reloc.c projects/binutils-2.17/sbin/dumpfs/dumpfs.c projects/binutils-2.17/sbin/hastd/parse.y projects/binutils-2.17/sbin/mount_nfs/mount_nfs.c projects/binutils-2.17/sbin/newfs/mkfs.c projects/binutils-2.17/sbin/newfs/newfs.8 projects/binutils-2.17/sbin/newfs/newfs.c projects/binutils-2.17/sbin/newfs/newfs.h projects/binutils-2.17/sbin/shutdown/Makefile projects/binutils-2.17/sbin/shutdown/shutdown.8 projects/binutils-2.17/sbin/shutdown/shutdown.c projects/binutils-2.17/sbin/tunefs/tunefs.8 projects/binutils-2.17/sbin/tunefs/tunefs.c projects/binutils-2.17/share/examples/etc/make.conf projects/binutils-2.17/share/mk/bsd.cpu.mk projects/binutils-2.17/sys/compat/linux/linux_ioctl.c projects/binutils-2.17/sys/compat/linux/linux_ioctl.h projects/binutils-2.17/sys/conf/kern.pre.mk projects/binutils-2.17/sys/conf/makeLINT.mk projects/binutils-2.17/sys/dev/cxgb/ulp/tom/cxgb_cpl_socket.c projects/binutils-2.17/sys/dev/cxgb/ulp/tom/cxgb_ddp.c projects/binutils-2.17/sys/dev/drm/via_dmablit.c projects/binutils-2.17/sys/dev/md/md.c projects/binutils-2.17/sys/dev/mpt/mpt_pci.c projects/binutils-2.17/sys/dev/sound/pci/hda/hdac.c projects/binutils-2.17/sys/dev/wpi/if_wpi.c projects/binutils-2.17/sys/dev/xen/console/console.c projects/binutils-2.17/sys/fs/nfs/nfs.h projects/binutils-2.17/sys/fs/nfs/nfs_commonsubs.c projects/binutils-2.17/sys/fs/nfs/nfs_var.h projects/binutils-2.17/sys/fs/nfsserver/nfs_nfsdport.c projects/binutils-2.17/sys/fs/nfsserver/nfs_nfsdserv.c projects/binutils-2.17/sys/fs/nfsserver/nfs_nfsdsocket.c projects/binutils-2.17/sys/geom/geom_disk.c projects/binutils-2.17/sys/geom/part/g_part_ebr.c projects/binutils-2.17/sys/i386/conf/XBOX projects/binutils-2.17/sys/i386/conf/XEN projects/binutils-2.17/sys/i386/xen/pmap.c projects/binutils-2.17/sys/kern/kern_resource.c projects/binutils-2.17/sys/kern/kern_timeout.c projects/binutils-2.17/sys/kern/kern_umtx.c projects/binutils-2.17/sys/kern/sched_4bsd.c projects/binutils-2.17/sys/kern/sched_ule.c projects/binutils-2.17/sys/kern/sys_pipe.c projects/binutils-2.17/sys/kern/uipc_cow.c projects/binutils-2.17/sys/kern/vfs_bio.c projects/binutils-2.17/sys/kern/vfs_subr.c projects/binutils-2.17/sys/mips/cavium/octeon_machdep.c projects/binutils-2.17/sys/net/bpf_zerocopy.c projects/binutils-2.17/sys/netinet/in_pcb.c projects/binutils-2.17/sys/netinet/sctp_asconf.c projects/binutils-2.17/sys/netinet/sctp_bsd_addr.c projects/binutils-2.17/sys/netinet/sctp_constants.h projects/binutils-2.17/sys/netinet/sctp_indata.c projects/binutils-2.17/sys/netinet/sctp_input.c projects/binutils-2.17/sys/netinet/sctp_output.c projects/binutils-2.17/sys/netinet/sctp_pcb.c projects/binutils-2.17/sys/netinet/sctp_timer.c projects/binutils-2.17/sys/netinet/sctp_usrreq.c projects/binutils-2.17/sys/netinet/sctputil.c projects/binutils-2.17/sys/netinet/tcp_input.c projects/binutils-2.17/sys/netinet/tcp_output.c projects/binutils-2.17/sys/netinet/tcp_sack.c projects/binutils-2.17/sys/netinet/tcp_subr.c projects/binutils-2.17/sys/netinet/tcp_var.h projects/binutils-2.17/sys/nfsserver/nfs_serv.c projects/binutils-2.17/sys/powerpc/aim/moea64_native.c projects/binutils-2.17/sys/sparc64/include/asmacros.h projects/binutils-2.17/sys/sparc64/include/cpufunc.h projects/binutils-2.17/sys/sparc64/include/pmap.h projects/binutils-2.17/sys/sparc64/include/tsb.h projects/binutils-2.17/sys/sparc64/sparc64/exception.S projects/binutils-2.17/sys/sparc64/sparc64/genassym.c projects/binutils-2.17/sys/sparc64/sparc64/mp_machdep.c projects/binutils-2.17/sys/sparc64/sparc64/pmap.c projects/binutils-2.17/sys/sparc64/sparc64/support.S projects/binutils-2.17/sys/sparc64/sparc64/tsb.c projects/binutils-2.17/sys/sys/param.h projects/binutils-2.17/sys/sys/sched.h projects/binutils-2.17/sys/ufs/ffs/ffs_alloc.c projects/binutils-2.17/sys/ufs/ffs/ffs_softdep.c projects/binutils-2.17/sys/ufs/ffs/ffs_vfsops.c projects/binutils-2.17/sys/ufs/ffs/fs.h projects/binutils-2.17/sys/ufs/ffs/softdep.h projects/binutils-2.17/sys/ufs/ufs/ufs_inode.c projects/binutils-2.17/sys/ufs/ufs/ufs_vnops.c projects/binutils-2.17/sys/ufs/ufs/ufsmount.h projects/binutils-2.17/sys/vm/vm_contig.c projects/binutils-2.17/sys/vm/vm_extern.h projects/binutils-2.17/sys/vm/vm_fault.c projects/binutils-2.17/sys/vm/vm_object.c projects/binutils-2.17/sys/vm/vm_object.h projects/binutils-2.17/sys/vm/vm_page.c projects/binutils-2.17/sys/xen/evtchn/evtchn.c projects/binutils-2.17/tools/regression/bin/sh/expansion/plus-minus1.0 projects/binutils-2.17/usr.bin/ar/ar.1 projects/binutils-2.17/usr.bin/c89/c89.1 projects/binutils-2.17/usr.bin/c99/c99.1 projects/binutils-2.17/usr.bin/calendar/calendar.1 projects/binutils-2.17/usr.bin/calendar/calendar.h projects/binutils-2.17/usr.bin/calendar/parsedata.c projects/binutils-2.17/usr.bin/gcore/gcore.1 projects/binutils-2.17/usr.bin/lock/lock.c projects/binutils-2.17/usr.bin/mail/mail.1 projects/binutils-2.17/usr.bin/printf/printf.c projects/binutils-2.17/usr.bin/tar/bsdtar.1 projects/binutils-2.17/usr.sbin/ancontrol/ancontrol.8 Directory Properties: projects/binutils-2.17/ (props changed) projects/binutils-2.17/cddl/contrib/opensolaris/ (props changed) projects/binutils-2.17/contrib/bind9/ (props changed) projects/binutils-2.17/contrib/binutils/ (props changed) projects/binutils-2.17/contrib/bzip2/ (props changed) projects/binutils-2.17/contrib/ee/ (props changed) projects/binutils-2.17/contrib/expat/ (props changed) projects/binutils-2.17/contrib/file/ (props changed) projects/binutils-2.17/contrib/gdb/ (props changed) projects/binutils-2.17/contrib/gdtoa/ (props changed) projects/binutils-2.17/contrib/gnu-sort/ (props changed) projects/binutils-2.17/contrib/groff/ (props changed) projects/binutils-2.17/contrib/less/ (props changed) projects/binutils-2.17/contrib/libpcap/ (props changed) projects/binutils-2.17/contrib/llvm/ (props changed) projects/binutils-2.17/contrib/llvm/tools/clang/ (props changed) projects/binutils-2.17/contrib/ncurses/ (props changed) projects/binutils-2.17/contrib/netcat/ (props changed) projects/binutils-2.17/contrib/ntp/ (props changed) projects/binutils-2.17/contrib/one-true-awk/ (props changed) projects/binutils-2.17/contrib/openbsm/ (props changed) projects/binutils-2.17/contrib/openpam/ (props changed) projects/binutils-2.17/contrib/pf/ (props changed) projects/binutils-2.17/contrib/sendmail/ (props changed) projects/binutils-2.17/contrib/tcpdump/ (props changed) projects/binutils-2.17/contrib/tcsh/ (props changed) projects/binutils-2.17/contrib/top/ (props changed) projects/binutils-2.17/contrib/top/install-sh (props changed) projects/binutils-2.17/contrib/tzcode/stdtime/ (props changed) projects/binutils-2.17/contrib/tzcode/zic/ (props changed) projects/binutils-2.17/contrib/tzdata/ (props changed) projects/binutils-2.17/contrib/wpa/ (props changed) projects/binutils-2.17/contrib/xz/ (props changed) projects/binutils-2.17/crypto/openssh/ (props changed) projects/binutils-2.17/crypto/openssl/ (props changed) projects/binutils-2.17/lib/libc/ (props changed) projects/binutils-2.17/lib/libc/stdtime/ (props changed) projects/binutils-2.17/lib/libutil/ (props changed) projects/binutils-2.17/lib/libz/ (props changed) projects/binutils-2.17/sbin/ (props changed) projects/binutils-2.17/sbin/ipfw/ (props changed) projects/binutils-2.17/share/mk/bsd.arch.inc.mk (props changed) projects/binutils-2.17/share/zoneinfo/ (props changed) projects/binutils-2.17/sys/ (props changed) projects/binutils-2.17/sys/amd64/include/xen/ (props changed) projects/binutils-2.17/sys/cddl/contrib/opensolaris/ (props changed) projects/binutils-2.17/sys/contrib/dev/acpica/ (props changed) projects/binutils-2.17/sys/contrib/octeon-sdk/ (props changed) projects/binutils-2.17/sys/contrib/pf/ (props changed) projects/binutils-2.17/sys/contrib/x86emu/ (props changed) projects/binutils-2.17/usr.bin/calendar/ (props changed) projects/binutils-2.17/usr.bin/csup/ (props changed) projects/binutils-2.17/usr.bin/procstat/ (props changed) projects/binutils-2.17/usr.sbin/zic/ (props changed) Modified: projects/binutils-2.17/Makefile ============================================================================== --- projects/binutils-2.17/Makefile Thu Dec 30 22:33:55 2010 (r216826) +++ projects/binutils-2.17/Makefile Thu Dec 30 23:35:23 2010 (r216827) @@ -350,8 +350,8 @@ KERNCONFS!= cd ${.CURDIR}/sys/${TARGET}/ universe_kernconfs: .for kernel in ${KERNCONFS} TARGET_ARCH_${kernel}!= cd ${.CURDIR}/sys/${TARGET}/conf && \ - config -m ${.CURDIR}/sys/${TARGET}/conf/${kernel} | \ - cut -f 2 + config -m ${.CURDIR}/sys/${TARGET}/conf/${kernel} 2> /dev/null | \ + cut -f 2 universe_kernconfs: universe_kernconf_${TARGET}_${kernel} universe_kernconf_${TARGET}_${kernel}: @(cd ${.CURDIR} && env __MAKE_CONF=/dev/null \ Modified: projects/binutils-2.17/UPDATING ============================================================================== --- projects/binutils-2.17/UPDATING Thu Dec 30 22:33:55 2010 (r216826) +++ projects/binutils-2.17/UPDATING Thu Dec 30 23:35:23 2010 (r216827) @@ -22,6 +22,13 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 9. machines to maximize performance. (To disable malloc debugging, run ln -s aj /etc/malloc.conf.) +20101228: + The TCP stack has been modified to allow Khelp modules to interact with + it via helper hook points and store per-connection data in the TCP + control block. Bump __FreeBSD_version to 900029. User space tools that + rely on the size of struct tcpcb in tcp_var.h (e.g. sockstat) need to + be recompiled. + 20101114: Generic IEEE 802.3 annex 31B full duplex flow control support has been added to mii(4) and bge(4), bce(4), msk(4), nfe(4) and stge(4) along Modified: projects/binutils-2.17/bin/sh/eval.c ============================================================================== --- projects/binutils-2.17/bin/sh/eval.c Thu Dec 30 22:33:55 2010 (r216826) +++ projects/binutils-2.17/bin/sh/eval.c Thu Dec 30 23:35:23 2010 (r216827) @@ -94,6 +94,7 @@ static void evalsubshell(union node *, i static void evalredir(union node *, int); static void expredir(union node *); static void evalpipe(union node *); +static int is_valid_fast_cmdsubst(union node *n); static void evalcommand(union node *, int, struct backcmd *); static void prehash(union node *); @@ -565,6 +566,19 @@ evalpipe(union node *n) +static int +is_valid_fast_cmdsubst(union node *n) +{ + union node *argp; + + if (n->type != NCMD) + return 0; + for (argp = n->ncmd.args ; argp ; argp = argp->narg.next) + if (expandhassideeffects(argp->narg.text)) + return 0; + return 1; +} + /* * Execute a command inside back quotes. If it's a builtin command, we * want to save its output in a block obtained from malloc. Otherwise @@ -578,6 +592,8 @@ evalbackcmd(union node *n, struct backcm int pip[2]; struct job *jp; struct stackmark smark; /* unnecessary */ + struct jmploc jmploc; + struct jmploc *savehandler; setstackmark(&smark); result->fd = -1; @@ -588,9 +604,21 @@ evalbackcmd(union node *n, struct backcm exitstatus = 0; goto out; } - if (n->type == NCMD) { + if (is_valid_fast_cmdsubst(n)) { exitstatus = oexitstatus; - evalcommand(n, EV_BACKCMD, result); + savehandler = handler; + if (setjmp(jmploc.loc)) { + if (exception == EXERROR || exception == EXEXEC) + exitstatus = 2; + else if (exception != 0) { + handler = savehandler; + longjmp(handler->loc, 1); + } + } else { + handler = &jmploc; + evalcommand(n, EV_BACKCMD, result); + } + handler = savehandler; } else { exitstatus = 0; if (pipe(pip) < 0) @@ -615,7 +643,31 @@ out: result->fd, result->buf, result->nleft, result->jp)); } - +/* + * Check if a builtin can safely be executed in the same process, + * even though it should be in a subshell (command substitution). + * Note that jobid, jobs, times and trap can show information not + * available in a child process; this is deliberate. + * The arguments should already have been expanded. + */ +static int +safe_builtin(int idx, int argc, char **argv) +{ + if (idx == BLTINCMD || idx == COMMANDCMD || idx == ECHOCMD || + idx == FALSECMD || idx == JOBIDCMD || idx == JOBSCMD || + idx == KILLCMD || idx == PRINTFCMD || idx == PWDCMD || + idx == TESTCMD || idx == TIMESCMD || idx == TRUECMD || + idx == TYPECMD) + return (1); + if (idx == EXPORTCMD || idx == TRAPCMD || idx == ULIMITCMD || + idx == UMASKCMD) + return (argc <= 1 || (argc == 2 && argv[1][0] == '-')); + if (idx == SETCMD) + return (argc <= 1 || (argc == 2 && (argv[1][0] == '-' || + argv[1][0] == '+') && argv[1][1] == 'o' && + argv[1][2] == '\0')); + return (0); +} /* * Execute a simple command. @@ -833,10 +885,8 @@ evalcommand(union node *cmd, int flags, || ((cmdentry.cmdtype == CMDNORMAL || cmdentry.cmdtype == CMDUNKNOWN) && ((flags & EV_EXIT) == 0 || have_traps())) || ((flags & EV_BACKCMD) != 0 - && (cmdentry.cmdtype != CMDBUILTIN - || cmdentry.u.index == CDCMD - || cmdentry.u.index == DOTCMD - || cmdentry.u.index == EVALCMD))) { + && (cmdentry.cmdtype != CMDBUILTIN || + !safe_builtin(cmdentry.u.index, argc, argv)))) { jp = makejob(cmd, 1); mode = cmd->ncmd.backgnd; if (flags & EV_BACKCMD) { Modified: projects/binutils-2.17/bin/sh/exec.c ============================================================================== --- projects/binutils-2.17/bin/sh/exec.c Thu Dec 30 22:33:55 2010 (r216826) +++ projects/binutils-2.17/bin/sh/exec.c Thu Dec 30 23:35:23 2010 (r216827) @@ -190,9 +190,8 @@ padvance(const char **path, const char * for (p = start; *p && *p != ':' && *p != '%'; p++) ; /* nothing */ len = p - start + strlen(name) + 2; /* "2" is for '/' and '\0' */ - while (stackblocksize() < len) - growstackblock(); - q = stackblock(); + STARTSTACKSTR(q); + CHECKSTRSPACE(len, q); if (p != start) { memcpy(q, start, p - start); q += p - start; Modified: projects/binutils-2.17/bin/sh/expand.c ============================================================================== --- projects/binutils-2.17/bin/sh/expand.c Thu Dec 30 22:33:55 2010 (r216826) +++ projects/binutils-2.17/bin/sh/expand.c Thu Dec 30 23:35:23 2010 (r216827) @@ -502,13 +502,14 @@ expbackq(union node *cmd, int quoted, in if (lastc == '\n') { nnl++; } else { + CHECKSTRSPACE(nnl + 2, dest); while (nnl > 0) { nnl--; - STPUTC('\n', dest); + USTPUTC('\n', dest); } if (quotes && syntax[(int)lastc] == CCTL) - STPUTC(CTLESC, dest); - STPUTC(lastc, dest); + USTPUTC(CTLESC, dest); + USTPUTC(lastc, dest); } } } @@ -1569,6 +1570,78 @@ cvtnum(int num, char *buf) } /* + * Check statically if expanding a string may have side effects. + */ +int +expandhassideeffects(const char *p) +{ + int c; + int arinest; + + arinest = 0; + while ((c = *p++) != '\0') { + switch (c) { + case CTLESC: + p++; + break; + case CTLVAR: + c = *p++; + /* Expanding $! sets the job to remembered. */ + if (*p == '!') + return 1; + if ((c & VSTYPE) == VSASSIGN) + return 1; + /* + * If we are in arithmetic, the parameter may contain + * '=' which may cause side effects. Exceptions are + * the length of a parameter and $$, $# and $? which + * are always numeric. + */ + if ((c & VSTYPE) == VSLENGTH) { + while (*p != '=') + p++; + p++; + break; + } + if ((*p == '$' || *p == '#' || *p == '?') && + p[1] == '=') { + p += 2; + break; + } + if (arinest > 0) + return 1; + break; + case CTLBACKQ: + case CTLBACKQ | CTLQUOTE: + if (arinest > 0) + return 1; + break; + case CTLARI: + arinest++; + break; + case CTLENDARI: + arinest--; + break; + case '=': + if (*p == '=') { + /* Allow '==' operator. */ + p++; + continue; + } + if (arinest > 0) + return 1; + break; + case '!': case '<': case '>': + /* Allow '!=', '<=', '>=' operators. */ + if (*p == '=') + p++; + break; + } + } + return 0; +} + +/* * Do most of the work for wordexp(3). */ Modified: projects/binutils-2.17/bin/sh/expand.h ============================================================================== --- projects/binutils-2.17/bin/sh/expand.h Thu Dec 30 22:33:55 2010 (r216826) +++ projects/binutils-2.17/bin/sh/expand.h Thu Dec 30 23:35:23 2010 (r216827) @@ -63,4 +63,5 @@ void expari(int); int patmatch(const char *, const char *, int); void rmescapes(char *); int casematch(union node *, const char *); +int expandhassideeffects(const char *); int wordexpcmd(int, char **); Modified: projects/binutils-2.17/bin/sh/histedit.c ============================================================================== --- projects/binutils-2.17/bin/sh/histedit.c Thu Dec 30 22:33:55 2010 (r216826) +++ projects/binutils-2.17/bin/sh/histedit.c Thu Dec 30 23:35:23 2010 (r216827) @@ -232,6 +232,7 @@ histcmd(int argc, char **argv) } argc -= optind, argv += optind; + savehandler = handler; /* * If executing... */ @@ -242,7 +243,6 @@ histcmd(int argc, char **argv) * Catch interrupts to reset active counter and * cleanup temp files. */ - savehandler = handler; if (setjmp(jmploc.loc)) { active = 0; if (editfile) @@ -399,6 +399,7 @@ histcmd(int argc, char **argv) --active; if (displayhist) displayhist = 0; + handler = savehandler; return 0; } Modified: projects/binutils-2.17/bin/sh/memalloc.c ============================================================================== --- projects/binutils-2.17/bin/sh/memalloc.c Thu Dec 30 22:33:55 2010 (r216826) +++ projects/binutils-2.17/bin/sh/memalloc.c Thu Dec 30 23:35:23 2010 (r216827) @@ -127,7 +127,7 @@ static struct stack_block *stackp; static struct stackmark *markp; char *stacknxt; int stacknleft; -int sstrnleft; +char *sstrend; static void @@ -146,6 +146,7 @@ stnewblock(int nbytes) sp->prev = stackp; stacknxt = SPACE(sp); stacknleft = allocsize - (stacknxt - (char*)sp); + sstrend = stacknxt + stacknleft; stackp = sp; INTON; } @@ -204,6 +205,7 @@ popstackmark(struct stackmark *mark) } stacknxt = mark->stacknxt; stacknleft = mark->stacknleft; + sstrend = stacknxt + stacknleft; INTON; } @@ -218,8 +220,8 @@ popstackmark(struct stackmark *mark) * part of the block that has been used. */ -void -growstackblock(void) +static void +growstackblock(int min) { char *p; int newlen; @@ -229,8 +231,15 @@ growstackblock(void) struct stack_block *oldstackp; struct stackmark *xmark; - newlen = (stacknleft == 0) ? MINSIZE : stacknleft * 2 + 100; - newlen = ALIGN(newlen); + if (min < stacknleft) + min = stacknleft; + if (min >= INT_MAX / 2 - ALIGN(sizeof(struct stack_block))) + error("Out of space"); + min += stacknleft; + min += ALIGN(sizeof(struct stack_block)); + newlen = 512; + while (newlen < min) + newlen <<= 1; oldspace = stacknxt; oldlen = stacknleft; @@ -243,6 +252,7 @@ growstackblock(void) stackp = sp; stacknxt = SPACE(sp); stacknleft = newlen - (stacknxt - (char*)sp); + sstrend = stacknxt + stacknleft; /* * Stack marks pointing to the start of the old block @@ -257,6 +267,7 @@ growstackblock(void) } INTON; } else { + newlen -= ALIGN(sizeof(struct stack_block)); p = stalloc(newlen); if (oldlen != 0) memcpy(p, oldspace, oldlen); @@ -295,10 +306,9 @@ grabstackblock(int len) */ static char * -growstrstackblock(int n) +growstrstackblock(int n, int min) { - growstackblock(); - sstrnleft = stackblocksize() - n; + growstackblock(min); return stackblock() + n; } @@ -308,7 +318,7 @@ growstackstr(void) int len; len = stackblocksize(); - return growstrstackblock(len); + return (growstrstackblock(len, 0)); } @@ -317,33 +327,21 @@ growstackstr(void) */ char * -makestrspace(void) +makestrspace(int min, char *p) { int len; - len = stackblocksize() - sstrnleft; - return growstrstackblock(len); -} - - - -void -ungrabstackstr(char *s, char *p) -{ - stacknleft += stacknxt - s; - stacknxt = s; - sstrnleft = stacknleft - (p - s); + len = p - stackblock(); + return (growstrstackblock(len, min)); } char * stputbin(const char *data, int len, char *p) { - int i; - - for (i = 0; i < len; i++) - STPUTC(data[i], p); - return (p); + CHECKSTRSPACE(len, p); + memcpy(p, data, len); + return (p + len); } char * Modified: projects/binutils-2.17/bin/sh/memalloc.h ============================================================================== --- projects/binutils-2.17/bin/sh/memalloc.h Thu Dec 30 22:33:55 2010 (r216826) +++ projects/binutils-2.17/bin/sh/memalloc.h Thu Dec 30 23:35:23 2010 (r216827) @@ -45,7 +45,7 @@ struct stackmark { extern char *stacknxt; extern int stacknleft; -extern int sstrnleft; +extern char *sstrend; pointer ckmalloc(size_t); pointer ckrealloc(pointer, int); @@ -55,11 +55,9 @@ pointer stalloc(int); void stunalloc(pointer); void setstackmark(struct stackmark *); void popstackmark(struct stackmark *); -void growstackblock(void); void grabstackblock(int); char *growstackstr(void); -char *makestrspace(void); -void ungrabstackstr(char *, char *); +char *makestrspace(int, char *); char *stputbin(const char *data, int len, char *p); char *stputs(const char *data, char *p); @@ -67,10 +65,10 @@ char *stputs(const char *data, char *p); #define stackblock() stacknxt #define stackblocksize() stacknleft -#define STARTSTACKSTR(p) p = stackblock(), sstrnleft = stackblocksize() -#define STPUTC(c, p) (--sstrnleft >= 0? (*p++ = (c)) : (p = growstackstr(), --sstrnleft, *p++ = (c))) -#define CHECKSTRSPACE(n, p) { if (sstrnleft < n) p = makestrspace(); } -#define USTPUTC(c, p) (--sstrnleft, *p++ = (c)) +#define STARTSTACKSTR(p) p = stackblock() +#define STPUTC(c, p) do { if (p == sstrend) p = growstackstr(); *p++ = (c); } while(0) +#define CHECKSTRSPACE(n, p) { if (sstrend - p < n) p = makestrspace(n, p); } +#define USTPUTC(c, p) (*p++ = (c)) /* * STACKSTRNUL's use is where we want to be able to turn a stack * (non-sentinel, character counting string) into a C string, @@ -78,10 +76,11 @@ char *stputs(const char *data, char *p); * Note: Because of STACKSTRNUL's semantics, STACKSTRNUL cannot be used * on a stack that will grabstackstr()ed. */ -#define STACKSTRNUL(p) (sstrnleft == 0? (p = growstackstr(), *p = '\0') : (*p = '\0')) -#define STUNPUTC(p) (++sstrnleft, --p) +#define STACKSTRNUL(p) (p == sstrend ? (p = growstackstr(), *p = '\0') : (*p = '\0')) +#define STUNPUTC(p) (--p) #define STTOPC(p) p[-1] -#define STADJUST(amount, p) (p += (amount), sstrnleft -= (amount)) -#define grabstackstr(p) stalloc(stackblocksize() - sstrnleft) +#define STADJUST(amount, p) (p += (amount)) +#define grabstackstr(p) stalloc((char *)p - stackblock()) +#define ungrabstackstr(s, p) stunalloc((s)) #define STPUTBIN(s, len, p) p = stputbin((s), (len), p) #define STPUTS(s, p) p = stputs((s), p) Modified: projects/binutils-2.17/bin/sh/parser.c ============================================================================== --- projects/binutils-2.17/bin/sh/parser.c Thu Dec 30 22:33:55 2010 (r216826) +++ projects/binutils-2.17/bin/sh/parser.c Thu Dec 30 23:35:23 2010 (r216827) @@ -1093,9 +1093,8 @@ done: popfile(); tokpushback = 0; } - while (stackblocksize() <= savelen) - growstackblock(); STARTSTACKSTR(out); + CHECKSTRSPACE(savelen + 1, out); INTOFF; if (str) { memcpy(out, str, savelen); Modified: projects/binutils-2.17/etc/portsnap.conf ============================================================================== --- projects/binutils-2.17/etc/portsnap.conf Thu Dec 30 22:33:55 2010 (r216826) +++ projects/binutils-2.17/etc/portsnap.conf Thu Dec 30 23:35:23 2010 (r216827) @@ -30,6 +30,5 @@ KEYPRINT=9b5feee6d69f170e3dd0a2c8e469ddb # REFUSE korean polish portuguese russian ukrainian vietnamese # List of INDEX files to build and the DESCRIBE file to use for each -INDEX INDEX-6 DESCRIBE.6 INDEX INDEX-7 DESCRIBE.7 INDEX INDEX-8 DESCRIBE.8 Modified: projects/binutils-2.17/etc/rc.d/devd ============================================================================== --- projects/binutils-2.17/etc/rc.d/devd Thu Dec 30 22:33:55 2010 (r216826) +++ projects/binutils-2.17/etc/rc.d/devd Thu Dec 30 23:35:23 2010 (r216827) @@ -13,11 +13,17 @@ name="devd" rcvar=`set_rcvar` command="/sbin/${name}" +pidfile=/var/run/${name}.pid + +start_precmd=${name}_prestart + +devd_prestart () +{ + # If devd is disabled, turn it off in the kernel to avoid memory leaks. + if ! checkyesno ${rcvar}; then + $SYSCTL hw.bus.devctl_disable=1 + fi +} load_rc_config $name run_rc_command "$1" - -# If devd is disabled, turn it off in the kernel to avoid memory leaks. -if ! checkyesno ${rcvar}; then - sysctl hw.bus.devctl_disable=1 -fi Modified: projects/binutils-2.17/gnu/lib/libgcc/Makefile ============================================================================== --- projects/binutils-2.17/gnu/lib/libgcc/Makefile Thu Dec 30 22:33:55 2010 (r216826) +++ projects/binutils-2.17/gnu/lib/libgcc/Makefile Thu Dec 30 23:35:23 2010 (r216827) @@ -15,7 +15,7 @@ MK_SSP= no .include "${.CURDIR}/../../usr.bin/cc/Makefile.tgt" -.if ${TARGET_CPUARCH} == "sparc64" +.if ${TARGET_CPUARCH} == "sparc64" || ${TARGET_CPUARCH} == "mips" LIB= gcc .endif Modified: projects/binutils-2.17/lib/libc/locale/mbrtowc.3 ============================================================================== --- projects/binutils-2.17/lib/libc/locale/mbrtowc.3 Thu Dec 30 22:33:55 2010 (r216826) +++ projects/binutils-2.17/lib/libc/locale/mbrtowc.3 Thu Dec 30 23:35:23 2010 (r216827) @@ -69,7 +69,7 @@ was .Dv NULL , .Fa s was an empty string -.Pq Qq \& +.Pq Qq and .Fa n was 1. Modified: projects/binutils-2.17/lib/libc/rpc/publickey.3 ============================================================================== --- projects/binutils-2.17/lib/libc/rpc/publickey.3 Thu Dec 30 22:33:55 2010 (r216826) +++ projects/binutils-2.17/lib/libc/rpc/publickey.3 Thu Dec 30 23:35:23 2010 (r216827) @@ -44,7 +44,7 @@ fails to decrypt the secret key, the rou argument will be a .Dv NULL string -.Pq Dq \& . +.Pq Dq . .Sh SEE ALSO .Xr publickey 5 .Pp Modified: projects/binutils-2.17/lib/libcompiler_rt/Makefile ============================================================================== --- projects/binutils-2.17/lib/libcompiler_rt/Makefile Thu Dec 30 22:33:55 2010 (r216826) +++ projects/binutils-2.17/lib/libcompiler_rt/Makefile Thu Dec 30 23:35:23 2010 (r216827) @@ -147,7 +147,7 @@ SRCS+= ${file}.c . endif .endfor -.if ${MACHINE_CPUARCH} != "sparc64" +.if ${MACHINE_CPUARCH} != "sparc64" && ${MACHINE_CPUARCH} != "mips" . if ${MK_INSTALLLIB} != "no" SYMLINKS+=libcompiler_rt.a ${LIBDIR}/libgcc.a . endif Modified: projects/binutils-2.17/lib/libkvm/kvm_getloadavg.3 ============================================================================== --- projects/binutils-2.17/lib/libkvm/kvm_getloadavg.3 Thu Dec 30 22:33:55 2010 (r216826) +++ projects/binutils-2.17/lib/libkvm/kvm_getloadavg.3 Thu Dec 30 23:35:23 2010 (r216827) @@ -50,7 +50,7 @@ averaged over various periods of time. Up to .Fa nelem samples are retrieved and assigned to successive elements of -.Fa loadavg Ns Bq \& . +.Fa loadavg Ns Bq . The system imposes a maximum of 3 samples, representing averages over the last 1, 5, and 15 minutes, respectively. .Sh DIAGNOSTICS Modified: projects/binutils-2.17/lib/libthr/thread/thr_mutex.c ============================================================================== --- projects/binutils-2.17/lib/libthr/thread/thr_mutex.c Thu Dec 30 22:33:55 2010 (r216826) +++ projects/binutils-2.17/lib/libthr/thread/thr_mutex.c Thu Dec 30 23:35:23 2010 (r216827) @@ -653,7 +653,7 @@ mutex_unlock_common(struct pthread_mutex m->m_count > 0)) { m->m_count--; } else { - if (curthread->will_sleep == 0 && (m->m_flags & PMUTEX_FLAG_DEFERED) != 0) { + if ((m->m_flags & PMUTEX_FLAG_DEFERED) != 0) { defered = 1; m->m_flags &= ~PMUTEX_FLAG_DEFERED; } else @@ -662,7 +662,7 @@ mutex_unlock_common(struct pthread_mutex DEQUEUE_MUTEX(curthread, m); _thr_umutex_unlock(&m->m_lock, id); - if (defered) { + if (curthread->will_sleep == 0 && defered) { _thr_wake_all(curthread->defer_waiters, curthread->nwaiter_defer); curthread->nwaiter_defer = 0; Modified: projects/binutils-2.17/libexec/rtld-elf/Makefile ============================================================================== --- projects/binutils-2.17/libexec/rtld-elf/Makefile Thu Dec 30 22:33:55 2010 (r216826) +++ projects/binutils-2.17/libexec/rtld-elf/Makefile Thu Dec 30 23:35:23 2010 (r216827) @@ -34,7 +34,7 @@ CFLAGS+= -fPIC .else CFLAGS+= -fpic .endif -CFLAGS+= -DPIC +CFLAGS+= -DPIC $(DEBUG) LDFLAGS+= -shared -Wl,-Bsymbolic DPADD= ${LIBC_PIC} LDADD= -lc_pic -lssp_nonshared Modified: projects/binutils-2.17/libexec/rtld-elf/amd64/reloc.c ============================================================================== --- projects/binutils-2.17/libexec/rtld-elf/amd64/reloc.c Thu Dec 30 22:33:55 2010 (r216826) +++ projects/binutils-2.17/libexec/rtld-elf/amd64/reloc.c Thu Dec 30 23:35:23 2010 (r216827) @@ -69,23 +69,28 @@ do_copy_relocations(Obj_Entry *dstobj) void *dstaddr; const Elf_Sym *dstsym; const char *name; - unsigned long hash; size_t size; const void *srcaddr; const Elf_Sym *srcsym; - Obj_Entry *srcobj; - const Ver_Entry *ve; + const Obj_Entry *srcobj, *defobj; + SymLook req; + int res; dstaddr = (void *) (dstobj->relocbase + rela->r_offset); dstsym = dstobj->symtab + ELF_R_SYM(rela->r_info); name = dstobj->strtab + dstsym->st_name; - hash = elf_hash(name); size = dstsym->st_size; - ve = fetch_ventry(dstobj, ELF_R_SYM(rela->r_info)); + symlook_init(&req, name); + req.ventry = fetch_ventry(dstobj, ELF_R_SYM(rela->r_info)); - for (srcobj = dstobj->next; srcobj != NULL; srcobj = srcobj->next) - if ((srcsym = symlook_obj(name, hash, srcobj, ve, 0)) != NULL) + for (srcobj = dstobj->next; srcobj != NULL; srcobj = srcobj->next) { + res = symlook_obj(&req, srcobj); + if (res == 0) { + srcsym = req.sym_out; + defobj = req.defobj_out; break; + } + } if (srcobj == NULL) { _rtld_error("Undefined symbol \"%s\" referenced from COPY" @@ -93,7 +98,7 @@ do_copy_relocations(Obj_Entry *dstobj) return -1; } - srcaddr = (const void *) (srcobj->relocbase + srcsym->st_value); + srcaddr = (const void *) (defobj->relocbase + srcsym->st_value); memcpy(dstaddr, srcaddr, size); } } @@ -113,7 +118,7 @@ init_pltgot(Obj_Entry *obj) /* Process the non-PLT relocations. */ int -reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld) +reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld, RtldLockState *lockstate) { const Elf_Rela *relalim; const Elf_Rela *rela; @@ -146,7 +151,7 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry const Obj_Entry *defobj; def = find_symdef(ELF_R_SYM(rela->r_info), obj, &defobj, - false, cache); + false, cache, lockstate); if (def == NULL) goto done; @@ -165,7 +170,7 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry const Obj_Entry *defobj; def = find_symdef(ELF_R_SYM(rela->r_info), obj, &defobj, - false, cache); + false, cache, lockstate); if (def == NULL) goto done; @@ -195,7 +200,7 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry const Obj_Entry *defobj; def = find_symdef(ELF_R_SYM(rela->r_info), obj, &defobj, - false, cache); + false, cache, lockstate); if (def == NULL) goto done; @@ -209,7 +214,7 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry const Obj_Entry *defobj; def = find_symdef(ELF_R_SYM(rela->r_info), obj, &defobj, - false, cache); + false, cache, lockstate); if (def == NULL) goto done; @@ -240,7 +245,7 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry const Obj_Entry *defobj; def = find_symdef(ELF_R_SYM(rela->r_info), obj, &defobj, - false, cache); + false, cache, lockstate); if (def == NULL) goto done; @@ -272,7 +277,7 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry const Obj_Entry *defobj; def = find_symdef(ELF_R_SYM(rela->r_info), obj, &defobj, - false, cache); + false, cache, lockstate); if (def == NULL) goto done; @@ -286,7 +291,7 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry const Obj_Entry *defobj; def = find_symdef(ELF_R_SYM(rela->r_info), obj, &defobj, - false, cache); + false, cache, lockstate); if (def == NULL) goto done; @@ -300,7 +305,7 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry const Obj_Entry *defobj; def = find_symdef(ELF_R_SYM(rela->r_info), obj, &defobj, - false, cache); + false, cache, lockstate); if (def == NULL) goto done; @@ -350,7 +355,7 @@ reloc_plt(Obj_Entry *obj) /* Relocate the jump slots in an object. */ int -reloc_jmpslots(Obj_Entry *obj) +reloc_jmpslots(Obj_Entry *obj, RtldLockState *lockstate) { const Elf_Rela *relalim; const Elf_Rela *rela; @@ -365,7 +370,8 @@ reloc_jmpslots(Obj_Entry *obj) assert(ELF_R_TYPE(rela->r_info) == R_X86_64_JMP_SLOT); where = (Elf_Addr *)(obj->relocbase + rela->r_offset); - def = find_symdef(ELF_R_SYM(rela->r_info), obj, &defobj, true, NULL); + def = find_symdef(ELF_R_SYM(rela->r_info), obj, &defobj, true, NULL, + lockstate); if (def == NULL) return -1; target = (Elf_Addr)(defobj->relocbase + def->st_value + rela->r_addend); Modified: projects/binutils-2.17/libexec/rtld-elf/arm/reloc.c ============================================================================== --- projects/binutils-2.17/libexec/rtld-elf/arm/reloc.c Thu Dec 30 22:33:55 2010 (r216826) +++ projects/binutils-2.17/libexec/rtld-elf/arm/reloc.c Thu Dec 30 23:35:23 2010 (r216827) @@ -36,31 +36,39 @@ do_copy_relocations(Obj_Entry *dstobj) void *dstaddr; const Elf_Sym *dstsym; const char *name; - unsigned long hash; size_t size; const void *srcaddr; const Elf_Sym *srcsym; - Obj_Entry *srcobj; - const Ver_Entry *ve; + const Obj_Entry *srcobj, *defobj; + SymLook req; + int res; dstaddr = (void *) (dstobj->relocbase + rel->r_offset); dstsym = dstobj->symtab + ELF_R_SYM(rel->r_info); name = dstobj->strtab + dstsym->st_name; - hash = elf_hash(name); size = dstsym->st_size; - ve = fetch_ventry(dstobj, ELF_R_SYM(rel->r_info)); - - for (srcobj = dstobj->next; srcobj != NULL; srcobj = srcobj->next) - if ((srcsym = symlook_obj(name, hash, srcobj, ve, 0)) != NULL) + + symlook_init(&req, name); + req.ventry = fetch_ventry(dstobj, + ELF_R_SYM(rel->r_info)); + for (srcobj = dstobj->next; srcobj != NULL; + srcobj = srcobj->next) { + res = symlook_obj(&req, srcobj); + if (res == 0) { + srcsym = req.sym_out; + defobj = req.defobj_out; break; - + } + } if (srcobj == NULL) { - _rtld_error("Undefined symbol \"%s\" referenced from COPY" - " relocation in %s", name, dstobj->path); - return -1; + _rtld_error( +"Undefined symbol \"%s\" referenced from COPY relocation in %s", + name, dstobj->path); + return (-1); } - srcaddr = (const void *) (srcobj->relocbase + srcsym->st_value); + srcaddr = (const void *)(defobj->relocbase + + srcsym->st_value); memcpy(dstaddr, srcaddr, size); } } @@ -123,7 +131,8 @@ store_ptr(void *where, Elf_Addr val) } static int -reloc_nonplt_object(Obj_Entry *obj, const Elf_Rel *rel, SymCache *cache) +reloc_nonplt_object(Obj_Entry *obj, const Elf_Rel *rel, SymCache *cache, + RtldLockState *lockstate) { Elf_Addr *where; const Elf_Sym *def; @@ -149,7 +158,8 @@ reloc_nonplt_object(Obj_Entry *obj, cons if (addend & 0x00800000) addend |= 0xff000000; - def = find_symdef(symnum, obj, &defobj, false, cache); + def = find_symdef(symnum, obj, &defobj, false, cache, + lockstate); if (def == NULL) return -1; tmp = (Elf_Addr)obj->relocbase + def->st_value @@ -175,7 +185,8 @@ reloc_nonplt_object(Obj_Entry *obj, cons case R_ARM_ABS32: /* word32 B + S + A */ case R_ARM_GLOB_DAT: /* word32 B + S */ - def = find_symdef(symnum, obj, &defobj, false, cache); + def = find_symdef(symnum, obj, &defobj, false, cache, + lockstate); if (def == NULL) return -1; if (__predict_true(RELOC_ALIGNED_P(where))) { @@ -240,7 +251,7 @@ reloc_nonplt_object(Obj_Entry *obj, cons * * Process non-PLT relocations * */ int -reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld) +reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld, RtldLockState *lockstate) { const Elf_Rel *rellim; const Elf_Rel *rel; @@ -259,7 +270,7 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry rellim = (const Elf_Rel *)((caddr_t)obj->rel + obj->relsize); for (rel = obj->rel; rel < rellim; rel++) { - if (reloc_nonplt_object(obj, rel, cache) < 0) + if (reloc_nonplt_object(obj, rel, cache, lockstate) < 0) goto done; } r = 0; @@ -296,7 +307,7 @@ reloc_plt(Obj_Entry *obj) * * LD_BIND_NOW was set - force relocation for all jump slots * */ int -reloc_jmpslots(Obj_Entry *obj) +reloc_jmpslots(Obj_Entry *obj, RtldLockState *lockstate) { const Obj_Entry *defobj; const Elf_Rel *rellim; @@ -310,7 +321,7 @@ reloc_jmpslots(Obj_Entry *obj) assert(ELF_R_TYPE(rel->r_info) == R_ARM_JUMP_SLOT); where = (Elf_Addr *)(obj->relocbase + rel->r_offset); def = find_symdef(ELF_R_SYM(rel->r_info), obj, &defobj, - true, NULL); + true, NULL, lockstate); if (def == NULL) { dbg("reloc_jmpslots: sym not found"); return (-1); Modified: projects/binutils-2.17/libexec/rtld-elf/i386/reloc.c ============================================================================== --- projects/binutils-2.17/libexec/rtld-elf/i386/reloc.c Thu Dec 30 22:33:55 2010 (r216826) +++ projects/binutils-2.17/libexec/rtld-elf/i386/reloc.c Thu Dec 30 23:35:23 2010 (r216827) @@ -70,23 +70,28 @@ do_copy_relocations(Obj_Entry *dstobj) void *dstaddr; const Elf_Sym *dstsym; const char *name; - unsigned long hash; size_t size; const void *srcaddr; const Elf_Sym *srcsym; - const Ver_Entry *ve; - Obj_Entry *srcobj; + const Obj_Entry *srcobj, *defobj; + SymLook req; + int res; dstaddr = (void *) (dstobj->relocbase + rel->r_offset); dstsym = dstobj->symtab + ELF_R_SYM(rel->r_info); name = dstobj->strtab + dstsym->st_name; - hash = elf_hash(name); size = dstsym->st_size; - ve = fetch_ventry(dstobj, ELF_R_SYM(rel->r_info)); + symlook_init(&req, name); + req.ventry = fetch_ventry(dstobj, ELF_R_SYM(rel->r_info)); - for (srcobj = dstobj->next; srcobj != NULL; srcobj = srcobj->next) - if ((srcsym = symlook_obj(name, hash, srcobj, ve, 0)) != NULL) + for (srcobj = dstobj->next; srcobj != NULL; srcobj = srcobj->next) { + res = symlook_obj(&req, srcobj); + if (res == 0) { + srcsym = req.sym_out; + defobj = req.defobj_out; break; + } + } if (srcobj == NULL) { _rtld_error("Undefined symbol \"%s\" referenced from COPY" @@ -94,7 +99,7 @@ do_copy_relocations(Obj_Entry *dstobj) return -1; } - srcaddr = (const void *) (srcobj->relocbase + srcsym->st_value); + srcaddr = (const void *) (defobj->relocbase + srcsym->st_value); memcpy(dstaddr, srcaddr, size); } } @@ -114,7 +119,7 @@ init_pltgot(Obj_Entry *obj) /* Process the non-PLT relocations. */ int -reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld) +reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld, RtldLockState *lockstate) { const Elf_Rel *rellim; const Elf_Rel *rel; @@ -146,7 +151,7 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry const Obj_Entry *defobj; def = find_symdef(ELF_R_SYM(rel->r_info), obj, &defobj, - false, cache); + false, cache, lockstate); if (def == NULL) goto done; @@ -165,7 +170,7 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry const Obj_Entry *defobj; def = find_symdef(ELF_R_SYM(rel->r_info), obj, &defobj, - false, cache); + false, cache, lockstate); if (def == NULL) goto done; @@ -195,7 +200,7 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry const Obj_Entry *defobj; def = find_symdef(ELF_R_SYM(rel->r_info), obj, &defobj, - false, cache); + false, cache, lockstate); if (def == NULL) goto done; @@ -213,7 +218,7 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry const Obj_Entry *defobj; def = find_symdef(ELF_R_SYM(rel->r_info), obj, &defobj, - false, cache); + false, cache, lockstate); if (def == NULL) goto done; @@ -243,7 +248,7 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry const Obj_Entry *defobj; def = find_symdef(ELF_R_SYM(rel->r_info), obj, &defobj, - false, cache); + false, cache, lockstate); if (def == NULL) goto done; @@ -257,7 +262,7 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry const Obj_Entry *defobj; def = find_symdef(ELF_R_SYM(rel->r_info), obj, &defobj, - false, cache); + false, cache, lockstate); if (def == NULL) goto done; @@ -301,7 +306,7 @@ reloc_plt(Obj_Entry *obj) /* Relocate the jump slots in an object. */ int -reloc_jmpslots(Obj_Entry *obj) +reloc_jmpslots(Obj_Entry *obj, RtldLockState *lockstate) { const Elf_Rel *rellim; const Elf_Rel *rel; @@ -316,7 +321,8 @@ reloc_jmpslots(Obj_Entry *obj) assert(ELF_R_TYPE(rel->r_info) == R_386_JMP_SLOT); where = (Elf_Addr *)(obj->relocbase + rel->r_offset); - def = find_symdef(ELF_R_SYM(rel->r_info), obj, &defobj, true, NULL); + def = find_symdef(ELF_R_SYM(rel->r_info), obj, &defobj, true, NULL, *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***