From owner-svn-src-user@FreeBSD.ORG Sun Aug 29 18:31:05 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1D9E210656B0; Sun, 29 Aug 2010 18:31:05 +0000 (UTC) (envelope-from nwhitehorn@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E75C58FC18; Sun, 29 Aug 2010 18:31:04 +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 o7TIV4AP071289; Sun, 29 Aug 2010 18:31:04 GMT (envelope-from nwhitehorn@svn.freebsd.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o7TIV43e071287; Sun, 29 Aug 2010 18:31:04 GMT (envelope-from nwhitehorn@svn.freebsd.org) Message-Id: <201008291831.o7TIV43e071287@svn.freebsd.org> From: Nathan Whitehorn Date: Sun, 29 Aug 2010 18:31:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r211968 - user/nwhitehorn/ps3/powerpc/ps3 X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Aug 2010 18:31:05 -0000 Author: nwhitehorn Date: Sun Aug 29 18:31:04 2010 New Revision: 211968 URL: http://svn.freebsd.org/changeset/base/211968 Log: Fix recording of ref/change bits. Before we overwrote the entire lower 12 bits of the PVO PTE with the equivalent ones from the hardware PTE, but these also store the page protection bits. The result was that these would be overwritten with old values when syncing ref/changed during a protection update, making all protection updates fail, breaking copy-on-write as well as many other things. With this change, my Playstation 3 now boots multiuser! Modified: user/nwhitehorn/ps3/powerpc/ps3/mmu_ps3.c Modified: user/nwhitehorn/ps3/powerpc/ps3/mmu_ps3.c ============================================================================== --- user/nwhitehorn/ps3/powerpc/ps3/mmu_ps3.c Sun Aug 29 18:17:38 2010 (r211967) +++ user/nwhitehorn/ps3/powerpc/ps3/mmu_ps3.c Sun Aug 29 18:31:04 2010 (r211968) @@ -51,7 +51,6 @@ #include "ps3-hvcall.h" #define VSID_HASH_MASK 0x0000007fffffffffUL -#define LV1_READ_HTAB_LO_MASK 0xfffUL extern int ps3fb_remap(void); @@ -199,7 +198,6 @@ mps3_pte_synch(struct lpte *pt, struct l uint64_t halfbucket[4], rcbits; uint64_t slot = (uint64_t)(pt)-1; - __asm __volatile("ptesync"); lv1_read_htab_entries(mps3_vas_id, slot & ~0x3UL, &halfbucket[0], &halfbucket[1], &halfbucket[2], &halfbucket[3], &rcbits); @@ -213,9 +211,9 @@ mps3_pte_synch(struct lpte *pt, struct l ("PTE upper word %#lx != %#lx\n", halfbucket[slot & 0x3], pvo_pt->pte_hi)); - pvo_pt->pte_lo &= ~LV1_READ_HTAB_LO_MASK; + pvo_pt->pte_lo &= ~(LPTE_CHG | LPTE_REF); pvo_pt->pte_lo |= (rcbits >> ((3 - (slot & 0x3))*16)) & - LV1_READ_HTAB_LO_MASK; + (LPTE_CHG | LPTE_REF); } static void @@ -245,11 +243,10 @@ mps3_pte_change(struct lpte *pt, struct uint64_t slot = (uint64_t)(pt)-1; mps3_pte_synch(pt, pvo_pt); - pvo_pt->pte_hi |= LPTE_VALID; - lv1_write_htab_entry(mps3_vas_id, slot & ~0x3UL, pvo_pt->pte_hi, + lv1_write_htab_entry(mps3_vas_id, slot, pvo_pt->pte_hi, pvo_pt->pte_lo); } - + static int mps3_pte_insert(u_int ptegidx, struct lpte *pvo_pt) { @@ -292,7 +289,8 @@ mps3_pte_insert(u_int ptegidx, struct lp ptegidx ^= moea64_pteg_mask; /* PTEs indexed by primary */ LIST_FOREACH(pvo, &moea64_pvo_table[ptegidx], pvo_olink) { - if (pvo->pvo_pte.lpte.pte_hi == evicted.pte_hi) { + if ((pvo->pvo_pte.lpte.pte_hi & LPTE_AVPN_MASK) + == (evicted.pte_hi & LPTE_AVPN_MASK)) { KASSERT(pvo->pvo_pte.lpte.pte_hi & LPTE_VALID, ("Invalid PVO for valid PTE!")); pvo->pvo_pte.lpte.pte_hi &= ~LPTE_VALID; From owner-svn-src-user@FreeBSD.ORG Sun Aug 29 21:05:35 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4761510656A6; Sun, 29 Aug 2010 21:05:35 +0000 (UTC) (envelope-from nwhitehorn@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3745E8FC15; Sun, 29 Aug 2010 21:05:35 +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 o7TL5ZMi074474; Sun, 29 Aug 2010 21:05:35 GMT (envelope-from nwhitehorn@svn.freebsd.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o7TL5ZgL074472; Sun, 29 Aug 2010 21:05:35 GMT (envelope-from nwhitehorn@svn.freebsd.org) Message-Id: <201008292105.o7TL5ZgL074472@svn.freebsd.org> From: Nathan Whitehorn Date: Sun, 29 Aug 2010 21:05:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r211974 - user/nwhitehorn/ps3/powerpc/ps3 X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Aug 2010 21:05:35 -0000 Author: nwhitehorn Date: Sun Aug 29 21:05:34 2010 New Revision: 211974 URL: http://svn.freebsd.org/changeset/base/211974 Log: Fix a horrible memory leak in glc(4) where no TX buffers were ever freed. Performance is still bad (max 4.5 MB a second, so 40% wirespeed), but I can live with that. Modified: user/nwhitehorn/ps3/powerpc/ps3/if_glc.c Modified: user/nwhitehorn/ps3/powerpc/ps3/if_glc.c ============================================================================== --- user/nwhitehorn/ps3/powerpc/ps3/if_glc.c Sun Aug 29 20:53:24 2010 (r211973) +++ user/nwhitehorn/ps3/powerpc/ps3/if_glc.c Sun Aug 29 21:05:34 2010 (r211974) @@ -126,7 +126,8 @@ glc_attach(device_t dev) mtx_init(&sc->sc_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK, MTX_DEF); - sc->next_txdma_slot = sc->first_used_txdma_slot = 0; + sc->next_txdma_slot = 0; + sc->first_used_txdma_slot = -1; /* * Shut down existing tasks. @@ -333,14 +334,16 @@ static void glc_start_locked(struct ifnet *ifp) { struct glc_softc *sc = ifp->if_softc; - struct glc_txsoft *txs; bus_addr_t first, pktdesc; - int i, kickstart; + int kickstart = 0; struct mbuf *mb_head; mtx_assert(&sc->sc_mtx, MA_OWNED); first = 0; + if (STAILQ_EMPTY(&sc->sc_txdirtyq)) + kickstart = 1; + while (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) { IFQ_DRV_DEQUEUE(&ifp->if_snd, mb_head); @@ -366,23 +369,8 @@ glc_start_locked(struct ifnet *ifp) bus_dmamap_sync(sc->sc_dmadesc_tag, sc->sc_txdmadesc_map, BUS_DMASYNC_PREREAD); + /* XXX: kickstart always until problems are sorted out */ kickstart = 1; - STAILQ_FOREACH(txs, &sc->sc_txdirtyq, txs_q) { - for (i = txs->txs_firstdesc; - i != (txs->txs_lastdesc+1) % GLC_MAX_TX_PACKETS; - i = (i + 1) % GLC_MAX_TX_PACKETS) { - /* - * Check if any segments are currently being processed. - * If so, the DMA engine will pick up the bits we - * added eventually, otherwise restart DMA - */ - - if (sc->sc_txdmadesc[i].cmd_stat & GELIC_DESCR_OWNED) { - kickstart = 0; - break; - } - } - } if (kickstart && first != 0) { lv1_net_stop_tx_dma(sc->sc_bus, sc->sc_dev, 0); @@ -505,6 +493,10 @@ glc_encap(struct glc_softc *sc, struct m int nsegs = 16; int err = 0; + /* Check if the ring buffer is full */ + if (sc->next_txdma_slot == sc->first_used_txdma_slot) + return (-1); + /* Max number of segments is the number of free DMA slots */ if (sc->next_txdma_slot >= sc->first_used_txdma_slot) nsegs = 128 - sc->next_txdma_slot + sc->first_used_txdma_slot; @@ -578,16 +570,19 @@ glc_encap(struct glc_softc *sc, struct m idx = (idx + 1) % GLC_MAX_TX_PACKETS; } sc->next_txdma_slot = idx; - - bus_dmamap_sync(sc->sc_txdma_tag, txs->txs_dmamap, - BUS_DMASYNC_PREWRITE); - idx = (txs->txs_firstdesc - 1) % GLC_MAX_TX_PACKETS; sc->sc_txdmadesc[idx].next = firstslotphys; + if (sc->first_used_txdma_slot < 0) + sc->first_used_txdma_slot = txs->txs_firstdesc; + bus_dmamap_sync(sc->sc_txdma_tag, txs->txs_dmamap, BUS_DMASYNC_PREWRITE); + STAILQ_REMOVE_HEAD(&sc->sc_txfreeq, txs_q); + STAILQ_INSERT_TAIL(&sc->sc_txdirtyq, txs, txs_q); + txs->txs_mbuf = *m_head; + if (pktdesc != NULL) *pktdesc = firstslotphys; @@ -653,7 +648,7 @@ glc_txintr(struct glc_softc *sc) while ((txs = STAILQ_FIRST(&sc->sc_txdirtyq)) != NULL) { if (sc->sc_txdmadesc[txs->txs_lastdesc].cmd_stat - != GELIC_CMDSTAT_DMA_DONE) + & GELIC_DESCR_OWNED) break; STAILQ_REMOVE_HEAD(&sc->sc_txdirtyq, txs_q); @@ -670,6 +665,11 @@ glc_txintr(struct glc_softc *sc) progress = 1; } + if (txs != NULL) + sc->first_used_txdma_slot = txs->txs_firstdesc; + else + sc->first_used_txdma_slot = -1; + if (progress) { /* * We freed some descriptors, so reset IFF_DRV_OACTIVE From owner-svn-src-user@FreeBSD.ORG Tue Aug 31 15:49:42 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 27ABB1065670; Tue, 31 Aug 2010 15:49:42 +0000 (UTC) (envelope-from nwhitehorn@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 171548FC0C; Tue, 31 Aug 2010 15:49:42 +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 o7VFnf8x034562; Tue, 31 Aug 2010 15:49:41 GMT (envelope-from nwhitehorn@svn.freebsd.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o7VFnfle034559; Tue, 31 Aug 2010 15:49:41 GMT (envelope-from nwhitehorn@svn.freebsd.org) Message-Id: <201008311549.o7VFnfle034559@svn.freebsd.org> From: Nathan Whitehorn Date: Tue, 31 Aug 2010 15:49:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r212055 - in user/nwhitehorn/ps3: conf powerpc/cell X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 31 Aug 2010 15:49:42 -0000 Author: nwhitehorn Date: Tue Aug 31 15:49:41 2010 New Revision: 212055 URL: http://svn.freebsd.org/changeset/base/212055 Log: Add some non-HV Cell bits. Added: user/nwhitehorn/ps3/powerpc/cell/ - copied from r211727, projects/ppc64/sys/powerpc/cell/ Modified: user/nwhitehorn/ps3/conf/files.powerpc user/nwhitehorn/ps3/conf/options.powerpc Modified: user/nwhitehorn/ps3/conf/files.powerpc ============================================================================== --- user/nwhitehorn/ps3/conf/files.powerpc Tue Aug 31 15:27:46 2010 (r212054) +++ user/nwhitehorn/ps3/conf/files.powerpc Tue Aug 31 15:49:41 2010 (r212055) @@ -100,6 +100,7 @@ powerpc/booke/pmap.c optional e500 powerpc/booke/swtch.S optional e500 powerpc/booke/trap.c optional e500 powerpc/booke/vm_machdep.c optional e500 +powerpc/cell/celliic.c optional cell powerpc/cpufreq/dfs.c optional cpufreq powerpc/cpufreq/pcr.c optional cpufreq aim powerpc/fpu/fpu_add.c optional fpu_emu powerpc Modified: user/nwhitehorn/ps3/conf/options.powerpc ============================================================================== --- user/nwhitehorn/ps3/conf/options.powerpc Tue Aug 31 15:27:46 2010 (r212054) +++ user/nwhitehorn/ps3/conf/options.powerpc Tue Aug 31 15:49:41 2010 (r212055) @@ -3,6 +3,7 @@ AIM opt_global.h E500 opt_global.h +CELL POWERPC POWERPC64 From owner-svn-src-user@FreeBSD.ORG Tue Aug 31 15:58:16 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 18A3E10656A6; Tue, 31 Aug 2010 15:58:16 +0000 (UTC) (envelope-from nwhitehorn@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 03E778FC08; Tue, 31 Aug 2010 15:58:16 +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 o7VFwGKd034852; Tue, 31 Aug 2010 15:58:16 GMT (envelope-from nwhitehorn@svn.freebsd.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o7VFwFNw034838; Tue, 31 Aug 2010 15:58:15 GMT (envelope-from nwhitehorn@svn.freebsd.org) Message-Id: <201008311558.o7VFwFNw034838@svn.freebsd.org> From: Nathan Whitehorn Date: Tue, 31 Aug 2010 15:58:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r212057 - in user/nwhitehorn/ps3: amd64/amd64 amd64/include boot/common cddl/compat/opensolaris/kern cddl/compat/opensolaris/sys cddl/contrib/opensolaris/uts/common cddl/contrib/opensol... X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 31 Aug 2010 15:58:16 -0000 Author: nwhitehorn Date: Tue Aug 31 15:58:15 2010 New Revision: 212057 URL: http://svn.freebsd.org/changeset/base/212057 Log: IFC @ r212055 Added: user/nwhitehorn/ps3/mips/rmi/dev/nlge/ - copied from r212055, head/sys/mips/rmi/dev/nlge/ user/nwhitehorn/ps3/mips/rmi/dev/xlr/debug.h - copied unchanged from r212055, head/sys/mips/rmi/dev/xlr/debug.h user/nwhitehorn/ps3/mips/rmi/fmn.c - copied unchanged from r212055, head/sys/mips/rmi/fmn.c user/nwhitehorn/ps3/mips/rmi/rmi_boot_info.h - copied unchanged from r212055, head/sys/mips/rmi/rmi_boot_info.h user/nwhitehorn/ps3/mips/rmi/xlr_pcmcia.c - copied unchanged from r212055, head/sys/mips/rmi/xlr_pcmcia.c user/nwhitehorn/ps3/powerpc/powermac/platform_powermac.c - copied unchanged from r212055, head/sys/powerpc/powermac/platform_powermac.c user/nwhitehorn/ps3/x86/pci/ - copied from r212055, head/sys/x86/pci/ Deleted: user/nwhitehorn/ps3/mips/rmi/clock.c user/nwhitehorn/ps3/mips/rmi/clock.h user/nwhitehorn/ps3/mips/rmi/debug.h user/nwhitehorn/ps3/mips/rmi/on_chip.c user/nwhitehorn/ps3/mips/rmi/shared_structs.h user/nwhitehorn/ps3/mips/rmi/shared_structs_func.h user/nwhitehorn/ps3/mips/rmi/shared_structs_offsets.h user/nwhitehorn/ps3/mips/rmi/xlrconfig.h user/nwhitehorn/ps3/powerpc/aim/platform_chrp.c user/nwhitehorn/ps3/powerpc/aim/trap_subr.S Modified: user/nwhitehorn/ps3/amd64/amd64/cpu_switch.S user/nwhitehorn/ps3/amd64/amd64/exception.S user/nwhitehorn/ps3/amd64/amd64/machdep.c user/nwhitehorn/ps3/amd64/amd64/trap.c user/nwhitehorn/ps3/amd64/include/segments.h user/nwhitehorn/ps3/amd64/include/trap.h user/nwhitehorn/ps3/boot/common/Makefile.inc user/nwhitehorn/ps3/boot/common/ufsread.c user/nwhitehorn/ps3/cddl/compat/opensolaris/kern/opensolaris_policy.c user/nwhitehorn/ps3/cddl/compat/opensolaris/sys/policy.h user/nwhitehorn/ps3/cddl/contrib/opensolaris/uts/common/Makefile.files user/nwhitehorn/ps3/cddl/contrib/opensolaris/uts/common/dtrace/fasttrap.c user/nwhitehorn/ps3/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c user/nwhitehorn/ps3/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c user/nwhitehorn/ps3/cddl/contrib/opensolaris/uts/common/fs/zfs/rrwlock.c user/nwhitehorn/ps3/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c user/nwhitehorn/ps3/cddl/contrib/opensolaris/uts/common/fs/zfs/space_map.c user/nwhitehorn/ps3/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/metaslab.h user/nwhitehorn/ps3/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/metaslab_impl.h user/nwhitehorn/ps3/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/spa_impl.h user/nwhitehorn/ps3/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/space_map.h user/nwhitehorn/ps3/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_acl.h user/nwhitehorn/ps3/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_znode.h user/nwhitehorn/ps3/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio.h user/nwhitehorn/ps3/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c user/nwhitehorn/ps3/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_queue.c user/nwhitehorn/ps3/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_acl.c user/nwhitehorn/ps3/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c user/nwhitehorn/ps3/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c user/nwhitehorn/ps3/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c user/nwhitehorn/ps3/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_znode.c user/nwhitehorn/ps3/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c user/nwhitehorn/ps3/cddl/contrib/opensolaris/uts/common/sys/vnode.h user/nwhitehorn/ps3/cddl/contrib/opensolaris/uts/intel/dtrace/fasttrap_isa.c user/nwhitehorn/ps3/compat/x86bios/x86bios.c user/nwhitehorn/ps3/compat/x86bios/x86bios.h user/nwhitehorn/ps3/conf/files.amd64 user/nwhitehorn/ps3/conf/files.i386 user/nwhitehorn/ps3/conf/files.powerpc user/nwhitehorn/ps3/dev/age/if_age.c user/nwhitehorn/ps3/dev/ahci/ahci.c user/nwhitehorn/ps3/dev/ata/ata-pci.h user/nwhitehorn/ps3/dev/ata/chipsets/ata-intel.c user/nwhitehorn/ps3/dev/e1000/if_em.c user/nwhitehorn/ps3/dev/e1000/if_em.h user/nwhitehorn/ps3/dev/e1000/if_igb.c user/nwhitehorn/ps3/dev/e1000/if_igb.h user/nwhitehorn/ps3/dev/e1000/if_lem.c user/nwhitehorn/ps3/dev/e1000/if_lem.h user/nwhitehorn/ps3/dev/ed/if_ed_isa.c user/nwhitehorn/ps3/dev/ed/if_ed_novell.c user/nwhitehorn/ps3/dev/ed/if_ed_pci.c user/nwhitehorn/ps3/dev/fb/vesa.c user/nwhitehorn/ps3/dev/ichsmb/ichsmb_pci.c user/nwhitehorn/ps3/dev/ichwd/ichwd.c user/nwhitehorn/ps3/dev/ichwd/ichwd.h user/nwhitehorn/ps3/dev/ixgb/if_ixgb.c user/nwhitehorn/ps3/dev/ixgb/if_ixgb.h user/nwhitehorn/ps3/dev/ixgbe/ixgbe.c user/nwhitehorn/ps3/dev/ixgbe/ixgbe.h user/nwhitehorn/ps3/dev/sound/pci/hda/hdac.c user/nwhitehorn/ps3/dev/twa/tw_cl.h user/nwhitehorn/ps3/dev/twa/tw_cl_externs.h user/nwhitehorn/ps3/dev/twa/tw_cl_fwif.h user/nwhitehorn/ps3/dev/twa/tw_cl_init.c user/nwhitehorn/ps3/dev/twa/tw_cl_intr.c user/nwhitehorn/ps3/dev/twa/tw_cl_io.c user/nwhitehorn/ps3/dev/twa/tw_cl_misc.c user/nwhitehorn/ps3/dev/twa/tw_cl_share.h user/nwhitehorn/ps3/dev/twa/tw_osl.h user/nwhitehorn/ps3/dev/twa/tw_osl_cam.c user/nwhitehorn/ps3/dev/twa/tw_osl_freebsd.c user/nwhitehorn/ps3/dev/twa/tw_osl_share.h user/nwhitehorn/ps3/dev/vr/if_vr.c user/nwhitehorn/ps3/fs/devfs/devfs_vnops.c user/nwhitehorn/ps3/fs/nfs/nfs_commonsubs.c user/nwhitehorn/ps3/fs/nfs/nfs_var.h user/nwhitehorn/ps3/fs/nfsserver/nfs_nfsdsocket.c user/nwhitehorn/ps3/fs/nfsserver/nfs_nfsdstate.c user/nwhitehorn/ps3/fs/nullfs/null_vnops.c user/nwhitehorn/ps3/fs/unionfs/union_subr.c user/nwhitehorn/ps3/geom/eli/g_eli.c user/nwhitehorn/ps3/geom/eli/g_eli.h user/nwhitehorn/ps3/i386/i386/exception.s user/nwhitehorn/ps3/i386/i386/machdep.c user/nwhitehorn/ps3/i386/i386/trap.c user/nwhitehorn/ps3/i386/include/segments.h user/nwhitehorn/ps3/i386/include/trap.h user/nwhitehorn/ps3/i386/include/vm86.h user/nwhitehorn/ps3/kern/init_sysent.c user/nwhitehorn/ps3/kern/kern_exec.c user/nwhitehorn/ps3/kern/kern_sig.c user/nwhitehorn/ps3/kern/kern_thr.c user/nwhitehorn/ps3/kern/kern_umtx.c user/nwhitehorn/ps3/kern/subr_acl_nfs4.c user/nwhitehorn/ps3/kern/subr_acl_posix1e.c user/nwhitehorn/ps3/kern/subr_taskqueue.c user/nwhitehorn/ps3/kern/sys_generic.c user/nwhitehorn/ps3/kern/syscalls.c user/nwhitehorn/ps3/kern/syscalls.master user/nwhitehorn/ps3/kern/systrace_args.c user/nwhitehorn/ps3/kern/vfs_default.c user/nwhitehorn/ps3/kern/vfs_mount.c user/nwhitehorn/ps3/kern/vfs_subr.c user/nwhitehorn/ps3/mips/include/atomic.h user/nwhitehorn/ps3/mips/include/locore.h user/nwhitehorn/ps3/mips/include/memdev.h user/nwhitehorn/ps3/mips/include/pcb.h user/nwhitehorn/ps3/mips/include/pmap.h user/nwhitehorn/ps3/mips/include/pte.h user/nwhitehorn/ps3/mips/include/regnum.h user/nwhitehorn/ps3/mips/include/ucontext.h user/nwhitehorn/ps3/mips/mips/pmap.c user/nwhitehorn/ps3/mips/rmi/board.c user/nwhitehorn/ps3/mips/rmi/board.h user/nwhitehorn/ps3/mips/rmi/dev/xlr/rge.c user/nwhitehorn/ps3/mips/rmi/files.xlr user/nwhitehorn/ps3/mips/rmi/interrupt.h user/nwhitehorn/ps3/mips/rmi/intr_machdep.c user/nwhitehorn/ps3/mips/rmi/iodi.c user/nwhitehorn/ps3/mips/rmi/iomap.h user/nwhitehorn/ps3/mips/rmi/msgring.h user/nwhitehorn/ps3/mips/rmi/pic.h user/nwhitehorn/ps3/mips/rmi/rmi_mips_exts.h user/nwhitehorn/ps3/mips/rmi/tick.c user/nwhitehorn/ps3/mips/rmi/xlr_machdep.c user/nwhitehorn/ps3/mips/rmi/xlr_pci.c user/nwhitehorn/ps3/modules/dtrace/Makefile user/nwhitehorn/ps3/modules/dtrace/dtrace/Makefile user/nwhitehorn/ps3/modules/dtrace/dtraceall/dtraceall.c user/nwhitehorn/ps3/modules/dtrace/fasttrap/Makefile user/nwhitehorn/ps3/net/if_epair.c user/nwhitehorn/ps3/netinet/ipfw/ip_fw_log.c user/nwhitehorn/ps3/netinet/sctp.h user/nwhitehorn/ps3/netinet/sctp_cc_functions.c user/nwhitehorn/ps3/netinet/sctp_crc32.c user/nwhitehorn/ps3/netinet/sctp_crc32.h user/nwhitehorn/ps3/netinet/sctp_indata.c user/nwhitehorn/ps3/netinet/sctp_input.c user/nwhitehorn/ps3/netinet/sctp_os_bsd.h user/nwhitehorn/ps3/netinet/sctp_output.c user/nwhitehorn/ps3/netinet/sctp_pcb.c user/nwhitehorn/ps3/netinet/sctp_pcb.h user/nwhitehorn/ps3/netinet/sctp_peeloff.c user/nwhitehorn/ps3/netinet/sctp_sysctl.c user/nwhitehorn/ps3/netinet/sctp_sysctl.h user/nwhitehorn/ps3/netinet/sctp_timer.c user/nwhitehorn/ps3/netinet/sctp_usrreq.c user/nwhitehorn/ps3/netinet/sctputil.c user/nwhitehorn/ps3/netinet/tcp_input.c user/nwhitehorn/ps3/netinet/tcp_subr.c user/nwhitehorn/ps3/netinet6/sctp6_usrreq.c user/nwhitehorn/ps3/nfsserver/nfs_serv.c user/nwhitehorn/ps3/pci/if_rl.c user/nwhitehorn/ps3/powerpc/aim/machdep.c user/nwhitehorn/ps3/powerpc/aim/mmu_oea.c user/nwhitehorn/ps3/powerpc/aim/mmu_oea64.c user/nwhitehorn/ps3/powerpc/aim/ofw_machdep.c user/nwhitehorn/ps3/powerpc/aim/vm_machdep.c user/nwhitehorn/ps3/powerpc/booke/platform_bare.c user/nwhitehorn/ps3/powerpc/include/ofw_machdep.h user/nwhitehorn/ps3/powerpc/mpc85xx/mpc85xx.c user/nwhitehorn/ps3/powerpc/powermac/cuda.c user/nwhitehorn/ps3/powerpc/powermac/pmu.c user/nwhitehorn/ps3/powerpc/powermac/smu.c user/nwhitehorn/ps3/powerpc/powerpc/platform.c user/nwhitehorn/ps3/powerpc/powerpc/platform_if.m user/nwhitehorn/ps3/powerpc/ps3/platform_ps3.c user/nwhitehorn/ps3/rpc/replay.c user/nwhitehorn/ps3/sys/cdefs.h user/nwhitehorn/ps3/sys/dtrace_bsd.h user/nwhitehorn/ps3/sys/mman.h user/nwhitehorn/ps3/sys/mount.h user/nwhitehorn/ps3/sys/param.h user/nwhitehorn/ps3/sys/signal.h user/nwhitehorn/ps3/sys/syscall.h user/nwhitehorn/ps3/sys/syscall.mk user/nwhitehorn/ps3/sys/sysproto.h user/nwhitehorn/ps3/vm/vm_mmap.c user/nwhitehorn/ps3/x86/x86/local_apic.c Directory Properties: user/nwhitehorn/ps3/ (props changed) user/nwhitehorn/ps3/amd64/include/xen/ (props changed) user/nwhitehorn/ps3/boot/powerpc/ps3/ (props changed) user/nwhitehorn/ps3/cddl/contrib/opensolaris/ (props changed) user/nwhitehorn/ps3/contrib/dev/acpica/ (props changed) user/nwhitehorn/ps3/contrib/pf/ (props changed) user/nwhitehorn/ps3/contrib/x86emu/ (props changed) user/nwhitehorn/ps3/dev/xen/xenpci/ (props changed) user/nwhitehorn/ps3/powerpc/ps3/ (props changed) Modified: user/nwhitehorn/ps3/amd64/amd64/cpu_switch.S ============================================================================== --- user/nwhitehorn/ps3/amd64/amd64/cpu_switch.S Tue Aug 31 15:52:12 2010 (r212056) +++ user/nwhitehorn/ps3/amd64/amd64/cpu_switch.S Tue Aug 31 15:58:15 2010 (r212057) @@ -338,19 +338,16 @@ ENTRY(savectx) movl $MSR_FSBASE,%ecx rdmsr - shlq $32,%rdx - leaq (%rax,%rdx),%rax - movq %rax,PCB_FSBASE(%rdi) + movl %eax,PCB_FSBASE(%rdi) + movl %edx,PCB_FSBASE+4(%rdi) movl $MSR_GSBASE,%ecx rdmsr - shlq $32,%rdx - leaq (%rax,%rdx),%rax - movq %rax,PCB_GSBASE(%rdi) + movl %eax,PCB_GSBASE(%rdi) + movl %edx,PCB_GSBASE+4(%rdi) movl $MSR_KGSBASE,%ecx rdmsr - shlq $32,%rdx - leaq (%rax,%rdx),%rax - movq %rax,PCB_KGSBASE(%rdi) + movl %eax,PCB_KGSBASE(%rdi) + movl %edx,PCB_KGSBASE+4(%rdi) sgdt PCB_GDT(%rdi) sidt PCB_IDT(%rdi) Modified: user/nwhitehorn/ps3/amd64/amd64/exception.S ============================================================================== --- user/nwhitehorn/ps3/amd64/amd64/exception.S Tue Aug 31 15:52:12 2010 (r212056) +++ user/nwhitehorn/ps3/amd64/amd64/exception.S Tue Aug 31 15:58:15 2010 (r212057) @@ -108,6 +108,10 @@ IDTVEC(dbg) TRAP_NOEN(T_TRCTRAP) IDTVEC(bpt) TRAP_NOEN(T_BPTFLT) +#ifdef KDTRACE_HOOKS +IDTVEC(dtrace_ret) + TRAP_NOEN(T_DTRACE_RET) +#endif /* Regular traps; The cpu does not supply tf_err for these. */ #define TRAP(a) \ Modified: user/nwhitehorn/ps3/amd64/amd64/machdep.c ============================================================================== --- user/nwhitehorn/ps3/amd64/amd64/machdep.c Tue Aug 31 15:52:12 2010 (r212056) +++ user/nwhitehorn/ps3/amd64/amd64/machdep.c Tue Aug 31 15:58:15 2010 (r212057) @@ -54,6 +54,7 @@ __FBSDID("$FreeBSD$"); #include "opt_msgbuf.h" #include "opt_perfmon.h" #include "opt_sched.h" +#include "opt_kdtrace.h" #include #include @@ -1089,6 +1090,9 @@ extern inthand_t IDTVEC(tss), IDTVEC(missing), IDTVEC(stk), IDTVEC(prot), IDTVEC(page), IDTVEC(mchk), IDTVEC(rsvd), IDTVEC(fpu), IDTVEC(align), IDTVEC(xmm), IDTVEC(dblfault), +#ifdef KDTRACE_HOOKS + IDTVEC(dtrace_ret), +#endif IDTVEC(fast_syscall), IDTVEC(fast_syscall32); #ifdef DDB @@ -1617,6 +1621,9 @@ hammer_time(u_int64_t modulep, u_int64_t setidt(IDT_AC, &IDTVEC(align), SDT_SYSIGT, SEL_KPL, 0); setidt(IDT_MC, &IDTVEC(mchk), SDT_SYSIGT, SEL_KPL, 0); setidt(IDT_XF, &IDTVEC(xmm), SDT_SYSIGT, SEL_KPL, 0); +#ifdef KDTRACE_HOOKS + setidt(IDT_DTRACE_RET, &IDTVEC(dtrace_ret), SDT_SYSIGT, SEL_UPL, 0); +#endif r_idt.rd_limit = sizeof(idt0) - 1; r_idt.rd_base = (long) idt; Modified: user/nwhitehorn/ps3/amd64/amd64/trap.c ============================================================================== --- user/nwhitehorn/ps3/amd64/amd64/trap.c Tue Aug 31 15:52:12 2010 (r212056) +++ user/nwhitehorn/ps3/amd64/amd64/trap.c Tue Aug 31 15:58:15 2010 (r212057) @@ -109,6 +109,13 @@ dtrace_doubletrap_func_t dtrace_doubletr * implementation opaque. */ systrace_probe_func_t systrace_probe_func; + +/* + * These hooks are necessary for the pid, usdt and fasttrap providers. + */ +dtrace_fasttrap_probe_ptr_t dtrace_fasttrap_probe_ptr; +dtrace_pid_probe_ptr_t dtrace_pid_probe_ptr; +dtrace_return_probe_ptr_t dtrace_return_probe_ptr; #endif extern void trap(struct trapframe *frame); @@ -239,6 +246,55 @@ trap(struct trapframe *frame) if (dtrace_trap_func != NULL) if ((*dtrace_trap_func)(frame, type)) goto out; + if (type == T_DTRACE_PROBE || type == T_DTRACE_RET || + type == T_BPTFLT) { + struct reg regs; + + regs.r_r15 = frame->tf_r15; + regs.r_r14 = frame->tf_r14; + regs.r_r13 = frame->tf_r13; + regs.r_r12 = frame->tf_r12; + regs.r_r11 = frame->tf_r11; + regs.r_r10 = frame->tf_r10; + regs.r_r9 = frame->tf_r9; + regs.r_r8 = frame->tf_r8; + regs.r_rdi = frame->tf_rdi; + regs.r_rsi = frame->tf_rsi; + regs.r_rbp = frame->tf_rbp; + regs.r_rbx = frame->tf_rbx; + regs.r_rdx = frame->tf_rdx; + regs.r_rcx = frame->tf_rcx; + regs.r_rax = frame->tf_rax; + regs.r_rip = frame->tf_rip; + regs.r_cs = frame->tf_cs; + regs.r_rflags = frame->tf_rflags; + regs.r_rsp = frame->tf_rsp; + regs.r_ss = frame->tf_ss; + if (frame->tf_flags & TF_HASSEGS) { + regs.r_ds = frame->tf_ds; + regs.r_es = frame->tf_es; + regs.r_fs = frame->tf_fs; + regs.r_gs = frame->tf_gs; + } else { + regs.r_ds = 0; + regs.r_es = 0; + regs.r_fs = 0; + regs.r_gs = 0; + } + if (type == T_DTRACE_PROBE && + dtrace_fasttrap_probe_ptr != NULL && + dtrace_fasttrap_probe_ptr(®s) == 0) + goto out; + if (type == T_BPTFLT && + dtrace_pid_probe_ptr != NULL && + dtrace_pid_probe_ptr(®s) == 0) + goto out; + if (type == T_DTRACE_RET && + dtrace_return_probe_ptr != NULL && + dtrace_return_probe_ptr(®s) == 0) + goto out; + + } #endif if ((frame->tf_rflags & PSL_I) == 0) { Modified: user/nwhitehorn/ps3/amd64/include/segments.h ============================================================================== --- user/nwhitehorn/ps3/amd64/include/segments.h Tue Aug 31 15:52:12 2010 (r212056) +++ user/nwhitehorn/ps3/amd64/include/segments.h Tue Aug 31 15:58:15 2010 (r212057) @@ -214,6 +214,7 @@ struct region_descriptor { #define IDT_XF 19 /* #XF: SIMD Floating-Point Exception */ #define IDT_IO_INTS NRSVIDT /* Base of IDT entries for I/O interrupts. */ #define IDT_SYSCALL 0x80 /* System Call Interrupt Vector */ +#define IDT_DTRACE_RET 0x92 /* DTrace pid provider Interrupt Vector */ /* * Entries in the Global Descriptor Table (GDT) Modified: user/nwhitehorn/ps3/amd64/include/trap.h ============================================================================== --- user/nwhitehorn/ps3/amd64/include/trap.h Tue Aug 31 15:52:12 2010 (r212056) +++ user/nwhitehorn/ps3/amd64/include/trap.h Tue Aug 31 15:58:15 2010 (r212057) @@ -62,6 +62,8 @@ #define T_MCHK 28 /* machine check trap */ #define T_XMMFLT 29 /* SIMD floating-point exception */ #define T_RESERVED 30 /* reserved (unknown) */ +#define T_DTRACE_RET 31 /* DTrace pid return */ +#define T_DTRACE_PROBE 32 /* DTrace fasttrap probe */ /* XXX most of the following codes aren't used, but could be. */ Modified: user/nwhitehorn/ps3/boot/common/Makefile.inc ============================================================================== --- user/nwhitehorn/ps3/boot/common/Makefile.inc Tue Aug 31 15:52:12 2010 (r212056) +++ user/nwhitehorn/ps3/boot/common/Makefile.inc Tue Aug 31 15:58:15 2010 (r212057) @@ -9,7 +9,7 @@ SRCS+= load_elf32.c load_elf32_obj.c rel SRCS+= load_elf64.c load_elf64_obj.c reloc_elf64.c .elif ${MACHINE} == "pc98" SRCS+= load_elf32.c load_elf32_obj.c reloc_elf32.c -.elif ${MACHINE_ARCH} == "powerpc" || ${MACHINE_CPUARCH} == "arm" +.elif ${MACHINE_CPUARCH} == "arm" SRCS+= load_elf32.c reloc_elf32.c .elif ${MACHINE_CPUARCH} == "powerpc" SRCS+= load_elf32.c reloc_elf32.c Modified: user/nwhitehorn/ps3/boot/common/ufsread.c ============================================================================== --- user/nwhitehorn/ps3/boot/common/ufsread.c Tue Aug 31 15:52:12 2010 (r212056) +++ user/nwhitehorn/ps3/boot/common/ufsread.c Tue Aug 31 15:58:15 2010 (r212057) @@ -223,14 +223,19 @@ fsread(ino_t inode, void *buf, size_t nb return -1; n = INO_TO_VBO(n, inode); #if defined(UFS1_ONLY) - dp1 = ((struct ufs1_dinode *)blkbuf)[n]; + memcpy(&dp1, (struct ufs1_dinode *)blkbuf + n, + sizeof(struct ufs1_dinode)); #elif defined(UFS2_ONLY) - dp2 = ((struct ufs2_dinode *)blkbuf)[n]; + memcpy(&dp2, (struct ufs2_dinode *)blkbuf + n, + sizeof(struct ufs2_dinode)); #else if (fs->fs_magic == FS_UFS1_MAGIC) - dp1 = ((struct ufs1_dinode *)blkbuf)[n]; + memcpy(&dp1, (struct ufs1_dinode *)blkbuf + n, + sizeof(struct ufs1_dinode)); else - dp2 = ((struct ufs2_dinode *)blkbuf)[n]; + memcpy(&dp2, (struct ufs2_dinode *)blkbuf + n, + sizeof(struct ufs2_dinode)); + #endif inomap = inode; fs_off = 0; Modified: user/nwhitehorn/ps3/cddl/compat/opensolaris/kern/opensolaris_policy.c ============================================================================== --- user/nwhitehorn/ps3/cddl/compat/opensolaris/kern/opensolaris_policy.c Tue Aug 31 15:52:12 2010 (r212056) +++ user/nwhitehorn/ps3/cddl/compat/opensolaris/kern/opensolaris_policy.c Tue Aug 31 15:58:15 2010 (r212057) @@ -332,7 +332,7 @@ secpolicy_vnode_owner(struct vnode *vp, } int -secpolicy_vnode_chown(struct vnode *vp, cred_t *cred, boolean_t check_self) +secpolicy_vnode_chown(struct vnode *vp, cred_t *cred, uid_t owner) { if (secpolicy_fs_owner(vp->v_mount, cred) == 0) Modified: user/nwhitehorn/ps3/cddl/compat/opensolaris/sys/policy.h ============================================================================== --- user/nwhitehorn/ps3/cddl/compat/opensolaris/sys/policy.h Tue Aug 31 15:52:12 2010 (r212056) +++ user/nwhitehorn/ps3/cddl/compat/opensolaris/sys/policy.h Tue Aug 31 15:58:15 2010 (r212057) @@ -47,8 +47,7 @@ int secpolicy_zinject(struct ucred *cred int secpolicy_fs_unmount(struct ucred *cred, struct mount *vfsp); int secpolicy_basic_link(struct vnode *vp, struct ucred *cred); int secpolicy_vnode_owner(struct vnode *vp, cred_t *cred, uid_t owner); -int secpolicy_vnode_chown(struct vnode *vp, cred_t *cred, - boolean_t check_self); +int secpolicy_vnode_chown(struct vnode *vp, cred_t *cred, uid_t owner); int secpolicy_vnode_stky_modify(struct ucred *cred); int secpolicy_vnode_remove(struct vnode *vp, struct ucred *cred); int secpolicy_vnode_access(struct ucred *cred, struct vnode *vp, Modified: user/nwhitehorn/ps3/cddl/contrib/opensolaris/uts/common/Makefile.files ============================================================================== --- user/nwhitehorn/ps3/cddl/contrib/opensolaris/uts/common/Makefile.files Tue Aug 31 15:52:12 2010 (r212056) +++ user/nwhitehorn/ps3/cddl/contrib/opensolaris/uts/common/Makefile.files Tue Aug 31 15:58:15 2010 (r212057) @@ -106,3 +106,6 @@ ZFS_OBJS += \ zfs_vfsops.o \ zfs_vnops.o \ zvol.o + +ZUT_OBJS += \ + zut.o Modified: user/nwhitehorn/ps3/cddl/contrib/opensolaris/uts/common/dtrace/fasttrap.c ============================================================================== --- user/nwhitehorn/ps3/cddl/contrib/opensolaris/uts/common/dtrace/fasttrap.c Tue Aug 31 15:52:12 2010 (r212056) +++ user/nwhitehorn/ps3/cddl/contrib/opensolaris/uts/common/dtrace/fasttrap.c Tue Aug 31 15:58:15 2010 (r212057) @@ -17,6 +17,10 @@ * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END + * + * Portions Copyright 2010 The FreeBSD Foundation + * + * $FreeBSD$ */ /* @@ -24,7 +28,9 @@ * Use is subject to license terms. */ +#if defined(sun) #pragma ident "%Z%%M% %I% %E% SMI" +#endif #include #include @@ -32,11 +38,15 @@ #include #include #include +#if defined(sun) #include +#endif #include #include #include +#if defined(sun) #include +#endif #include #include #include @@ -44,9 +54,17 @@ #include #include #include -#include #include +#if defined(sun) #include +#endif +#include +#include +#if !defined(sun) +#include +#include +#include +#endif /* * User-Land Trap-Based Tracing @@ -125,11 +143,20 @@ * never hold the provider lock and creation lock simultaneously */ -static dev_info_t *fasttrap_devi; +static d_open_t fasttrap_open; +static d_ioctl_t fasttrap_ioctl; + +static struct cdevsw fasttrap_cdevsw = { + .d_version = D_VERSION, + .d_open = fasttrap_open, + .d_ioctl = fasttrap_ioctl, + .d_name = "fasttrap", +}; +static struct cdev *fasttrap_cdev; static dtrace_meta_provider_id_t fasttrap_meta_id; -static timeout_id_t fasttrap_timeout; -static kmutex_t fasttrap_cleanup_mtx; +static struct callout fasttrap_timeout; +static struct mtx fasttrap_cleanup_mtx; static uint_t fasttrap_cleanup_work; /* @@ -181,6 +208,10 @@ static void fasttrap_proc_release(fasttr #define FASTTRAP_PROCS_INDEX(pid) ((pid) & fasttrap_procs.fth_mask) +#if !defined(sun) +static kmutex_t fasttrap_cpuc_pid_lock[MAXCPU]; +#endif + static int fasttrap_highbit(ulong_t i) { @@ -229,6 +260,7 @@ fasttrap_hash_str(const char *p) void fasttrap_sigtrap(proc_t *p, kthread_t *t, uintptr_t pc) { +#if defined(sun) sigqueue_t *sqp = kmem_zalloc(sizeof (sigqueue_t), KM_SLEEP); sqp->sq_info.si_signo = SIGTRAP; @@ -241,6 +273,17 @@ fasttrap_sigtrap(proc_t *p, kthread_t *t if (t != NULL) aston(t); +#else + ksiginfo_t *ksi = kmem_zalloc(sizeof (ksiginfo_t), KM_SLEEP); + + ksiginfo_init(ksi); + ksi->ksi_signo = SIGTRAP; + ksi->ksi_code = TRAP_DTRACE; + ksi->ksi_addr = (caddr_t)pc; + PROC_LOCK(p); + (void) tdksignal(t, SIGTRAP, ksi); + PROC_UNLOCK(p); +#endif } /* @@ -257,9 +300,9 @@ fasttrap_mod_barrier(uint64_t gen) fasttrap_mod_gen++; - for (i = 0; i < NCPU; i++) { - mutex_enter(&cpu_core[i].cpuc_pid_lock); - mutex_exit(&cpu_core[i].cpuc_pid_lock); + CPU_FOREACH(i) { + mutex_enter(&fasttrap_cpuc_pid_lock[i]); + mutex_exit(&fasttrap_cpuc_pid_lock[i]); } } @@ -274,16 +317,15 @@ fasttrap_pid_cleanup_cb(void *data) fasttrap_provider_t **fpp, *fp; fasttrap_bucket_t *bucket; dtrace_provider_id_t provid; - int i, later; + int i, later = 0; static volatile int in = 0; ASSERT(in == 0); in = 1; - mutex_enter(&fasttrap_cleanup_mtx); while (fasttrap_cleanup_work) { fasttrap_cleanup_work = 0; - mutex_exit(&fasttrap_cleanup_mtx); + mtx_unlock(&fasttrap_cleanup_mtx); later = 0; @@ -349,10 +391,12 @@ fasttrap_pid_cleanup_cb(void *data) mutex_exit(&bucket->ftb_mtx); } - mutex_enter(&fasttrap_cleanup_mtx); + mtx_lock(&fasttrap_cleanup_mtx); } +#if 0 ASSERT(fasttrap_timeout != 0); +#endif /* * If we were unable to remove a retired provider, try again after @@ -364,14 +408,17 @@ fasttrap_pid_cleanup_cb(void *data) * get a chance to do that work if and when the timeout is reenabled * (if detach fails). */ - if (later > 0 && fasttrap_timeout != (timeout_id_t)1) - fasttrap_timeout = timeout(&fasttrap_pid_cleanup_cb, NULL, hz); + if (later > 0 && callout_active(&fasttrap_timeout)) + callout_reset(&fasttrap_timeout, hz, &fasttrap_pid_cleanup_cb, + NULL); else if (later > 0) fasttrap_cleanup_work = 1; - else - fasttrap_timeout = 0; + else { +#if !defined(sun) + /* Nothing to be done for FreeBSD */ +#endif + } - mutex_exit(&fasttrap_cleanup_mtx); in = 0; } @@ -381,11 +428,11 @@ fasttrap_pid_cleanup_cb(void *data) static void fasttrap_pid_cleanup(void) { - mutex_enter(&fasttrap_cleanup_mtx); + + mtx_lock(&fasttrap_cleanup_mtx); fasttrap_cleanup_work = 1; - if (fasttrap_timeout == 0) - fasttrap_timeout = timeout(&fasttrap_pid_cleanup_cb, NULL, 1); - mutex_exit(&fasttrap_cleanup_mtx); + callout_reset(&fasttrap_timeout, 1, &fasttrap_pid_cleanup_cb, NULL); + mtx_unlock(&fasttrap_cleanup_mtx); } /* @@ -400,9 +447,23 @@ fasttrap_fork(proc_t *p, proc_t *cp) pid_t ppid = p->p_pid; int i; +#if defined(sun) ASSERT(curproc == p); ASSERT(p->p_proc_flag & P_PR_LOCK); +#else + PROC_LOCK_ASSERT(p, MA_OWNED); +#endif +#if defined(sun) ASSERT(p->p_dtrace_count > 0); +#else + /* + * This check is purposely here instead of in kern_fork.c because, + * for legal resons, we cannot include the dtrace_cddl.h header + * inside kern_fork.c and insert if-clause there. + */ + if (p->p_dtrace_count == 0) + return; +#endif ASSERT(cp->p_dtrace_count == 0); /* @@ -419,9 +480,11 @@ fasttrap_fork(proc_t *p, proc_t *cp) * We don't have to worry about the child process disappearing * because we're in fork(). */ - mutex_enter(&cp->p_lock); +#if defined(sun) + mtx_lock_spin(&cp->p_slock); sprlock_proc(cp); - mutex_exit(&cp->p_lock); + mtx_unlock_spin(&cp->p_slock); +#endif /* * Iterate over every tracepoint looking for ones that belong to the @@ -451,8 +514,10 @@ fasttrap_fork(proc_t *p, proc_t *cp) mutex_exit(&bucket->ftb_mtx); } +#if defined(sun) mutex_enter(&cp->p_lock); sprunlock(cp); +#endif } /* @@ -463,24 +528,24 @@ fasttrap_fork(proc_t *p, proc_t *cp) static void fasttrap_exec_exit(proc_t *p) { +#if defined(sun) ASSERT(p == curproc); - ASSERT(MUTEX_HELD(&p->p_lock)); - - mutex_exit(&p->p_lock); +#endif + PROC_LOCK_ASSERT(p, MA_OWNED); + PROC_UNLOCK(p); /* * We clean up the pid provider for this process here; user-land * static probes are handled by the meta-provider remove entry point. */ fasttrap_provider_retire(p->p_pid, FASTTRAP_PID_NAME, 0); - - mutex_enter(&p->p_lock); + PROC_LOCK(p); } /*ARGSUSED*/ static void -fasttrap_pid_provide(void *arg, const dtrace_probedesc_t *desc) +fasttrap_pid_provide(void *arg, dtrace_probedesc_t *desc) { /* * There are no "default" pid probes. @@ -504,7 +569,9 @@ fasttrap_tracepoint_enable(proc_t *p, fa ASSERT(probe->ftp_tps[index].fit_tp->ftt_pid == pid); +#if defined(sun) ASSERT(!(p->p_flag & SVFORK)); +#endif /* * Before we make any modifications, make sure we've imposed a barrier @@ -610,7 +677,11 @@ again: * Increment the count of the number of tracepoints active in * the victim process. */ +#if defined(sun) ASSERT(p->p_proc_flag & P_PR_LOCK); +#else + PROC_LOCK_ASSERT(p, MA_OWNED); +#endif p->p_dtrace_count++; return (rc); @@ -666,7 +737,7 @@ fasttrap_tracepoint_disable(proc_t *p, f fasttrap_bucket_t *bucket; fasttrap_provider_t *provider = probe->ftp_prov; fasttrap_tracepoint_t **pp, *tp; - fasttrap_id_t *id, **idp; + fasttrap_id_t *id, **idp = NULL; pid_t pid; uintptr_t pc; @@ -800,7 +871,11 @@ fasttrap_tracepoint_disable(proc_t *p, f * Decrement the count of the number of tracepoints active * in the victim process. */ +#if defined(sun) ASSERT(p->p_proc_flag & P_PR_LOCK); +#else + PROC_LOCK_ASSERT(p, MA_OWNED); +#endif p->p_dtrace_count--; } @@ -851,26 +926,31 @@ fasttrap_enable_callbacks(void) static void fasttrap_disable_callbacks(void) { +#if defined(sun) ASSERT(MUTEX_HELD(&cpu_lock)); +#endif + mutex_enter(&fasttrap_count_mtx); ASSERT(fasttrap_pid_count > 0); fasttrap_pid_count--; if (fasttrap_pid_count == 0) { +#if defined(sun) cpu_t *cur, *cpu = CPU; for (cur = cpu->cpu_next_onln; cur != cpu; cur = cur->cpu_next_onln) { rw_enter(&cur->cpu_ft_lock, RW_WRITER); } - +#endif dtrace_pid_probe_ptr = NULL; dtrace_return_probe_ptr = NULL; - +#if defined(sun) for (cur = cpu->cpu_next_onln; cur != cpu; cur = cur->cpu_next_onln) { rw_exit(&cur->cpu_ft_lock); } +#endif } mutex_exit(&fasttrap_count_mtx); } @@ -880,13 +960,16 @@ static void fasttrap_pid_enable(void *arg, dtrace_id_t id, void *parg) { fasttrap_probe_t *probe = parg; - proc_t *p; + proc_t *p = NULL; int i, rc; + ASSERT(probe != NULL); ASSERT(!probe->ftp_enabled); ASSERT(id == probe->ftp_id); +#if defined(sun) ASSERT(MUTEX_HELD(&cpu_lock)); +#endif /* * Increment the count of enabled probes on this probe's provider; @@ -911,6 +994,7 @@ fasttrap_pid_enable(void *arg, dtrace_id * a fork in which the traced process is being born and we're copying * USDT probes. Otherwise, the process is gone so bail. */ +#if defined(sun) if ((p = sprlock(probe->ftp_pid)) == NULL) { if ((curproc->p_flag & SFORKING) == 0) return; @@ -934,13 +1018,19 @@ fasttrap_pid_enable(void *arg, dtrace_id ASSERT(!(p->p_flag & SVFORK)); mutex_exit(&p->p_lock); +#else + if ((p = pfind(probe->ftp_pid)) == NULL) + return; +#endif /* * We have to enable the trap entry point before any user threads have * the chance to execute the trap instruction we're about to place * in their process's text. */ + PROC_UNLOCK(p); fasttrap_enable_callbacks(); + PROC_LOCK(p); /* * Enable all the tracepoints and add this probe's id to each @@ -967,8 +1057,12 @@ fasttrap_pid_enable(void *arg, dtrace_id i--; } +#if defined(sun) mutex_enter(&p->p_lock); sprunlock(p); +#else + PROC_UNLOCK(p); +#endif /* * Since we're not actually enabling this probe, @@ -978,9 +1072,12 @@ fasttrap_pid_enable(void *arg, dtrace_id return; } } - +#if defined(sun) mutex_enter(&p->p_lock); sprunlock(p); +#else + PROC_UNLOCK(p); +#endif probe->ftp_enabled = 1; } @@ -996,19 +1093,19 @@ fasttrap_pid_disable(void *arg, dtrace_i ASSERT(id == probe->ftp_id); + mutex_enter(&provider->ftp_mtx); + /* * We won't be able to acquire a /proc-esque lock on the process * iff the process is dead and gone. In this case, we rely on the * provider lock as a point of mutual exclusion to prevent other * DTrace consumers from disabling this probe. */ - if ((p = sprlock(probe->ftp_pid)) != NULL) { - ASSERT(!(p->p_flag & SVFORK)); - mutex_exit(&p->p_lock); + if ((p = pfind(probe->ftp_pid)) == NULL) { + mutex_exit(&provider->ftp_mtx); + return; } - mutex_enter(&provider->ftp_mtx); - /* * Disable all the associated tracepoints (for fully enabled probes). */ @@ -1030,9 +1127,6 @@ fasttrap_pid_disable(void *arg, dtrace_i if (provider->ftp_retired && !provider->ftp_marked) whack = provider->ftp_marked = 1; mutex_exit(&provider->ftp_mtx); - - mutex_enter(&p->p_lock); - sprunlock(p); } else { /* * If the process is dead, we're just waiting for the @@ -1042,6 +1136,9 @@ fasttrap_pid_disable(void *arg, dtrace_i whack = provider->ftp_marked = 1; mutex_exit(&provider->ftp_mtx); } +#if !defined(sun) + PROC_UNLOCK(p); +#endif if (whack) fasttrap_pid_cleanup(); @@ -1051,7 +1148,9 @@ fasttrap_pid_disable(void *arg, dtrace_i probe->ftp_enabled = 0; +#if defined(sun) ASSERT(MUTEX_HELD(&cpu_lock)); +#endif fasttrap_disable_callbacks(); } @@ -1163,6 +1262,7 @@ fasttrap_proc_lookup(pid_t pid) fasttrap_bucket_t *bucket; fasttrap_proc_t *fprc, *new_fprc; + bucket = &fasttrap_procs.fth_table[FASTTRAP_PROCS_INDEX(pid)]; mutex_enter(&bucket->ftb_mtx); @@ -1189,6 +1289,10 @@ fasttrap_proc_lookup(pid_t pid) new_fprc->ftpc_pid = pid; new_fprc->ftpc_rcount = 1; new_fprc->ftpc_acount = 1; +#if !defined(sun) + mutex_init(&new_fprc->ftpc_mtx, "fasttrap proc mtx", MUTEX_DEFAULT, + NULL); +#endif mutex_enter(&bucket->ftb_mtx); @@ -1311,17 +1415,8 @@ fasttrap_provider_lookup(pid_t pid, cons * Make sure the process exists, isn't a child created as the result * of a vfork(2), and isn't a zombie (but may be in fork). */ - mutex_enter(&pidlock); - if ((p = prfind(pid)) == NULL) { - mutex_exit(&pidlock); + if ((p = pfind(pid)) == NULL) return (NULL); - } - mutex_enter(&p->p_lock); - mutex_exit(&pidlock); - if (p->p_flag & (SVFORK | SEXITING)) { - mutex_exit(&p->p_lock); - return (NULL); - } /* * Increment p_dtrace_probes so that the process knows to inform us @@ -1334,15 +1429,18 @@ fasttrap_provider_lookup(pid_t pid, cons * Grab the credentials for this process so we have * something to pass to dtrace_register(). */ - mutex_enter(&p->p_crlock); - crhold(p->p_cred); - cred = p->p_cred; - mutex_exit(&p->p_crlock); - mutex_exit(&p->p_lock); + PROC_LOCK_ASSERT(p, MA_OWNED); + crhold(p->p_ucred); + cred = p->p_ucred; + PROC_UNLOCK(p); new_fp = kmem_zalloc(sizeof (fasttrap_provider_t), KM_SLEEP); new_fp->ftp_pid = pid; new_fp->ftp_proc = fasttrap_proc_lookup(pid); +#if !defined(sun) + mutex_init(&new_fp->ftp_mtx, "provider mtx", MUTEX_DEFAULT, NULL); + mutex_init(&new_fp->ftp_cmtx, "lock on creating", MUTEX_DEFAULT, NULL); +#endif ASSERT(new_fp->ftp_proc != NULL); @@ -1420,6 +1518,10 @@ fasttrap_provider_free(fasttrap_provider fasttrap_proc_release(provider->ftp_proc); +#if !defined(sun) + mutex_destroy(&provider->ftp_mtx); + mutex_destroy(&provider->ftp_cmtx); +#endif kmem_free(provider, sizeof (fasttrap_provider_t)); /* @@ -1429,17 +1531,14 @@ fasttrap_provider_free(fasttrap_provider * corresponds to this process's hash chain in the provider hash * table. Don't sweat it if we can't find the process. */ - mutex_enter(&pidlock); - if ((p = prfind(pid)) == NULL) { - mutex_exit(&pidlock); + if ((p = pfind(pid)) == NULL) { return; } - mutex_enter(&p->p_lock); - mutex_exit(&pidlock); - p->p_dtrace_probes--; - mutex_exit(&p->p_lock); +#if !defined(sun) + PROC_UNLOCK(p); +#endif } static void @@ -1527,7 +1626,7 @@ fasttrap_add_probe(fasttrap_probe_spec_t fasttrap_probe_t *pp; fasttrap_tracepoint_t *tp; char *name; - int i, aframes, whack; + int i, aframes = 0, whack; /* * There needs to be at least one desired trace point. @@ -1715,7 +1814,7 @@ fasttrap_meta_provide(void *arg, dtrace_ */ if (strlen(dhpv->dthpv_provname) + 10 >= sizeof (provider->ftp_name)) { - cmn_err(CE_WARN, "failed to instantiate provider %s: " + printf("failed to instantiate provider %s: " "name too long to accomodate pid", dhpv->dthpv_provname); return (NULL); } @@ -1724,7 +1823,7 @@ fasttrap_meta_provide(void *arg, dtrace_ * Don't let folks spoof the true pid provider. */ if (strcmp(dhpv->dthpv_provname, FASTTRAP_PID_NAME) == 0) { - cmn_err(CE_WARN, "failed to instantiate provider %s: " + printf("failed to instantiate provider %s: " "%s is an invalid name", dhpv->dthpv_provname, FASTTRAP_PID_NAME); return (NULL); @@ -1747,7 +1846,7 @@ fasttrap_meta_provide(void *arg, dtrace_ if ((provider = fasttrap_provider_lookup(pid, dhpv->dthpv_provname, &dhpv->dthpv_pattr)) == NULL) { - cmn_err(CE_WARN, "failed to instantiate provider %s for " + printf("failed to instantiate provider %s for " "process %u", dhpv->dthpv_provname, (uint_t)pid); return (NULL); } @@ -1908,15 +2007,21 @@ static dtrace_mops_t fasttrap_mops = { /*ARGSUSED*/ static int -fasttrap_open(dev_t *devp, int flag, int otyp, cred_t *cred_p) +fasttrap_open(struct cdev *dev __unused, int oflags __unused, + int devtype __unused, struct thread *td __unused) { return (0); } /*ARGSUSED*/ static int -fasttrap_ioctl(dev_t dev, int cmd, intptr_t arg, int md, cred_t *cr, int *rv) +fasttrap_ioctl(struct cdev *dev, u_long cmd, caddr_t arg, int fflag, + struct thread *td) { +#ifdef notyet + struct kinfo_proc kp; + const cred_t *cr = td->td_ucred; +#endif if (!dtrace_attached()) return (EAGAIN); @@ -1928,9 +2033,13 @@ fasttrap_ioctl(dev_t dev, int cmd, intpt int ret; char *c; +#if defined(sun) if (copyin(&uprobe->ftps_noffs, &noffs, sizeof (uprobe->ftps_noffs))) return (EFAULT); +#else + noffs = uprobe->ftps_noffs; +#endif /* * Probes must have at least one tracepoint. @@ -1946,10 +2055,19 @@ fasttrap_ioctl(dev_t dev, int cmd, intpt probe = kmem_alloc(size, KM_SLEEP); +#if defined(sun) if (copyin(uprobe, probe, size) != 0) { kmem_free(probe, size); return (EFAULT); } +#else + memcpy(probe, uprobe, sizeof(*probe)); + if (noffs > 1 && copyin(uprobe + 1, probe + 1, size) != 0) { + kmem_free(probe, size); + return (EFAULT); + } +#endif + /* * Verify that the function and module strings contain no @@ -1969,30 +2087,52 @@ fasttrap_ioctl(dev_t dev, int cmd, intpt } } +#ifdef notyet if (!PRIV_POLICY_CHOICE(cr, PRIV_ALL, B_FALSE)) { proc_t *p; pid_t pid = probe->ftps_pid; +#if defined(sun) mutex_enter(&pidlock); +#endif /* * Report an error if the process doesn't exist * or is actively being birthed. */ - if ((p = prfind(pid)) == NULL || p->p_stat == SIDL) { + p = pfind(pid); + if (p) + fill_kinfo_proc(p, &kp); + if (p == NULL || kp.ki_stat == SIDL) { +#if defined(sun) mutex_exit(&pidlock); +#endif return (ESRCH); } +#if defined(sun) mutex_enter(&p->p_lock); mutex_exit(&pidlock); +#else + PROC_LOCK_ASSERT(p, MA_OWNED); +#endif +#ifdef notyet if ((ret = priv_proc_cred_perm(cr, p, NULL, VREAD | VWRITE)) != 0) { +#if defined(sun) mutex_exit(&p->p_lock); +#else + PROC_UNLOCK(p); +#endif return (ret); } - +#endif /* notyet */ +#if defined(sun) mutex_exit(&p->p_lock); +#else + PROC_UNLOCK(p); +#endif } +#endif /* notyet */ ret = fasttrap_add_probe(probe); err: @@ -2004,35 +2144,62 @@ err: fasttrap_instr_query_t instr; fasttrap_tracepoint_t *tp; uint_t index; +#if defined(sun) int ret; +#endif +#if defined(sun) if (copyin((void *)arg, &instr, sizeof (instr)) != 0) return (EFAULT); +#endif +#ifdef notyet if (!PRIV_POLICY_CHOICE(cr, PRIV_ALL, B_FALSE)) { proc_t *p; pid_t pid = instr.ftiq_pid; +#if defined(sun) mutex_enter(&pidlock); +#endif /* * Report an error if the process doesn't exist * or is actively being birthed. */ - if ((p = prfind(pid)) == NULL || p->p_stat == SIDL) { + p = pfind(pid); + if (p) + fill_kinfo_proc(p, &kp); + if (p == NULL || kp.ki_stat == SIDL) { +#if defined(sun) mutex_exit(&pidlock); +#endif return (ESRCH); *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-user@FreeBSD.ORG Wed Sep 1 17:02:31 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8209B1065693; Wed, 1 Sep 2010 17:02:31 +0000 (UTC) (envelope-from nwhitehorn@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 701EB8FC14; Wed, 1 Sep 2010 17:02:31 +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 o81H2Vsl073218; Wed, 1 Sep 2010 17:02:31 GMT (envelope-from nwhitehorn@svn.freebsd.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o81H2VjG073206; Wed, 1 Sep 2010 17:02:31 GMT (envelope-from nwhitehorn@svn.freebsd.org) Message-Id: <201009011702.o81H2VjG073206@svn.freebsd.org> From: Nathan Whitehorn Date: Wed, 1 Sep 2010 17:02:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r212101 - in user/nwhitehorn/ps3/powerpc: aim include powerpc ps3 X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 01 Sep 2010 17:02:31 -0000 Author: nwhitehorn Date: Wed Sep 1 17:02:31 2010 New Revision: 212101 URL: http://svn.freebsd.org/changeset/base/212101 Log: Enable use of the high 128 MB of memory on the PS3. On PowerPC hypervisors, only a limited subset of physical memory is typically available in real mode. In addition, the information on what that subset is is typically hypervisor privileged. This commit extends the platform interface to provide a hook for querying that information, and modifies the small amounts of the kernel that care to use it appropriately. Modified: user/nwhitehorn/ps3/powerpc/aim/mmu_oea64.c user/nwhitehorn/ps3/powerpc/aim/slb.c user/nwhitehorn/ps3/powerpc/aim/uma_machdep.c user/nwhitehorn/ps3/powerpc/include/platform.h user/nwhitehorn/ps3/powerpc/include/vmparam.h user/nwhitehorn/ps3/powerpc/powerpc/platform.c user/nwhitehorn/ps3/powerpc/powerpc/platform_if.m user/nwhitehorn/ps3/powerpc/ps3/if_glc.c user/nwhitehorn/ps3/powerpc/ps3/if_glcreg.h user/nwhitehorn/ps3/powerpc/ps3/mmu_ps3.c user/nwhitehorn/ps3/powerpc/ps3/platform_ps3.c Modified: user/nwhitehorn/ps3/powerpc/aim/mmu_oea64.c ============================================================================== --- user/nwhitehorn/ps3/powerpc/aim/mmu_oea64.c Wed Sep 1 16:53:38 2010 (r212100) +++ user/nwhitehorn/ps3/powerpc/aim/mmu_oea64.c Wed Sep 1 17:02:31 2010 (r212101) @@ -2338,6 +2338,9 @@ moea64_bootstrap_alloc(vm_size_t size, u if (s < phys_avail[i] || e > phys_avail[i + 1]) continue; + if (s + size > platform_real_maxaddr()) + continue; + if (s == phys_avail[i]) { phys_avail[i] += size; } else if (e == phys_avail[i + 1]) { Modified: user/nwhitehorn/ps3/powerpc/aim/slb.c ============================================================================== --- user/nwhitehorn/ps3/powerpc/aim/slb.c Wed Sep 1 16:53:38 2010 (r212100) +++ user/nwhitehorn/ps3/powerpc/aim/slb.c Wed Sep 1 17:02:31 2010 (r212101) @@ -40,11 +40,14 @@ #include #include +#include #include #include uintptr_t moea64_get_unique_vsid(void); void moea64_release_vsid(uint64_t vsid); +void *uma_small_alloc_core(uma_zone_t zone, int bytes, u_int8_t *flags, + int wait, vm_offset_t minphys, vm_offset_t maxphys); struct slbcontainer { struct slb slb; @@ -273,6 +276,18 @@ slb_compare(struct slbcontainer *a, stru return (1); } +static void * +slb_uma_cache_alloc(uma_zone_t zone, int bytes, u_int8_t *flags, int wait) +{ + static vm_offset_t realmax = 0; + + if (realmax == 0) + realmax = platform_real_maxaddr(); + + return (uma_small_alloc_core(zone, bytes, flags, wait, 0, realmax)); +} + + static void slb_zone_init(void *dummy) { @@ -281,6 +296,9 @@ slb_zone_init(void *dummy) NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_VM); slb_cache_zone = uma_zcreate("SLB cache", 64*sizeof(struct slb), NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_VM); + + if (platform_real_maxaddr() != VM_MAX_ADDRESS) + uma_zone_set_allocf(slb_cache_zone, slb_uma_cache_alloc); } struct slb * Modified: user/nwhitehorn/ps3/powerpc/aim/uma_machdep.c ============================================================================== --- user/nwhitehorn/ps3/powerpc/aim/uma_machdep.c Wed Sep 1 16:53:38 2010 (r212100) +++ user/nwhitehorn/ps3/powerpc/aim/uma_machdep.c Wed Sep 1 17:02:31 2010 (r212101) @@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -48,9 +49,20 @@ static int hw_uma_mdpages; SYSCTL_INT(_hw, OID_AUTO, uma_mdpages, CTLFLAG_RD, &hw_uma_mdpages, 0, "UMA MD pages in use"); +void *uma_small_alloc_core(uma_zone_t zone, int bytes, u_int8_t *flags, + int wait, vm_offset_t minphys, vm_offset_t maxphys); + void * uma_small_alloc(uma_zone_t zone, int bytes, u_int8_t *flags, int wait) { + return (uma_small_alloc_core(zone, bytes, flags, wait, + 0, VM_MAX_ADDRESS)); +} + +void * +uma_small_alloc_core(uma_zone_t zone, int bytes, u_int8_t *flags, int wait, + vm_offset_t minphys, vm_offset_t maxphys) +{ static vm_pindex_t color; void *va; vm_page_t m; @@ -65,7 +77,12 @@ uma_small_alloc(uma_zone_t zone, int byt pflags |= VM_ALLOC_ZERO; for (;;) { - m = vm_page_alloc(NULL, color++, pflags | VM_ALLOC_NOOBJ); + if (minphys == 0 && maxphys == VM_MAX_ADDRESS) + m = vm_page_alloc(NULL, color++, + pflags | VM_ALLOC_NOOBJ); + else + m = vm_phys_alloc_contig(1, minphys, maxphys, PAGE_SIZE, + PAGE_SIZE); if (m == NULL) { if (wait & M_NOWAIT) return (NULL); Modified: user/nwhitehorn/ps3/powerpc/include/platform.h ============================================================================== --- user/nwhitehorn/ps3/powerpc/include/platform.h Wed Sep 1 16:53:38 2010 (r212100) +++ user/nwhitehorn/ps3/powerpc/include/platform.h Wed Sep 1 17:02:31 2010 (r212101) @@ -44,6 +44,7 @@ struct mem_region { }; void mem_regions(struct mem_region **, int *, struct mem_region **, int *); +vm_offset_t platform_real_maxaddr(void); u_long platform_timebase_freq(struct cpuref *); Modified: user/nwhitehorn/ps3/powerpc/include/vmparam.h ============================================================================== --- user/nwhitehorn/ps3/powerpc/include/vmparam.h Wed Sep 1 16:53:38 2010 (r212100) +++ user/nwhitehorn/ps3/powerpc/include/vmparam.h Wed Sep 1 17:02:31 2010 (r212101) @@ -142,7 +142,11 @@ struct pmap_physseg { /* * The physical address space is densely populated. */ +#ifdef __powerpc64__ +#define VM_PHYSSEG_SPARSE +#else #define VM_PHYSSEG_DENSE +#endif /* * Create three free page pools: VM_FREEPOOL_DEFAULT is the default pool Modified: user/nwhitehorn/ps3/powerpc/powerpc/platform.c ============================================================================== --- user/nwhitehorn/ps3/powerpc/powerpc/platform.c Wed Sep 1 16:53:38 2010 (r212100) +++ user/nwhitehorn/ps3/powerpc/powerpc/platform.c Wed Sep 1 17:02:31 2010 (r212101) @@ -69,6 +69,12 @@ mem_regions(struct mem_region **phys, in PLATFORM_MEM_REGIONS(plat_obj, phys, physsz, avail, availsz); } +vm_offset_t +platform_real_maxaddr(void) +{ + return (PLATFORM_REAL_MAXADDR(plat_obj)); +} + const char * installed_platform() { Modified: user/nwhitehorn/ps3/powerpc/powerpc/platform_if.m ============================================================================== --- user/nwhitehorn/ps3/powerpc/powerpc/platform_if.m Wed Sep 1 16:53:38 2010 (r212100) +++ user/nwhitehorn/ps3/powerpc/powerpc/platform_if.m Wed Sep 1 17:02:31 2010 (r212101) @@ -34,6 +34,7 @@ #include #include #include +#include /** * @defgroup PLATFORM platform - KObj methods for PowerPC platform @@ -66,6 +67,10 @@ CODE { { return (ENOENT); } + static vm_offset_t platform_null_real_maxaddr(platform_t plat) + { + return (VM_MAX_ADDRESS); + } }; /** @@ -109,6 +114,15 @@ METHOD void mem_regions { }; /** + * @brief Return the maximum address accessible in real mode + * (for use with hypervisors) + */ +METHOD vm_offset_t real_maxaddr { + platform_t _plat; +} DEFAULT platform_null_real_maxaddr; + + +/** * @brief Get the CPU's timebase frequency, in ticks per second. * * @param _cpu CPU whose timebase to query Modified: user/nwhitehorn/ps3/powerpc/ps3/if_glc.c ============================================================================== --- user/nwhitehorn/ps3/powerpc/ps3/if_glc.c Wed Sep 1 16:53:38 2010 (r212100) +++ user/nwhitehorn/ps3/powerpc/ps3/if_glc.c Wed Sep 1 17:02:31 2010 (r212101) @@ -49,6 +49,7 @@ #include #include +#include #include #include #include @@ -110,13 +111,36 @@ glc_getphys(void *xaddr, bus_dma_segment *(bus_addr_t *)xaddr = segs[0].ds_addr; } +static bus_addr_t +glc_map_addr(struct glc_softc *sc, bus_addr_t lpar_addr) +{ + static struct mem_region *regions = NULL; + static int rcount; + int i; + + if (regions == NULL) + mem_regions(®ions, &rcount, ®ions, &rcount); + + for (i = 0; i < rcount; i++) { + if (lpar_addr >= regions[i].mr_start && + lpar_addr < regions[i].mr_start + regions[i].mr_size) + break; + } + + if (i == rcount) + panic("glc: unable to map address %#lx", lpar_addr); + + return (sc->sc_dma_base[i] + (lpar_addr - regions[i].mr_start)); +} + static int glc_attach(device_t dev) { struct glc_softc *sc; struct glc_txsoft *txs; + struct mem_region *regions; uint64_t mac64, val, junk; - int i, err; + int i, err, rcount; sc = device_get_softc(dev); @@ -184,24 +208,29 @@ glc_attach(device_t dev) */ /* XXX: following should be integrated to busdma */ - err = lv1_allocate_device_dma_region(sc->sc_bus, sc->sc_dev, - 0x8000000 /* 128 MB */, 24 /* log_2(16 MB) */, - 0 /* 32-bit transfers */, &sc->sc_dma_base); - if (err != 0) { - device_printf(dev, "could not allocate DMA region: %d\n", err); - goto fail; - } + mem_regions(®ions, &rcount, ®ions, &rcount); + for (i = 0; i < rcount; i++) { + err = lv1_allocate_device_dma_region(sc->sc_bus, sc->sc_dev, + regions[i].mr_size, 24 /* log_2(16 MB) */, + 0 /* 32-bit transfers */, &sc->sc_dma_base[i]); + if (err != 0) { + device_printf(dev, + "could not allocate DMA region %d: %d\n", i, err); + goto fail; + } - err = lv1_map_device_dma_region(sc->sc_bus, sc->sc_dev, 0 /* physmem */, - sc->sc_dma_base, 0x8000000 /* 128 MB */, - 0xf800000000000000UL /* see Cell IO/MMU docs */); - if (err != 0) { - device_printf(dev, "could not map DMA region: %d\n", err); - goto fail; + err = lv1_map_device_dma_region(sc->sc_bus, sc->sc_dev, + regions[i].mr_start, sc->sc_dma_base[i], regions[i].mr_size, + 0xf800000000000000UL /* see Cell IO/MMU docs */); + if (err != 0) { + device_printf(dev, + "could not map DMA region %d: %d\n", i, err); + goto fail; + } } err = bus_dma_tag_create(bus_get_dma_tag(dev), 32, 0, - BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, + BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL, NULL, 129*sizeof(struct glc_dmadesc), 1, 128*sizeof(struct glc_dmadesc), 0, NULL,NULL, &sc->sc_dmadesc_tag); @@ -219,11 +248,11 @@ glc_attach(device_t dev) &sc->sc_rxdmadesc_phys, 0); err = bus_dma_tag_create(bus_get_dma_tag(dev), 128, 0, - BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, + BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL, NULL, BUS_SPACE_MAXSIZE_32BIT, 0, BUS_SPACE_MAXSIZE_32BIT, 0, NULL,NULL, &sc->sc_rxdma_tag); err = bus_dma_tag_create(bus_get_dma_tag(dev), 1, 0, - BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, + BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL, NULL, BUS_SPACE_MAXSIZE_32BIT, 16, BUS_SPACE_MAXSIZE_32BIT, 0, NULL,NULL, &sc->sc_txdma_tag); @@ -469,15 +498,15 @@ glc_add_rxbuf_dma(struct glc_softc *sc, struct glc_rxsoft *rxs = &sc->sc_rxsoft[idx]; bzero(&sc->sc_rxdmadesc[idx], sizeof(sc->sc_rxdmadesc[idx])); - sc->sc_rxdmadesc[idx].paddr = sc->sc_dma_base + rxs->segment.ds_addr; + sc->sc_rxdmadesc[idx].paddr = glc_map_addr(sc, rxs->segment.ds_addr); sc->sc_rxdmadesc[idx].len = rxs->segment.ds_len; - sc->sc_rxdmadesc[idx].next = sc->sc_dma_base + sc->sc_rxdmadesc_phys + - ((idx + 1) % GLC_MAX_RX_PACKETS)*sizeof(sc->sc_rxdmadesc[idx]); + sc->sc_rxdmadesc[idx].next = glc_map_addr(sc, sc->sc_rxdmadesc_phys + + ((idx + 1) % GLC_MAX_RX_PACKETS)*sizeof(sc->sc_rxdmadesc[idx])); sc->sc_rxdmadesc[idx].cmd_stat = GELIC_DESCR_OWNED; rxs->rxs_desc_slot = idx; - rxs->rxs_desc = sc->sc_dma_base + sc->sc_rxdmadesc_phys + - idx*sizeof(struct glc_dmadesc); + rxs->rxs_desc = glc_map_addr(sc, sc->sc_rxdmadesc_phys + + idx*sizeof(struct glc_dmadesc)); return (0); } @@ -544,19 +573,19 @@ glc_encap(struct glc_softc *sc, struct m txs->txs_firstdesc = sc->next_txdma_slot; idx = txs->txs_firstdesc; - firstslotphys = sc->sc_dma_base + sc->sc_txdmadesc_phys + - txs->txs_firstdesc*sizeof(struct glc_dmadesc); + firstslotphys = glc_map_addr(sc, sc->sc_txdmadesc_phys + + txs->txs_firstdesc*sizeof(struct glc_dmadesc)); for (i = 0; i < nsegs; i++) { if (i+1 == nsegs) txs->txs_lastdesc = sc->next_txdma_slot; bzero(&sc->sc_txdmadesc[idx], sizeof(sc->sc_txdmadesc[idx])); - sc->sc_txdmadesc[idx].paddr = sc->sc_dma_base + segs[i].ds_addr; + sc->sc_txdmadesc[idx].paddr = glc_map_addr(sc, segs[i].ds_addr); sc->sc_txdmadesc[idx].len = segs[i].ds_len; - sc->sc_txdmadesc[idx].next = sc->sc_dma_base + + sc->sc_txdmadesc[idx].next = glc_map_addr(sc, sc->sc_txdmadesc_phys + - ((idx + 1) % GLC_MAX_TX_PACKETS)*sizeof(struct glc_dmadesc); + ((idx + 1) % GLC_MAX_TX_PACKETS)*sizeof(struct glc_dmadesc)); sc->sc_txdmadesc[idx].cmd_stat |= GELIC_CMDSTAT_NOIPSEC; if (i+1 == nsegs) { Modified: user/nwhitehorn/ps3/powerpc/ps3/if_glcreg.h ============================================================================== --- user/nwhitehorn/ps3/powerpc/ps3/if_glcreg.h Wed Sep 1 16:53:38 2010 (r212100) +++ user/nwhitehorn/ps3/powerpc/ps3/if_glcreg.h Wed Sep 1 17:02:31 2010 (r212101) @@ -70,7 +70,7 @@ struct glc_softc { int sc_tx_vlan, sc_rx_vlan; int sc_ifpflags; - uint64_t sc_dma_base; + uint64_t sc_dma_base[5]; bus_dma_tag_t sc_dmadesc_tag; int sc_irqid; Modified: user/nwhitehorn/ps3/powerpc/ps3/mmu_ps3.c ============================================================================== --- user/nwhitehorn/ps3/powerpc/ps3/mmu_ps3.c Wed Sep 1 16:53:38 2010 (r212100) +++ user/nwhitehorn/ps3/powerpc/ps3/mmu_ps3.c Wed Sep 1 17:02:31 2010 (r212101) @@ -264,7 +264,7 @@ mps3_pte_insert(u_int ptegidx, struct lp if (result != 0) { /* No freeable slots in either PTEG? We're hosed. */ - mtmsr(mfmsr() | PSL_DR); panic("moea64_pte_insert: overflow"); + panic("mps3_pte_insert: overflow (%d)", result); return (-1); } Modified: user/nwhitehorn/ps3/powerpc/ps3/platform_ps3.c ============================================================================== --- user/nwhitehorn/ps3/powerpc/ps3/platform_ps3.c Wed Sep 1 16:53:38 2010 (r212100) +++ user/nwhitehorn/ps3/powerpc/ps3/platform_ps3.c Wed Sep 1 17:02:31 2010 (r212101) @@ -62,6 +62,7 @@ static int ps3_probe(platform_t); static int ps3_attach(platform_t); static void ps3_mem_regions(platform_t, struct mem_region **phys, int *physsz, struct mem_region **avail, int *availsz); +static vm_offset_t ps3_real_maxaddr(platform_t); static u_long ps3_timebase_freq(platform_t, struct cpuref *cpuref); static int ps3_smp_first_cpu(platform_t, struct cpuref *cpuref); static int ps3_smp_next_cpu(platform_t, struct cpuref *cpuref); @@ -73,6 +74,7 @@ static platform_method_t ps3_methods[] = PLATFORMMETHOD(platform_probe, ps3_probe), PLATFORMMETHOD(platform_attach, ps3_attach), PLATFORMMETHOD(platform_mem_regions, ps3_mem_regions), + PLATFORMMETHOD(platform_real_maxaddr, ps3_real_maxaddr), PLATFORMMETHOD(platform_timebase_freq, ps3_timebase_freq), PLATFORMMETHOD(platform_smp_first_cpu, ps3_smp_first_cpu), @@ -114,34 +116,48 @@ ps3_probe(platform_t plat) #endif } +#define MEM_REGIONS 2 +static struct mem_region avail_regions[MEM_REGIONS]; + static int ps3_attach(platform_t plat) { + uint64_t lpar_id, junk, ppe_id; + + /* Get real mode memory region */ + avail_regions[0].mr_start = 0; + lv1_get_logical_partition_id(&lpar_id); + lv1_get_logical_ppe_id(&ppe_id); + lv1_get_repository_node_value(lpar_id, + lv1_repository_string("bi") >> 32, lv1_repository_string("pu"), + ppe_id, lv1_repository_string("rm_size"), + &avail_regions[0].mr_size, &junk); + + /* Now get extended memory region */ + lv1_get_repository_node_value(lpar_id, + lv1_repository_string("bi") >> 32, + lv1_repository_string("rgntotal"), 0, 0, + &avail_regions[1].mr_size, &junk); + + /* Convert to maximum amount we can allocate in 16 MB pages */ + avail_regions[1].mr_size -= avail_regions[0].mr_size; + avail_regions[1].mr_size -= avail_regions[1].mr_size % (16*1024*1024); + + lv1_allocate_memory(avail_regions[1].mr_size, 24 /* 16 MB pages */, + 0, 0x04 /* any address */, &avail_regions[1].mr_start, &junk); pmap_mmu_install("mmu_ps3", BUS_PROBE_SPECIFIC); return (0); } -#define MEM_REGIONS 8 -static struct mem_region avail_regions[MEM_REGIONS]; - void ps3_mem_regions(platform_t plat, struct mem_region **phys, int *physsz, struct mem_region **avail, int *availsz) { - uint64_t lpar_id, junk, ppe_id; - - avail_regions[0].mr_start = 0; - lv1_get_logical_partition_id(&lpar_id); - lv1_get_logical_ppe_id(&ppe_id); - lv1_get_repository_node_value(lpar_id, - lv1_repository_string("bi") >> 32, lv1_repository_string("pu"), - ppe_id, lv1_repository_string("rm_size"), - &avail_regions[0].mr_size, &junk); *phys = *avail = avail_regions; - *physsz = *availsz = 1; + *physsz = *availsz = MEM_REGIONS; } static u_long @@ -223,3 +239,10 @@ ps3_reset(platform_t plat) { lv1_panic(1); } + +static vm_offset_t +ps3_real_maxaddr(platform_t plat) +{ + return (avail_regions[0].mr_start + avail_regions[0].mr_size); +} + From owner-svn-src-user@FreeBSD.ORG Thu Sep 2 16:09:47 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 21F4B10656F5; Thu, 2 Sep 2010 16:09:47 +0000 (UTC) (envelope-from nwhitehorn@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0FB1B8FC16; Thu, 2 Sep 2010 16:09:47 +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 o82G9ltI010464; Thu, 2 Sep 2010 16:09:47 GMT (envelope-from nwhitehorn@svn.freebsd.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o82G9kJ1010454; Thu, 2 Sep 2010 16:09:46 GMT (envelope-from nwhitehorn@svn.freebsd.org) Message-Id: <201009021609.o82G9kJ1010454@svn.freebsd.org> From: Nathan Whitehorn Date: Thu, 2 Sep 2010 16:09:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r212151 - in user/nwhitehorn/ps3: powerpc/aim powerpc/booke powerpc/powerpc powerpc/ps3 sys X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 02 Sep 2010 16:09:47 -0000 Author: nwhitehorn Date: Thu Sep 2 16:09:46 2010 New Revision: 212151 URL: http://svn.freebsd.org/changeset/base/212151 Log: Bring up both threads on Cell in a useful way. This consists of several changes: - Provide a new method (based on the one on i386) to provide MD idle routines. These can be overridden by the hypervisor module if required. - Introduce a new mechanism to the platform KOBJ to report CPU topology. - Extend the PS3 hypervisor module to use the above. - Add IPI support to ps3pic. Modified: user/nwhitehorn/ps3/powerpc/aim/machdep.c user/nwhitehorn/ps3/powerpc/booke/machdep.c user/nwhitehorn/ps3/powerpc/powerpc/cpu.c user/nwhitehorn/ps3/powerpc/powerpc/mp_machdep.c user/nwhitehorn/ps3/powerpc/powerpc/platform.c user/nwhitehorn/ps3/powerpc/powerpc/platform_if.m user/nwhitehorn/ps3/powerpc/ps3/platform_ps3.c user/nwhitehorn/ps3/powerpc/ps3/ps3pic.c user/nwhitehorn/ps3/sys/smp.h Modified: user/nwhitehorn/ps3/powerpc/aim/machdep.c ============================================================================== --- user/nwhitehorn/ps3/powerpc/aim/machdep.c Thu Sep 2 16:09:09 2010 (r212150) +++ user/nwhitehorn/ps3/powerpc/aim/machdep.c Thu Sep 2 16:09:46 2010 (r212151) @@ -623,52 +623,6 @@ cpu_halt(void) OF_exit(); } -void -cpu_idle(int busy) -{ - register_t msr; - uint16_t vers; - - msr = mfmsr(); - vers = mfpvr() >> 16; - -#ifdef INVARIANTS - if ((msr & PSL_EE) != PSL_EE) { - struct thread *td = curthread; - printf("td msr %#lx\n", (u_long)td->td_md.md_saved_msr); - panic("ints disabled in idleproc!"); - } -#endif - if (powerpc_pow_enabled) { - switch (vers) { - case IBM970: - case IBM970FX: - case IBM970MP: - case MPC7447A: - case MPC7448: - case MPC7450: - case MPC7455: - case MPC7457: - __asm __volatile("\ - dssall; sync; mtmsr %0; isync" - :: "r"(msr | PSL_POW)); - break; - default: - powerpc_sync(); - mtmsr(msr | PSL_POW); - isync(); - break; - } - } -} - -int -cpu_idle_wakeup(int cpu) -{ - - return (0); -} - int ptrace_set_pc(struct thread *td, unsigned long addr) { Modified: user/nwhitehorn/ps3/powerpc/booke/machdep.c ============================================================================== --- user/nwhitehorn/ps3/powerpc/booke/machdep.c Thu Sep 2 16:09:09 2010 (r212150) +++ user/nwhitehorn/ps3/powerpc/booke/machdep.c Thu Sep 2 16:09:46 2010 (r212151) @@ -468,38 +468,6 @@ cpu_flush_dcache(void *ptr, size_t len) /* TBD */ } -/* - * cpu_idle - * - * Set Wait state enable. - */ -void -cpu_idle (int busy) -{ - register_t msr; - - msr = mfmsr(); - -#ifdef INVARIANTS - if ((msr & PSL_EE) != PSL_EE) { - struct thread *td = curthread; - printf("td msr %x\n", td->td_md.md_saved_msr); - panic("ints disabled in idleproc!"); - } -#endif - - /* Freescale E500 core RM section 6.4.1. */ - msr = msr | PSL_WE; - __asm __volatile("msync; mtmsr %0; isync" :: "r" (msr)); -} - -int -cpu_idle_wakeup(int cpu) -{ - - return (0); -} - void spinlock_enter(void) { Modified: user/nwhitehorn/ps3/powerpc/powerpc/cpu.c ============================================================================== --- user/nwhitehorn/ps3/powerpc/powerpc/cpu.c Thu Sep 2 16:09:09 2010 (r212150) +++ user/nwhitehorn/ps3/powerpc/powerpc/cpu.c Thu Sep 2 16:09:46 2010 (r212151) @@ -64,6 +64,7 @@ #include #include #include +#include #include #include @@ -73,12 +74,15 @@ #include #include -int powerpc_pow_enabled; - static void cpu_6xx_setup(int cpuid, uint16_t vers); static void cpu_e500_setup(int cpuid, uint16_t vers); static void cpu_970_setup(int cpuid, uint16_t vers); +int powerpc_pow_enabled; +void (*cpu_idle_hook)(void) = NULL; +static void cpu_idle_60x(void); +static void cpu_idle_e500(void); + struct cputab { const char *name; uint16_t version; @@ -377,6 +381,9 @@ cpu_6xx_setup(int cpuid, uint16_t vers) } printf("cpu%d: HID0 %b\n", cpuid, (int)hid0, bitmask); + + if (cpu_idle_hook == NULL) + cpu_idle_hook = cpu_idle_60x; } @@ -444,6 +451,9 @@ cpu_e500_setup(int cpuid, uint16_t vers) mtspr(SPR_HID0, hid0); printf("cpu%d: HID0 %b\n", cpuid, (int)hid0, HID0_E500_BITMASK); + + if (cpu_idle_hook == NULL) + cpu_idle_hook = cpu_idle_e500; } static void @@ -481,6 +491,8 @@ cpu_970_setup(int cpuid, uint16_t vers) : "=r" (hid0_hi) : "K" (SPR_HID0)); printf("cpu%d: HID0 %b\n", cpuid, (int)(hid0_hi), HID0_970_BITMASK); #endif + + cpu_idle_hook = cpu_idle_60x; } static int @@ -493,3 +505,74 @@ cpu_feature_bit(SYSCTL_HANDLER_ARGS) return (sysctl_handle_int(oidp, &result, 0, req)); } +void +cpu_idle(int busy) +{ + +#ifdef INVARIANTS + if ((mfmsr() & PSL_EE) != PSL_EE) { + struct thread *td = curthread; + printf("td msr %#lx\n", (u_long)td->td_md.md_saved_msr); + panic("ints disabled in idleproc!"); + } +#endif + + if (cpu_idle_hook != NULL) + cpu_idle_hook(); +} + +int +cpu_idle_wakeup(int cpu) +{ + return (0); +} + +static void +cpu_idle_60x(void) +{ + register_t msr; + uint16_t vers; + + if (!powerpc_pow_enabled) + return; + + msr = mfmsr(); + vers = mfpvr() >> 16; + +#ifdef AIM + switch (vers) { + case IBM970: + case IBM970FX: + case IBM970MP: + case MPC7447A: + case MPC7448: + case MPC7450: + case MPC7455: + case MPC7457: + __asm __volatile("\ + dssall; sync; mtmsr %0; isync" + :: "r"(msr | PSL_POW)); + break; + default: + powerpc_sync(); + mtmsr(msr | PSL_POW); + isync(); + break; + } +#endif +} + +static void +cpu_idle_e500(void) +{ + register_t msr; + + msr = mfmsr(); + +#ifdef E500 + /* Freescale E500 core RM section 6.4.1. */ + __asm __volatile("msync; mtmsr %0; isync" :: + "r" (msr | PSL_WE)); +#endif +} + Modified: user/nwhitehorn/ps3/powerpc/powerpc/mp_machdep.c ============================================================================== --- user/nwhitehorn/ps3/powerpc/powerpc/mp_machdep.c Thu Sep 2 16:09:09 2010 (r212150) +++ user/nwhitehorn/ps3/powerpc/powerpc/mp_machdep.c Thu Sep 2 16:09:46 2010 (r212151) @@ -100,13 +100,6 @@ machdep_ap_bootstrap(void) sched_throw(NULL); } -struct cpu_group * -cpu_topo(void) -{ - - return (smp_topo_none()); -} - void cpu_mp_setmaxid(void) { Modified: user/nwhitehorn/ps3/powerpc/powerpc/platform.c ============================================================================== --- user/nwhitehorn/ps3/powerpc/powerpc/platform.c Thu Sep 2 16:09:09 2010 (r212150) +++ user/nwhitehorn/ps3/powerpc/powerpc/platform.c Thu Sep 2 16:09:46 2010 (r212151) @@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -111,6 +112,14 @@ platform_smp_start_cpu(struct pcpu *cpu) return (PLATFORM_SMP_START_CPU(plat_obj, cpu)); } +#ifdef SMP +struct cpu_group * +cpu_topo(void) +{ + return (PLATFORM_SMP_TOPO(plat_obj)); +} +#endif + /* * Reset back to firmware. */ Modified: user/nwhitehorn/ps3/powerpc/powerpc/platform_if.m ============================================================================== --- user/nwhitehorn/ps3/powerpc/powerpc/platform_if.m Thu Sep 2 16:09:09 2010 (r212150) +++ user/nwhitehorn/ps3/powerpc/powerpc/platform_if.m Thu Sep 2 16:09:46 2010 (r212151) @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -67,6 +68,14 @@ CODE { { return (ENOENT); } + static struct cpu_group *platform_null_smp_topo(platform_t plat) + { +#ifdef SMP + return (smp_topo_none()); +#else + return (NULL); +#endif + } static vm_offset_t platform_null_real_maxaddr(platform_t plat) { return (VM_MAX_ADDRESS); @@ -176,6 +185,13 @@ METHOD int smp_start_cpu { }; /** + * @brief Return SMP topology + */ +METHOD cpu_group_t smp_topo { + platform_t _plat; +} DEFAULT platform_null_smp_topo; + +/** * @brief Reset system */ METHOD void reset { Modified: user/nwhitehorn/ps3/powerpc/ps3/platform_ps3.c ============================================================================== --- user/nwhitehorn/ps3/powerpc/ps3/platform_ps3.c Thu Sep 2 16:09:09 2010 (r212150) +++ user/nwhitehorn/ps3/powerpc/ps3/platform_ps3.c Thu Sep 2 16:09:46 2010 (r212151) @@ -64,11 +64,15 @@ static void ps3_mem_regions(platform_t, struct mem_region **avail, int *availsz); static vm_offset_t ps3_real_maxaddr(platform_t); static u_long ps3_timebase_freq(platform_t, struct cpuref *cpuref); +#ifdef SMP static int ps3_smp_first_cpu(platform_t, struct cpuref *cpuref); static int ps3_smp_next_cpu(platform_t, struct cpuref *cpuref); static int ps3_smp_get_bsp(platform_t, struct cpuref *cpuref); static int ps3_smp_start_cpu(platform_t, struct pcpu *cpu); +static struct cpu_group *ps3_smp_topo(platform_t); +#endif static void ps3_reset(platform_t); +static void ps3_cpu_idle(void); static platform_method_t ps3_methods[] = { PLATFORMMETHOD(platform_probe, ps3_probe), @@ -77,10 +81,13 @@ static platform_method_t ps3_methods[] = PLATFORMMETHOD(platform_real_maxaddr, ps3_real_maxaddr), PLATFORMMETHOD(platform_timebase_freq, ps3_timebase_freq), +#ifdef SMP PLATFORMMETHOD(platform_smp_first_cpu, ps3_smp_first_cpu), PLATFORMMETHOD(platform_smp_next_cpu, ps3_smp_next_cpu), PLATFORMMETHOD(platform_smp_get_bsp, ps3_smp_get_bsp), PLATFORMMETHOD(platform_smp_start_cpu, ps3_smp_start_cpu), + PLATFORMMETHOD(platform_smp_topo, ps3_smp_topo), +#endif PLATFORMMETHOD(platform_reset, ps3_reset), @@ -147,6 +154,7 @@ ps3_attach(platform_t plat) 0, 0x04 /* any address */, &avail_regions[1].mr_start, &junk); pmap_mmu_install("mmu_ps3", BUS_PROBE_SPECIFIC); + cpu_idle_hook = ps3_cpu_idle; return (0); } @@ -174,6 +182,7 @@ ps3_timebase_freq(platform_t plat, struc return (ticks); } +#ifdef SMP static int ps3_smp_first_cpu(platform_t plat, struct cpuref *cpuref) { @@ -210,7 +219,6 @@ ps3_smp_get_bsp(platform_t plat, struct static int ps3_smp_start_cpu(platform_t plat, struct pcpu *pc) { -#ifdef SMP /* loader(8) is spinning on 0x40 == 0 right now */ uint32_t *secondary_spin_sem = (uint32_t *)(0x40); int timeout; @@ -228,12 +236,15 @@ ps3_smp_start_cpu(platform_t plat, struc DELAY(100); return ((pc->pc_awake) ? 0 : EBUSY); -#else - /* No SMP support */ - return (ENXIO); -#endif } +static struct cpu_group * +ps3_smp_topo(platform_t plat) +{ + return (smp_topo_1level(CG_SHARE_L1, 2, CG_FLAG_SMT)); +} +#endif + static void ps3_reset(platform_t plat) { @@ -246,3 +257,19 @@ ps3_real_maxaddr(platform_t plat) return (avail_regions[0].mr_start + avail_regions[0].mr_size); } +static void +ps3_cpu_idle(void) +{ + static volatile int pausing = 0; + + /* + * XXX: It appears that the PS3 can livelock if both threads + * call lv1_pause(0) simultaneously. + */ + if (!atomic_cmpset_int(&pausing, 0, 1)) + return; + + lv1_pause(0); + pausing = 0; +} + Modified: user/nwhitehorn/ps3/powerpc/ps3/ps3pic.c ============================================================================== --- user/nwhitehorn/ps3/powerpc/ps3/ps3pic.c Thu Sep 2 16:09:09 2010 (r212150) +++ user/nwhitehorn/ps3/powerpc/ps3/ps3pic.c Thu Sep 2 16:09:46 2010 (r212151) @@ -62,6 +62,7 @@ struct ps3pic_softc { uint64_t *bitmap_thread1; uint64_t *mask_thread1; + uint64_t sc_ipi_outlet[2]; int sc_vector[64]; }; @@ -119,9 +120,6 @@ ps3pic_attach(device_t dev) uint64_t ppe; int thread; - powerpc_register_pic(dev, 64); - root_pic = dev; /* PS3s have only one PIC */ - sc = device_get_softc(dev); sc->bitmap_thread0 = contigmalloc(128 /* 512 bits * 2 */, M_PS3PIC, @@ -138,8 +136,19 @@ ps3pic_attach(device_t dev) #ifdef SMP lv1_configure_irq_state_bitmap(ppe, !thread, vtophys(sc->bitmap_thread1)); + + /* Map both IPIs to the same VIRQ to avoid changes in intr_machdep */ + lv1_construct_event_receive_port(&sc->sc_ipi_outlet[0]); + lv1_connect_irq_plug_ext(ppe, thread, sc->sc_ipi_outlet[0], + sc->sc_ipi_outlet[0], 0); + lv1_construct_event_receive_port(&sc->sc_ipi_outlet[1]); + lv1_connect_irq_plug_ext(ppe, !thread, sc->sc_ipi_outlet[0], + sc->sc_ipi_outlet[1], 0); #endif + powerpc_register_pic(dev, sc->sc_ipi_outlet[0]); + root_pic = dev; /* PS3s have only one PIC */ + return (0); } @@ -175,9 +184,6 @@ ps3pic_enable(device_t dev, u_int irq, u { struct ps3pic_softc *sc; - if (irq > 63) /* IPI */ - return; - sc = device_get_softc(dev); sc->sc_vector[irq] = vector; @@ -197,8 +203,12 @@ ps3pic_eoi(device_t dev, u_int irq) } static void -ps3pic_ipi(device_t dev, u_int irq) +ps3pic_ipi(device_t dev, u_int cpu) { + struct ps3pic_softc *sc; + sc = device_get_softc(dev); + + lv1_send_event_locally(sc->sc_ipi_outlet[cpu]); } static void @@ -208,6 +218,11 @@ ps3pic_mask(device_t dev, u_int irq) uint64_t ppe; sc = device_get_softc(dev); + + /* Do not mask IPIs! */ + if (irq == sc->sc_ipi_outlet[0]) + return; + sc->mask_thread0[0] &= ~(1UL << (63 - irq)); sc->mask_thread1[0] &= ~(1UL << (63 - irq)); Modified: user/nwhitehorn/ps3/sys/smp.h ============================================================================== --- user/nwhitehorn/ps3/sys/smp.h Thu Sep 2 16:09:09 2010 (r212150) +++ user/nwhitehorn/ps3/sys/smp.h Thu Sep 2 16:09:46 2010 (r212151) @@ -16,8 +16,6 @@ #ifndef LOCORE -#ifdef SMP - /* * Topology of a NUMA or HTT system. * @@ -41,6 +39,8 @@ struct cpu_group { int8_t cg_flags; /* Traversal modifiers. */ }; +typedef struct cpu_group *cpu_group_t; + /* * Defines common resources for CPUs in the group. The highest level * resource should be used when multiple are shared. @@ -60,6 +60,7 @@ struct cpu_group { /* * Convenience routines for building topologies. */ +#ifdef SMP struct cpu_group *smp_topo(void); struct cpu_group *smp_topo_none(void); struct cpu_group *smp_topo_1level(int l1share, int l1count, int l1flags); From owner-svn-src-user@FreeBSD.ORG Sat Sep 4 17:04:35 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 491011065695; Sat, 4 Sep 2010 17:04:35 +0000 (UTC) (envelope-from nwhitehorn@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1E8CD8FC0A; Sat, 4 Sep 2010 17:04:35 +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 o84H4ZXH024208; Sat, 4 Sep 2010 17:04:35 GMT (envelope-from nwhitehorn@svn.freebsd.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o84H4ZOQ024206; Sat, 4 Sep 2010 17:04:35 GMT (envelope-from nwhitehorn@svn.freebsd.org) Message-Id: <201009041704.o84H4ZOQ024206@svn.freebsd.org> From: Nathan Whitehorn Date: Sat, 4 Sep 2010 17:04:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r212211 - user/nwhitehorn/ps3/powerpc/ps3 X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 04 Sep 2010 17:04:35 -0000 Author: nwhitehorn Date: Sat Sep 4 17:04:34 2010 New Revision: 212211 URL: http://svn.freebsd.org/changeset/base/212211 Log: Fix a bug where the passed PTEG index to mps3_pte_insert was taken as the PTEG index where the evicted PTE came from, although the evicted PTE may have come from the secondary PTEG. Fix this by using the page table slot of the inserted PTE to get the evicted PTE's PTEG. Modified: user/nwhitehorn/ps3/powerpc/ps3/mmu_ps3.c Modified: user/nwhitehorn/ps3/powerpc/ps3/mmu_ps3.c ============================================================================== --- user/nwhitehorn/ps3/powerpc/ps3/mmu_ps3.c Sat Sep 4 16:27:14 2010 (r212210) +++ user/nwhitehorn/ps3/powerpc/ps3/mmu_ps3.c Sat Sep 4 17:04:34 2010 (r212211) @@ -51,6 +51,7 @@ #include "ps3-hvcall.h" #define VSID_HASH_MASK 0x0000007fffffffffUL +#define PTESYNC() __asm __volatile("ptesync") extern int ps3fb_remap(void); @@ -198,6 +199,7 @@ mps3_pte_synch(struct lpte *pt, struct l uint64_t halfbucket[4], rcbits; uint64_t slot = (uint64_t)(pt)-1; + PTESYNC(); lv1_read_htab_entries(mps3_vas_id, slot & ~0x3UL, &halfbucket[0], &halfbucket[1], &halfbucket[2], &halfbucket[3], &rcbits); @@ -211,7 +213,6 @@ mps3_pte_synch(struct lpte *pt, struct l ("PTE upper word %#lx != %#lx\n", halfbucket[slot & 0x3], pvo_pt->pte_hi)); - pvo_pt->pte_lo &= ~(LPTE_CHG | LPTE_REF); pvo_pt->pte_lo |= (rcbits >> ((3 - (slot & 0x3))*16)) & (LPTE_CHG | LPTE_REF); } @@ -285,12 +286,16 @@ mps3_pte_insert(u_int ptegidx, struct lp * here after a fault. */ + ptegidx = index >> 3; /* Where the sacrifice PTE was found */ if (evicted.pte_hi & LPTE_HID) ptegidx ^= moea64_pteg_mask; /* PTEs indexed by primary */ + result = 0; LIST_FOREACH(pvo, &moea64_pvo_table[ptegidx], pvo_olink) { - if ((pvo->pvo_pte.lpte.pte_hi & LPTE_AVPN_MASK) - == (evicted.pte_hi & LPTE_AVPN_MASK)) { + if (!PVO_PTEGIDX_ISSET(pvo)) + continue; + + if (pvo->pvo_pte.lpte.pte_hi == (evicted.pte_hi | LPTE_VALID)) { KASSERT(pvo->pvo_pte.lpte.pte_hi & LPTE_VALID, ("Invalid PVO for valid PTE!")); pvo->pvo_pte.lpte.pte_hi &= ~LPTE_VALID; @@ -299,10 +304,13 @@ mps3_pte_insert(u_int ptegidx, struct lp PVO_PTEGIDX_CLR(pvo); moea64_pte_valid--; moea64_pte_overflow++; + result = 1; break; } } + KASSERT(result == 1, ("PVO for sacrifice PTE not found")); + return (index & 0x7); } From owner-svn-src-user@FreeBSD.ORG Sat Sep 4 17:27:48 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DC89410656BE; Sat, 4 Sep 2010 17:27:48 +0000 (UTC) (envelope-from nwhitehorn@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id CC7FE8FC1B; Sat, 4 Sep 2010 17:27:48 +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 o84HRm4o025475; Sat, 4 Sep 2010 17:27:48 GMT (envelope-from nwhitehorn@svn.freebsd.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o84HRmNt025473; Sat, 4 Sep 2010 17:27:48 GMT (envelope-from nwhitehorn@svn.freebsd.org) Message-Id: <201009041727.o84HRmNt025473@svn.freebsd.org> From: Nathan Whitehorn Date: Sat, 4 Sep 2010 17:27:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r212212 - user/nwhitehorn/ps3/powerpc/powerpc X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 04 Sep 2010 17:27:48 -0000 Author: nwhitehorn Date: Sat Sep 4 17:27:48 2010 New Revision: 212212 URL: http://svn.freebsd.org/changeset/base/212212 Log: It does not make sense to allocate 30MB of physical memory for bounce pages on low energy machines. On a PS3, 15% of the available physical memory was going into bounce page reservations. Instead, cap the number at 2.5% of physical memory or 30MB, whichever is smaller. Modified: user/nwhitehorn/ps3/powerpc/powerpc/busdma_machdep.c Modified: user/nwhitehorn/ps3/powerpc/powerpc/busdma_machdep.c ============================================================================== --- user/nwhitehorn/ps3/powerpc/powerpc/busdma_machdep.c Sat Sep 4 17:04:34 2010 (r212211) +++ user/nwhitehorn/ps3/powerpc/powerpc/busdma_machdep.c Sat Sep 4 17:27:48 2010 (r212212) @@ -53,7 +53,7 @@ __FBSDID("$FreeBSD$"); #include #include -#define MAX_BPAGES 8192 +#define MAX_BPAGES MIN(8192, physmem/40) struct bounce_zone; From owner-svn-src-user@FreeBSD.ORG Sat Sep 4 23:53:47 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9118B10656AA; Sat, 4 Sep 2010 23:53:47 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 74FB68FC08; Sat, 4 Sep 2010 23:53:47 +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 o84Nrljv044920; Sat, 4 Sep 2010 23:53:47 GMT (envelope-from dougb@svn.freebsd.org) Received: (from dougb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o84NrlIN044918; Sat, 4 Sep 2010 23:53:47 GMT (envelope-from dougb@svn.freebsd.org) Message-Id: <201009042353.o84NrlIN044918@svn.freebsd.org> From: Doug Barton Date: Sat, 4 Sep 2010 23:53:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r212215 - user/dougb/portmaster X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 04 Sep 2010 23:53:47 -0000 Author: dougb Date: Sat Sep 4 23:53:47 2010 New Revision: 212215 URL: http://svn.freebsd.org/changeset/base/212215 Log: In messages that refer to the INDEX file, use the variable to make it clear what we're working with. Be more careful to check that there is a line for the port in the INDEX when working --index-only. In dependency_check() be clear when we're using the INDEX instead of ports In the package fetching routine use a better string match to see if we have already downloaded the directory listing. The previous one worked but would match too many files for net* and x11*, especially when installing a lot of ports. So add a '.' to differentiate these. Modified: user/dougb/portmaster/portmaster Modified: user/dougb/portmaster/portmaster ============================================================================== --- user/dougb/portmaster/portmaster Sat Sep 4 21:23:46 2010 (r212214) +++ user/dougb/portmaster/portmaster Sat Sep 4 23:53:47 2010 (r212215) @@ -1086,7 +1086,7 @@ if [ -n "$CLEAN_PACKAGES" ]; then fi else if ! port_ver=`parse_index $origin name`; then - echo "===>>> Cannot determine latest version of ${package##*/} from INDEX" + echo "===>>> Cannot determine latest version of ${package##*/} from $PM_INDEX" fi fi @@ -1422,7 +1422,9 @@ check_for_updates () { if [ -n "$PM_INDEX" ]; then case "$PM_INDEX_PORTS" in - *${iport}*) port_ver=`parse_index $origin name` ; do_update=upd_idx ;; + *${iport}*) port_ver=`parse_index $origin name` || + fail "No entry for $origin in $PM_INDEX" + do_update=upd_idx ;; esac [ -z "$do_update" -a -z "$LIST_PLUS" ] && { @@ -2106,7 +2108,7 @@ update_build_l () { pm_cd $pd/$origin && new_port=`pm_make -V PKGNAME` else new_port=`parse_index $origin name` || - fail "No INDEX entry for $origin" + fail "No entry for $origin in $PM_INDEX" fi case `pkg_version -t $iport $new_port 2>/dev/null` in @@ -2232,7 +2234,11 @@ dependency_check () { # Print a message here because sometimes list generation takes # a long time to return. - echo "===>>> Gathering dependency list for $portdir from ports" + if [ -z "$PM_INDEX_ONLY" ]; then + echo "===>>> Gathering dependency list for $portdir from ports" + else + echo "===>>> Gathering dependency list for $portdir from ${PM_INDEX##*/}" + fi d_port_list=`gen_dep_list $1` if [ -z "$d_port_list" ]; then @@ -2959,7 +2965,12 @@ fi # START -[ -z "$PM_INDEX_ONLY" ] && { pm_cd $pd/$portdir || no_valid_port; } +if [ -z "$PM_INDEX_ONLY" ]; then + pm_cd $pd/$portdir || no_valid_port +else + new_port=`parse_index $portdir name` || + fail "No entry for $portdir in $PM_INDEX" +fi if [ -z "$PM_DEPTH" ]; then PM_DEPTH="${upg_port:-$portdir} " @@ -3154,7 +3165,8 @@ if [ -z "$new_port" ]; then if [ -z "$PM_INDEX_ONLY" ]; then new_port=`pm_make -V PKGNAME` else - new_port=`parse_index $portdir name` || fail "No INDEX entry for $origin" + new_port=`parse_index $portdir name` || + fail "No entry for $origin in $PM_INDEX" fi fi @@ -3250,7 +3262,7 @@ fetch_package () { fi if [ -z "$latest_pv" -a -z "$PM_PACKAGES_LOCAL" ]; then - dirlist=`echo ${TMPDIR}/f-${PM_PARENT_PID}-dl-${portdir%/*}*` + dirlist=`echo ${TMPDIR}/f-${PM_PARENT_PID}-dl-${portdir%/*}\.*` if [ ! -r "$dirlist" ]; then pm_unlink $dirlist # JIC dirlist=`pm_mktemp dl-${portdir%/*}`