From patchwork Mon Mar 2 06:22:45 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Herrenschmidt X-Patchwork-Id: 23922 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from ozlabs.org (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id E8F1ADE133 for ; Mon, 2 Mar 2009 17:24:09 +1100 (EST) X-Original-To: linuxppc-dev@ozlabs.org Delivered-To: linuxppc-dev@ozlabs.org Received: by ozlabs.org (Postfix, from userid 1030) id D547ADDEF0; Mon, 2 Mar 2009 17:23:45 +1100 (EST) To: From: Benjamin Herrenschmidt Date: Mon, 02 Mar 2009 17:22:45 +1100 Subject: [PATCH] powerpc/mm: Tweak PTE bit combination definitions Message-Id: <20090302062345.D547ADDEF0@ozlabs.org> X-BeenThere: linuxppc-dev@ozlabs.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@ozlabs.org This patch tweaks the way some PTE bit combinations are defined, in such a way that the 32 and 64-bit variant become almost identical and that will make it easier to bring in a new common pte-* file for the new variant of the Book3-E support. The combination of bits defining access to kernel pages are now clearly separated from the combination used by userspace and the core VM. The resulting generated code should remain identical unless I made a mistake. Note: While at it, I removed a non-sensical statement related to CONFIG_KGDB in ppc_mmu_32.c which could cause kernel mappings to be user accessible when that option is enabled. Probably something that bitrot. Signed-off-by: Benjamin Herrenschmidt --- arch/powerpc/include/asm/fixmap.h | 2 arch/powerpc/include/asm/pgtable-ppc32.h | 105 +++---------------------------- arch/powerpc/include/asm/pgtable-ppc64.h | 44 +++++++----- arch/powerpc/include/asm/pgtable.h | 4 + arch/powerpc/include/asm/pte-8xx.h | 3 arch/powerpc/include/asm/pte-hash32.h | 1 arch/powerpc/include/asm/pte-hash64-4k.h | 3 arch/powerpc/include/asm/pte-hash64.h | 47 +++++++------ arch/powerpc/mm/fsl_booke_mmu.c | 2 arch/powerpc/mm/pgtable_32.c | 4 - arch/powerpc/mm/ppc_mmu_32.c | 10 -- arch/powerpc/sysdev/cpm_common.c | 2 12 files changed, 79 insertions(+), 148 deletions(-) --- linux-work.orig/arch/powerpc/include/asm/pgtable-ppc64.h 2009-03-02 13:41:49.000000000 +1100 +++ linux-work/arch/powerpc/include/asm/pgtable-ppc64.h 2009-03-02 16:11:50.000000000 +1100 @@ -81,11 +81,6 @@ */ #include -/* To make some generic powerpc code happy */ -#ifndef _PAGE_HWEXEC -#define _PAGE_HWEXEC 0 -#endif - /* Some other useful definitions */ #define PTE_RPN_MAX (1UL << (64 - PTE_RPN_SHIFT)) #define PTE_RPN_MASK (~((1UL< Index: linux-work/arch/powerpc/include/asm/pgtable-ppc32.h =================================================================== --- linux-work.orig/arch/powerpc/include/asm/pgtable-ppc32.h 2009-03-02 14:01:44.000000000 +1100 +++ linux-work/arch/powerpc/include/asm/pgtable-ppc32.h 2009-03-02 16:11:50.000000000 +1100 @@ -103,79 +103,6 @@ extern int icache_44x_need_flush; #endif /* - * Some bits are only used on some cpu families... Make sure that all - * the undefined gets defined as 0 - */ -#ifndef _PAGE_HASHPTE -#define _PAGE_HASHPTE 0 -#endif -#ifndef _PTE_NONE_MASK -#define _PTE_NONE_MASK 0 -#endif -#ifndef _PAGE_SHARED -#define _PAGE_SHARED 0 -#endif -#ifndef _PAGE_HWWRITE -#define _PAGE_HWWRITE 0 -#endif -#ifndef _PAGE_HWEXEC -#define _PAGE_HWEXEC 0 -#endif -#ifndef _PAGE_EXEC -#define _PAGE_EXEC 0 -#endif -#ifndef _PAGE_ENDIAN -#define _PAGE_ENDIAN 0 -#endif -#ifndef _PAGE_COHERENT -#define _PAGE_COHERENT 0 -#endif -#ifndef _PAGE_WRITETHRU -#define _PAGE_WRITETHRU 0 -#endif -#ifndef _PAGE_SPECIAL -#define _PAGE_SPECIAL 0 -#endif -#ifndef _PMD_PRESENT_MASK -#define _PMD_PRESENT_MASK _PMD_PRESENT -#endif -#ifndef _PMD_SIZE -#define _PMD_SIZE 0 -#define PMD_PAGE_SIZE(pmd) bad_call_to_PMD_PAGE_SIZE() -#endif - -#define _PAGE_HPTEFLAGS _PAGE_HASHPTE - -/* Location of the PFN in the PTE. Most platforms use the same as _PAGE_SHIFT - * here (ie, naturally aligned). Platform who don't just pre-define the - * value so we don't override it here - */ -#ifndef PTE_RPN_SHIFT -#define PTE_RPN_SHIFT (PAGE_SHIFT) -#endif - -#ifdef CONFIG_PTE_64BIT -#define PTE_RPN_MAX (1ULL << (64 - PTE_RPN_SHIFT)) -#define PTE_RPN_MASK (~((1ULL<= _stext && (char *) v < etext); - f = ktext ?_PAGE_RAM_TEXT : _PAGE_RAM; + f = ktext ? PAGE_KERNEL_TEXT : PAGE_KERNEL; map_page(v, p, f); #ifdef CONFIG_PPC_STD_MMU_32 if (ktext) Index: linux-work/arch/powerpc/mm/ppc_mmu_32.c =================================================================== --- linux-work.orig/arch/powerpc/mm/ppc_mmu_32.c 2009-03-02 14:37:05.000000000 +1100 +++ linux-work/arch/powerpc/mm/ppc_mmu_32.c 2009-03-02 15:15:36.000000000 +1100 @@ -74,9 +74,6 @@ unsigned long p_mapped_by_bats(phys_addr unsigned long __init mmu_mapin_ram(void) { -#ifdef CONFIG_POWER4 - return 0; -#else unsigned long tot, bl, done; unsigned long max_size = (256<<20); @@ -95,7 +92,7 @@ unsigned long __init mmu_mapin_ram(void) break; } - setbat(2, PAGE_OFFSET, 0, bl, _PAGE_RAM); + setbat(2, PAGE_OFFSET, 0, bl, PAGE_KERNEL_X); done = (unsigned long)bat_addrs[2].limit - PAGE_OFFSET + 1; if ((done < tot) && !bat_addrs[3].limit) { /* use BAT3 to cover a bit more */ @@ -103,12 +100,11 @@ unsigned long __init mmu_mapin_ram(void) for (bl = 128<<10; bl < max_size; bl <<= 1) if (bl * 2 > tot) break; - setbat(3, PAGE_OFFSET+done, done, bl, _PAGE_RAM); + setbat(3, PAGE_OFFSET+done, done, bl, PAGE_KERNEL_X); done = (unsigned long)bat_addrs[3].limit - PAGE_OFFSET + 1; } return done; -#endif } /* @@ -136,9 +132,7 @@ void __init setbat(int index, unsigned l wimgxpp |= (flags & _PAGE_RW)? BPP_RW: BPP_RX; bat[1].batu = virt | (bl << 2) | 2; /* Vs=1, Vp=0 */ bat[1].batl = BAT_PHYS_ADDR(phys) | wimgxpp; -#ifndef CONFIG_KGDB /* want user access for breakpoints */ if (flags & _PAGE_USER) -#endif bat[1].batu |= 1; /* Vp = 1 */ if (flags & _PAGE_GUARDED) { /* G bit must be zero in IBATs */ Index: linux-work/arch/powerpc/sysdev/cpm_common.c =================================================================== --- linux-work.orig/arch/powerpc/sysdev/cpm_common.c 2009-03-02 14:26:07.000000000 +1100 +++ linux-work/arch/powerpc/sysdev/cpm_common.c 2009-03-02 15:32:45.000000000 +1100 @@ -56,7 +56,7 @@ void __init udbg_init_cpm(void) { if (cpm_udbg_txdesc) { #ifdef CONFIG_CPM2 - setbat(1, 0xf0000000, 0xf0000000, 1024*1024, _PAGE_IO); + setbat(1, 0xf0000000, 0xf0000000, 1024*1024, PAGE_KERNEL_NCG); #endif udbg_putc = udbg_putc_cpm; } Index: linux-work/arch/powerpc/include/asm/fixmap.h =================================================================== --- linux-work.orig/arch/powerpc/include/asm/fixmap.h 2009-03-02 14:43:23.000000000 +1100 +++ linux-work/arch/powerpc/include/asm/fixmap.h 2009-03-02 15:33:15.000000000 +1100 @@ -61,7 +61,7 @@ extern void __set_fixmap (enum fixed_add * Some hardware wants to get fixmapped without caching. */ #define set_fixmap_nocache(idx, phys) \ - __set_fixmap(idx, phys, PAGE_KERNEL_NOCACHE) + __set_fixmap(idx, phys, PAGE_KERNEL_NCG) #define clear_fixmap(idx) \ __set_fixmap(idx, 0, __pgprot(0)) Index: linux-work/arch/powerpc/include/asm/pgtable.h =================================================================== --- linux-work.orig/arch/powerpc/include/asm/pgtable.h 2009-03-02 15:31:31.000000000 +1100 +++ linux-work/arch/powerpc/include/asm/pgtable.h 2009-03-02 16:11:50.000000000 +1100 @@ -25,6 +25,10 @@ static inline void assert_pte_locked(str # include #endif +/* Special mapping for AGP */ +#define PAGE_AGP (PAGE_KERNEL_NC) +#define HAVE_PAGE_AGP + #ifndef __ASSEMBLY__ /* Insert a PTE, top-level function is out of line. It uses an inline Index: linux-work/arch/powerpc/mm/fsl_booke_mmu.c =================================================================== --- linux-work.orig/arch/powerpc/mm/fsl_booke_mmu.c 2009-03-02 16:12:37.000000000 +1100 +++ linux-work/arch/powerpc/mm/fsl_booke_mmu.c 2009-03-02 16:12:42.000000000 +1100 @@ -162,7 +162,7 @@ unsigned long __init mmu_mapin_ram(void) phys_addr_t phys = memstart_addr; while (cam[tlbcam_index] && tlbcam_index < ARRAY_SIZE(cam)) { - settlbcam(tlbcam_index, virt, phys, cam[tlbcam_index], _PAGE_KERNEL, 0); + settlbcam(tlbcam_index, virt, phys, cam[tlbcam_index], PAGE_KERNEL_X, 0); virt += cam[tlbcam_index]; phys += cam[tlbcam_index]; tlbcam_index++;