From owner-svn-src-stable-8@FreeBSD.ORG Sun Dec 4 01:15:52 2011 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7C58C1065677; Sun, 4 Dec 2011 01:15:52 +0000 (UTC) (envelope-from alc@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6B9C08FC08; Sun, 4 Dec 2011 01:15:52 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pB41Fq5M064197; Sun, 4 Dec 2011 01:15:52 GMT (envelope-from alc@svn.freebsd.org) Received: (from alc@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pB41Fqud064195; Sun, 4 Dec 2011 01:15:52 GMT (envelope-from alc@svn.freebsd.org) Message-Id: <201112040115.pB41Fqud064195@svn.freebsd.org> From: Alan Cox Date: Sun, 4 Dec 2011 01:15:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r228249 - stable/8/sys/fs/tmpfs X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 04 Dec 2011 01:15:52 -0000 Author: alc Date: Sun Dec 4 01:15:52 2011 New Revision: 228249 URL: http://svn.freebsd.org/changeset/base/228249 Log: MFC r218863 tmpfs_remove() isn't modifying the file's data, so it shouldn't set TMPFS_NODE_MODIFIED on the node. PR: 152488 Modified: stable/8/sys/fs/tmpfs/tmpfs_vnops.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/fs/tmpfs/tmpfs_vnops.c ============================================================================== --- stable/8/sys/fs/tmpfs/tmpfs_vnops.c Sat Dec 3 23:36:36 2011 (r228248) +++ stable/8/sys/fs/tmpfs/tmpfs_vnops.c Sun Dec 4 01:15:52 2011 (r228249) @@ -823,8 +823,7 @@ tmpfs_remove(struct vop_remove_args *v) tmpfs_free_dirent(tmp, de, TRUE); if (node->tn_links > 0) - node->tn_status |= TMPFS_NODE_ACCESSED | TMPFS_NODE_CHANGED | \ - TMPFS_NODE_MODIFIED; + node->tn_status |= TMPFS_NODE_ACCESSED | TMPFS_NODE_CHANGED; error = 0; out: From owner-svn-src-stable-8@FreeBSD.ORG Sun Dec 4 02:06:12 2011 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 81122106566B; Sun, 4 Dec 2011 02:06:12 +0000 (UTC) (envelope-from alc@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 705248FC12; Sun, 4 Dec 2011 02:06:12 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pB426CVx065758; Sun, 4 Dec 2011 02:06:12 GMT (envelope-from alc@svn.freebsd.org) Received: (from alc@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pB426C3m065756; Sun, 4 Dec 2011 02:06:12 GMT (envelope-from alc@svn.freebsd.org) Message-Id: <201112040206.pB426C3m065756@svn.freebsd.org> From: Alan Cox Date: Sun, 4 Dec 2011 02:06:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r228251 - stable/8/sys/vm X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 04 Dec 2011 02:06:12 -0000 Author: alc Date: Sun Dec 4 02:06:12 2011 New Revision: 228251 URL: http://svn.freebsd.org/changeset/base/228251 Log: MFC r224689 Fix an error in kmem_alloc_attr(). Unless "tries" is updated, kmem_alloc_attr() could get stuck in a loop. Modified: stable/8/sys/vm/vm_contig.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/vm/vm_contig.c ============================================================================== --- stable/8/sys/vm/vm_contig.c Sun Dec 4 01:22:22 2011 (r228250) +++ stable/8/sys/vm/vm_contig.c Sun Dec 4 02:06:12 2011 (r228251) @@ -253,6 +253,7 @@ retry: vm_contig_grow_cache(tries, low, high); vm_map_lock(map); VM_OBJECT_LOCK(object); + tries++; goto retry; } while (i != 0) { From owner-svn-src-stable-8@FreeBSD.ORG Sun Dec 4 06:09:02 2011 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CFC1C106566C; Sun, 4 Dec 2011 06:09:02 +0000 (UTC) (envelope-from alc@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id BDDBD8FC08; Sun, 4 Dec 2011 06:09:02 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pB4692K0073453; Sun, 4 Dec 2011 06:09:02 GMT (envelope-from alc@svn.freebsd.org) Received: (from alc@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pB4692J7073449; Sun, 4 Dec 2011 06:09:02 GMT (envelope-from alc@svn.freebsd.org) Message-Id: <201112040609.pB4692J7073449@svn.freebsd.org> From: Alan Cox Date: Sun, 4 Dec 2011 06:09:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r228253 - in stable/8/sys/amd64: amd64 include X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 04 Dec 2011 06:09:02 -0000 Author: alc Date: Sun Dec 4 06:09:02 2011 New Revision: 228253 URL: http://svn.freebsd.org/changeset/base/228253 Log: MFC r214425,214954 [1] According to the x86 architectural specifications, no virtual-to- physical page mapping should span two or more MTRRs of different types. Add a pmap function, pmap_demote_DMAP(), by which the MTRR module can ensure that the direct map region doesn't have such a mapping. [2] Fix a couple of nearby style errors in amd64_mrset(). [3] Re-enable the use of 1GB page mappings for implementing the direct map. (See also r197580 and r213897.) Modified: stable/8/sys/amd64/amd64/amd64_mem.c stable/8/sys/amd64/amd64/pmap.c stable/8/sys/amd64/include/pmap.h Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/amd64/amd64/amd64_mem.c ============================================================================== --- stable/8/sys/amd64/amd64/amd64_mem.c Sun Dec 4 02:13:54 2011 (r228252) +++ stable/8/sys/amd64/amd64/amd64_mem.c Sun Dec 4 06:09:02 2011 (r228253) @@ -35,6 +35,10 @@ __FBSDID("$FreeBSD$"); #include #include +#include +#include +#include + #include #include #include @@ -527,9 +531,9 @@ static int amd64_mrset(struct mem_range_softc *sc, struct mem_range_desc *mrd, int *arg) { struct mem_range_desc *targ; - int error = 0; + int error, i; - switch(*arg) { + switch (*arg) { case MEMRANGE_SET_UPDATE: /* * Make sure that what's being asked for is even @@ -568,6 +572,21 @@ amd64_mrset(struct mem_range_softc *sc, return (EOPNOTSUPP); } + /* + * Ensure that the direct map region does not contain any mappings + * that span MTRRs of different types. However, the fixed MTRRs can + * be ignored, because a large page mapping the first 1 MB of physical + * memory is a special case that the processor handles. The entire + * TLB will be invalidated by amd64_mrstore(), so pmap_demote_DMAP() + * needn't do it. + */ + i = (sc->mr_cap & MR686_FIXMTRR) ? MTRR_N64K + MTRR_N16K + MTRR_N4K : 0; + mrd = sc->mr_desc + i; + for (; i < sc->mr_ndesc; i++, mrd++) { + if ((mrd->mr_flags & (MDF_ACTIVE | MDF_BOGUS)) == MDF_ACTIVE) + pmap_demote_DMAP(mrd->mr_base, mrd->mr_len, FALSE); + } + /* Update the hardware. */ amd64_mrstore(sc); @@ -657,6 +676,21 @@ amd64_mrinit(struct mem_range_softc *sc) if (mrd->mr_flags & MDF_ACTIVE) mrd->mr_flags |= MDF_FIRMWARE; } + + /* + * Ensure that the direct map region does not contain any mappings + * that span MTRRs of different types. However, the fixed MTRRs can + * be ignored, because a large page mapping the first 1 MB of physical + * memory is a special case that the processor handles. Invalidate + * any old TLB entries that might hold inconsistent memory type + * information. + */ + i = (sc->mr_cap & MR686_FIXMTRR) ? MTRR_N64K + MTRR_N16K + MTRR_N4K : 0; + mrd = sc->mr_desc + i; + for (; i < sc->mr_ndesc; i++, mrd++) { + if ((mrd->mr_flags & (MDF_ACTIVE | MDF_BOGUS)) == MDF_ACTIVE) + pmap_demote_DMAP(mrd->mr_base, mrd->mr_len, TRUE); + } } /* Modified: stable/8/sys/amd64/amd64/pmap.c ============================================================================== --- stable/8/sys/amd64/amd64/pmap.c Sun Dec 4 02:13:54 2011 (r228252) +++ stable/8/sys/amd64/amd64/pmap.c Sun Dec 4 06:09:02 2011 (r228253) @@ -447,7 +447,7 @@ create_pagetables(vm_paddr_t *firstaddr) if (ndmpdp < 4) /* Minimum 4GB of dirmap */ ndmpdp = 4; DMPDPphys = allocpages(firstaddr, NDMPML4E); - if (TRUE || (amd_feature & AMDID_PAGE1GB) == 0) + if ((amd_feature & AMDID_PAGE1GB) == 0) DMPDphys = allocpages(firstaddr, ndmpdp); dmaplimit = (vm_paddr_t)ndmpdp << PDPSHIFT; @@ -479,11 +479,16 @@ create_pagetables(vm_paddr_t *firstaddr) ((pdp_entry_t *)KPDPphys)[i + KPDPI] |= PG_RW | PG_V | PG_U; } - /* Now set up the direct map space using either 2MB or 1GB pages */ - /* Preset PG_M and PG_A because demotion expects it */ - if (TRUE || (amd_feature & AMDID_PAGE1GB) == 0) { + /* + * Now, set up the direct map region using either 2MB or 1GB pages. + * Later, if pmap_mapdev{_attr}() uses the direct map for non-write- + * back memory, pmap_change_attr() will demote any 2MB or 1GB page + * mappings that are partially used. + */ + if ((amd_feature & AMDID_PAGE1GB) == 0) { for (i = 0; i < NPDEPG * ndmpdp; i++) { ((pd_entry_t *)DMPDphys)[i] = (vm_paddr_t)i << PDRSHIFT; + /* Preset PG_M and PG_A because demotion expects it. */ ((pd_entry_t *)DMPDphys)[i] |= PG_RW | PG_V | PG_PS | PG_G | PG_M | PG_A; } @@ -497,6 +502,7 @@ create_pagetables(vm_paddr_t *firstaddr) for (i = 0; i < ndmpdp; i++) { ((pdp_entry_t *)DMPDPphys)[i] = (vm_paddr_t)i << PDPSHIFT; + /* Preset PG_M and PG_A because demotion expects it. */ ((pdp_entry_t *)DMPDPphys)[i] |= PG_RW | PG_V | PG_PS | PG_G | PG_M | PG_A; } @@ -4821,6 +4827,49 @@ pmap_change_attr_locked(vm_offset_t va, } /* + * Demotes any mapping within the direct map region that covers more than the + * specified range of physical addresses. This range's size must be a power + * of two and its starting address must be a multiple of its size. Since the + * demotion does not change any attributes of the mapping, a TLB invalidation + * is not mandatory. The caller may, however, request a TLB invalidation. + */ +void +pmap_demote_DMAP(vm_paddr_t base, vm_size_t len, boolean_t invalidate) +{ + pdp_entry_t *pdpe; + pd_entry_t *pde; + vm_offset_t va; + boolean_t changed; + + if (len < NBPDP) { + va = PHYS_TO_DMAP(base); + changed = FALSE; + PMAP_LOCK(kernel_pmap); + pdpe = pmap_pdpe(kernel_pmap, va); + if ((*pdpe & PG_V) == 0) + panic("pmap_demote_DMAP: invalid PDPE"); + if ((*pdpe & PG_PS) != 0) { + if (!pmap_demote_pdpe(kernel_pmap, pdpe, va)) + panic("pmap_demote_DMAP: PDPE failed"); + changed = TRUE; + } + if (len < NBPDR) { + pde = pmap_pdpe_to_pde(pdpe, va); + if ((*pde & PG_V) == 0) + panic("pmap_demote_DMAP: invalid PDE"); + if ((*pde & PG_PS) != 0) { + if (!pmap_demote_pde(kernel_pmap, pde, va)) + panic("pmap_demote_DMAP: PDE failed"); + changed = TRUE; + } + } + if (changed && invalidate) + pmap_invalidate_page(kernel_pmap, va); + PMAP_UNLOCK(kernel_pmap); + } +} + +/* * perform the pmap work for mincore */ int Modified: stable/8/sys/amd64/include/pmap.h ============================================================================== --- stable/8/sys/amd64/include/pmap.h Sun Dec 4 02:13:54 2011 (r228252) +++ stable/8/sys/amd64/include/pmap.h Sun Dec 4 06:09:02 2011 (r228253) @@ -305,6 +305,7 @@ extern vm_offset_t virtual_end; void pmap_bootstrap(vm_paddr_t *); int pmap_change_attr(vm_offset_t, vm_size_t, int); +void pmap_demote_DMAP(vm_paddr_t base, vm_size_t len, boolean_t invalidate); void pmap_init_pat(void); void pmap_kenter(vm_offset_t va, vm_paddr_t pa); void *pmap_kenter_temporary(vm_paddr_t pa, int i); From owner-svn-src-stable-8@FreeBSD.ORG Sun Dec 4 06:55:28 2011 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0799B106564A; Sun, 4 Dec 2011 06:55:28 +0000 (UTC) (envelope-from alc@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id EAFF68FC0A; Sun, 4 Dec 2011 06:55:27 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pB46tR8X074932; Sun, 4 Dec 2011 06:55:27 GMT (envelope-from alc@svn.freebsd.org) Received: (from alc@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pB46tRZL074930; Sun, 4 Dec 2011 06:55:27 GMT (envelope-from alc@svn.freebsd.org) Message-Id: <201112040655.pB46tRZL074930@svn.freebsd.org> From: Alan Cox Date: Sun, 4 Dec 2011 06:55:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r228254 - stable/8/sys/amd64/amd64 X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 04 Dec 2011 06:55:28 -0000 Author: alc Date: Sun Dec 4 06:55:27 2011 New Revision: 228254 URL: http://svn.freebsd.org/changeset/base/228254 Log: MFC r214563,214576 Add safety belts to pmap_demote_DMAP(). Modified: stable/8/sys/amd64/amd64/pmap.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/amd64/amd64/pmap.c ============================================================================== --- stable/8/sys/amd64/amd64/pmap.c Sun Dec 4 06:09:02 2011 (r228253) +++ stable/8/sys/amd64/amd64/pmap.c Sun Dec 4 06:55:27 2011 (r228254) @@ -4841,7 +4841,12 @@ pmap_demote_DMAP(vm_paddr_t base, vm_siz vm_offset_t va; boolean_t changed; - if (len < NBPDP) { + if (len == 0) + return; + KASSERT(powerof2(len), ("pmap_demote_DMAP: len is not a power of 2")); + KASSERT((base & (len - 1)) == 0, + ("pmap_demote_DMAP: base is not a multiple of len")); + if (len < NBPDP && base < dmaplimit) { va = PHYS_TO_DMAP(base); changed = FALSE; PMAP_LOCK(kernel_pmap); From owner-svn-src-stable-8@FreeBSD.ORG Sun Dec 4 07:18:54 2011 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EFDDB106564A; Sun, 4 Dec 2011 07:18:54 +0000 (UTC) (envelope-from alc@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C608A8FC13; Sun, 4 Dec 2011 07:18:54 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pB47IsXP075670; Sun, 4 Dec 2011 07:18:54 GMT (envelope-from alc@svn.freebsd.org) Received: (from alc@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pB47Iss3075668; Sun, 4 Dec 2011 07:18:54 GMT (envelope-from alc@svn.freebsd.org) Message-Id: <201112040718.pB47Iss3075668@svn.freebsd.org> From: Alan Cox Date: Sun, 4 Dec 2011 07:18:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r228255 - stable/8/sys/amd64/amd64 X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 04 Dec 2011 07:18:55 -0000 Author: alc Date: Sun Dec 4 07:18:54 2011 New Revision: 228255 URL: http://svn.freebsd.org/changeset/base/228255 Log: MFC r213897 Update pmap_extract() to handle 1GB page mappings. Some device drivers use pmap_extract() rather than pmap_kextract() on direct map addresses. Thus, pmap_extract() needs to be able to deal with 1GB page mappings if we are to use 1GB page mappings for the direct map. (See r197580.) Modified: stable/8/sys/amd64/amd64/pmap.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/amd64/amd64/pmap.c ============================================================================== --- stable/8/sys/amd64/amd64/pmap.c Sun Dec 4 06:55:27 2011 (r228254) +++ stable/8/sys/amd64/amd64/pmap.c Sun Dec 4 07:18:54 2011 (r228255) @@ -1141,26 +1141,33 @@ pmap_is_current(pmap_t pmap) vm_paddr_t pmap_extract(pmap_t pmap, vm_offset_t va) { - vm_paddr_t rtval; + pdp_entry_t *pdpe; + pd_entry_t *pde; pt_entry_t *pte; - pd_entry_t pde, *pdep; + vm_paddr_t pa; - rtval = 0; + pa = 0; PMAP_LOCK(pmap); - pdep = pmap_pde(pmap, va); - if (pdep != NULL) { - pde = *pdep; - if (pde) { - if ((pde & PG_PS) != 0) - rtval = (pde & PG_PS_FRAME) | (va & PDRMASK); - else { - pte = pmap_pde_to_pte(pdep, va); - rtval = (*pte & PG_FRAME) | (va & PAGE_MASK); + pdpe = pmap_pdpe(pmap, va); + if (pdpe != NULL && (*pdpe & PG_V) != 0) { + if ((*pdpe & PG_PS) != 0) + pa = (*pdpe & PG_PS_FRAME) | (va & PDPMASK); + else { + pde = pmap_pdpe_to_pde(pdpe, va); + if ((*pde & PG_V) != 0) { + if ((*pde & PG_PS) != 0) { + pa = (*pde & PG_PS_FRAME) | + (va & PDRMASK); + } else { + pte = pmap_pde_to_pte(pde, va); + pa = (*pte & PG_FRAME) | + (va & PAGE_MASK); + } } } } PMAP_UNLOCK(pmap); - return (rtval); + return (pa); } /* From owner-svn-src-stable-8@FreeBSD.ORG Sun Dec 4 07:28:50 2011 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D2055106566B; Sun, 4 Dec 2011 07:28:50 +0000 (UTC) (envelope-from alc@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C04448FC08; Sun, 4 Dec 2011 07:28:50 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pB47Sorc076018; Sun, 4 Dec 2011 07:28:50 GMT (envelope-from alc@svn.freebsd.org) Received: (from alc@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pB47SoeR076012; Sun, 4 Dec 2011 07:28:50 GMT (envelope-from alc@svn.freebsd.org) Message-Id: <201112040728.pB47SoeR076012@svn.freebsd.org> From: Alan Cox Date: Sun, 4 Dec 2011 07:28:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r228256 - in stable/8/sys: amd64/amd64 i386/i386 i386/xen ia64/ia64 mips/mips X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 04 Dec 2011 07:28:51 -0000 Author: alc Date: Sun Dec 4 07:28:50 2011 New Revision: 228256 URL: http://svn.freebsd.org/changeset/base/228256 Log: MFC r223732 When iterating over a paging queue, explicitly check for PG_MARKER, instead of relying on zeroed memory being interpreted as an empty PV list. Modified: stable/8/sys/amd64/amd64/pmap.c stable/8/sys/i386/i386/pmap.c stable/8/sys/i386/xen/pmap.c stable/8/sys/ia64/ia64/pmap.c stable/8/sys/mips/mips/pmap.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/amd64/amd64/pmap.c ============================================================================== --- stable/8/sys/amd64/amd64/pmap.c Sun Dec 4 07:18:54 2011 (r228255) +++ stable/8/sys/amd64/amd64/pmap.c Sun Dec 4 07:28:50 2011 (r228256) @@ -2028,7 +2028,7 @@ pmap_collect(pmap_t locked_pmap, struct vm_page_t m, free; TAILQ_FOREACH(m, &vpq->pl, pageq) { - if (m->hold_count || m->busy) + if ((m->flags & PG_MARKER) != 0 || m->hold_count || m->busy) continue; TAILQ_FOREACH_SAFE(pv, &m->md.pv_list, pv_list, next_pv) { va = pv->pv_va; Modified: stable/8/sys/i386/i386/pmap.c ============================================================================== --- stable/8/sys/i386/i386/pmap.c Sun Dec 4 07:18:54 2011 (r228255) +++ stable/8/sys/i386/i386/pmap.c Sun Dec 4 07:28:50 2011 (r228256) @@ -2166,7 +2166,7 @@ pmap_collect(pmap_t locked_pmap, struct sched_pin(); TAILQ_FOREACH(m, &vpq->pl, pageq) { - if (m->hold_count || m->busy) + if ((m->flags & PG_MARKER) != 0 || m->hold_count || m->busy) continue; TAILQ_FOREACH_SAFE(pv, &m->md.pv_list, pv_list, next_pv) { va = pv->pv_va; Modified: stable/8/sys/i386/xen/pmap.c ============================================================================== --- stable/8/sys/i386/xen/pmap.c Sun Dec 4 07:18:54 2011 (r228255) +++ stable/8/sys/i386/xen/pmap.c Sun Dec 4 07:28:50 2011 (r228256) @@ -2068,7 +2068,7 @@ pmap_collect(pmap_t locked_pmap, struct sched_pin(); TAILQ_FOREACH(m, &vpq->pl, pageq) { - if (m->hold_count || m->busy) + if ((m->flags & PG_MARKER) != 0 || m->hold_count || m->busy) continue; TAILQ_FOREACH_SAFE(pv, &m->md.pv_list, pv_list, next_pv) { va = pv->pv_va; Modified: stable/8/sys/ia64/ia64/pmap.c ============================================================================== --- stable/8/sys/ia64/ia64/pmap.c Sun Dec 4 07:18:54 2011 (r228255) +++ stable/8/sys/ia64/ia64/pmap.c Sun Dec 4 07:28:50 2011 (r228256) @@ -798,7 +798,7 @@ get_pv_entry(pmap_t locked_pmap) vpq = &vm_page_queues[PQ_INACTIVE]; retry: TAILQ_FOREACH(m, &vpq->pl, pageq) { - if (m->hold_count || m->busy) + if ((m->flags & PG_MARKER) != 0 || m->hold_count || m->busy) continue; TAILQ_FOREACH_SAFE(pv, &m->md.pv_list, pv_list, next_pv) { va = pv->pv_va; Modified: stable/8/sys/mips/mips/pmap.c ============================================================================== --- stable/8/sys/mips/mips/pmap.c Sun Dec 4 07:18:54 2011 (r228255) +++ stable/8/sys/mips/mips/pmap.c Sun Dec 4 07:28:50 2011 (r228256) @@ -1405,7 +1405,7 @@ get_pv_entry(pmap_t locked_pmap) vpq = &vm_page_queues[PQ_INACTIVE]; retry: TAILQ_FOREACH(m, &vpq->pl, pageq) { - if (m->hold_count || m->busy) + if ((m->flags & PG_MARKER) != 0 || m->hold_count || m->busy) continue; TAILQ_FOREACH_SAFE(pv, &m->md.pv_list, pv_list, next_pv) { va = pv->pv_va; From owner-svn-src-stable-8@FreeBSD.ORG Sun Dec 4 18:55:19 2011 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CB6EB1065672; Sun, 4 Dec 2011 18:55:19 +0000 (UTC) (envelope-from alc@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B0FC58FC1E; Sun, 4 Dec 2011 18:55:19 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pB4ItJ49098811; Sun, 4 Dec 2011 18:55:19 GMT (envelope-from alc@svn.freebsd.org) Received: (from alc@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pB4ItJY3098809; Sun, 4 Dec 2011 18:55:19 GMT (envelope-from alc@svn.freebsd.org) Message-Id: <201112041855.pB4ItJY3098809@svn.freebsd.org> From: Alan Cox Date: Sun, 4 Dec 2011 18:55:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r228262 - stable/8/sys/amd64/amd64 X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 04 Dec 2011 18:55:20 -0000 Author: alc Date: Sun Dec 4 18:55:19 2011 New Revision: 228262 URL: http://svn.freebsd.org/changeset/base/228262 Log: MFC r219157 Make a change to the implementation of the direct map to improve performance on processors that support 1 GB pages. Specifically, if the end of physical memory is not aligned to a 1 GB page boundary, then map the residual physical memory with multiple 2 MB page mappings rather than a single 1 GB page mapping. When a 1 GB page mapping is used for this residual memory, access to the memory is slower than when multiple 2 MB page mappings are used. (I suspect that the reason for this slowdown is that the TLB is actually being loaded with 4 KB page mappings for the residual memory.) Modified: stable/8/sys/amd64/amd64/pmap.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/amd64/amd64/pmap.c ============================================================================== --- stable/8/sys/amd64/amd64/pmap.c Sun Dec 4 18:43:09 2011 (r228261) +++ stable/8/sys/amd64/amd64/pmap.c Sun Dec 4 18:55:19 2011 (r228262) @@ -435,7 +435,7 @@ allocpages(vm_paddr_t *firstaddr, int n) static void create_pagetables(vm_paddr_t *firstaddr) { - int i; + int i, j, ndm1g; /* Allocate pages */ KPTphys = allocpages(firstaddr, NKPT); @@ -447,8 +447,11 @@ create_pagetables(vm_paddr_t *firstaddr) if (ndmpdp < 4) /* Minimum 4GB of dirmap */ ndmpdp = 4; DMPDPphys = allocpages(firstaddr, NDMPML4E); - if ((amd_feature & AMDID_PAGE1GB) == 0) - DMPDphys = allocpages(firstaddr, ndmpdp); + ndm1g = 0; + if ((amd_feature & AMDID_PAGE1GB) != 0) + ndm1g = ptoa(Maxmem) >> PDPSHIFT; + if (ndm1g < ndmpdp) + DMPDphys = allocpages(firstaddr, ndmpdp - ndm1g); dmaplimit = (vm_paddr_t)ndmpdp << PDPSHIFT; /* Fill in the underlying page table pages */ @@ -480,32 +483,28 @@ create_pagetables(vm_paddr_t *firstaddr) } /* - * Now, set up the direct map region using either 2MB or 1GB pages. - * Later, if pmap_mapdev{_attr}() uses the direct map for non-write- - * back memory, pmap_change_attr() will demote any 2MB or 1GB page - * mappings that are partially used. - */ - if ((amd_feature & AMDID_PAGE1GB) == 0) { - for (i = 0; i < NPDEPG * ndmpdp; i++) { - ((pd_entry_t *)DMPDphys)[i] = (vm_paddr_t)i << PDRSHIFT; - /* Preset PG_M and PG_A because demotion expects it. */ - ((pd_entry_t *)DMPDphys)[i] |= PG_RW | PG_V | PG_PS | - PG_G | PG_M | PG_A; - } - /* And the direct map space's PDP */ - for (i = 0; i < ndmpdp; i++) { - ((pdp_entry_t *)DMPDPphys)[i] = DMPDphys + - (i << PAGE_SHIFT); - ((pdp_entry_t *)DMPDPphys)[i] |= PG_RW | PG_V | PG_U; - } - } else { - for (i = 0; i < ndmpdp; i++) { - ((pdp_entry_t *)DMPDPphys)[i] = - (vm_paddr_t)i << PDPSHIFT; - /* Preset PG_M and PG_A because demotion expects it. */ - ((pdp_entry_t *)DMPDPphys)[i] |= PG_RW | PG_V | PG_PS | - PG_G | PG_M | PG_A; - } + * Now, set up the direct map region using 2MB and/or 1GB pages. If + * the end of physical memory is not aligned to a 1GB page boundary, + * then the residual physical memory is mapped with 2MB pages. Later, + * if pmap_mapdev{_attr}() uses the direct map for non-write-back + * memory, pmap_change_attr() will demote any 2MB or 1GB page mappings + * that are partially used. + */ + for (i = NPDEPG * ndm1g, j = 0; i < NPDEPG * ndmpdp; i++, j++) { + ((pd_entry_t *)DMPDphys)[j] = (vm_paddr_t)i << PDRSHIFT; + /* Preset PG_M and PG_A because demotion expects it. */ + ((pd_entry_t *)DMPDphys)[j] |= PG_RW | PG_V | PG_PS | PG_G | + PG_M | PG_A; + } + for (i = 0; i < ndm1g; i++) { + ((pdp_entry_t *)DMPDPphys)[i] = (vm_paddr_t)i << PDPSHIFT; + /* Preset PG_M and PG_A because demotion expects it. */ + ((pdp_entry_t *)DMPDPphys)[i] |= PG_RW | PG_V | PG_PS | PG_G | + PG_M | PG_A; + } + for (j = 0; i < ndmpdp; i++, j++) { + ((pdp_entry_t *)DMPDPphys)[i] = DMPDphys + (j << PAGE_SHIFT); + ((pdp_entry_t *)DMPDPphys)[i] |= PG_RW | PG_V | PG_U; } /* And recursively map PML4 to itself in order to get PTmap */ From owner-svn-src-stable-8@FreeBSD.ORG Mon Dec 5 23:29:27 2011 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B258D106564A; Mon, 5 Dec 2011 23:29:27 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A1CBA8FC13; Mon, 5 Dec 2011 23:29:27 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pB5NTRfx062802; Mon, 5 Dec 2011 23:29:27 GMT (envelope-from gonzo@svn.freebsd.org) Received: (from gonzo@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pB5NTRJV062800; Mon, 5 Dec 2011 23:29:27 GMT (envelope-from gonzo@svn.freebsd.org) Message-Id: <201112052329.pB5NTRJV062800@svn.freebsd.org> From: Oleksandr Tymoshenko Date: Mon, 5 Dec 2011 23:29:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r228294 - stable/8/share/mk X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Dec 2011 23:29:27 -0000 Author: gonzo Date: Mon Dec 5 23:29:27 2011 New Revision: 228294 URL: http://svn.freebsd.org/changeset/base/228294 Log: Unbreak Modified: stable/8/share/mk/bsd.cpu.mk Modified: stable/8/share/mk/bsd.cpu.mk ============================================================================== --- stable/8/share/mk/bsd.cpu.mk Mon Dec 5 22:55:52 2011 (r228293) +++ stable/8/share/mk/bsd.cpu.mk Mon Dec 5 23:29:27 2011 (r228294) @@ -242,11 +242,11 @@ LD += -EB .if ${MACHINE_ARCH} == "mips" . if defined(TARGET_BIG_ENDIAN) CFLAGS += -EB -LDFLAGS += -Wl,-EB +LDFLAGS += -EB LD += -EB . else CFLAGS += -EL -LDFLAGS += -Wl,-EL +LDFLAGS += -EL LD += -EL . endif CFLAGS += -msoft-float -G0 -mno-dsp -mabicalls From owner-svn-src-stable-8@FreeBSD.ORG Tue Dec 6 00:05:12 2011 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C2AE31065670; Tue, 6 Dec 2011 00:05:12 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B23E28FC12; Tue, 6 Dec 2011 00:05:12 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pB605CIg063969; Tue, 6 Dec 2011 00:05:12 GMT (envelope-from gonzo@svn.freebsd.org) Received: (from gonzo@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pB605CO8063967; Tue, 6 Dec 2011 00:05:12 GMT (envelope-from gonzo@svn.freebsd.org) Message-Id: <201112060005.pB605CO8063967@svn.freebsd.org> From: Oleksandr Tymoshenko Date: Tue, 6 Dec 2011 00:05:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r228295 - stable/8/sys/mips/mips X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Dec 2011 00:05:12 -0000 Author: gonzo Date: Tue Dec 6 00:05:12 2011 New Revision: 228295 URL: http://svn.freebsd.org/changeset/base/228295 Log: Unbreak build: add missing coma Modified: stable/8/sys/mips/mips/elf_machdep.c Modified: stable/8/sys/mips/mips/elf_machdep.c ============================================================================== --- stable/8/sys/mips/mips/elf_machdep.c Mon Dec 5 23:29:27 2011 (r228294) +++ stable/8/sys/mips/mips/elf_machdep.c Tue Dec 6 00:05:12 2011 (r228295) @@ -78,7 +78,7 @@ struct sysentvec elf64_freebsd_sysvec = .sv_setregs = exec_setregs, .sv_fixlimit = NULL, .sv_maxssiz = NULL, - .sv_flags = SV_ABI_FREEBSD | SV_LP64 + .sv_flags = SV_ABI_FREEBSD | SV_LP64, .sv_schedtail = NULL, }; From owner-svn-src-stable-8@FreeBSD.ORG Tue Dec 6 00:11:20 2011 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A2265106564A; Tue, 6 Dec 2011 00:11:20 +0000 (UTC) (envelope-from gonzo@hq.bluezbox.com) Received: from hq.bluezbox.com (hq.bluezbox.com [70.38.37.145]) by mx1.freebsd.org (Postfix) with ESMTP id 3667B8FC16; Tue, 6 Dec 2011 00:11:20 +0000 (UTC) Received: from localhost ([127.0.0.1]) by hq.bluezbox.com with esmtpsa (TLSv1:CAMELLIA256-SHA:256) (Exim 4.73 (FreeBSD)) (envelope-from ) id 1RXiBp-000HFX-Vq; Mon, 05 Dec 2011 15:43:18 -0800 Message-ID: <4EDD5716.6030006@freebsd.org> Date: Mon, 05 Dec 2011 15:43:18 -0800 From: Oleksandr Tymoshenko User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:8.0) Gecko/20111105 Thunderbird/8.0 MIME-Version: 1.0 References: <201112052329.pB5NTRJV062800@svn.freebsd.org> In-Reply-To: <201112052329.pB5NTRJV062800@svn.freebsd.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Sender: gonzo@hq.bluezbox.com X-Spam-Level: --- X-Spam-Report: Spam detection software, running on the system "hq.bluezbox.com", has identified this incoming email as possible spam. The original message has been attached to this so you can view it (if it isn't spam) or label similar future email. If you have any questions, see The administrator of that system for details. Content preview: Sorry for short comment. It was editor glitch :( Proper comment is: Unbreak 8-STABLE build. LDFLAGS is used as an argument for both ld (in kmod.mk) and cc when it acts as a linker. In latter case cc properly passes byte-order settings to ld so there is no need for -Wl, part. [...] Content analysis details: (-3.1 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.8 ALL_TRUSTED Passed through trusted hosts only via SMTP 1.3 MISSING_HEADERS Missing To: header -2.6 BAYES_00 BODY: Bayesian spam probability is 0 to 1% [score: 0.0000] Cc: svn-src-stable@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, svn-src-stable-8@freebsd.org Subject: Re: svn commit: r228294 - stable/8/share/mk X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Dec 2011 00:11:20 -0000 Sorry for short comment. It was editor glitch :( Proper comment is: Unbreak 8-STABLE build. LDFLAGS is used as an argument for both ld (in kmod.mk) and cc when it acts as a linker. In latter case cc properly passes byte-order settings to ld so there is no need for -Wl, part. On 05/12/2011 3:29 PM, Oleksandr Tymoshenko wrote: > Author: gonzo > Date: Mon Dec 5 23:29:27 2011 > New Revision: 228294 > URL: http://svn.freebsd.org/changeset/base/228294 > > Log: > Unbreak > > Modified: > stable/8/share/mk/bsd.cpu.mk > > Modified: stable/8/share/mk/bsd.cpu.mk > ============================================================================== > --- stable/8/share/mk/bsd.cpu.mk Mon Dec 5 22:55:52 2011 (r228293) > +++ stable/8/share/mk/bsd.cpu.mk Mon Dec 5 23:29:27 2011 (r228294) > @@ -242,11 +242,11 @@ LD += -EB > .if ${MACHINE_ARCH} == "mips" > . if defined(TARGET_BIG_ENDIAN) > CFLAGS += -EB > -LDFLAGS += -Wl,-EB > +LDFLAGS += -EB > LD += -EB > . else > CFLAGS += -EL > -LDFLAGS += -Wl,-EL > +LDFLAGS += -EL > LD += -EL > . endif > CFLAGS += -msoft-float -G0 -mno-dsp -mabicalls > From owner-svn-src-stable-8@FreeBSD.ORG Tue Dec 6 00:13:40 2011 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E9E47106566B; Tue, 6 Dec 2011 00:13:40 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D944C8FC17; Tue, 6 Dec 2011 00:13:40 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pB60DeAI064248; Tue, 6 Dec 2011 00:13:40 GMT (envelope-from gonzo@svn.freebsd.org) Received: (from gonzo@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pB60DelX064246; Tue, 6 Dec 2011 00:13:40 GMT (envelope-from gonzo@svn.freebsd.org) Message-Id: <201112060013.pB60DelX064246@svn.freebsd.org> From: Oleksandr Tymoshenko Date: Tue, 6 Dec 2011 00:13:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r228296 - stable/8/sys/mips/include X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Dec 2011 00:13:41 -0000 Author: gonzo Date: Tue Dec 6 00:13:40 2011 New Revision: 228296 URL: http://svn.freebsd.org/changeset/base/228296 Log: Unbreak mips64 build by MFCing r202031 that fixes _ALIGN macros Modified: stable/8/sys/mips/include/param.h Modified: stable/8/sys/mips/include/param.h ============================================================================== --- stable/8/sys/mips/include/param.h Tue Dec 6 00:05:12 2011 (r228295) +++ stable/8/sys/mips/include/param.h Tue Dec 6 00:13:40 2011 (r228296) @@ -77,11 +77,11 @@ /* * Round p (pointer or byte index) up to a correctly-aligned value for all - * data types (int, long, ...). The result is u_int and must be cast to + * data types (int, long, ...). The result is u_long and must be cast to * any desired pointer type. */ #define _ALIGNBYTES 7 -#define _ALIGN(p) (((u_int)(p) + _ALIGNBYTES) &~ _ALIGNBYTES) +#define _ALIGN(p) (((u_long)(p) + _ALIGNBYTES) &~ _ALIGNBYTES) #define ALIGNBYTES _ALIGNBYTES #define ALIGN(p) _ALIGN(p) From owner-svn-src-stable-8@FreeBSD.ORG Thu Dec 8 00:47:23 2011 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 628D41065670; Thu, 8 Dec 2011 00:47:23 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4CB108FC16; Thu, 8 Dec 2011 00:47:23 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pB80lNwW063037; Thu, 8 Dec 2011 00:47:23 GMT (envelope-from gonzo@svn.freebsd.org) Received: (from gonzo@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pB80lMpY063030; Thu, 8 Dec 2011 00:47:22 GMT (envelope-from gonzo@svn.freebsd.org) Message-Id: <201112080047.pB80lMpY063030@svn.freebsd.org> From: Oleksandr Tymoshenko Date: Thu, 8 Dec 2011 00:47:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r228337 - in stable/8: contrib/binutils/bfd contrib/binutils/gas/config contrib/binutils/include/elf contrib/binutils/include/opcode contrib/binutils/opcodes contrib/gcc/config contrib/... X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Dec 2011 00:47:23 -0000 Author: gonzo Date: Thu Dec 8 00:47:22 2011 New Revision: 228337 URL: http://svn.freebsd.org/changeset/base/228337 Log: MFC r208737 (required by OCTEON* kernels): Add/improve mips64r2, Octeon, n32 and n64 support in the toolchain. o) Add TARGET_ABI to the MIPS toolchain build process. This sets the default ABI to one of o32, n32 or n64. If it is not set, o32 is assumed as that is the current default. o) Set the default GCC cpu type to any specified TARGET_CPUTYPE. This is necessary to have a working "cc" if e.g. mips64 is specified, as binutils will refuse to link objects using different ISAs in some cases. o) Add support for n32 and n64 ABIs to binutils and GCC. o) Add additional required libgcc2 stubs for n32 and n64. o) Add support for the "mips64r2" architecture to GCC. Add the "octeon" o) When static linking, wrap default libraries in --start-group and --end-group. This is required for static linking to work on n64 with the interdependencies between libraries there. This is what other OSes that support n64 seem to do, as well. o) Fix our GCC spec to define __mips64 for 64-bit targets, not __mips64__, the former being what libgcc, etc., check and the latter seemingly being a misspelling of a hand merge from a Linux spec. o) When no TARGET_CPUTYPE is specified at build time, make GCC take the default ISA from the ABI. Our old defaults were too liberal and assumed that 64-bit ABIs should default to the MIPS64 ISA and that 32-bit ABIs should default to the MIPS32 ISA, when we are supporting or will support some systems based on earlier 32-bit and 64-bit ISAs, most notably MIPS-III. o) Merge a new opcode file (and support code) from a later version of binutils and add flags and code necessary to support Octeon-specific instructions. This should also make merging opcodes for other modern architectures easier. No objections from: imp, jmallet, jchandra MFC after: 18 months Added: stable/8/contrib/gcc/config/fixdfdi.c - copied unchanged from r208737, head/contrib/gcc/config/fixdfdi.c stable/8/contrib/gcc/config/fixsfdi.c - copied unchanged from r208737, head/contrib/gcc/config/fixsfdi.c stable/8/contrib/gcc/config/fixunsdfsi.c - copied unchanged from r208737, head/contrib/gcc/config/fixunsdfsi.c stable/8/contrib/gcc/config/fixunssfsi.c - copied unchanged from r208737, head/contrib/gcc/config/fixunssfsi.c stable/8/contrib/gcc/config/floatdidf.c - copied unchanged from r208737, head/contrib/gcc/config/floatdidf.c stable/8/contrib/gcc/config/floatdisf.c - copied unchanged from r208737, head/contrib/gcc/config/floatdisf.c stable/8/contrib/gcc/config/floatundidf.c - copied unchanged from r208737, head/contrib/gcc/config/floatundidf.c stable/8/contrib/gcc/config/floatundisf.c - copied unchanged from r208737, head/contrib/gcc/config/floatundisf.c Modified: stable/8/contrib/binutils/bfd/archures.c stable/8/contrib/binutils/bfd/bfd-in2.h stable/8/contrib/binutils/bfd/cpu-mips.c stable/8/contrib/binutils/bfd/elfxx-mips.c stable/8/contrib/binutils/gas/config/tc-mips.c stable/8/contrib/binutils/gas/config/tc-mips.h stable/8/contrib/binutils/include/elf/mips.h stable/8/contrib/binutils/include/opcode/mips.h stable/8/contrib/binutils/opcodes/mips-dis.c stable/8/contrib/binutils/opcodes/mips-opc.c stable/8/contrib/binutils/opcodes/mips16-opc.c stable/8/contrib/gcc/config/mips/freebsd.h stable/8/contrib/gcc/config/mips/mips.c stable/8/contrib/gcc/config/mips/mips.h stable/8/contrib/gcc/config/mips/mips.md stable/8/gnu/lib/libgcc/Makefile stable/8/gnu/lib/libgomp/Makefile stable/8/gnu/usr.bin/binutils/Makefile.inc0 stable/8/gnu/usr.bin/binutils/ld/Makefile.mips stable/8/gnu/usr.bin/binutils/libbfd/Makefile.mips stable/8/gnu/usr.bin/binutils/libbfd/bfd.h Directory Properties: stable/8/contrib/ (props changed) stable/8/contrib/binutils/ (props changed) stable/8/contrib/gcc/ (props changed) stable/8/gnu/ (props changed) stable/8/gnu/lib/libgcc/ (props changed) stable/8/gnu/usr.bin/ (props changed) stable/8/gnu/usr.bin/binutils/ld/ (props changed) Modified: stable/8/contrib/binutils/bfd/archures.c ============================================================================== --- stable/8/contrib/binutils/bfd/archures.c Wed Dec 7 23:20:14 2011 (r228336) +++ stable/8/contrib/binutils/bfd/archures.c Thu Dec 8 00:47:22 2011 (r228337) @@ -1,6 +1,6 @@ /* BFD library support routines for architectures. Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, - 2000, 2001, 2002, 2003 + 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. Hacked by John Gilmore and Steve Chamberlain of Cygnus Support. @@ -18,7 +18,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ #include "bfd.h" #include "sysdep.h" @@ -141,10 +141,12 @@ DESCRIPTION .#define bfd_mach_mips6000 6000 .#define bfd_mach_mips7000 7000 .#define bfd_mach_mips8000 8000 +.#define bfd_mach_mips9000 9000 .#define bfd_mach_mips10000 10000 .#define bfd_mach_mips12000 12000 .#define bfd_mach_mips16 16 .#define bfd_mach_mips5 5 +.#define bfd_mach_mips_octeon 6502 .#define bfd_mach_mips_sb1 12310201 {* octal 'SB', 01 *} .#define bfd_mach_mipsisa32 32 .#define bfd_mach_mipsisa32r2 33 Modified: stable/8/contrib/binutils/bfd/bfd-in2.h ============================================================================== --- stable/8/contrib/binutils/bfd/bfd-in2.h Wed Dec 7 23:20:14 2011 (r228336) +++ stable/8/contrib/binutils/bfd/bfd-in2.h Thu Dec 8 00:47:22 2011 (r228337) @@ -8,7 +8,8 @@ /* Main header file for the bfd library -- portable access to object files. Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, - 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. + 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. Contributed by Cygnus Support. @@ -26,7 +27,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef __BFD_H_SEEN__ #define __BFD_H_SEEN__ Modified: stable/8/contrib/binutils/bfd/cpu-mips.c ============================================================================== --- stable/8/contrib/binutils/bfd/cpu-mips.c Wed Dec 7 23:20:14 2011 (r228336) +++ stable/8/contrib/binutils/bfd/cpu-mips.c Thu Dec 8 00:47:22 2011 (r228337) @@ -1,6 +1,6 @@ /* bfd back-end for mips support Copyright 1990, 1991, 1993, 1994, 1995, 1996, 1997, 1998, 2000, 2001, - 2002, 2003 Free Software Foundation, Inc. + 2002, 2003, 2004 Free Software Foundation, Inc. Written by Steve Chamberlain of Cygnus Support. This file is part of BFD, the Binary File Descriptor library. @@ -17,7 +17,7 @@ GNU General Public License for more deta You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ #include "bfd.h" #include "sysdep.h" @@ -76,6 +76,7 @@ enum I_mips6000, I_mips7000, I_mips8000, + I_mips9000, I_mips10000, I_mips12000, I_mips16, @@ -84,6 +85,7 @@ enum I_mipsisa32r2, I_mipsisa64, I_mipsisa64r2, + I_mipsocteon, I_sb1, }; @@ -108,6 +110,7 @@ static const bfd_arch_info_type arch_inf N (32, 32, bfd_mach_mips6000, "mips:6000", FALSE, NN(I_mips6000)), N (64, 64, bfd_mach_mips7000, "mips:7000", FALSE, NN(I_mips7000)), N (64, 64, bfd_mach_mips8000, "mips:8000", FALSE, NN(I_mips8000)), + N (64, 64, bfd_mach_mips9000, "mips:9000", FALSE, NN(I_mips9000)), N (64, 64, bfd_mach_mips10000,"mips:10000", FALSE, NN(I_mips10000)), N (64, 64, bfd_mach_mips12000,"mips:12000", FALSE, NN(I_mips12000)), N (64, 64, bfd_mach_mips16, "mips:16", FALSE, NN(I_mips16)), @@ -116,6 +119,7 @@ static const bfd_arch_info_type arch_inf N (32, 32, bfd_mach_mipsisa32r2,"mips:isa32r2", FALSE, NN(I_mipsisa32r2)), N (64, 64, bfd_mach_mipsisa64, "mips:isa64", FALSE, NN(I_mipsisa64)), N (64, 64, bfd_mach_mipsisa64r2,"mips:isa64r2", FALSE, NN(I_mipsisa64r2)), + N (64, 64, bfd_mach_mips_octeon,"mips:octeon", FALSE, NN(I_mipsocteon)), N (64, 64, bfd_mach_mips_sb1, "mips:sb1", FALSE, 0), }; Modified: stable/8/contrib/binutils/bfd/elfxx-mips.c ============================================================================== --- stable/8/contrib/binutils/bfd/elfxx-mips.c Wed Dec 7 23:20:14 2011 (r228336) +++ stable/8/contrib/binutils/bfd/elfxx-mips.c Thu Dec 8 00:47:22 2011 (r228337) @@ -1,6 +1,6 @@ /* MIPS-specific support for ELF Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, - 2003 Free Software Foundation, Inc. + 2003, 2004, 2005, 2006 Free Software Foundation, Inc. Most of the information added by Ian Lance Taylor, Cygnus Support, . @@ -23,7 +23,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ /* This file handles functionality common to the different MIPS ABI's. */ @@ -4088,6 +4088,12 @@ _bfd_elf_mips_mach (flagword flags) case E_MIPS_MACH_5500: return bfd_mach_mips5500; + case E_MIPS_MACH_9000: + return bfd_mach_mips9000; + + case E_MIPS_MACH_OCTEON: + return bfd_mach_mips_octeon; + case E_MIPS_MACH_SB1: return bfd_mach_mips_sb1; @@ -7159,6 +7165,10 @@ mips_set_isa_flags (bfd *abfd) val = E_MIPS_ARCH_4 | E_MIPS_MACH_5500; break; + case bfd_mach_mips9000: + val = E_MIPS_ARCH_4 | E_MIPS_MACH_9000; + break; + case bfd_mach_mips5000: case bfd_mach_mips7000: case bfd_mach_mips8000: @@ -7171,6 +7181,10 @@ mips_set_isa_flags (bfd *abfd) val = E_MIPS_ARCH_5; break; + case bfd_mach_mips_octeon: + val = E_MIPS_ARCH_64R2 | E_MIPS_MACH_OCTEON; + break; + case bfd_mach_mips_sb1: val = E_MIPS_ARCH_64 | E_MIPS_MACH_SB1; break; @@ -8873,6 +8887,9 @@ struct mips_mach_extension { are ordered topologically with MIPS I extensions listed last. */ static const struct mips_mach_extension mips_mach_extensions[] = { + /* MIPS64r2 extensions. */ + { bfd_mach_mips_octeon, bfd_mach_mipsisa64r2 }, + /* MIPS64 extensions. */ { bfd_mach_mipsisa64r2, bfd_mach_mipsisa64 }, { bfd_mach_mips_sb1, bfd_mach_mipsisa64 }, @@ -8896,6 +8913,7 @@ static const struct mips_mach_extension { bfd_mach_mips10000, bfd_mach_mips8000 }, { bfd_mach_mips5000, bfd_mach_mips8000 }, { bfd_mach_mips7000, bfd_mach_mips8000 }, + { bfd_mach_mips9000, bfd_mach_mips8000 }, /* VR4100 extensions. */ { bfd_mach_mips4120, bfd_mach_mips4100 }, @@ -8930,11 +8948,26 @@ mips_mach_extends_p (unsigned long base, { size_t i; - for (i = 0; extension != base && i < ARRAY_SIZE (mips_mach_extensions); i++) + if (extension == base) + return TRUE; + + if (base == bfd_mach_mipsisa32 + && mips_mach_extends_p (bfd_mach_mipsisa64, extension)) + return TRUE; + + if (base == bfd_mach_mipsisa32r2 + && mips_mach_extends_p (bfd_mach_mipsisa64r2, extension)) + return TRUE; + + for (i = 0; i < ARRAY_SIZE (mips_mach_extensions); i++) if (extension == mips_mach_extensions[i].extension) - extension = mips_mach_extensions[i].base; + { + extension = mips_mach_extensions[i].base; + if (extension == base) + return TRUE; + } - return extension == base; + return FALSE; } Modified: stable/8/contrib/binutils/gas/config/tc-mips.c ============================================================================== --- stable/8/contrib/binutils/gas/config/tc-mips.c Wed Dec 7 23:20:14 2011 (r228336) +++ stable/8/contrib/binutils/gas/config/tc-mips.c Thu Dec 8 00:47:22 2011 (r228337) @@ -1,6 +1,6 @@ /* tc-mips.c -- assemble code for a MIPS chip. Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, - 2003, 2004 Free Software Foundation, Inc. + 2003, 2004, 2005 Free Software Foundation, Inc. Contributed by the OSF and Ralph Campbell. Written by Keith Knowles and Ralph Campbell, working independently. Modified for ECOFF and R4000 support by Ian Lance Taylor of Cygnus @@ -20,8 +20,8 @@ You should have received a copy of the GNU General Public License along with GAS; see the file COPYING. If not, write to the Free - Software Foundation, 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. */ + Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA + 02110-1301, USA. */ #include "as.h" #include "config.h" @@ -33,6 +33,7 @@ #include "opcode/mips.h" #include "itbl-ops.h" #include "dwarf2dbg.h" +#include "dw2gencfi.h" #ifdef DEBUG #define DBG(x) printf x @@ -83,6 +84,25 @@ int mips_flag_pdr = FALSE; int mips_flag_pdr = TRUE; #endif +/* Control generation of error message for unsupported instructions in + Octeon. Octeon does not have floating point, and all the instructions + that use floating point registers are not allowed in Elf targets but + are allowed in Linux targets by default. */ +#ifdef OCTEON_ERROR_ON_UNSUPPORTED +static int octeon_error_on_unsupported = 1; +#else +static int octeon_error_on_unsupported = 0; +#endif + +/* Control generation of Octeon/MIPS unaligned load/store instructions. + For ELF target, default to Octeon load/store instructions. + For Linux target, default to MIPS load/store instructions. */ +#ifdef OCTEON_USE_UNALIGN +static int octeon_use_unalign = 1; +#else +static int octeon_use_unalign = 0; +#endif + #include "ecoff.h" #if defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF) @@ -111,9 +131,7 @@ static char *mips_regmask_frag; extern int target_big_endian; /* The name of the readonly data section. */ -#define RDATA_SECTION_NAME (OUTPUT_FLAVOR == bfd_target_aout_flavour \ - ? ".data" \ - : OUTPUT_FLAVOR == bfd_target_ecoff_flavour \ +#define RDATA_SECTION_NAME (OUTPUT_FLAVOR == bfd_target_ecoff_flavour \ ? ".rdata" \ : OUTPUT_FLAVOR == bfd_target_coff_flavour \ ? ".rdata" \ @@ -121,6 +139,43 @@ extern int target_big_endian; ? ".rodata" \ : (abort (), "")) +/* Information about an instruction, including its format, operands + and fixups. */ +struct mips_cl_insn +{ + /* The opcode's entry in mips_opcodes or mips16_opcodes. */ + const struct mips_opcode *insn_mo; + + /* True if this is a mips16 instruction and if we want the extended + form of INSN_MO. */ + bfd_boolean use_extend; + + /* The 16-bit extension instruction to use when USE_EXTEND is true. */ + unsigned short extend; + + /* The 16-bit or 32-bit bitstring of the instruction itself. This is + a copy of INSN_MO->match with the operands filled in. */ + unsigned long insn_opcode; + + /* The frag that contains the instruction. */ + struct frag *frag; + + /* The offset into FRAG of the first instruction byte. */ + long where; + + /* The relocs associated with the instruction, if any. */ + fixS *fixp[3]; + + /* True if this entry cannot be moved from its current position. */ + unsigned int fixed_p : 1; + + /* True if this instruction occured in a .set noreorder block. */ + unsigned int noreorder_p : 1; + + /* True for mips16 instructions that jump to an absolute address. */ + unsigned int mips16_absolute_jump_p : 1; +}; + /* The ABI to use. */ enum mips_abi_level { @@ -138,6 +193,10 @@ static enum mips_abi_level mips_abi = NO /* Whether or not we have code that can call pic code. */ int mips_abicalls = FALSE; +/* Whether or not we have code which can be put into a shared + library. */ +static bfd_boolean mips_in_shared = TRUE; + /* This is the set of options which may be modified by the .set pseudo-op. We use a struct so that .set push and .set pop are more reliable. */ @@ -153,6 +212,8 @@ struct mips_set_options command line options, and based on the default architecture. */ int ase_mips3d; int ase_mdmx; + int ase_dsp; + int ase_mt; /* Whether we are assembling for the mips16 processor. 0 if we are not, 1 if we are, and -1 if the value has not been initialized. Changed by `.set mips16' and `.set nomips16', and the -mips16 and @@ -187,6 +248,8 @@ struct mips_set_options /* MIPS architecture (CPU) type. Changed by .set arch=FOO, the -march command line option, and the default CPU. */ int arch; + /* True if ".set sym32" is in effect. */ + bfd_boolean sym32; }; /* True if -mgp32 was passed. */ @@ -201,7 +264,7 @@ static int file_mips_fp32 = -1; static struct mips_set_options mips_opts = { - ISA_UNKNOWN, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, CPU_UNKNOWN + ISA_UNKNOWN, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, CPU_UNKNOWN, FALSE }; /* These variables are filled in with the masks of registers used. @@ -225,6 +288,14 @@ static int file_ase_mips3d; command line (e.g., by -march). */ static int file_ase_mdmx; +/* True if -mdsp was passed or implied by arguments passed on the + command line (e.g., by -march). */ +static int file_ase_dsp; + +/* True if -mmt was passed or implied by arguments passed on the + command line (e.g., by -march). */ +static int file_ase_mt; + /* The argument of the -march= flag. The architecture we are assembling. */ static int file_mips_arch = CPU_UNKNOWN; static const char *mips_arch_string; @@ -268,6 +339,12 @@ static int mips_32bitmode = 0; || (ISA) == ISA_MIPS64R2 \ ) +/* Return true if ISA supports ins instructions. */ +#define ISA_HAS_INS(ISA) ( \ + (ISA) == ISA_MIPS32R2 \ + || (ISA) == ISA_MIPS64R2 \ + ) + #define HAVE_32BIT_GPRS \ (mips_opts.gp32 || ! ISA_HAS_64BIT_REGS (mips_opts.isa)) @@ -284,15 +361,16 @@ static int mips_32bitmode = 0; /* True if relocations are stored in-place. */ #define HAVE_IN_PLACE_ADDENDS (!HAVE_NEWABI) -/* We can only have 64bit addresses if the object file format - supports it. */ -#define HAVE_32BIT_ADDRESSES \ - (HAVE_32BIT_GPRS \ - || ((bfd_arch_bits_per_address (stdoutput) == 32 \ - || ! HAVE_64BIT_OBJECTS) \ - && mips_pic != EMBEDDED_PIC)) - -#define HAVE_64BIT_ADDRESSES (! HAVE_32BIT_ADDRESSES) +/* The ABI-derived address size. */ +#define HAVE_64BIT_ADDRESSES \ + (HAVE_64BIT_GPRS && (mips_abi == EABI_ABI || mips_abi == N64_ABI)) +#define HAVE_32BIT_ADDRESSES (!HAVE_64BIT_ADDRESSES) + +/* The size of symbolic constants (i.e., expressions of the form + "SYMBOL" or "SYMBOL + OFFSET"). */ +#define HAVE_32BIT_SYMBOLS \ + (HAVE_32BIT_ADDRESSES || !HAVE_64BIT_OBJECTS || mips_opts.sym32) +#define HAVE_64BIT_SYMBOLS (!HAVE_32BIT_SYMBOLS) /* Addresses are loaded in different ways, depending on the address size in use. The n32 ABI Documentation also mandates the use of additions @@ -322,6 +400,14 @@ static int mips_32bitmode = 0; #define CPU_HAS_MDMX(cpu) (FALSE \ ) +/* Return true if the given CPU supports the DSP ASE. */ +#define CPU_HAS_DSP(cpu) (FALSE \ + ) + +/* Return true if the given CPU supports the MT ASE. */ +#define CPU_HAS_MT(cpu) (FALSE \ + ) + /* True if CPU has a dror instruction. */ #define CPU_HAS_DROR(CPU) ((CPU) == CPU_VR5400 || (CPU) == CPU_VR5500) @@ -349,7 +435,6 @@ static int mips_32bitmode = 0; || mips_opts.arch == CPU_R10000 \ || mips_opts.arch == CPU_R12000 \ || mips_opts.arch == CPU_RM7000 \ - || mips_opts.arch == CPU_SB1 \ || mips_opts.arch == CPU_VR5500 \ ) @@ -360,8 +445,6 @@ static int mips_32bitmode = 0; level I. */ #define gpr_interlocks \ (mips_opts.isa != ISA_MIPS1 \ - || mips_opts.arch == CPU_VR5400 \ - || mips_opts.arch == CPU_VR5500 \ || mips_opts.arch == CPU_R3900) /* Whether the processor uses hardware interlocks to avoid delays @@ -377,9 +460,6 @@ static int mips_32bitmode = 0; && mips_opts.isa != ISA_MIPS2 \ && mips_opts.isa != ISA_MIPS3) \ || mips_opts.arch == CPU_R4300 \ - || mips_opts.arch == CPU_VR5400 \ - || mips_opts.arch == CPU_VR5500 \ - || mips_opts.arch == CPU_SB1 \ ) /* Whether the processor uses hardware interlocks to protect reads @@ -521,44 +601,27 @@ static int mips_optimize = 2; equivalent to seeing no -g option at all. */ static int mips_debug = 0; -/* The previous instruction. */ -static struct mips_cl_insn prev_insn; - -/* The instruction before prev_insn. */ -static struct mips_cl_insn prev_prev_insn; +/* The maximum number of NOPs needed to avoid the VR4130 mflo/mfhi errata. */ +#define MAX_VR4130_NOPS 4 -/* If we don't want information for prev_insn or prev_prev_insn, we - point the insn_mo field at this dummy integer. */ -static const struct mips_opcode dummy_opcode = { NULL, NULL, 0, 0, 0, 0 }; +/* The maximum number of NOPs needed to fill delay slots. */ +#define MAX_DELAY_NOPS 2 -/* Non-zero if prev_insn is valid. */ -static int prev_insn_valid; +/* The maximum number of NOPs needed for any purpose. */ +#define MAX_NOPS 4 -/* The frag for the previous instruction. */ -static struct frag *prev_insn_frag; +/* A list of previous instructions, with index 0 being the most recent. + We need to look back MAX_NOPS instructions when filling delay slots + or working around processor errata. We need to look back one + instruction further if we're thinking about using history[0] to + fill a branch delay slot. */ +static struct mips_cl_insn history[1 + MAX_NOPS]; -/* The offset into prev_insn_frag for the previous instruction. */ -static long prev_insn_where; +/* Nop instructions used by emit_nop. */ +static struct mips_cl_insn nop_insn, mips16_nop_insn; -/* The reloc type for the previous instruction, if any. */ -static bfd_reloc_code_real_type prev_insn_reloc_type[3]; - -/* The reloc for the previous instruction, if any. */ -static fixS *prev_insn_fixp[3]; - -/* Non-zero if the previous instruction was in a delay slot. */ -static int prev_insn_is_delay_slot; - -/* Non-zero if the previous instruction was in a .set noreorder. */ -static int prev_insn_unreordered; - -/* Non-zero if the previous instruction uses an extend opcode (if - mips16). */ -static int prev_insn_extended; - -/* Non-zero if the previous previous instruction was in a .set - noreorder. */ -static int prev_prev_insn_unreordered; +/* The appropriate nop for the current mode. */ +#define NOP_INSN (mips_opts.mips16 ? &mips16_nop_insn : &nop_insn) /* If this is set, it points to a frag holding nop instructions which were inserted before the start of a noreorder section. If those @@ -625,8 +688,29 @@ static const unsigned int mips16_to_32_r 16, 17, 2, 3, 4, 5, 6, 7 }; +/* Classifies the kind of instructions we're interested in when + implementing -mfix-vr4120. */ +enum fix_vr4120_class { + FIX_VR4120_MACC, + FIX_VR4120_DMACC, + FIX_VR4120_MULT, + FIX_VR4120_DMULT, + FIX_VR4120_DIV, + FIX_VR4120_MTHILO, + NUM_FIX_VR4120_CLASSES +}; + +/* Given two FIX_VR4120_* values X and Y, bit Y of element X is set if + there must be at least one other instruction between an instruction + of type X and an instruction of type Y. */ +static unsigned int vr4120_conflicts[NUM_FIX_VR4120_CLASSES]; + +/* True if -mfix-vr4120 is in force. */ static int mips_fix_vr4120; +/* ...likewise -mfix-vr4130. */ +static int mips_fix_vr4130; + /* We don't relax branches by default, since this causes us to expand `la .l2 - .l1' if there's a branch between .l1 and .l2, because we fail to compute the offset before expanding the macro to the most @@ -820,6 +904,41 @@ static int mips_relax_branch; (((x) &~ (offsetT) 0x7fff) == 0 \ || (((x) &~ (offsetT) 0x7fff) == ~ (offsetT) 0x7fff)) +/* Is the given value a zero-extended 32-bit value? Or a negated one? */ +#define IS_ZEXT_32BIT_NUM(x) \ + (((x) &~ (offsetT) 0xffffffff) == 0 \ + || (((x) &~ (offsetT) 0xffffffff) == ~ (offsetT) 0xffffffff)) + +/* Replace bits MASK << SHIFT of STRUCT with the equivalent bits in + VALUE << SHIFT. VALUE is evaluated exactly once. */ +#define INSERT_BITS(STRUCT, VALUE, MASK, SHIFT) \ + (STRUCT) = (((STRUCT) & ~((MASK) << (SHIFT))) \ + | (((VALUE) & (MASK)) << (SHIFT))) + +/* Extract bits MASK << SHIFT from STRUCT and shift them right + SHIFT places. */ +#define EXTRACT_BITS(STRUCT, MASK, SHIFT) \ + (((STRUCT) >> (SHIFT)) & (MASK)) + +/* Change INSN's opcode so that the operand given by FIELD has value VALUE. + INSN is a mips_cl_insn structure and VALUE is evaluated exactly once. + + include/opcode/mips.h specifies operand fields using the macros + OP_MASK_ and OP_SH_. The MIPS16 equivalents start + with "MIPS16OP" instead of "OP". */ +#define INSERT_OPERAND(FIELD, INSN, VALUE) \ + INSERT_BITS ((INSN).insn_opcode, VALUE, OP_MASK_##FIELD, OP_SH_##FIELD) +#define MIPS16_INSERT_OPERAND(FIELD, INSN, VALUE) \ + INSERT_BITS ((INSN).insn_opcode, VALUE, \ + MIPS16OP_MASK_##FIELD, MIPS16OP_SH_##FIELD) + +/* Extract the operand given by FIELD from mips_cl_insn INSN. */ +#define EXTRACT_OPERAND(FIELD, INSN) \ + EXTRACT_BITS ((INSN).insn_opcode, OP_MASK_##FIELD, OP_SH_##FIELD) +#define MIPS16_EXTRACT_OPERAND(FIELD, INSN) \ + EXTRACT_BITS ((INSN).insn_opcode, \ + MIPS16OP_MASK_##FIELD, \ + MIPS16OP_SH_##FIELD) /* Global variables used when generating relaxable macros. See the comment above RELAX_ENCODE for more details about how relaxation @@ -866,7 +985,7 @@ enum mips_regclass { MIPS_GR_REG, MIPS_F static void append_insn (struct mips_cl_insn *ip, expressionS *p, bfd_reloc_code_real_type *r); -static void mips_no_prev_insn (int); +static void mips_no_prev_insn (void); static void mips16_macro_build (expressionS *, const char *, const char *, va_list); static void load_register (int, expressionS *, int); @@ -1092,8 +1211,6 @@ mips_target_format (void) { switch (OUTPUT_FLAVOR) { - case bfd_target_aout_flavour: - return target_big_endian ? "a.out-mips-big" : "a.out-mips-little"; case bfd_target_ecoff_flavour: return target_big_endian ? "ecoff-bigmips" : ECOFF_LITTLE_FORMAT; case bfd_target_coff_flavour: @@ -1127,6 +1244,174 @@ mips_target_format (void) } } +/* Return the length of instruction INSN. */ + +static inline unsigned int +insn_length (const struct mips_cl_insn *insn) +{ + if (!mips_opts.mips16) + return 4; + return insn->mips16_absolute_jump_p || insn->use_extend ? 4 : 2; +} + +/* Initialise INSN from opcode entry MO. Leave its position unspecified. */ + +static void +create_insn (struct mips_cl_insn *insn, const struct mips_opcode *mo) +{ + size_t i; + + insn->insn_mo = mo; + insn->use_extend = FALSE; + insn->extend = 0; + insn->insn_opcode = mo->match; + insn->frag = NULL; + insn->where = 0; + for (i = 0; i < ARRAY_SIZE (insn->fixp); i++) + insn->fixp[i] = NULL; + insn->fixed_p = (mips_opts.noreorder > 0); + insn->noreorder_p = (mips_opts.noreorder > 0); + insn->mips16_absolute_jump_p = 0; +} + +/* Install INSN at the location specified by its "frag" and "where" fields. */ + +static void +install_insn (const struct mips_cl_insn *insn) +{ + char *f = insn->frag->fr_literal + insn->where; + if (!mips_opts.mips16) + md_number_to_chars (f, insn->insn_opcode, 4); + else if (insn->mips16_absolute_jump_p) + { + md_number_to_chars (f, insn->insn_opcode >> 16, 2); + md_number_to_chars (f + 2, insn->insn_opcode & 0xffff, 2); + } + else + { + if (insn->use_extend) + { + md_number_to_chars (f, 0xf000 | insn->extend, 2); + f += 2; + } + md_number_to_chars (f, insn->insn_opcode, 2); + } +} + +/* Move INSN to offset WHERE in FRAG. Adjust the fixups accordingly + and install the opcode in the new location. */ + +static void +move_insn (struct mips_cl_insn *insn, fragS *frag, long where) +{ + size_t i; + + insn->frag = frag; + insn->where = where; + for (i = 0; i < ARRAY_SIZE (insn->fixp); i++) + if (insn->fixp[i] != NULL) + { + insn->fixp[i]->fx_frag = frag; + insn->fixp[i]->fx_where = where; + } + install_insn (insn); +} + +/* Add INSN to the end of the output. */ + +static void +add_fixed_insn (struct mips_cl_insn *insn) +{ + char *f = frag_more (insn_length (insn)); + move_insn (insn, frag_now, f - frag_now->fr_literal); +} + +/* Start a variant frag and move INSN to the start of the variant part, + marking it as fixed. The other arguments are as for frag_var. */ + +static void +add_relaxed_insn (struct mips_cl_insn *insn, int max_chars, int var, + relax_substateT subtype, symbolS *symbol, offsetT offset) +{ + frag_grow (max_chars); + move_insn (insn, frag_now, frag_more (0) - frag_now->fr_literal); + insn->fixed_p = 1; + frag_var (rs_machine_dependent, max_chars, var, + subtype, symbol, offset, NULL); +} + +/* Insert N copies of INSN into the history buffer, starting at + position FIRST. Neither FIRST nor N need to be clipped. */ + +static void +insert_into_history (unsigned int first, unsigned int n, + const struct mips_cl_insn *insn) +{ + if (mips_relax.sequence != 2) + { + unsigned int i; + + for (i = ARRAY_SIZE (history); i-- > first;) + if (i >= first + n) + history[i] = history[i - n]; + else + history[i] = *insn; + } +} + +/* Emit a nop instruction, recording it in the history buffer. */ + +static void +emit_nop (void) +{ + add_fixed_insn (NOP_INSN); + insert_into_history (0, 1, NOP_INSN); +} + +/* Initialize vr4120_conflicts. There is a bit of duplication here: + the idea is to make it obvious at a glance that each errata is + included. */ + +static void +init_vr4120_conflicts (void) +{ +#define CONFLICT(FIRST, SECOND) \ + vr4120_conflicts[FIX_VR4120_##FIRST] |= 1 << FIX_VR4120_##SECOND + + /* Errata 21 - [D]DIV[U] after [D]MACC */ + CONFLICT (MACC, DIV); + CONFLICT (DMACC, DIV); + + /* Errata 23 - Continuous DMULT[U]/DMACC instructions. */ + CONFLICT (DMULT, DMULT); + CONFLICT (DMULT, DMACC); + CONFLICT (DMACC, DMULT); + CONFLICT (DMACC, DMACC); + + /* Errata 24 - MT{LO,HI} after [D]MACC */ + CONFLICT (MACC, MTHILO); + CONFLICT (DMACC, MTHILO); + + /* VR4181A errata MD(1): "If a MULT, MULTU, DMULT or DMULTU + instruction is executed immediately after a MACC or DMACC + instruction, the result of [either instruction] is incorrect." */ + CONFLICT (MACC, MULT); + CONFLICT (MACC, DMULT); + CONFLICT (DMACC, MULT); + CONFLICT (DMACC, DMULT); + + /* VR4181A errata MD(4): "If a MACC or DMACC instruction is + executed immediately after a DMULT, DMULTU, DIV, DIVU, + DDIV or DDIVU instruction, the result of the MACC or + DMACC instruction is incorrect.". */ + CONFLICT (DMULT, MACC); + CONFLICT (DMULT, DMACC); + CONFLICT (DIV, MACC); + CONFLICT (DIV, DMACC); + +#undef CONFLICT +} + /* This function is called once, at assembler startup time. It should set up all the tables, etc. that the MD part of the assembler will need. */ @@ -1137,6 +1422,13 @@ md_begin (void) int i = 0; int broken = 0; + if (mips_pic != NO_PIC) + { + if (g_switch_seen && g_switch_value != 0) + as_bad (_("-G may not be used in position-independent code")); + g_switch_value = 0; + } + if (! bfd_set_arch_mach (stdoutput, bfd_arch_mips, file_mips_arch)) as_warn (_("Could not set architecture and machine")); @@ -1160,6 +1452,11 @@ md_begin (void) { if (!validate_mips_insn (&mips_opcodes[i])) broken = 1; + if (nop_insn.insn_mo == NULL && strcmp (name, "nop") == 0) + { + create_insn (&nop_insn, mips_opcodes + i); + nop_insn.fixed_p = 1; + } } ++i; } @@ -1187,6 +1484,11 @@ md_begin (void) mips16_opcodes[i].name, mips16_opcodes[i].args); broken = 1; } + if (mips16_nop_insn.insn_mo == NULL && strcmp (name, "nop") == 0) + { + create_insn (&mips16_nop_insn, mips16_opcodes + i); + mips16_nop_insn.fixed_p = 1; + } ++i; } while (i < bfd_mips16_num_opcodes @@ -1239,7 +1541,7 @@ md_begin (void) &zero_address_frag)); } - mips_no_prev_insn (FALSE); + mips_no_prev_insn (); mips_gprmask = 0; mips_cprmask[0] = 0; @@ -1250,15 +1552,15 @@ md_begin (void) /* set the default alignment for the text section (2**2) */ record_alignment (text_section, 2); - if (USE_GLOBAL_POINTER_OPT) - bfd_set_gp_size (stdoutput, g_switch_value); + bfd_set_gp_size (stdoutput, g_switch_value); if (OUTPUT_FLAVOR == bfd_target_elf_flavour) { /* On a native system, sections must be aligned to 16 byte - boundaries. When configured for an embedded ELF target, we + boundaries. When configured for an embedded ELF target, we don't bother. */ - if (strcmp (TARGET_OS, "elf") != 0) + if (strcmp (TARGET_OS, "elf") != 0 + && strcmp (TARGET_OS, "vxworks") != 0) { (void) bfd_set_section_alignment (stdoutput, text_section, 4); (void) bfd_set_section_alignment (stdoutput, data_section, 4); @@ -1346,6 +1648,9 @@ md_begin (void) if (! ECOFF_DEBUGGING) md_obj_begin (); + + if (mips_fix_vr4120) + init_vr4120_conflicts (); } void @@ -1408,8 +1713,8 @@ md_assemble (char *str) } /* Return true if the given relocation might need a matching %lo(). - Note that R_MIPS_GOT16 relocations only need a matching %lo() when - applied to local symbols. */ + This is only "might" because SVR4 R_MIPS_GOT16 relocations only + need a matching %lo() when applied to local symbols. */ static inline bfd_boolean reloc_needs_lo_p (bfd_reloc_code_real_type reloc) @@ -1434,7 +1739,7 @@ fixup_has_matching_lo_p (fixS *fixp) of register. */ static int -insn_uses_reg (struct mips_cl_insn *ip, unsigned int reg, +insn_uses_reg (const struct mips_cl_insn *ip, unsigned int reg, enum mips_regclass class) { if (class == MIPS16_REG) @@ -1459,38 +1764,33 @@ insn_uses_reg (struct mips_cl_insn *ip, because there is no instruction that sets both $f0 and $f1 and requires a delay. */ if ((ip->insn_mo->pinfo & INSN_READ_FPR_S) - && ((((ip->insn_opcode >> OP_SH_FS) & OP_MASK_FS) &~(unsigned)1) + && ((EXTRACT_OPERAND (FS, *ip) & ~(unsigned) 1) == (reg &~ (unsigned) 1))) return 1; if ((ip->insn_mo->pinfo & INSN_READ_FPR_T) - && ((((ip->insn_opcode >> OP_SH_FT) & OP_MASK_FT) &~(unsigned)1) + && ((EXTRACT_OPERAND (FT, *ip) & ~(unsigned) 1) == (reg &~ (unsigned) 1))) return 1; } else if (! mips_opts.mips16) { if ((ip->insn_mo->pinfo & INSN_READ_GPR_S) - && ((ip->insn_opcode >> OP_SH_RS) & OP_MASK_RS) == reg) + && EXTRACT_OPERAND (RS, *ip) == reg) return 1; if ((ip->insn_mo->pinfo & INSN_READ_GPR_T) - && ((ip->insn_opcode >> OP_SH_RT) & OP_MASK_RT) == reg) + && EXTRACT_OPERAND (RT, *ip) == reg) return 1; } else { if ((ip->insn_mo->pinfo & MIPS16_INSN_READ_X) - && (mips16_to_32_reg_map[((ip->insn_opcode >> MIPS16OP_SH_RX) - & MIPS16OP_MASK_RX)] - == reg)) + && mips16_to_32_reg_map[MIPS16_EXTRACT_OPERAND (RX, *ip)] == reg) return 1; if ((ip->insn_mo->pinfo & MIPS16_INSN_READ_Y) - && (mips16_to_32_reg_map[((ip->insn_opcode >> MIPS16OP_SH_RY) - & MIPS16OP_MASK_RY)] - == reg)) + && mips16_to_32_reg_map[MIPS16_EXTRACT_OPERAND (RY, *ip)] == reg) return 1; if ((ip->insn_mo->pinfo & MIPS16_INSN_READ_Z) - && (mips16_to_32_reg_map[((ip->insn_opcode >> MIPS16OP_SH_MOVE32Z) - & MIPS16OP_MASK_MOVE32Z)] + && (mips16_to_32_reg_map[MIPS16_EXTRACT_OPERAND (MOVE32Z, *ip)] == reg)) return 1; if ((ip->insn_mo->pinfo & MIPS16_INSN_READ_T) && reg == TREG) @@ -1500,8 +1800,7 @@ insn_uses_reg (struct mips_cl_insn *ip, if ((ip->insn_mo->pinfo & MIPS16_INSN_READ_31) && reg == RA) return 1; if ((ip->insn_mo->pinfo & MIPS16_INSN_READ_GPR_X) - && ((ip->insn_opcode >> MIPS16OP_SH_REGR32) - & MIPS16OP_MASK_REGR32) == reg) + && MIPS16_EXTRACT_OPERAND (REGR32, *ip) == reg) return 1; } @@ -1516,7 +1815,7 @@ reg_needs_delay (unsigned int reg) { unsigned long prev_pinfo; - prev_pinfo = prev_insn.insn_mo->pinfo; + prev_pinfo = history[0].insn_mo->pinfo; if (! mips_opts.noreorder && (((prev_pinfo & INSN_LOAD_MEMORY_DELAY) && ! gpr_interlocks) @@ -1527,13 +1826,33 @@ reg_needs_delay (unsigned int reg) delay the use of general register rt for one instruction. */ /* Itbl support may require additional care here. */ know (prev_pinfo & INSN_WRITE_GPR_T); - if (reg == ((prev_insn.insn_opcode >> OP_SH_RT) & OP_MASK_RT)) + if (reg == EXTRACT_OPERAND (RT, history[0])) return 1; } return 0; } +/* Move all labels in insn_labels to the current insertion point. */ + +static void +mips_move_labels (void) +{ + struct insn_label_list *l; + valueT val; + + for (l = insn_labels; l != NULL; l = l->next) + { + assert (S_GET_SEGMENT (l->label) == now_seg); + symbol_set_frag (l->label, frag_now); + val = (valueT) frag_now_fix (); + /* mips16 text labels are stored as odd. */ + if (mips_opts.mips16) + ++val; + S_SET_VALUE (l->label, val); + } +} + /* Mark instruction labels in mips16 mode. This permits the linker to handle them specially, such as generating jalx instructions when needed. We also make them odd for the duration of the assembly, in @@ -1609,6 +1928,273 @@ relax_end (void) mips_relax.sequence = 0; } +/* Classify an instruction according to the FIX_VR4120_* enumeration. + Return NUM_FIX_VR4120_CLASSES if the instruction isn't affected + by VR4120 errata. */ + +static unsigned int +classify_vr4120_insn (const char *name) +{ + if (strncmp (name, "macc", 4) == 0) + return FIX_VR4120_MACC; + if (strncmp (name, "dmacc", 5) == 0) + return FIX_VR4120_DMACC; + if (strncmp (name, "mult", 4) == 0) + return FIX_VR4120_MULT; + if (strncmp (name, "dmult", 5) == 0) + return FIX_VR4120_DMULT; + if (strstr (name, "div")) + return FIX_VR4120_DIV; + if (strcmp (name, "mtlo") == 0 || strcmp (name, "mthi") == 0) + return FIX_VR4120_MTHILO; + return NUM_FIX_VR4120_CLASSES; +} + +/* Return the number of instructions that must separate INSN1 and INSN2, *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-8@FreeBSD.ORG Thu Dec 8 00:48:06 2011 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A14141065675; Thu, 8 Dec 2011 00:48:06 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9057F8FC1D; Thu, 8 Dec 2011 00:48:06 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pB80m6xc063097; Thu, 8 Dec 2011 00:48:06 GMT (envelope-from gonzo@svn.freebsd.org) Received: (from gonzo@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pB80m6OQ063095; Thu, 8 Dec 2011 00:48:06 GMT (envelope-from gonzo@svn.freebsd.org) Message-Id: <201112080048.pB80m6OQ063095@svn.freebsd.org> From: Oleksandr Tymoshenko Date: Thu, 8 Dec 2011 00:48:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r228338 - stable/8/sys/mips/conf X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Dec 2011 00:48:06 -0000 Author: gonzo Date: Thu Dec 8 00:48:06 2011 New Revision: 228338 URL: http://svn.freebsd.org/changeset/base/228338 Log: Unbreak MALTA64 build by providing proper ldscript name Modified: stable/8/sys/mips/conf/MALTA64 Modified: stable/8/sys/mips/conf/MALTA64 ============================================================================== --- stable/8/sys/mips/conf/MALTA64 Thu Dec 8 00:47:22 2011 (r228337) +++ stable/8/sys/mips/conf/MALTA64 Thu Dec 8 00:48:06 2011 (r228338) @@ -21,7 +21,7 @@ ident MALTA makeoptions ARCH_FLAGS="-march=mips64 -mabi=64" makeoptions MIPS_LITTLE_ENDIAN=defined -makeoptions LDSCRIPT_NAME= ldscript.mips.mips64 +makeoptions LDSCRIPT_NAME= ldscript.mips.64 options YAMON From owner-svn-src-stable-8@FreeBSD.ORG Thu Dec 8 00:48:47 2011 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 988581065673; Thu, 8 Dec 2011 00:48:47 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 879EC8FC12; Thu, 8 Dec 2011 00:48:47 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pB80mlL4063152; Thu, 8 Dec 2011 00:48:47 GMT (envelope-from gonzo@svn.freebsd.org) Received: (from gonzo@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pB80mlia063150; Thu, 8 Dec 2011 00:48:47 GMT (envelope-from gonzo@svn.freebsd.org) Message-Id: <201112080048.pB80mlia063150@svn.freebsd.org> From: Oleksandr Tymoshenko Date: Thu, 8 Dec 2011 00:48:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r228339 - stable/8/sys/mips/conf X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Dec 2011 00:48:47 -0000 Author: gonzo Date: Thu Dec 8 00:48:47 2011 New Revision: 228339 URL: http://svn.freebsd.org/changeset/base/228339 Log: Add -march=octeon optoin for building OCTEON1-32 kernel Modified: stable/8/sys/mips/conf/OCTEON1-32 Modified: stable/8/sys/mips/conf/OCTEON1-32 ============================================================================== --- stable/8/sys/mips/conf/OCTEON1-32 Thu Dec 8 00:48:06 2011 (r228338) +++ stable/8/sys/mips/conf/OCTEON1-32 Thu Dec 8 00:48:47 2011 (r228339) @@ -24,7 +24,7 @@ ident OCTEON1 # Don't build any modules yet. makeoptions MODULES_OVERRIDE="" makeoptions TARGET_BIG_ENDIAN=defined -#makeoptions ARCH_FLAGS="-march=octeon" +makeoptions ARCH_FLAGS="-march=octeon" makeoptions LDSCRIPT_NAME=ldscript.mips.octeon1.32 makeoptions KERNLOADADDR=0x81000000 From owner-svn-src-stable-8@FreeBSD.ORG Thu Dec 8 00:50:15 2011 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 06EFE106564A; Thu, 8 Dec 2011 00:50:15 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E13568FC12; Thu, 8 Dec 2011 00:50:14 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pB80oEqi063238; Thu, 8 Dec 2011 00:50:14 GMT (envelope-from gonzo@svn.freebsd.org) Received: (from gonzo@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pB80oEQ4063236; Thu, 8 Dec 2011 00:50:14 GMT (envelope-from gonzo@svn.freebsd.org) Message-Id: <201112080050.pB80oEQ4063236@svn.freebsd.org> From: Oleksandr Tymoshenko Date: Thu, 8 Dec 2011 00:50:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r228340 - stable/8/sys/conf X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Dec 2011 00:50:15 -0000 Author: gonzo Date: Thu Dec 8 00:50:14 2011 New Revision: 228340 URL: http://svn.freebsd.org/changeset/base/228340 Log: Add ldscripts for OCTEON1 and OCTEON1-32 Added: - copied unchanged from r215938, head/sys/conf/ldscript.mips.octeon1.32 - copied unchanged from r215938, head/sys/conf/ldscript.mips.octeon1.64 Directory Properties: stable/8/sys/conf/ldscript.mips.octeon1.32 (props changed) stable/8/sys/conf/ldscript.mips.octeon1.64 (props changed) Copied: stable/8/sys/conf/ldscript.mips.octeon1.32 (from r215938, head/sys/conf/ldscript.mips.octeon1.32) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/8/sys/conf/ldscript.mips.octeon1.32 Thu Dec 8 00:50:14 2011 (r228340, copy of r215938, head/sys/conf/ldscript.mips.octeon1.32) @@ -0,0 +1,60 @@ +/* $FreeBSD$ */ + +TARGET(elf32-tradbigmips) +OUTPUT_FORMAT("elf32-tradbigmips", "elf32-tradbigmips", "elf32-tradlittlemips") +OUTPUT_ARCH(mips) +ENTRY(_start) + __DYNAMIC = 0; +PROVIDE (_DYNAMIC = 0); + +SECTIONS { + . = KERNLOADADDR + SIZEOF_HEADERS; + + .text . : { + *(.text) + *(.dynamic) + etext = .; + _etext = .; + . = ALIGN(0x2000); + } + + .rodata ALIGN(0x2000) : { + _fdata = .; + *(.rodata) + . = ALIGN(32); + } + + .data . : { + _rwdata = .; + *(.data) + . = ALIGN(32); + CONSTRUCTORS; + } + + _gp = (. + 0x8000); + + .sdata . : { + _small_start = .; + *(.sdata) + . = ALIGN(32); + edata = .; + _edata = .; + } + + .sbss . : { + __bss_start = .; + _fbss = .; + *(.sbss) *(.scommon) + _small_end = .; + . = ALIGN(32); + } + + .bss . : { + *(.bss) + *(COMMON) + . = ALIGN(32); + _end = .; + end = .; + } + +} Copied: stable/8/sys/conf/ldscript.mips.octeon1.64 (from r215938, head/sys/conf/ldscript.mips.octeon1.64) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/8/sys/conf/ldscript.mips.octeon1.64 Thu Dec 8 00:50:14 2011 (r228340, copy of r215938, head/sys/conf/ldscript.mips.octeon1.64) @@ -0,0 +1,65 @@ +/* $FreeBSD$ */ + +TARGET(elf64-tradbigmips) +OUTPUT_FORMAT("elf64-tradbigmips", "elf64-tradbigmips", "elf64-tradlittlemips") +OUTPUT_ARCH(mips) +ENTRY(_start) + __DYNAMIC = 0; +PROVIDE (_DYNAMIC = 0); + +PHDRS { + text PT_LOAD FLAGS(0x7); +} + +SECTIONS { + . = KERNLOADADDR + SIZEOF_HEADERS; + + .text : { + *(.text) + *(.dynamic) + etext = .; + _etext = .; + . = ALIGN(0x2000); + } : text + + . = ALIGN(0x2000); + .rodata : { + _fdata = .; + *(.rodata) + . = ALIGN(32); + } + + .data : { + _rwdata = .; + *(.data) + . = ALIGN(32); + CONSTRUCTORS; + } + + _gp = (. + 0x8000); + + .sdata : { + _small_start = .; + *(.sdata) + . = ALIGN(32); + edata = .; + _edata = .; + } : text + + .sbss : { + __bss_start = .; + _fbss = .; + *(.sbss) *(.scommon) + _small_end = .; + . = ALIGN(32); + } + + .bss : { + *(.bss) + *(COMMON) + . = ALIGN(32); + _end = .; + end = .; + } + +} From owner-svn-src-stable-8@FreeBSD.ORG Thu Dec 8 00:56:24 2011 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4F42A106564A; Thu, 8 Dec 2011 00:56:24 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3E63F8FC0C; Thu, 8 Dec 2011 00:56:24 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pB80uOhw063466; Thu, 8 Dec 2011 00:56:24 GMT (envelope-from gonzo@svn.freebsd.org) Received: (from gonzo@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pB80uOb1063464; Thu, 8 Dec 2011 00:56:24 GMT (envelope-from gonzo@svn.freebsd.org) Message-Id: <201112080056.pB80uOb1063464@svn.freebsd.org> From: Oleksandr Tymoshenko Date: Thu, 8 Dec 2011 00:56:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r228341 - stable/8/sys/dev/ic X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Dec 2011 00:56:24 -0000 Author: gonzo Date: Thu Dec 8 00:56:23 2011 New Revision: 228341 URL: http://svn.freebsd.org/changeset/base/228341 Log: MFS r202062: Defintions for cavium uart MFC after: 23 months Modified: stable/8/sys/dev/ic/ns16550.h Directory Properties: stable/8/sys/ (props changed) Modified: stable/8/sys/dev/ic/ns16550.h ============================================================================== --- stable/8/sys/dev/ic/ns16550.h Thu Dec 8 00:50:14 2011 (r228340) +++ stable/8/sys/dev/ic/ns16550.h Thu Dec 8 00:56:23 2011 (r228341) @@ -52,6 +52,7 @@ #define REG_IIR com_iir #define IIR_IMASK 0xf #define IIR_RXTOUT 0xc +#define IIR_BUSY 0x7 #define IIR_RLS 0x6 #define IIR_RXRDY 0x4 #define IIR_TXRDY 0x2 @@ -181,6 +182,10 @@ #define com_xoff1 6 /* XOFF 1 character (R/W) */ #define com_xoff2 7 /* XOFF 2 character (R/W) */ +#define com_usr 39 /* Octeon 16750/16550 Uart Status Reg */ +#define REG_USR com_usr +#define USR_TXFIFO_NOTFULL 2 /* Uart TX FIFO Not full */ + /* 16950 register #1. Access enabled by ACR[7]. Also requires !LCR[7]. */ #define com_asr 1 /* additional status register (R[0-7]/W[0-1]) */ From owner-svn-src-stable-8@FreeBSD.ORG Thu Dec 8 10:42:38 2011 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 970771065670; Thu, 8 Dec 2011 10:42:38 +0000 (UTC) (envelope-from ru@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 854EC8FC12; Thu, 8 Dec 2011 10:42:38 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pB8AgcOZ081797; Thu, 8 Dec 2011 10:42:38 GMT (envelope-from ru@svn.freebsd.org) Received: (from ru@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pB8Agcfg081785; Thu, 8 Dec 2011 10:42:38 GMT (envelope-from ru@svn.freebsd.org) Message-Id: <201112081042.pB8Agcfg081785@svn.freebsd.org> From: Ruslan Ermilov Date: Thu, 8 Dec 2011 10:42:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r228348 - stable/8/contrib/one-true-awk X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Dec 2011 10:42:38 -0000 Author: ru Date: Thu Dec 8 10:42:38 2011 New Revision: 228348 URL: http://svn.freebsd.org/changeset/base/228348 Log: Update to a 10-Aug-2011 release. Deleted: stable/8/contrib/one-true-awk/proctab.c Modified: stable/8/contrib/one-true-awk/FIXES stable/8/contrib/one-true-awk/README stable/8/contrib/one-true-awk/awkgram.y stable/8/contrib/one-true-awk/b.c stable/8/contrib/one-true-awk/lex.c stable/8/contrib/one-true-awk/lib.c stable/8/contrib/one-true-awk/main.c stable/8/contrib/one-true-awk/makefile stable/8/contrib/one-true-awk/proto.h stable/8/contrib/one-true-awk/run.c stable/8/contrib/one-true-awk/tran.c Directory Properties: stable/8/contrib/one-true-awk/ (props changed) Modified: stable/8/contrib/one-true-awk/FIXES ============================================================================== --- stable/8/contrib/one-true-awk/FIXES Thu Dec 8 09:21:30 2011 (r228347) +++ stable/8/contrib/one-true-awk/FIXES Thu Dec 8 10:42:38 2011 (r228348) @@ -25,6 +25,59 @@ THIS SOFTWARE. This file lists all bug fixes, changes, etc., made since the AWK book was sent to the printers in August, 1987. +Aug 10, 2011: + another fix to avoid core dump with delete(ARGV); again, many thanks + to ruslan ermilov. + +Aug 7, 2011: + split(s, a, //) now behaves the same as split(s, a, "") + +Jun 12, 2011: + /pat/, \n /pat/ {...} is now legal, though bad style to use. + + added checks to new -v code that permits -vnospace; thanks to + ruslan ermilov for spotting this and providing the patch. + + removed fixed limit on number of open files; thanks to aleksey + cheusov and christos zoulos. + + fixed day 1 bug that resurrected deleted elements of ARGV when + used as filenames (in lib.c). + + minor type fiddles to make gcc -Wall -pedantic happier (but not + totally so); turned on -fno-strict-aliasing in makefile. + +May 6, 2011: + added #ifdef for isblank. + now allows -ffoo as well as -f foo arguments. + (thanks, ruslan) + +May 1, 2011: + after advice from todd miller, kevin lo, ruslan ermilov, + and arnold robbins, changed srand() to return the previous + seed (which is 1 on the first call of srand). the seed is + an Awkfloat internally though converted to unsigned int to + pass to the library srand(). thanks, everyone. + + fixed a subtle (and i hope low-probability) overflow error + in fldbld, by adding space for one extra \0. thanks to + robert bassett for spotting this one and providing a fix. + + removed the files related to compilation on windows. i no + longer have anything like a current windows environment, so + i can't test any of it. + +May 23, 2010: + fixed long-standing overflow bug in run.c; many thanks to + nelson beebe for spotting it and providing the fix. + + fixed bug that didn't parse -vd=1 properly; thanks to santiago + vila for spotting it. + +Feb 8, 2010: + i give up. replaced isblank with isspace in b.c; there are + no consistent header files. + Nov 26, 2009: fixed a long-standing issue with when FS takes effect. a change to FS is now noticed immediately for subsequent splits. Modified: stable/8/contrib/one-true-awk/README ============================================================================== --- stable/8/contrib/one-true-awk/README Thu Dec 8 09:21:30 2011 (r228347) +++ stable/8/contrib/one-true-awk/README Thu Dec 8 10:42:38 2011 (r228348) @@ -29,7 +29,7 @@ by Al Aho, Brian Kernighan, and Peter We Changes, mostly bug fixes and occasional enhancements, are listed in FIXES. If you distribute this code further, please please please distribute FIXES with it. If you find errors, please report them -to bwk@bell-labs.com. Thanks. +to bwk@cs.princeton.edu. Thanks. The program itself is created by make Modified: stable/8/contrib/one-true-awk/awkgram.y ============================================================================== --- stable/8/contrib/one-true-awk/awkgram.y Thu Dec 8 09:21:30 2011 (r228347) +++ stable/8/contrib/one-true-awk/awkgram.y Thu Dec 8 10:42:38 2011 (r228348) @@ -174,8 +174,8 @@ pa_pat: pa_stat: pa_pat { $$ = stat2(PASTAT, $1, stat2(PRINT, rectonode(), NIL)); } | pa_pat lbrace stmtlist '}' { $$ = stat2(PASTAT, $1, $3); } - | pa_pat ',' pa_pat { $$ = pa2stat($1, $3, stat2(PRINT, rectonode(), NIL)); } - | pa_pat ',' pa_pat lbrace stmtlist '}' { $$ = pa2stat($1, $3, $5); } + | pa_pat ',' opt_nl pa_pat { $$ = pa2stat($1, $4, stat2(PRINT, rectonode(), NIL)); } + | pa_pat ',' opt_nl pa_pat lbrace stmtlist '}' { $$ = pa2stat($1, $4, $6); } | lbrace stmtlist '}' { $$ = stat2(PASTAT, NIL, $2); } | XBEGIN lbrace stmtlist '}' { beginloc = linkum(beginloc, $3); $$ = 0; } Modified: stable/8/contrib/one-true-awk/b.c ============================================================================== --- stable/8/contrib/one-true-awk/b.c Thu Dec 8 09:21:30 2011 (r228347) +++ stable/8/contrib/one-true-awk/b.c Thu Dec 8 10:42:38 2011 (r228348) @@ -234,7 +234,7 @@ void freetr(Node *p) /* free parse tree /* in the parsing of regular expressions, metacharacters like . have */ /* to be seen literally; \056 is not a metacharacter. */ -int hexstr(char **pp) /* find and eval hex string at pp, return new p */ +int hexstr(uschar **pp) /* find and eval hex string at pp, return new p */ { /* only pick up one 8-bit byte (2 chars) */ uschar *p; int n = 0; @@ -248,16 +248,16 @@ int hexstr(char **pp) /* find and eval h else if (*p >= 'A' && *p <= 'F') n = 16 * n + *p - 'A' + 10; } - *pp = (char *) p; + *pp = (uschar *) p; return n; } #define isoctdigit(c) ((c) >= '0' && (c) <= '7') /* multiple use of arg */ -int quoted(char **pp) /* pick up next thing after a \\ */ +int quoted(uschar **pp) /* pick up next thing after a \\ */ /* and increment *pp */ { - char *p = *pp; + uschar *p = *pp; int c; if ((c = *p++) == 't') @@ -314,13 +314,13 @@ char *cclenter(const char *argp) /* add bp = buf; for (i = 0; (c = *p++) != 0; ) { if (c == '\\') { - c = quoted((char **) &p); + c = quoted(&p); } else if (c == '-' && i > 0 && bp[-1] != 0) { if (*p != 0) { c = bp[-1]; c2 = *p++; if (c2 == '\\') - c2 = quoted((char **) &p); + c2 = quoted(&p); if (collate_range_cmp(c, c2) > 0) { bp--; i--; @@ -752,7 +752,7 @@ Node *unary(Node *np) /* #define HAS_ISBLANK */ #ifndef HAS_ISBLANK -int (isblank)(int c) +int (xisblank)(int c) { return c==' ' || c=='\t'; } @@ -766,7 +766,11 @@ struct charclass { } charclasses[] = { { "alnum", 5, isalnum }, { "alpha", 5, isalpha }, +#ifndef HAS_ISBLANK + { "blank", 5, isspace }, /* was isblank */ +#else { "blank", 5, isblank }, +#endif { "cntrl", 5, iscntrl }, { "digit", 5, isdigit }, { "graph", 5, isgraph }, @@ -803,7 +807,7 @@ int relex(void) /* lexical analyzer for case ')': return c; case '\\': - rlxval = quoted((char **) &prestr); + rlxval = quoted(&prestr); return CHAR; default: rlxval = c; Modified: stable/8/contrib/one-true-awk/lex.c ============================================================================== --- stable/8/contrib/one-true-awk/lex.c Thu Dec 8 09:21:30 2011 (r228347) +++ stable/8/contrib/one-true-awk/lex.c Thu Dec 8 10:42:38 2011 (r228348) @@ -411,7 +411,7 @@ int string(void) } *px = 0; unput(c); - sscanf(xbuf, "%x", &n); + sscanf(xbuf, "%x", (unsigned int *) &n); *bp++ = n; break; } Modified: stable/8/contrib/one-true-awk/lib.c ============================================================================== --- stable/8/contrib/one-true-awk/lib.c Thu Dec 8 09:21:30 2011 (r228347) +++ stable/8/contrib/one-true-awk/lib.c Thu Dec 8 10:42:38 2011 (r228348) @@ -89,8 +89,13 @@ void initgetrec(void) char *p; for (i = 1; i < *ARGC; i++) { - if (!isclvar(p = getargv(i))) { /* find 1st real filename */ - setsval(lookup("FILENAME", symtab), getargv(i)); + p = getargv(i); /* find 1st real filename */ + if (p == NULL || *p == '\0') { /* deleted or zapped */ + argno++; + continue; + } + if (!isclvar(p)) { + setsval(lookup("FILENAME", symtab), p); return; } setclvar(p); /* a commandline assignment before filename */ @@ -124,7 +129,7 @@ int getrec(char **pbuf, int *pbufsize, i dprintf( ("argno=%d, file=|%s|\n", argno, file) ); if (infile == NULL) { /* have to open a new file */ file = getargv(argno); - if (*file == '\0') { /* it's been zapped */ + if (file == NULL || *file == '\0') { /* deleted or zapped */ argno++; continue; } @@ -187,6 +192,7 @@ int readrec(char **pbuf, int *pbufsize, if (strlen(*FS) >= sizeof(inputFS)) FATAL("field separator %.10s... is too long", *FS); + /*fflush(stdout); avoids some buffering problem but makes it 25% slower*/ strcpy(inputFS, *FS); /* for subsequent field splitting */ if ((sep = **RS) == 0) { sep = '\n'; @@ -227,6 +233,8 @@ char *getargv(int n) /* get ARGV[n] */ extern Array *ARGVtab; sprintf(temp, "%d", n); + if (lookup(temp, ARGVtab) == NULL) + return NULL; x = setsymtab(temp, "", 0.0, STR, ARGVtab); s = getsval(x); dprintf( ("getargv(%d) returns |%s|\n", n, s) ); @@ -256,6 +264,7 @@ void fldbld(void) /* create fields from { /* this relies on having fields[] the same length as $0 */ /* the fields are all stored in this one array with \0's */ + /* possibly with a final trailing \0 not associated with any field */ char *r, *fr, sep; Cell *p; int i, j, n; @@ -268,7 +277,7 @@ void fldbld(void) /* create fields from n = strlen(r); if (n > fieldssize) { xfree(fields); - if ((fields = (char *) malloc(n+1)) == NULL) + if ((fields = (char *) malloc(n+2)) == NULL) /* possibly 2 final \0s */ FATAL("out of space for fields in fldbld %d", n); fieldssize = n; } @@ -476,14 +485,14 @@ void recbld(void) /* create $0 from $1.. if (!adjbuf(&record, &recsize, 2+r-record, recsize, &r, "recbld 3")) FATAL("built giant record `%.30s...'", record); *r = '\0'; - dprintf( ("in recbld inputFS=%s, fldtab[0]=%p\n", inputFS, fldtab[0]) ); + dprintf( ("in recbld inputFS=%s, fldtab[0]=%p\n", inputFS, (void*)fldtab[0]) ); if (freeable(fldtab[0])) xfree(fldtab[0]->sval); fldtab[0]->tval = REC | STR | DONTFREE; fldtab[0]->sval = record; - dprintf( ("in recbld inputFS=%s, fldtab[0]=%p\n", inputFS, fldtab[0]) ); + dprintf( ("in recbld inputFS=%s, fldtab[0]=%p\n", inputFS, (void*)fldtab[0]) ); dprintf( ("recbld = |%s|\n", record) ); donerec = 1; } Modified: stable/8/contrib/one-true-awk/main.c ============================================================================== --- stable/8/contrib/one-true-awk/main.c Thu Dec 8 09:21:30 2011 (r228347) +++ stable/8/contrib/one-true-awk/main.c Thu Dec 8 10:42:38 2011 (r228348) @@ -25,7 +25,7 @@ THIS SOFTWARE. #include __FBSDID("$FreeBSD$"); -const char *version = "version 20091126 (FreeBSD)"; +const char *version = "version 20110810 (FreeBSD)"; #define DEBUG #include @@ -41,6 +41,7 @@ extern char **environ; extern int nfields; int dbg = 0; +Awkfloat srand_seed = 1; char *cmdname; /* gets argv[0] for error messages */ extern FILE *yyin; /* lex input file */ char *lexprog; /* points to program argument if it exists */ @@ -71,6 +72,10 @@ int main(int argc, char *argv[]) exit(1); } signal(SIGFPE, fpecatch); + + srand_seed = 1; + srand(srand_seed); + yyin = NULL; symtab = makesymtab(NSYMTAB/NSYMTAB); while (argc > 1 && argv[1][0] == '-' && argv[1][1] != '\0') { @@ -90,7 +95,7 @@ int main(int argc, char *argv[]) safe = 1; break; case 'f': /* next argument is program filename */ - if (argv[1][2] != 0) { /* arg is -fsomething */ + if (argv[1][2] != 0) { /* arg is -fsomething */ if (npfile >= MAX_PFILE - 1) FATAL("too many -f options"); pfile[npfile++] = &argv[1][2]; @@ -120,13 +125,19 @@ int main(int argc, char *argv[]) WARNING("field separator FS is empty"); break; case 'v': /* -v a=1 to be done NOW. one -v for each */ - if (argv[1][2] != 0) { /* arg is -vsomething */ - if (argv[1][2] != 0) + if (argv[1][2] != 0) { /* arg is -vsomething */ + if (isclvar(&argv[1][2])) setclvar(&argv[1][2]); + else + FATAL("invalid -v option argument: %s", &argv[1][2]); } else { /* arg is -v something */ argc--; argv++; - if (argc > 1 && isclvar(argv[1])) + if (argc <= 1) + FATAL("no variable name"); + if (isclvar(argv[1])) setclvar(argv[1]); + else + FATAL("invalid -v option argument: %s", argv[1]); } break; case 'd': Modified: stable/8/contrib/one-true-awk/makefile ============================================================================== --- stable/8/contrib/one-true-awk/makefile Thu Dec 8 09:21:30 2011 (r228347) +++ stable/8/contrib/one-true-awk/makefile Thu Dec 8 10:42:38 2011 (r228348) @@ -26,12 +26,11 @@ CFLAGS = -g CFLAGS = -O2 CFLAGS = -CC = gcc -Wall -g -Wwrite-strings -CC = gcc -fprofile-arcs -ftest-coverage # then gcov f1.c; cat f1.c.gcov CC = gcc -Wall -g CC = cc -CC = gcc -O4 - +CC = gcc -Wall -g -Wwrite-strings +CC = gcc -fprofile-arcs -ftest-coverage # then gcov f1.c; cat f1.c.gcov +CC = gcc -O4 -Wall -pedantic -fno-strict-aliasing YACC = bison -y YACC = yacc @@ -40,13 +39,13 @@ YFLAGS = -d OFILES = b.o main.o parse.o proctab.o tran.o lib.o run.o lex.o SOURCE = awk.h ytab.c ytab.h proto.h awkgram.y lex.c b.c main.c \ - maketab.c parse.c lib.c run.c tran.c proctab.c missing95.c + maketab.c parse.c lib.c run.c tran.c proctab.c LISTING = awk.h proto.h awkgram.y lex.c b.c main.c maketab.c parse.c \ - lib.c run.c tran.c missing95.c + lib.c run.c tran.c -SHIP = README FIXES $(SOURCE) ytab[ch].bak makefile makefile.win \ - vcvars32.bat buildwin.bat awk.1 +SHIP = README FIXES $(SOURCE) ytab[ch].bak makefile \ + awk.1 a.out: ytab.o $(OFILES) $(CC) $(CFLAGS) ytab.o $(OFILES) $(ALLOC) -lm Modified: stable/8/contrib/one-true-awk/proto.h ============================================================================== --- stable/8/contrib/one-true-awk/proto.h Thu Dec 8 09:21:30 2011 (r228347) +++ stable/8/contrib/one-true-awk/proto.h Thu Dec 8 10:42:38 2011 (r228348) @@ -43,8 +43,8 @@ extern fa *mkdfa(const char *, int); extern int makeinit(fa *, int); extern void penter(Node *); extern void freetr(Node *); -extern int hexstr(char **); -extern int quoted(char **); +extern int hexstr(uschar **); +extern int quoted(uschar **); extern char *cclenter(const char *); extern void overflo(const char *); extern void cfoll(fa *, Node *); Modified: stable/8/contrib/one-true-awk/run.c ============================================================================== --- stable/8/contrib/one-true-awk/run.c Thu Dec 8 09:21:30 2011 (r228347) +++ stable/8/contrib/one-true-awk/run.c Thu Dec 8 10:42:38 2011 (r228348) @@ -69,6 +69,7 @@ void tempfree(Cell *p) { jmp_buf env; extern int pairstack[]; +extern Awkfloat srand_seed; Node *winner = NULL; /* root of parse tree */ Cell *tmps; /* free temporary cells for execution */ @@ -1238,6 +1239,12 @@ Cell *split(Node **a, int nnn) /* split( ap->sval = (char *) makesymtab(NSYMTAB); n = 0; + if (arg3type == REGEXPR && strlen((char*)((fa*)a[2])->restr) == 0) { + /* split(s, a, //); have to arrange that it looks like empty sep */ + arg3type = 0; + fs = ""; + sep = 0; + } if (*s != '\0' && (strlen(fs) > 1 || arg3type == REGEXPR)) { /* reg expr */ fa *pfa; if (arg3type == REGEXPR) { /* it's ready already */ @@ -1469,6 +1476,7 @@ Cell *bltin(Node **a, int n) /* builtin Cell *x, *y; Awkfloat u; int t; + Awkfloat tmp; char *p, *buf; Node *nextarg; FILE *fp; @@ -1520,7 +1528,10 @@ Cell *bltin(Node **a, int n) /* builtin u = time((time_t *)0); else u = getfval(x); + tmp = u; srand((unsigned int) u); + u = srand_seed; + srand_seed = tmp; break; case FTOUPPER: case FTOLOWER: @@ -1616,17 +1627,25 @@ struct files { FILE *fp; const char *fname; int mode; /* '|', 'a', 'w' => LE/LT, GT */ -} files[FOPEN_MAX] ={ - { NULL, "/dev/stdin", LT }, /* watch out: don't free this! */ - { NULL, "/dev/stdout", GT }, - { NULL, "/dev/stderr", GT } -}; +} *files; + +int nfiles; void stdinit(void) /* in case stdin, etc., are not constants */ { - files[0].fp = stdin; - files[1].fp = stdout; - files[2].fp = stderr; + nfiles = FOPEN_MAX; + files = calloc(nfiles, sizeof(*files)); + if (files == NULL) + FATAL("can't allocate file memory for %u files", nfiles); + files[0].fp = stdin; + files[0].fname = "/dev/stdin"; + files[0].mode = LT; + files[1].fp = stdout; + files[1].fname = "/dev/stdout"; + files[1].mode = GT; + files[2].fp = stderr; + files[2].fname = "/dev/stderr"; + files[2].mode = GT; } FILE *openfile(int a, const char *us) @@ -1637,7 +1656,7 @@ FILE *openfile(int a, const char *us) if (*s == '\0') FATAL("null file name in print or getline"); - for (i=0; i < FOPEN_MAX; i++) + for (i=0; i < nfiles; i++) if (files[i].fname && strcmp(s, files[i].fname) == 0) { if (a == files[i].mode || (a==APPEND && files[i].mode==GT)) return files[i].fp; @@ -1647,11 +1666,19 @@ FILE *openfile(int a, const char *us) if (a == FFLUSH) /* didn't find it, so don't create it! */ return NULL; - for (i=0; i < FOPEN_MAX; i++) + for (i=0; i < nfiles; i++) if (files[i].fp == 0) break; - if (i >= FOPEN_MAX) - FATAL("%s makes too many open files", s); + if (i >= nfiles) { + struct files *nf; + int nnf = nfiles + FOPEN_MAX; + nf = realloc(files, nnf * sizeof(*nf)); + if (nf == NULL) + FATAL("cannot grow files for %s and %d files", s, nnf); + memset(&nf[nfiles], 0, FOPEN_MAX * sizeof(*nf)); + nfiles = nnf; + files = nf; + } fflush(stdout); /* force a semblance of order */ m = a; if (a == GT) { @@ -1679,7 +1706,7 @@ const char *filename(FILE *fp) { int i; - for (i = 0; i < FOPEN_MAX; i++) + for (i = 0; i < nfiles; i++) if (fp == files[i].fp) return files[i].fname; return "???"; @@ -1694,7 +1721,7 @@ Cell *closefile(Node **a, int n) x = execute(a[0]); getsval(x); stat = -1; - for (i = 0; i < FOPEN_MAX; i++) { + for (i = 0; i < nfiles; i++) { if (files[i].fname && strcmp(x->sval, files[i].fname) == 0) { if (ferror(files[i].fp)) WARNING( "i/o error occurred on %s", files[i].fname ); @@ -1738,7 +1765,7 @@ void flush_all(void) { int i; - for (i = 0; i < FOPEN_MAX; i++) + for (i = 0; i < nfiles; i++) if (files[i].fp) fflush(files[i].fp); } @@ -1890,9 +1917,10 @@ Cell *gsub(Node **a, int nnn) /* global adjbuf(&buf, &bufsz, 1+strlen(sptr)+pb-buf, 0, &pb, "gsub"); while ((*pb++ = *sptr++) != 0) ; - done: if (pb > buf + bufsz) - FATAL("gsub result2 %.30s too big; can't happen", buf); - *pb = '\0'; + done: if (pb < buf + bufsz) + *pb = '\0'; + else if (*(pb-1) != '\0') + FATAL("gsub result2 %.30s truncated; can't happen", buf); setsval(x, buf); /* BUG: should be able to avoid copy + free */ pfa->initstat = tempstat; } Modified: stable/8/contrib/one-true-awk/tran.c ============================================================================== --- stable/8/contrib/one-true-awk/tran.c Thu Dec 8 09:21:30 2011 (r228347) +++ stable/8/contrib/one-true-awk/tran.c Thu Dec 8 10:42:38 2011 (r228348) @@ -212,7 +212,7 @@ Cell *setsymtab(const char *n, const cha if (n != NULL && (p = lookup(n, tp)) != NULL) { dprintf( ("setsymtab found %p: n=%s s=\"%s\" f=%g t=%o\n", - p, NN(p->nval), NN(p->sval), p->fval, p->tval) ); + (void*)p, NN(p->nval), NN(p->sval), p->fval, p->tval) ); return(p); } p = (Cell *) malloc(sizeof(Cell)); @@ -231,7 +231,7 @@ Cell *setsymtab(const char *n, const cha p->cnext = tp->tab[h]; tp->tab[h] = p; dprintf( ("setsymtab set %p: n=%s s=\"%s\" f=%g t=%o\n", - p, p->nval, p->sval, p->fval, p->tval) ); + (void*)p, p->nval, p->sval, p->fval, p->tval) ); return(p); } @@ -298,7 +298,7 @@ Awkfloat setfval(Cell *vp, Awkfloat f) / xfree(vp->sval); /* free any previous string */ vp->tval &= ~STR; /* mark string invalid */ vp->tval |= NUM; /* mark number ok */ - dprintf( ("setfval %p: %s = %g, t=%o\n", vp, NN(vp->nval), f, vp->tval) ); + dprintf( ("setfval %p: %s = %g, t=%o\n", (void*)vp, NN(vp->nval), f, vp->tval) ); return vp->fval = f; } @@ -318,7 +318,7 @@ char *setsval(Cell *vp, const char *s) / int fldno; dprintf( ("starting setsval %p: %s = \"%s\", t=%o, r,f=%d,%d\n", - vp, NN(vp->nval), s, vp->tval, donerec, donefld) ); + (void*)vp, NN(vp->nval), s, vp->tval, donerec, donefld) ); if ((vp->tval & (NUM | STR)) == 0) funnyvar(vp, "assign to"); if (isfld(vp)) { @@ -338,7 +338,7 @@ char *setsval(Cell *vp, const char *s) / vp->tval |= STR; vp->tval &= ~DONTFREE; dprintf( ("setsval %p: %s = \"%s (%p) \", t=%o r,f=%d,%d\n", - vp, NN(vp->nval), t,t, vp->tval, donerec, donefld) ); + (void*)vp, NN(vp->nval), t,t, vp->tval, donerec, donefld) ); return(vp->sval = t); } @@ -355,7 +355,8 @@ Awkfloat getfval(Cell *vp) /* get float if (is_number(vp->sval) && !(vp->tval&CON)) vp->tval |= NUM; /* make NUM only sparingly */ } - dprintf( ("getfval %p: %s = %g, t=%o\n", vp, NN(vp->nval), vp->fval, vp->tval) ); + dprintf( ("getfval %p: %s = %g, t=%o\n", + (void*)vp, NN(vp->nval), vp->fval, vp->tval) ); return(vp->fval); } @@ -381,7 +382,8 @@ static char *get_str_val(Cell *vp, char vp->tval &= ~DONTFREE; vp->tval |= STR; } - dprintf( ("getsval %p: %s = \"%s (%p)\", t=%o\n", vp, NN(vp->nval), vp->sval, vp->sval, vp->tval) ); + dprintf( ("getsval %p: %s = \"%s (%p)\", t=%o\n", + (void*)vp, NN(vp->nval), vp->sval, vp->sval, vp->tval) ); return(vp->sval); }