[parisc-linux-cvs] Large Memory Support patch

John Marvin jsm@udlkern.fc.hp.com
Tue, 13 Feb 2001 08:47:41 -0700 (MST)


The following patch contains code that I just commited that moves
PAGE_OFFSET to 0x10000000 (256 Mb). This allows the kernel to support
3.5Gb of memory on a 32 bit system (the same for 64 bit kernels, but
we will eventually do better there).

John

--- arch/parisc/kernel/ccio-dma.c.old	Mon Feb 12 02:38:13 2001
+++ arch/parisc/kernel/ccio-dma.c	Mon Feb 12 02:38:46 2001
@@ -556,8 +556,7 @@ ccio_io_pdir_entry(u64 *pdir_ptr, space_
 	register unsigned long ci; /* coherent index */
 
 	/* We currently only support kernel addresses */
-	ASSERT(sid == 0);
-	ASSERT(((unsigned long) vba & 0xc0000000UL) == 0xc0000000UL);
+	ASSERT(sid == KERNEL_SPACE);
 
 	mtsp(sid,1);
 
--- arch/parisc/kernel/entry.S.old	Sat Feb 10 01:01:29 2001
+++ arch/parisc/kernel/entry.S	Tue Feb 13 07:06:28 2001
@@ -56,8 +56,7 @@
 	/* Switch to virtual mapping, trashing only %r1 */
 	.macro	virt_map rfi_type
 	mtsm	%r0
-	tovirt	%r29
-	tovirt	%r30
+	tovirt_r1 %r29
 	mfsp	%sr7, %r1
 	mtsp	%r1, %sr3
 	mtsp	%r0, %sr4
@@ -66,13 +65,11 @@
 	mtsp	%r0, %sr7
 	ldil	L%KERNEL_PSW, %r1
 	ldo	R%KERNEL_PSW(%r1), %r1
-	LDIL_FIXUP(%r1)
 	mtctl	%r1, %cr22
 	mtctl	%r0, %cr17
 	mtctl	%r0, %cr17
 	ldil	L%4f, %r1
 	ldo	R%4f(%r1), %r1
-	LDIL_FIXUP(%r1)
 	mtctl	%r1, %cr18
 	ldo	4(%r1), %r1
 	mtctl	%r1, %cr18
@@ -87,8 +84,9 @@
 	comib,=,n 0, %r1, 0f   /* forward so predicted not taken */
 
 	/* we save the registers in the task struct */
-	ldo	TASK_REGS(%r1), %r29
-	tophys	%r29
+
+	tophys  %r1,%r29
+	ldo     TASK_REGS(%r29),%r29
 	STREG	%r30, PT_GR30(%r29)
 	STREG	%r1,  PT_CR30(%r29)
 	ldo	TASK_SZ_ALGN(%r1), %r30
@@ -96,9 +94,8 @@
 	mtctl	%r0,%cr30
 0:
 	/* we put a struct pt_regs on the stack and save the registers there */
-	copy	%r30,%r29
+	tophys  %r30,%r29
 	ldo	PT_SZ_ALGN(%r30),%r30
-	tophys	%r29
 	STREG	%r30,PT_GR30(%r29)
 	STREG	%r0,PT_CR30(%r29)
 1:
@@ -562,7 +559,6 @@ _switch_to:
 
 	ldil	L%_switch_to_ret, %r2
 	ldo	R%_switch_to_ret(%r2), %r2
-	LDIL_FIXUP(%r2)
 
 	STREG	%r2, TASK_PT_KPC(%r26)
 	LDREG	TASK_PT_KPC(%r25), %r2
@@ -619,7 +615,6 @@ intr_return:
 
 	ldil	L%irq_stat,%r19
 	ldo	R%irq_stat(%r19),%r19
-	LDIL_FIXUP(%r19)
 
 #ifdef CONFIG_SMP
 	copy	%r30,%r1
@@ -659,11 +654,10 @@ intr_check_sig:
 	comib,<>,n 0,%r19,intr_do_signal /* forward */
 
 intr_restore:
-	copy	    	%r16, %r29
-	ldo		PT_FR31(%r29), %r29
+	copy            %r16, %r1
+	ldo             PT_FR31(%r1), %r29
 	rest_fp		%r29
-	copy    	%r16, %r29
-	rest_general 	%r29
+	rest_general    %r1
 	ssm		0,%r0
 	nop
 	nop
@@ -672,7 +666,7 @@ intr_restore:
 	nop
 	nop
 	nop
-	tophys		%r29
+	tophys          %r1,%r29
 	mtsm		%r0
 	rest_specials	%r29
 	rest_stack	%r29
@@ -758,9 +752,8 @@ intr_extint:
 	ldil		L%cpu_irq_region, %r25
 	ldo		R%cpu_irq_region(%r25), %r25
 #ifdef __LP64__
-	ldo		-16(%r30),%r29	/* Reference param save area */
 	bl		do_irq_mask,%r2
-	LDIL_FIXUP(%r25)
+	ldo		-16(%r30),%r29	/* Reference param save area */
 #else
 	bl		do_irq_mask,%r2
 	nop
@@ -897,7 +890,6 @@ dtlb_check_alias_20w:
 
 	cmpib,<>,n      0,spc,dtlb_fault /* forward */
 	ldil            L%(TMPALIAS_MAP_START),t0
-	LDIL_FIXUP(t0)
 	copy            va,t1
 	depdi           0,63,23,t1
 	cmpb,*<>,n      t0,t1,dtlb_fault /* forward */
@@ -1771,7 +1763,6 @@ sys_fork_wrapper:
 	STREG	%r30,PT_GR20(%r1)
 	ldil    L%child_return,%r3
 	ldo     R%child_return(%r3),%r3
-	LDIL_FIXUP(%r3)
 	STREG	%r3,PT_GR21(%r1)	/* save for child */
 
 	LDREG	PT_GR30(%r1),%r25
@@ -1811,7 +1802,6 @@ sys_clone_wrapper:
 	STREG	%r30,PT_GR20(%r1)
 	ldil	L%child_return,%r3
 	ldo	R%child_return(%r3),%r3
-	LDIL_FIXUP(%r3)
 	STREG	%r3,PT_GR21(%r1)	/* save for child */
 
 	bl	sys_clone,%r2
@@ -1834,7 +1824,6 @@ sys_vfork_wrapper:
 	STREG	%r30,PT_GR20(%r1)
 	ldil	L%child_return,%r3
 	ldo	R%child_return(%r3),%r3
-	LDIL_FIXUP(%r3)
 	STREG	%r3,PT_GR21(%r1)	/* save for child */
 
 	bl	sys_vfork,%r2
@@ -2006,7 +1995,6 @@ syscall_check_bh:
 
 	ldil    L%irq_stat,%r19
 	ldo     R%irq_stat(%r19),%r19
-	LDIL_FIXUP(%r19)
 
 #ifdef CONFIG_SMP
 	/* sched.h: int processor */
--- arch/parisc/kernel/head.S.old	Sun Feb 11 01:14:36 2001
+++ arch/parisc/kernel/head.S	Mon Feb 12 06:36:19 2001
@@ -64,9 +64,13 @@ stext:
 	mtctl		%r4,%cr24	/* Initialize kernel root pointer */
 	mtctl		%r4,%cr25	/* Initialize user root pointer */
 
-	stw		%r3,0xc00(%r4)	/* Hardwired 0xc... kernel Vaddr start*/
+#if (__PAGE_OFFSET != 0x10000000UL)
+Error! Code below (the next two stw's) needs to be changed
+#endif
+
+	stw             %r3,0x100(%r4)  /* Hardwired 0x1... kernel Vaddr start*/
 	ldo		0x1000(%r3),%r3
-	stw		%r3,0xc04(%r4)
+	stw             %r3,0x104(%r4)
 	ldo		_PAGE_KERNEL(%r0),%r3 /* Hardwired 0 phys addr start */
 $pgt_fill_loop:
 	stwm		%r3,4(%r1)
@@ -194,7 +198,6 @@ $install_iva:
 	nop
 
 	.procend
-
 
 #ifdef CONFIG_SMP
 
--- arch/parisc/kernel/hpmc.S.old	Sat Feb 10 01:01:29 2001
+++ arch/parisc/kernel/hpmc.S	Sat Feb 10 22:40:08 2001
@@ -261,7 +261,7 @@ os_hpmc_5:
 	mtsp	%r0, %sr6
 	mtsp	%r0, %sr7
 
-	tovirt  %r30        /* make sp virtual */
+	tovirt_r1 %r30      /* make sp virtual */
 
 	rsm 8,%r0           /* Clear Q bit */
 	ldi     1,%r1
--- arch/parisc/kernel/pacache.S.old	Sat Feb 10 01:01:29 2001
+++ arch/parisc/kernel/pacache.S	Tue Feb 13 07:06:28 2001
@@ -189,7 +189,6 @@ fdtdone:
 	mtctl	%r0, %cr17
 	ldil    L%(2f), %r1
 	ldo     R%(2f)(%r1), %r1
-	LDIL_FIXUP(%r1)
 	mtctl	%r1, %cr18
 	ldo	4(%r1), %r1
 	mtctl	%r1, %cr18
@@ -213,7 +212,6 @@ flush_instruction_cache:
 	mtsp            %r0,%sr1
 	ldil            L%cache_info,%r1
 	ldo             R%cache_info(%r1),%r1
-	LDIL_FIXUP(%r1)
 
 	/* Flush Instruction Cache */
 
@@ -254,7 +252,6 @@ flush_data_cache:
 	mtsp            %r0,%sr1
 	ldil            L%cache_info,%r1
 	ldo             R%cache_info(%r1),%r1
-	LDIL_FIXUP(%r1)
 
 	/* Flush Data Cache */
 
@@ -349,8 +346,8 @@ copy_user_page_asm:
 
 	.procend
 
-#if (TMPALIAS_MAP_START != 0xff000000UL)
-#warning TMPALIAS_MAP_START changed. If > 32 bit, code in pacache.S is bogus
+#if (TMPALIAS_MAP_START >= 0x80000000UL)
+Warning TMPALIAS_MAP_START changed. If > 2 Gb, code in pacache.S is bogus
 #endif
 
 /*
@@ -396,12 +393,11 @@ copy_user_page_asm:
 	.callinfo NO_CALLS
 	.entry
 
-	tophys  %r26
-	tophys  %r25
-	copy    %r25,%r23 /* move into non shadowed register */
+	ldil    L%(__PAGE_OFFSET),%r1
+	sub     %r26,%r1,%r26
+	sub     %r25,%r1,%r23  /* move physical addr into non shadowed reg */
 
 	ldil    L%(TMPALIAS_MAP_START),%r28
-	LDIL_FIXUP(%r28)
 #ifdef __LP64__
 	extrd,u %r26,56,32,%r26 /* convert phys addr to tlb insert format */
 	extrd,u %r23,56,32,%r23 /* convert phys addr to tlb insert format */
@@ -486,10 +482,9 @@ clear_user_page_asm:
 	.callinfo NO_CALLS
 	.entry
 
-	tophys  %r26
+	tophys_r1 %r26
 
 	ldil    L%(TMPALIAS_MAP_START),%r28
-	LDIL_FIXUP(%r28)
 #ifdef __LP64__
 	extrd,u %r26,56,32,%r26 /* convert phys addr to tlb insert format */
 	depd    %r25,63,22,%r28 /* Form aliased virtual address 'to' */
@@ -540,7 +535,6 @@ flush_kernel_dcache_page:
 	.entry
 
 	ldil    L%dcache_stride,%r1
-	LDIL_FIXUP(%r1)
 	ldw     R%dcache_stride(%r1),%r23
 
 #ifdef __LP64__
@@ -585,7 +579,6 @@ purge_kernel_dcache_page:
 	.entry
 
 	ldil    L%dcache_stride,%r1
-	LDIL_FIXUP(%r1)
 	ldw     R%dcache_stride(%r1),%r23
 
 #ifdef __LP64__
@@ -633,10 +626,9 @@ flush_alias_page:
 	.callinfo NO_CALLS
 	.entry
 
-	tophys  %r26
+	tophys_r1 %r26
 
 	ldil    L%(TMPALIAS_MAP_START),%r28
-	LDIL_FIXUP(%r28)
 #ifdef __LP64__
 	extrd,u %r26,56,32,%r26 /* convert phys addr to tlb insert format */
 	depd    %r25,63,22,%r28 /* Form aliased virtual address 'to' */
@@ -652,7 +644,6 @@ flush_alias_page:
 	pdtlb   0(%r28)
 
 	ldil    L%dcache_stride,%r1
-	LDIL_FIXUP(%r1)
 	ldw     R%dcache_stride(%r1),%r23
 
 #ifdef __LP64__
@@ -697,7 +688,6 @@ flush_user_dcache_range_asm:
 	.entry
 
 	ldil    L%dcache_stride,%r1
-	LDIL_FIXUP(%r1)
 	ldw     R%dcache_stride(%r1),%r23
 	ldo     -1(%r23),%r21
 	ANDCM   %r26,%r21,%r26
@@ -720,7 +710,6 @@ flush_kernel_dcache_range_asm:
 	.entry
 
 	ldil    L%dcache_stride,%r1
-	LDIL_FIXUP(%r1)
 	ldw     R%dcache_stride(%r1),%r23
 	ldo     -1(%r23),%r21
 	ANDCM   %r26,%r21,%r26
@@ -744,7 +733,6 @@ flush_user_icache_range_asm:
 	.entry
 
 	ldil    L%icache_stride,%r1
-	LDIL_FIXUP(%r1)
 	ldw     R%icache_stride(%r1),%r23
 	ldo     -1(%r23),%r21
 	ANDCM   %r26,%r21,%r26
@@ -767,7 +755,6 @@ flush_kernel_icache_range_asm:
 	.entry
 
 	ldil    L%icache_stride,%r1
-	LDIL_FIXUP(%r1)
 	ldw     R%icache_stride(%r1),%r23
 	ldo     -1(%r23),%r21
 	ANDCM   %r26,%r21,%r26
@@ -862,7 +849,6 @@ srdis_done:
 	mtctl	%r0, %cr17
 	ldil    L%(2f), %r1
 	ldo     R%(2f)(%r1), %r1
-	LDIL_FIXUP(%r1)
 	mtctl	%r1, %cr18
 	ldo	4(%r1), %r1
 	mtctl	%r1, %cr18
--- arch/parisc/kernel/real2.S.old	Sat Feb 10 01:01:29 2001
+++ arch/parisc/kernel/real2.S	Tue Feb 13 08:03:15 2001
@@ -30,8 +30,11 @@ save_cr_space:
 
 /************************ 32-bit real-mode calls ***********************/
 /* This can be called in both narrow and wide kernels */
+
 	.text
+
 	.export real32_call_asm
+
 	/* unsigned long real32_call_asm(unsigned int *sp,
 	 *		unsigned int *arg0p,
 	 *		unsigned int iodc_fn)
@@ -39,6 +42,7 @@ save_cr_space:
 	 *	arg0p points to where saved arg values may be found
 	 *	iodc_fn is the IODC function to call
 	 */
+
 real32_call_asm:
 	STREG	%rp, -RP_OFFSET(%sp)	/* save RP */
 #ifdef __LP64__
@@ -60,7 +64,7 @@ real32_call_asm:
 	ldw	-12(%arg1), %arg3
 	ldw	-4(%arg1), %arg1	/* obviously must do this one last! */
 
-	tophys	%sp
+	tophys_r1  %sp
 
 	b,l	rfi_virt2real,%r2
 	nop
@@ -87,7 +91,7 @@ ric_ret:
 	b,l	rfi_real2virt,%r2
 	nop
 
-	tovirt	%sp
+	tovirt_r1 %sp
 	LDREG	-REG_SZ(%sp), %sp	/* restore SP */
 #ifdef __LP64__
 	LDREG	-1*REG_SZ(%sp), %r27
@@ -169,7 +173,7 @@ rfi_virt2real:
 	nop
 	nop
 rfi_v2r_1:
-	tophys	%r2
+	tophys_r1 %r2
 	bv	0(%r2)
 	nop
 
@@ -206,7 +210,7 @@ rfi_real2virt:
 	nop
 	nop
 rfi_r2v_1:
-	tovirt	%r2
+	tovirt_r1 %r2
 	bv	0(%r2)
 	nop
 
@@ -245,7 +249,7 @@ real64_call_asm:
 	ldd	7*REG_SZ(%arg1), %r19
 	ldd	1*REG_SZ(%arg1), %arg1		/* do this one last! */
 
-	tophys	%sp
+	tophys_r1 %sp
 
 	b,l	rfi_virt2real,%r2
 	nop
@@ -264,7 +268,7 @@ r64_ret:
 	b,l	rfi_real2virt,%r2
 	nop
 
-	tovirt	%sp
+	tovirt_r1 %sp
 	ldd	-8(%sp), %sp		/* restore SP */
 	ldd	-0x10(%sp), %rp		/* restore RP */
 	bv	0(%rp)
--- arch/parisc/kernel/sba_iommu.c.old	Mon Feb 12 02:36:12 2001
+++ arch/parisc/kernel/sba_iommu.c	Mon Feb 12 02:38:46 2001
@@ -703,8 +703,7 @@ sba_io_pdir_entry(u64 *pdir_ptr, space_t
 	register unsigned ci; /* coherent index */
 
 	/* We currently only support kernel addresses */
-	ASSERT(sid == 0);
-	ASSERT(((unsigned long) vba & 0xc0000000UL) == 0xc0000000UL);
+	ASSERT(sid == KERNEL_SPACE);
 
 	pa = virt_to_phys(vba);
 	pa &= ~4095ULL;			/* clear out offset bits */
--- arch/parisc/kernel/setup.c.old	Tue Feb 13 05:37:13 2001
+++ arch/parisc/kernel/setup.c	Tue Feb 13 05:39:06 2001
@@ -451,7 +451,7 @@ void __init start_parisc(unsigned arg0, 
 	}
 
 	mem_start = __pa(memory_start);
-#define MAX_MEM (512*1024*1024)
+#define MAX_MEM (3584*1024*1024)
 	mem_max = (PAGE0->imm_max_mem > MAX_MEM ? MAX_MEM : PAGE0->imm_max_mem);
 
 	collect_boot_cpu_data();
--- arch/parisc/kernel/syscall.S.old	Tue Feb 13 07:17:27 2001
+++ arch/parisc/kernel/syscall.S	Tue Feb 13 07:30:13 2001
@@ -121,7 +121,6 @@ linux_gateway_entry:
 
 	ldil	L%sys_call_table, %r1
 	ldo     R%sys_call_table(%r1), %r19
-	LDIL_FIXUP(%r19)
 	
 	comiclr,>>=	__NR_Linux_syscalls, %r20, %r0
 	b,n	.Lsyscall_nosys
@@ -140,13 +139,11 @@ linux_gateway_entry:
 	comb,=	%r2,%r20,.Lrt_sigreturn
 .Lin_syscall:
 	ldil	L%syscall_exit,%r2
-	LDIL_FIXUP(%r2)
 	be      0(%sr7,%r19)
 	ldo	R%syscall_exit(%r2),%r2
 .Lrt_sigreturn:
 	comib,<> 0,%r25,.Lin_syscall
 	ldil	L%syscall_exit_rfi,%r2
-	LDIL_FIXUP(%r2)
 	be      0(%sr7,%r19)
 	ldo	R%syscall_exit_rfi(%r2),%r2
 
@@ -158,7 +155,6 @@ linux_gateway_entry:
 .Lsyscall_nosys:
 syscall_nosys:
 	ldil	L%syscall_exit,%r1
-	LDIL_FIXUP(%r1)
 	be	R%syscall_exit(%sr7,%r1)
 	ldo	-ENOSYS(%r0),%r28		   /* set errno */
 
@@ -219,15 +215,12 @@ tracesys:
 	/* Finished saving things for the debugger */
 
 	ldil	L%syscall_trace,%r1
-	LDIL_FIXUP(%r1)
 	ldil	L%tracesys_next,%r2
-	LDIL_FIXUP(%r2)
 	be	R%syscall_trace(%sr7,%r1)
 	ldo	R%tracesys_next(%r2),%r2
 	
 tracesys_next:	
 	ldil	L%sys_call_table,%r1
-	LDIL_FIXUP(%r1)
 	ldo     R%sys_call_table(%r1), %r19
 
 	ldo     -TASK_SZ_ALGN-FRAME_SIZE(%r30),%r1      /* get task ptr */
@@ -259,7 +252,6 @@ tracesys_next:	
 	comb,=	%r2,%r20,.Ltrace_rt_sigreturn
 .Ltrace_in_syscall:
 	ldil	L%tracesys_exit,%r2
-	LDIL_FIXUP(%r2)
 	be      0(%sr7,%r19)
 	ldo	R%tracesys_exit(%r2),%r2
 
@@ -277,13 +269,11 @@ tracesys_exit:
 	LDREG   TASK_PT_GR28(%r1), %r28		/* Restore return val. */
 
 	ldil	L%syscall_exit,%r1
-	LDIL_FIXUP(%r1)
 	be,n	R%syscall_exit(%sr7,%r1)
 
 .Ltrace_rt_sigreturn:
 	comib,<> 0,%r25,.Ltrace_in_syscall
 	ldil	L%tracesys_sigexit,%r2
-	LDIL_FIXUP(%r2)
 	be      0(%sr7,%r19)
 	ldo	R%tracesys_sigexit(%r2),%r2
 
@@ -296,7 +286,6 @@ tracesys_sigexit:
 	nop
 
 	ldil	L%syscall_exit_rfi,%r1
-	LDIL_FIXUP(%r1)
 	be,n	R%syscall_exit_rfi(%sr7,%r1)
 
 #ifdef __LP64__
--- arch/parisc/kernel/traps.c.old	Mon Feb 12 06:53:17 2001
+++ arch/parisc/kernel/traps.c	Mon Feb 12 07:09:19 2001
@@ -668,11 +668,15 @@ void handle_interruption(int code, struc
 	return;
 }
 
-void show_stack(unsigned long sp)
+void show_stack(struct pt_regs *regs)
 {
+
 #if 1
-	if ((sp & 0xc0000000UL) == 0xc0000000UL) {
+	/* If regs->cr30 == 0, a kernel stack pointer is installed in sp */
+
+	if (regs->cr30 == 0) {
 
+	    unsigned long sp = regs->gr[30];
 	    __u32 *stackptr;
 	    __u32 *dumpptr;
 
@@ -702,7 +706,7 @@ void parisc_terminate(char *msg, struct 
 	    transfer_pim_to_trap_frame(regs);
 
 #if 1
-	show_stack(regs->gr[30]);
+	show_stack(regs);
 #endif
 
 	printk("\n%s: Code=%d regs=%p (Addr=%08lx)\n",msg,code,regs,offset);
--- arch/parisc/mm/init.c.old	Tue Feb 13 05:17:53 2001
+++ arch/parisc/mm/init.c	Tue Feb 13 06:49:04 2001
@@ -37,6 +37,7 @@ void free_initmem(void)  {
  * a hole of 4kB between each vmalloced area for the same reason.
  */
 
+#define MAP_START 0x4000 /* Leave room for gateway page expansion */
 #define VM_MAP_OFFSET  (32*1024)
 #define SET_MAP_OFFSET(x) ((void *)(((unsigned long)(x) + VM_MAP_OFFSET) \
 				     & ~(VM_MAP_OFFSET-1)))
@@ -53,12 +54,12 @@ void __init mem_init(void)
 	printk("Memory: %luk available\n", totalram_pages << (PAGE_SHIFT-10));
 
 	if (hppa_dma_ops == &pcxl_dma_ops) {
-	    pcxl_dma_start = (unsigned long)SET_MAP_OFFSET(high_memory);
+	    pcxl_dma_start = (unsigned long)SET_MAP_OFFSET(MAP_START);
 	    vmalloc_start = SET_MAP_OFFSET(pcxl_dma_start + PCXL_DMA_MAP_SIZE);
 	}
 	else {
 	    pcxl_dma_start = 0;
-	    vmalloc_start = SET_MAP_OFFSET(high_memory);
+	    vmalloc_start = SET_MAP_OFFSET(MAP_START);
 	}
 }
 
@@ -176,6 +177,7 @@ static void __init pagetable_init(void)
 	pgd_t *pg_dir;
 	pmd_t *pmd;
 	pte_t *pg_table;
+	unsigned long start_pmd;
 	unsigned long tmp1;
 	unsigned long tmp2;
 	unsigned long address;
@@ -193,7 +195,14 @@ static void __init pagetable_init(void)
 	printk("pagetable_init\n");
 
 	/* Map whole memory from PAGE_OFFSET */
-	pg_dir = (pgd_t *)swapper_pg_dir + USER_PGD_PTRS;
+
+	pg_dir = pgd_offset_k(PAGE_OFFSET);
+
+#if PTRS_PER_PMD == 1
+	start_pmd = 0;
+#else
+	start_pmd = (((PAGE_OFFSET) >> PMD_SHIFT) & (PTRS_PER_PMD - 1));
+#endif
 
 	address = 0;
 	while (address < mem_max) {
@@ -219,8 +228,8 @@ static void __init pagetable_init(void)
 
 		/* now change pmd to kernel virtual addresses */
 
-		pmd = (pmd_t *) __va(pmd);
-		for (tmp1 = 0 ; tmp1 < PTRS_PER_PMD ; tmp1++,pmd++) {
+		pmd = (pmd_t *)__va(pmd) + start_pmd;
+		for (tmp1 = start_pmd; tmp1 < PTRS_PER_PMD; tmp1++,pmd++) {
 
 			/*
 			 * pg_table is physical at this point
@@ -267,6 +276,7 @@ static void __init pagetable_init(void)
 			if (address >= mem_max)
 			    break;
 		}
+		start_pmd = 0;
 	}
 
 	empty_zero_page = alloc_bootmem_pages(PAGE_SIZE);
@@ -295,33 +305,23 @@ static void __init gateway_init(void)
 	 * page 0), so it doesn't need to be aliased into user space.
 	 */
 
-	pg_dir = (pgd_t *)swapper_pg_dir;
-
-#if PTRS_PER_PMD == 1
-	pmd_base = (pmd_t *)pg_dir;
-	pmd = pmd_base +
-		((linux_gateway_page_addr) >> PGDIR_SHIFT);
+	pg_dir = pgd_offset_k(linux_gateway_page_addr);
 
-#else
-	pmd_base = (pmd_t *) alloc_bootmem_pages(PAGE_SIZE);
-	pgd_val(*(pg_dir + (linux_gateway_page_addr >> PGDIR_SHIFT))) =
-		_PAGE_TABLE | __pa(pmd_base);
-
-	pmd = pmd_base +
-		((linux_gateway_page_addr & (PMD_MASK) & (PGDIR_SIZE - 1)) >>
-								PMD_SHIFT);
+#if (PTRS_PER_PMD != 1)
+	if (pgd_none(*pg_dir)) {
+		pmd_base = (pmd_t *) alloc_bootmem_pages(PAGE_SIZE);
+		pgd_val(*pg_dir) = _PAGE_TABLE | __pa(pmd_base);
+	}
 #endif
 
-	pg_table_base = (pte_t *) alloc_bootmem_pages(PAGE_SIZE);
-
-	pmd_val(*pmd) = _PAGE_TABLE | __pa(pg_table_base);
+	pmd = pmd_offset(pg_dir,linux_gateway_page_addr);
+	if (pmd_none(*pmd)) {
+		pg_table_base = (pte_t *) alloc_bootmem_pages(PAGE_SIZE);
+		pmd_val(*pmd) = _PAGE_TABLE | __pa(pg_table_base);
+	}
 
+	pg_table = pte_offset(pmd,linux_gateway_page_addr);
 	pte = __mk_pte(__pa(&linux_gateway_page), PAGE_GATEWAY);
-
-	pg_table = pg_table_base +
-		((linux_gateway_page_addr & (PAGE_MASK) & (PMD_SIZE - 1)) >>
-								PAGE_SHIFT);
-
 	set_pte(pg_table,pte);
 
 	return;
--- arch/parisc/vmlinux.lds.old	Sun Feb 11 01:27:28 2001
+++ arch/parisc/vmlinux.lds	Mon Feb 12 06:30:26 2001
@@ -4,12 +4,7 @@ ENTRY(_stext)
 SECTIONS
 {
 
-/* right now use 0x10000/0x11000, later when we don't use Console and
- * Boot-Device IODC, we will change this to 0x8000 !!!
- */
-
-  . = 0xc0100000;   
-/*	. = 0x10000;  */
+  . = 0x10100000;
 
   _text = .;			/* Text and read-only data */
   .text BLOCK(16) : {
--- arch/parisc64/kernel/head.S.old	Sat Feb 10 01:01:29 2001
+++ arch/parisc64/kernel/head.S	Tue Feb 13 08:03:15 2001
@@ -57,30 +57,31 @@ stext:
 
 	ldil		L%PA(pg0),%r1
 	ldo		R%PA(pg0)(%r1),%r1
-	depdi		0, 31, 32, %r1
 
 	ldil		L%PA(pmd0),%r5
 	ldo		R%PA(pmd0)(%r5),%r5
-	depdi		0, 31, 32, %r5
 	ldo		_PAGE_TABLE(%r5),%r3
 
 	ldil		L%PA(swapper_pg_dir),%r4
 	ldo		R%PA(swapper_pg_dir)(%r4),%r4
-	depdi		0, 31, 32, %r4
 
 	mtctl		%r4,%cr24	/* Initialize kernel root pointer */
 	mtctl		%r4,%cr25	/* Initialize user root pointer */
-	std		%r3,0x18(%r4)	/* Hardwired 0xc... kernel Vaddr start*/
+
+#if (__PAGE_OFFSET != 0x10000000UL)
+Error! Code below (the next five std's) needs to be changed
+#endif
+
+	std             %r3,0x00(%r4)   /* Hardwired 0x1... kernel Vaddr start*/
 
 	ldo		_PAGE_TABLE(%r1),%r3
-	std		%r3,0x00(%r5)	/* Hardwired 0xc... kernel Vaddr start*/
+	std             %r3,0x400(%r5)  /* Hardwired 0x1... kernel Vaddr start*/
 	ldo		0x1000(%r3),%r3
-	std		%r3,0x08(%r5)
+	std             %r3,0x408(%r5)
 	ldo		0x1000(%r3),%r3
-	std		%r3,0x10(%r5)
-
+	std             %r3,0x410(%r5)
 	ldo		0x1000(%r3),%r3
-	std		%r3,0x18(%r5)
+	std             %r3,0x418(%r5)
 
 	ldo		_PAGE_KERNEL(%r0),%r3 /* Hardwired 0 phys addr start */
 $pgt_fill_loop:
@@ -182,7 +183,7 @@ stext_pdc_ret:
 	mtctl	%r0,%cr13
 
 	/* Prepare to RFI! Man all the cannons! */
-	tovirt		%sp
+	tovirt_r1       %sp
 
 	/* Initialize the global data pointer */
 	load32		__gp,%dp
@@ -196,7 +197,6 @@ stext_pdc_ret:
 	/* Set up our interrupt table.  HPMCs might not work after this! */
 	ldil		L%PA(fault_vector_20),%r10
 	ldo		R%PA(fault_vector_20)(%r10),%r10
-	depdi		0, 31, 32, %r10
 	mtctl		%r10,%cr14
 
 	b		aligned_rfi
@@ -277,9 +277,8 @@ smp_slave_stext:
 	/*  Initialize the SP - monarch sets up smp_init_current_idle_task */
 	load32		PA(smp_init_current_idle_task),%sp
 	ldd		0(%sp),%sp	/* load task address */
-	addil		L%TASK_SZ_ALGN,%sp	/* Stack is above task */
-	ldo		R%TASK_SZ_ALGN(%r1),%sp
-	tophys		%sp
+	ldo             TASK_SZ_ALGN(%sp),%sp
+	tophys_r1       %sp
 
 	/* point CPU to kernel page tables */
 	load32		PA(swapper_pg_dir),%r4
--- arch/parisc64/vmlinux.lds.old	Mon Feb 12 06:40:28 2001
+++ arch/parisc64/vmlinux.lds	Mon Feb 12 06:40:42 2001
@@ -4,12 +4,7 @@ ENTRY(_stext)
 SECTIONS
 {
 
-/* right now use 0x10000/0x11000, later when we don't use Console and
- * Boot-Device IODC, we will change this to 0x8000 !!!
- */
-
-  . = 0xc0100000;   
-/*	. = 0x10000;  */
+  . = 0x10100000;
 
   _text = .;			/* Text and read-only data */
   .text BLOCK(16) : {
--- include/asm-parisc/assembly.h.old	Sat Feb 10 00:07:45 2001
+++ include/asm-parisc/assembly.h	Tue Feb 13 07:34:54 2001
@@ -36,17 +36,34 @@
 	gp	=	27
 	ipsw	=	22
 
-#if __PAGE_OFFSET == 0xc0000000
-	.macro	tophys	gr
-	zdep	\gr, 31, 30, \gr
+	/*
+	 * We provide two versions of each macro to convert from physical
+	 * to virtual and vice versa. The "_r1" versions take one argument
+	 * register, but trashes r1 to do the conversion. The other
+	 * version takes two arguments: a src and destination register.
+	 * However, the source and destination registers can not be
+	 * the same register.
+	 */
+
+	.macro  tophys  grvirt, grphys
+	ldil    L%(__PAGE_OFFSET), \grphys
+	sub     \grvirt, \grphys, \grphys
 	.endm
 	
-	.macro	tovirt	gr
-	depi	3,1,2,\gr
+	.macro  tovirt  grphys, grvirt
+	ldil    L%(__PAGE_OFFSET), \grvirt
+	add     \grphys, \grvirt, \grvirt
+	.endm
+
+	.macro  tophys_r1  gr
+	ldil    L%(__PAGE_OFFSET), %r1
+	sub     \gr, %r1, \gr
+	.endm
+	
+	.macro  tovirt_r1  gr
+	ldil    L%(__PAGE_OFFSET), %r1
+	add     \gr, %r1, \gr
 	.endm
-#else
-#error	unknown __PAGE_OFFSET
-#endif
 
 	.macro delay value
 	ldil	L%\value, 1
@@ -72,10 +89,6 @@
 	.macro shld r, sa, t
 	depd,z	\r, 63-\sa, 64-\sa, \t
 	.endm
-
-# define LDIL_FIXUP(reg) depdi 0,31,32,reg
-#else
-# define LDIL_FIXUP(reg)
 #endif
 
 	/* load 32-bit 'value' into 'reg' compensating for the ldil
@@ -85,7 +98,6 @@
 	.macro	load32 value, reg
 	ldil	L%\value, \reg
 	ldo	R%\value(\reg), \reg
-	LDIL_FIXUP(\reg)
 	.endm
 
 #ifdef __LP64__
@@ -102,7 +114,6 @@
 #ifdef __LP64__
 	ldil		L%__gp, %r27
 	ldo		R%__gp(%r27), %r27
-	LDIL_FIXUP(%r27)
 #else
 	ldil		L%$global$, %r27
 	ldo		R%$global$(%r27), %r27
--- include/asm-parisc/fixmap.h.old	Mon Feb 12 06:19:47 2001
+++ include/asm-parisc/fixmap.h	Mon Feb 12 06:23:39 2001
@@ -3,12 +3,10 @@
 
 /*
  * Allocate a 8 Mb temporary mapping area for copy_user_page/clear_user_page.
- * This area needs to be aligned on a 8 Mb boundary. We also don't want
- * to use the page that includes 0xfffff000-0xffffffff, so we leave 8 Mb
- * unused at the top, and take the next 8 Mb section below that.
+ * This area needs to be aligned on a 8 Mb boundary.
  */
 
-#define TMPALIAS_MAP_START 0xff000000
+#define TMPALIAS_MAP_START (__PAGE_OFFSET - 0x01000000)
 #define FIXADDR_START   ((unsigned long)TMPALIAS_MAP_START)
 
 #endif
--- include/asm-parisc/page.h.old	Sun Feb 11 01:19:24 2001
+++ include/asm-parisc/page.h	Mon Feb 12 03:12:55 2001
@@ -85,7 +85,7 @@ extern __inline__ int get_order(unsigned
 
 
 #define LINUX_GATEWAY_SPACE     0
-#define __PAGE_OFFSET		(0xc0000000)
+#define __PAGE_OFFSET           (0x10000000)
 
 #define PAGE_OFFSET		((unsigned long)__PAGE_OFFSET)
 /* These macros don't work for 64-bit C code -- don't allow in C at all */
--- include/asm-parisc/pdc.h.old	Mon Feb 12 02:15:36 2001
+++ include/asm-parisc/pdc.h	Mon Feb 12 02:16:28 2001
@@ -509,7 +509,7 @@ struct pz_device {
 
 #ifndef __ASSEMBLY__
 
-#define	PAGE0	((struct zeropage *)0xc0000000)
+#define PAGE0   ((struct zeropage *)__PAGE_OFFSET)
 
 struct zeropage {
 	/* [0x000] initialize vectors (VEC) */
--- include/asm-parisc/pgtable.h.old	Tue Feb 13 05:57:07 2001
+++ include/asm-parisc/pgtable.h	Tue Feb 13 05:57:37 2001
@@ -50,7 +50,6 @@
  * pgd entries used up by user/kernel:
  */
 
-#define USER_PGD_PTRS (PAGE_OFFSET >> PGDIR_SHIFT)
 #define FIRST_USER_PGD_NR	0
 
 #ifndef __ASSEMBLY__
--- include/asm-parisc/processor.h.old	Mon Feb 12 02:18:36 2001
+++ include/asm-parisc/processor.h	Mon Feb 12 02:19:10 2001
@@ -229,10 +229,10 @@ extern inline unsigned long thread_saved
    | additional faked arg strings if |
    | we're invoked via binfmt_script |
    |---------------------------------| (mm->arg_start)
-   stack base is at 0xC000'0000 - rlim_max.
+   stack base is at TASK_SIZE - rlim_max.
 
 on downward growing arches, it looks like this:
-   stack base at 0xC000'0000
+   stack base at TASK_SIZE
    | filename passed to execve
    | env strings
    | arg strings