Skip to contentSkip to conversation

head.S fix for unusual load addrs

PATCH David Mosberger 6 participants 60 messages Apr 17, 2003 – May 28, 2003

Subsystems (2)
lore
Share & tools
lore
#0 lore raw
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · Jesse Barnes

Jesse> David, is something like this ok with you? On our systems, Jesse> elilo won't load the kernel where head.S expects it, so we Jesse> look at the ip to figure it out.

I don't have an issue with the particular patch, but I don't like to take new features incrementally. At the moment, the normal ia64 kernel doesn't support loading at arbitrary physical addresses. If there is a complete patch to add such a feature, we should consider it for inclusion.

	--david
#1 lore raw

Ok, great. I'll post it when I have it.

Thanks,
Jesse

Quoted 13 lines · David Mosberger
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · Jesse Barnes

Jesse> David, is something like this ok with you? On our systems, Jesse> elilo won't load the kernel where head.S expects it, so we Jesse> look at the ip to figure it out.

I don't have an issue with the particular patch, but I don't like to take new features incrementally. At the moment, the normal ia64 kernel doesn't support loading at arbitrary physical addresses. If there is a complete patch to add such a feature, we should consider it for inclusion.

	--david
#2 lore raw
In reply to David Mosberger
Quoted 5 lines · David Mosberger

I don't have an issue with the particular patch, but I don't like to take new features incrementally. At the moment, the normal ia64 kernel doesn't support loading at arbitrary physical addresses. If there is a complete patch to add such a feature, we should consider it for inclusion.

Chris Wedgwood reminded me that Tony posted one awhile back. I wonder what you think of his approach? I've attached it for reference since the linux-ia64 archive only had a mangled copy. It's against 2.5.39. If you have any other ideas about how we can address this, I'd like to hear them. Ideally, a generic kernel would work on all ia64 platforms at the same virtual load address (which is one problem with Tony's old patch IMO), regardless of physical load address.

Thanks a lot,
Jesse

arch/ia64/Config.help renamed from ../REF/linux-2.5.39-ia64-020928/arch/ia64/Config.help +6 -0
diff -ru ../../REF/linux-2.5.39-ia64-020928/arch/ia64/Config.help aegl/arch/ia64/Config.help
@@ -567,3 +567,9 @@
 
   Select "16MB" for a small granule size.
   Select "64MB" for a large granule size.  This is the current default.
+
+CONFIG_IA64_VMAP_KERNEL
+  If you say Y here, the kernel will be configured to map the kernel
+  to the top 4GB of the 64-bit virtual space.  This is needed for
+  certain ccNUMA machines that do not guarantee the presence of
+  memory at any particular physical address.
arch/ia64/config.in renamed from ../REF/linux-2.5.39-ia64-020928/arch/ia64/config.in +2 -0
diff -ru ../../REF/linux-2.5.39-ia64-020928/arch/ia64/config.in aegl/arch/ia64/config.in
@@ -71,6 +71,8 @@
 	define_bool CONFIG_IOSAPIC y
 fi
 
+bool 'Virtual mapped kernel' CONFIG_IA64_VMAP_KERNEL
+
 if [ "$CONFIG_IA64_SGI_SN1" = "y" -o "$CONFIG_IA64_SGI_SN2" = "y" ]; then
 	define_bool CONFIG_IA64_SGI_SN y
 	bool '  Enable extra debugging code' CONFIG_IA64_SGI_SN_DEBUG
arch/ia64/kernel/efi_stub.S renamed from ../REF/linux-2.5.39-ia64-020928/arch/ia64/kernel/efi_stub.S +2 -2
diff -ru ../../REF/linux-2.5.39-ia64-020928/arch/ia64/kernel/efi_stub.S aegl/arch/ia64/kernel/efi_stub.S
@@ -62,7 +62,7 @@
 	mov b6=r2
 	;;
 	andcm r16=loc3,r16		// get psr with IT, DT, and RT bits cleared
-	br.call.sptk.many rp=ia64_switch_mode
+	br.call.sptk.many rp=ia64_switch_mode_phys
 .ret0:	mov out4=in5
 	mov out0=in1
 	mov out1=in2
@@ -73,7 +73,7 @@
 	br.call.sptk.many rp=b6		// call the EFI function
 .ret1:	mov ar.rsc=0			// put RSE in enforced lazy, LE mode
 	mov r16=loc3
-	br.call.sptk.many rp=ia64_switch_mode // return to virtual mode
+	br.call.sptk.many rp=ia64_switch_mode_virt // return to virtual mode
 .ret2:	mov ar.rsc=loc4			// restore RSE configuration
 	mov ar.pfs=loc1
 	mov rp=loc0
arch/ia64/kernel/entry.S renamed from ../REF/linux-2.5.39-ia64-020928/arch/ia64/kernel/entry.S +9 -0
diff -ru ../../REF/linux-2.5.39-ia64-020928/arch/ia64/kernel/entry.S aegl/arch/ia64/kernel/entry.S
@@ -175,6 +175,14 @@
 	;;
 	st8 [r22]=sp			// save kernel stack pointer of old task
 	shr.u r26=r20,IA64_GRANULE_SHIFT
+#ifdef CONFIG_IA64_VMAP_KERNEL
+	adds r21=IA64_TASK_THREAD_KSP_OFFSET,in0
+	;;
+	/*
+	 * If we've already mapped this task's page, we can skip doing it again.
+	 */
+	cmp.eq p7,p6=r26,r27
+#else
 	shr.u r17=r20,KERNEL_TR_PAGE_SHIFT
 	;;
 	cmp.ne p6,p7=KERNEL_TR_PAGE_NUM,r17
@@ -184,6 +192,7 @@
 	 * If we've already mapped this task's page, we can skip doing it again.
 	 */
 (p6)	cmp.eq p7,p6=r26,r27
+#endif
 (p6)	br.cond.dpnt .map
 	;;
 .done:
arch/ia64/kernel/head.S renamed from ../REF/linux-2.5.39-ia64-020928/arch/ia64/kernel/head.S +101 -13

172 lines not on this page · raw message

arch/ia64/kernel/ia64_ksyms.c renamed from ../REF/linux-2.5.39-ia64-020928/arch/ia64/kernel/ia64_ksyms.c +3 -0
diff -ru ../../REF/linux-2.5.39-ia64-020928/arch/ia64/kernel/ia64_ksyms.c aegl/arch/ia64/kernel/ia64_ksyms.c
@@ -143,3 +143,6 @@
 #endif
 EXPORT_SYMBOL(machvec_noop);
 
+#ifdef CONFIG_IA64_VMAP_KERNEL
+EXPORT_SYMBOL(zero_page_memmap_ptr);
+#endif
arch/ia64/kernel/ivt.S renamed from ../REF/linux-2.5.39-ia64-020928/arch/ia64/kernel/ivt.S +20 -0
diff -ru ../../REF/linux-2.5.39-ia64-020928/arch/ia64/kernel/ivt.S aegl/arch/ia64/kernel/ivt.S
@@ -122,8 +122,18 @@
 	shr.u r18=r22,PGDIR_SHIFT		// get bits 33-63 of the faulting address
 	;;
 (p7)	dep r17=r17,r19,(PAGE_SHIFT-3),3	// put region number bits in place
+#ifdef CONFIG_IA64_VMAP_KERNEL
+	.global ia64_ivt_patch1
+ia64_ivt_patch1:
+{	.mlx // we patch this bundle to include physical address of swapper_pg_dir
+	srlz.d					// ensure "rsm psr.dt" has taken effect
+(p6)	movl r19=swapper_pg_dir			// region 5 is rooted at swapper_pg_dir
+}
+	.pred.rel "mutex", p6, p7
+#else
 	srlz.d					// ensure "rsm psr.dt" has taken effect
 (p6)	movl r19=__pa(swapper_pg_dir)		// region 5 is rooted at swapper_pg_dir
+#endif
 (p6)	shr.u r21=r21,PGDIR_SHIFT+PAGE_SHIFT
 (p7)	shr.u r21=r21,PGDIR_SHIFT+PAGE_SHIFT-3
 	;;
@@ -415,8 +425,18 @@
 	shr.u r18=r16,PGDIR_SHIFT		// get bits 33-63 of faulting address
 	;;
 (p7)	dep r17=r17,r19,(PAGE_SHIFT-3),3	// put region number bits in place
+#ifdef CONFIG_IA64_VMAP_KERNEL
+	.global ia64_ivt_patch2
+ia64_ivt_patch2:
+{	.mlx // we patch this bundle to include physical address of swapper_pg_dir
+	srlz.d					// ensure "rsm psr.dt" has taken effect
+(p6)	movl r19=swapper_pg_dir			// region 5 is rooted at swapper_pg_dir
+}
+#else
 	srlz.d
 (p6)	movl r19=__pa(swapper_pg_dir)		// region 5 is rooted at swapper_pg_dir
+#endif
+	.pred.rel "mutex", p6, p7
 (p6)	shr.u r21=r21,PGDIR_SHIFT+PAGE_SHIFT
 (p7)	shr.u r21=r21,PGDIR_SHIFT+PAGE_SHIFT-3
 	;;
arch/ia64/kernel/mca.c renamed from ../REF/linux-2.5.39-ia64-020928/arch/ia64/kernel/mca.c +8 -8
diff -ru ../../REF/linux-2.5.39-ia64-020928/arch/ia64/kernel/mca.c aegl/arch/ia64/kernel/mca.c
@@ -434,17 +434,17 @@
 
 	IA64_MCA_DEBUG("ia64_mca_init: registered mca rendezvous spinloop and wakeup mech.\n");
 
-	ia64_mc_info.imi_mca_handler        = __pa(mca_hldlr_ptr->fp);
+	ia64_mc_info.imi_mca_handler        = __tpa(mca_hldlr_ptr->fp);
 	/*
 	 * XXX - disable SAL checksum by setting size to 0; should be
-	 *	__pa(ia64_os_mca_dispatch_end) - __pa(ia64_os_mca_dispatch);
+	 *	__tpa(ia64_os_mca_dispatch_end) - __tpa(ia64_os_mca_dispatch);
 	 */
 	ia64_mc_info.imi_mca_handler_size	= 0;
 
 	/* Register the os mca handler with SAL */
 	if ((rc = ia64_sal_set_vectors(SAL_VECTOR_OS_MCA,
 				       ia64_mc_info.imi_mca_handler,
-				       mca_hldlr_ptr->gp,
+				       __tpa(mca_hldlr_ptr->gp),
 				       ia64_mc_info.imi_mca_handler_size,
 				       0, 0, 0)))
 	{
@@ -454,15 +454,15 @@
 	}
 
 	IA64_MCA_DEBUG("ia64_mca_init: registered os mca handler with SAL at 0x%lx, gp = 0x%lx\n",
-		       ia64_mc_info.imi_mca_handler, mca_hldlr_ptr->gp);
+		       ia64_mc_info.imi_mca_handler, __tpa(mca_hldlr_ptr->gp));
 
 	/*
 	 * XXX - disable SAL checksum by setting size to 0, should be
 	 * IA64_INIT_HANDLER_SIZE
 	 */
-	ia64_mc_info.imi_monarch_init_handler		= __pa(mon_init_ptr->fp);
+	ia64_mc_info.imi_monarch_init_handler		= __tpa(mon_init_ptr->fp);
 	ia64_mc_info.imi_monarch_init_handler_size	= 0;
-	ia64_mc_info.imi_slave_init_handler		= __pa(slave_init_ptr->fp);
+	ia64_mc_info.imi_slave_init_handler		= __tpa(slave_init_ptr->fp);
 	ia64_mc_info.imi_slave_init_handler_size	= 0;
 
 	IA64_MCA_DEBUG("ia64_mca_init: os init handler at %lx\n",
@@ -471,10 +471,10 @@
 	/* Register the os init handler with SAL */
 	if ((rc = ia64_sal_set_vectors(SAL_VECTOR_OS_INIT,
 				       ia64_mc_info.imi_monarch_init_handler,
-				       __pa(ia64_get_gp()),
+				       __tpa(ia64_get_gp()),
 				       ia64_mc_info.imi_monarch_init_handler_size,
 				       ia64_mc_info.imi_slave_init_handler,
-				       __pa(ia64_get_gp()),
+				       __tpa(ia64_get_gp()),
 				       ia64_mc_info.imi_slave_init_handler_size)))
 	{
 		printk("ia64_mca_init: Failed to register m/s init handlers with SAL. rc = %ld\n",
arch/ia64/kernel/pal.S renamed from ../REF/linux-2.5.39-ia64-020928/arch/ia64/kernel/pal.S +8 -4
diff -ru ../../REF/linux-2.5.39-ia64-020928/arch/ia64/kernel/pal.S aegl/arch/ia64/kernel/pal.S
@@ -164,7 +164,11 @@
 	;; 
 	mov loc4=ar.rsc			// save RSE configuration
 	dep.z loc2=loc2,0,61		// convert pal entry point to physical
+#ifdef CONFIG_IA64_VMAP_KERNEL
+	tpa r8=r8			// convert rp to physical
+#else
 	dep.z r8=r8,0,61		// convert rp to physical
+#endif
 	;;
 	mov b7 = loc2			// install target to branch reg
 	mov ar.rsc=0			// put RSE in enforced lazy, LE mode
@@ -174,13 +178,13 @@
 	or loc3=loc3,r17		// add in psr the bits to set
 	;;
 	andcm r16=loc3,r16		// removes bits to clear from psr
-	br.call.sptk.many rp=ia64_switch_mode
+	br.call.sptk.many rp=ia64_switch_mode_phys
 .ret1:	mov rp = r8			// install return address (physical)
 	br.cond.sptk.many b7
 1:
 	mov ar.rsc=0			// put RSE in enforced lazy, LE mode
 	mov r16=loc3			// r16= original psr
-	br.call.sptk.many rp=ia64_switch_mode // return to virtual mode
+	br.call.sptk.many rp=ia64_switch_mode_virt // return to virtual mode
 .ret2:
 	mov psr.l = loc3		// restore init PSR
 
@@ -228,13 +232,13 @@
 	mov b7 = loc2			// install target to branch reg
 	;;
 	andcm r16=loc3,r16		// removes bits to clear from psr
-	br.call.sptk.many rp=ia64_switch_mode
+	br.call.sptk.many rp=ia64_switch_mode_phys
 .ret6:
 	br.call.sptk.many rp=b7		// now make the call
 .ret7:
 	mov ar.rsc=0			// put RSE in enforced lazy, LE mode
 	mov r16=loc3			// r16= original psr
-	br.call.sptk.many rp=ia64_switch_mode	// return to virtual mode
+	br.call.sptk.many rp=ia64_switch_mode_virt	// return to virtual mode
 
 .ret8:	mov psr.l  = loc3		// restore init PSR
 	mov ar.pfs = loc1
arch/ia64/kernel/setup.c renamed from ../REF/linux-2.5.39-ia64-020928/arch/ia64/kernel/setup.c +49 -2

69 lines not on this page · raw message

arch/ia64/kernel/smpboot.c renamed from ../REF/linux-2.5.39-ia64-020928/arch/ia64/kernel/smpboot.c +1 -1
diff -ru ../../REF/linux-2.5.39-ia64-020928/arch/ia64/kernel/smpboot.c aegl/arch/ia64/kernel/smpboot.c
@@ -522,7 +522,7 @@
 	/* Tell SAL where to drop the AP's.  */
 	ap_startup = (struct fptr *) start_ap;
 	sal_ret = ia64_sal_set_vectors(SAL_VECTOR_OS_BOOT_RENDEZ,
-				       __pa(ap_startup->fp), __pa(ap_startup->gp), 0, 0, 0, 0);
+				       __tpa(ap_startup->fp), __tpa(ap_startup->gp), 0, 0, 0, 0);
 	if (sal_ret < 0)
 		printk("SMP: Can't set SAL AP Boot Rendezvous: %s\n", ia64_sal_strerror(sal_ret));
 }
arch/ia64/mm/init.c renamed from ../REF/linux-2.5.39-ia64-020928/arch/ia64/mm/init.c +14 -5
diff -ru ../../REF/linux-2.5.39-ia64-020928/arch/ia64/mm/init.c aegl/arch/ia64/mm/init.c
@@ -39,6 +39,10 @@
 
 static int pgt_cache_water[2] = { 25, 50 };
 
+#ifdef CONFIG_IA64_VMAP_KERNEL
+struct page *zero_page_memmap_ptr;		/* map entry for zero page */
+#endif
+
 void
 check_pgt_cache (void)
 {
@@ -104,14 +108,16 @@
 void
 free_initmem (void)
 {
-	unsigned long addr;
+	unsigned long addr, eaddr;
 
-	addr = (unsigned long) &__init_begin;
-	for (; addr < (unsigned long) &__init_end; addr += PAGE_SIZE) {
+	addr = (unsigned long)__imva(&__init_begin);
+	eaddr = (unsigned long)__imva(&__init_end);
+	while (addr < eaddr) {
 		ClearPageReserved(virt_to_page(addr));
 		set_page_count(virt_to_page(addr), 1);
 		free_page(addr);
 		++totalram_pages;
+		addr += PAGE_SIZE;
 	}
 	printk(KERN_INFO "Freeing unused kernel memory: %ldkB freed\n",
 	       (&__init_end - &__init_begin) >> 10);
@@ -286,7 +292,7 @@
 	ia64_srlz_d();
 
 	ia64_itr(0x2, IA64_TR_PERCPU_DATA, PERCPU_ADDR,
-		 pte_val(pfn_pte(__pa(my_cpu_data) >> PAGE_SHIFT, PAGE_KERNEL)), PAGE_SHIFT);
+		 pte_val(pfn_pte(__tpa(my_cpu_data) >> PAGE_SHIFT, PAGE_KERNEL)), PAGE_SHIFT);
 
 	ia64_set_psr(psr);
 	ia64_srlz_i();
@@ -364,6 +370,9 @@
 		zones_size[ZONE_NORMAL] = max_low_pfn - max_dma;
 	}
 	free_area_init(zones_size);
+#ifdef CONFIG_IA64_VMAP_KERNEL
+	zero_page_memmap_ptr = virt_to_page(__imva(empty_zero_page));
+#endif
 }
 
 static int
@@ -442,7 +451,7 @@
 		pgt_cache_water[1] = num_pgt_pages;
 
 	/* install the gate page in the global page table: */
-	put_gate_page(virt_to_page(__start_gate_section), GATE_ADDR);
+	put_gate_page(virt_to_page(__imva(__start_gate_section)), GATE_ADDR);
 
 #ifdef CONFIG_IA32_SUPPORT
 	ia32_gdt_init();
arch/ia64/vmlinux.lds.S renamed from ../REF/linux-2.5.39-ia64-020928/arch/ia64/vmlinux.lds.S +33 -27

170 lines not on this page · raw message

fs/proc/kcore.c renamed from ../REF/linux-2.5.39-ia64-020928/fs/proc/kcore.c +50 -9

118 lines not on this page · raw message

include/asm-ia64/page.h renamed from ../REF/linux-2.5.39-ia64-020928/include/asm-ia64/page.h +7 -0
diff -ru ../../REF/linux-2.5.39-ia64-020928/include/asm-ia64/page.h aegl/include/asm-ia64/page.h
@@ -106,6 +106,13 @@
  */
 #define __pa(x)		({ia64_va _v; _v.l = (long) (x); _v.f.reg = 0; _v.l;})
 #define __va(x)		({ia64_va _v; _v.l = (long) (x); _v.f.reg = -1; _v.p;})
+#ifdef CONFIG_IA64_VMAP_KERNEL
+#define __tpa(x)	({ia64_va _v; asm("tpa %0=%1" : "=r"(_v.l) : "r"(x)); _v.l;})
+#define __imva(x)	((long)__va(__tpa(x)))
+#else
+#define __tpa(x)	__pa(x)
+#define __imva(x)	(x)
+#endif
 
 #define REGION_NUMBER(x)	({ia64_va _v; _v.l = (long) (x); _v.f.reg;})
 #define REGION_OFFSET(x)	({ia64_va _v; _v.l = (long) (x); _v.f.off;})
include/asm-ia64/pgtable.h renamed from ../REF/linux-2.5.39-ia64-020928/include/asm-ia64/pgtable.h +7 -0
diff -ru ../../REF/linux-2.5.39-ia64-020928/include/asm-ia64/pgtable.h aegl/include/asm-ia64/pgtable.h
@@ -415,7 +415,12 @@
  * for zero-mapped memory areas etc..
  */
 extern unsigned long empty_zero_page[PAGE_SIZE/sizeof(unsigned long)];
+#ifdef CONFIG_IA64_VMAP_KERNEL
+extern struct page *zero_page_memmap_ptr;
+#define ZERO_PAGE(vaddr) (zero_page_memmap_ptr)
+#else
 #define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page))
+#endif
 
 /* We provide our own get_unmapped_area to cope with VA holes for userland */
 #define HAVE_ARCH_UNMAPPED_AREA
@@ -440,7 +445,9 @@
  */
 #define KERNEL_TR_PAGE_SHIFT	_PAGE_SIZE_64M
 #define KERNEL_TR_PAGE_SIZE	(1 << KERNEL_TR_PAGE_SHIFT)
+#ifndef CONFIG_IA64_VMAP_KERNEL
 #define KERNEL_TR_PAGE_NUM	((KERNEL_START - PAGE_OFFSET) / KERNEL_TR_PAGE_SIZE)
+#endif
 
 /*
  * No page table caches to initialise
include/asm-ia64/system.h renamed from ../REF/linux-2.5.39-ia64-020928/include/asm-ia64/system.h +4 -0
diff -ru ../../REF/linux-2.5.39-ia64-020928/include/asm-ia64/system.h aegl/include/asm-ia64/system.h
@@ -18,7 +18,11 @@
 #include <asm/page.h>
 #include <asm/pal.h>
 
+#ifdef	CONFIG_IA64_VMAP_KERNEL
+#define KERNEL_START		(0xffffffff00000000)
+#else
 #define KERNEL_START		(PAGE_OFFSET + 68*1024*1024)
+#endif
 
 #define GATE_ADDR		(0xa000000000000000 + PAGE_SIZE)
 #define PERCPU_ADDR		(0xa000000000000000 + 2*PAGE_SIZE)
#3 lore raw
In reply to David Mosberger

Hi Jesse,

I thought I had responded to this already, but my mailer claims otherwise.

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · Jesse Barnes
Quoted 5 lines · David Mosberger
Quoted 5 lines

I don't have an issue with the particular patch, but I don't like to take new features incrementally. At the moment, the normal ia64 kernel doesn't support loading at arbitrary physical addresses. If there is a complete patch to add such a feature, we should consider it for inclusion.

Jesse> Chris Wedgwood reminded me that Tony posted one awhile back. I wonder Jesse> what you think of his approach? I've attached it for reference since Jesse> the linux-ia64 archive only had a mangled copy. It's against 2.5.39. Jesse> If you have any other ideas about how we can address this, I'd like to Jesse> hear them. Ideally, a generic kernel would work on all ia64 platforms Jesse> at the same virtual load address (which is one problem with Tony's old Jesse> patch IMO), regardless of physical load address.

Keeping the load address the same would definitely make life easier. Otherwise, any tool that depends on System.map may break.

To be honest, conceptually, I prefer boot-time relocation, because it keeps the kernel model simpler (and there is already relocation code in the in-kernel module loader which you could leverage). But having the kernel text addresses vary from one machine to another, depending on memory configuration is not a exactly a pleasant thought. I don't really have much of a stake in this, so I'd like the folks who really care to work out a patch that works on all ia64 NUMA platforms and then convince me why it's a good idea to include that patch and why it's really The Right Thing.

	--david
#4 lore raw
In reply to David Mosberger
Quoted 12 lines

Keeping the load address the same would definitely make life easier. Otherwise, any tool that depends on System.map may break.

To be honest, conceptually, I prefer boot-time relocation, because it keeps the kernel model simpler (and there is already relocation code in the in-kernel module loader which you could leverage). But having the kernel text addresses vary from one machine to another, depending on memory configuration is not a exactly a pleasant thought. I don't really have much of a stake in this, so I'd like the folks who really care to work out a patch that works on all ia64 NUMA platforms and then convince me why it's a good idea to include that patch and why it's really The Right Thing.

In case anyone missed the point of this, the issue is handling machines that don't have physical memory at the location that Linux expects to be loaded at (some ccNUMA machines that configure memory based on node numbers cannot guarantee until boot time where any of the memory is physically located ... depending on which nodes exist).

Here are the approaches that have been proposed and/or tried so far:

1) My patch (posted around October last year) which picked virtual addresses in the wild blue yonder (initial versions used 0xe002000000000000, later ones used 0xffffffff00000000) for the link address for the kernel. Elilo can load kernel at any suitably aligned physical address, and head.S establishes the mappings using itr[0] and dtr[0].

pros) provided separate maps for kernel text and data, so supported kernel text
replication too.
cons) __pa() no longer works on kernel addresses, use new __tpa() instead.
Some ugly runtime patching of kernel code to get physical address of swapper_pg_dir into the TLB miss code.

2) I think SGI are currently running a modified version of #1 without the text replication support, and that provides a mapping from the normal virtual address that the kernel is linked for (0xe00000000044000000) to whatever physical address it was actually loaded at ... at least I think that's what Jack said.

pros) simpler than my patch

cons) Still needs __tpa() instead of __pa() for kernel addresses.

3) David's suggestion of boot-time relocation. Probably simplest to implement this in elilo, but if you are really good at PIC asm code it could be done in the kernel startup sequence.

pros) Just like linking kernel at a new address.
Avoids the __tpa() issue.
Doesn't invalidate any assumptions about how to get from virtual to physical addresses and back again.

cons) Nobody has implemented it.

-Tony

#5 lore raw
In reply to David Mosberger

Hi Tony,

Great summary!

Tony> 3) David's suggestion of boot-time relocation. Probably Tony> simplest to implement this in elilo, but if you are really Tony> good at PIC asm code it could be done in the kernel startup Tony> sequence.

Agreed. Anyone who's ever debugged the ld.so startup code will agree that it's much better to do the relocation in elilo.

Tony> pros) Just like linking kernel at a new address. Avoids the Tony> __tpa() issue. Doesn't invalidate any assumptions about how Tony> to get from virtual to physical addresses and back again.

Tony> cons) Nobody has implemented it.

I think:

- kernel text addresses vary depending on physical memory conf.

is potentially a bigger issue. Implementing the relocator in elilo should be really easy (just take the kernel loader and massage it a bit).

How many tools are out there that depend on System.map or similar? I suppose you could just generate a fresh System.map at boot time (or have something like /proc/System.map).

	--david
#6 lore raw
In reply to David Mosberger
Quoted 3 lines · David Mosberger

Hi Tony,

Great summary!

Yeah, thanks. It's a good outline of our options.

Quoted 18 lines

Tony> 3) David's suggestion of boot-time relocation. Probably Tony> simplest to implement this in elilo, but if you are really Tony> good at PIC asm code it could be done in the kernel startup Tony> sequence.

Agreed. Anyone who's ever debugged the ld.so startup code will agree that it's much better to do the relocation in elilo.

Tony> pros) Just like linking kernel at a new address. Avoids the Tony> __tpa() issue. Doesn't invalidate any assumptions about how Tony> to get from virtual to physical addresses and back again.

Tony> cons) Nobody has implemented it.

I think:

- kernel text addresses vary depending on physical memory conf.

Quoted 7 lines

is potentially a bigger issue. Implementing the relocator in elilo should be really easy (just take the kernel loader and massage it a bit).

How many tools are out there that depend on System.map or similar? I suppose you could just generate a fresh System.map at boot time (or have something like /proc/System.map).

Ahh, this might be a good way to go. We'd basically be relinking the kernel at load time with a new KERNEL_START, right? I haven't looked at the new module loader code yet (in fact, I've never done any linker stuff), but I will now.

Thanks,
Jesse

#7 lore raw
In reply to David Mosberger
Quoted 3 lines · David Mosberger

How many tools are out there that depend on System.map or similar? I suppose you could just generate a fresh System.map at boot time (or have something like /proc/System.map).

Forgot to mention that there are tools that depend on this (e.g. VTune, but it only cares about the load addr and size), but /proc/ksyms may be enough already if the right symbols are exported. Is it still there in 2.5?

Thanks,
Jesse

#8 lore raw
In reply to David Mosberger
Quoted 3 lines

How many tools are out there that depend on System.map or similar? I suppose you could just generate a fresh System.map at boot time (or have something like /proc/System.map).

Apparently a few, but not a vast number ... on RedHat AS2.1:

 # grep -rl 'System.map' /bin /usr/bin /usr/sbin /etc /sbin
   /bin/ps
   /usr/bin/ksymoops
   /usr/bin/kpm
   /usr/sbin/readprofile
   /etc/rc.d/rc.sysinit
   /etc/rc.sysinit
   /sbin/depmod
   /sbin/insmod.static
   /sbin/insmod
   /sbin/modprobe
   /sbin/ksyms
   /sbin/kallsyms
   /sbin/lsmod
   /sbin/modinfo
   /sbin/rmmod
   /sbin/klogd
   /sbin/installkernel
   /sbin/new-kernel-pkg
#9 lore raw
In reply to David Mosberger
Quoted 3 lines · David Mosberger

How many tools are out there that depend on System.map or similar? I suppose you could just generate a fresh System.map at boot time (or have something like /proc/System.map).

ksymoops (user space), kdb, kksymoops (kernel).

Both kdb and kksymoops are specifically designed to not use relocations, they store kernel addresses as absolute numbers. Not that big a deal, ia64 setup can run the kallsyms tables at boot time and relocate them.

ksymoops in user space is a bigger problem, it reads System.map. Fixing user space will be a problem. OTOH, the function descriptor problem in ia64 means that ksymoops in user space gets thousands of address mismatches between System.map and /proc/ksyms so ksymoops is not used very much for ia64.

#10 lore raw
In reply to David Mosberger
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · Jesse Barnes

Jesse> Ahh, this might be a good way to go. We'd basically be Jesse> relinking the kernel at load time with a new KERNEL_START, Jesse> right?

Yup.

	--david
#11 lore raw
In reply to David Mosberger
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines · David Mosberger

On Wed, 7 May 2003 17:00:45 -0700, Jesse Barnes <[email protected]> said:

Jesse> Ahh, this might be a good way to go. We'd basically be Jesse> relinking the kernel at load time with a new KERNEL_START, Jesse> right?

David> Yup.

On second thought, "relinking" might be confusing. "Relocating" is more accurate (we don't rearrange anything within the kernel, just moving the whole thing around, which is a lot easier).

	--david
#12 lore raw
In reply to David Mosberger
Quoted 18 lines · Tony

David wrote

Quoted 3 lines

How many tools are out there that depend on System.map or similar? I suppose you could just generate a fresh System.map at boot time (or have something like /proc/System.map).

Apparently a few, but not a vast number ... on RedHat AS2.1:

# grep -rl 'System.map' /bin /usr/bin /usr/sbin /etc /sbin
  /bin/ps
  /usr/bin/ksymoops
  /usr/bin/kpm
  /usr/sbin/readprofile
  /etc/rc.d/rc.sysinit
  /etc/rc.sysinit
  /sbin/depmod
  /sbin/insmod.static
  /sbin/insmod
  /sbin/modprobe
Quoted 8 lines
  /sbin/ksyms
  /sbin/kallsyms
  /sbin/lsmod
  /sbin/modinfo
  /sbin/rmmod
  /sbin/klogd
  /sbin/installkernel
  /sbin/new-kernel-pkg

Out of the modutils programs, only depmod actually reads System.map and only when doing make modules_install. It does not care about the addresses, only if a symbol is exported or not. insmod, modprobe, ksyms, lsmod, modinfo, rmmod contain a reference to System.map because of a table that lists files that might appear in /lib/modules/uname -r, they only care about the file name, not its contents.

kallsyms will require run time relocation, its table uses absolute kernel addresses.

rc.sysinit only looks for the file System.map so it can set up a symlink, it does not read the contents.

installkernel and new-kernel-pkg just copy System.map so other tools can find it.

klogd, ps, readprofile and lkcd (not on that list) will need a clean copy of System.map. IOW it has to be regenerated for those programs.

Don't know about kpm.

#13 lore raw
In reply to David Mosberger
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · Jesse Barnes

Jesse> Forgot to mention that there are tools that depend on this Jesse> (e.g. VTune, but it only cares about the load addr and Jesse> size), but /proc/ksyms may be enough already if the right Jesse> symbols are exported. Is it still there in 2.5?

Nope, it's gone. Check with Rusty on what the story is here. I can't believe there is no way for user-space to get at the kallsym info in 2.5, but if there is, I sure haven't found it yet.

	--david
#14 lore raw
In reply to David Mosberger
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · Keith Owens

Keith> On Wed, 7 May 2003 16:51:21 -0700, David Mosberger

Quoted 3 lines · Keith> <[email protected]> wrote:
Quoted 3 lines

How many tools are out there that depend on System.map or similar? I suppose you could just generate a fresh System.map at boot time (or have something like /proc/System.map).

Keith> ksymoops (user space), kdb, kksymoops (kernel).

What about crash-dump tools such as lkcd? Do they depend on absolute addresses?

	--david
#15 lore raw
In reply to David Mosberger
Quoted 4 lines · David Mosberger

Keith> ksymoops (user space), kdb, kksymoops (kernel).

What about crash-dump tools such as lkcd? Do they depend on absolute addresses?

We've added an ioctl to the lkcd device so the user level tools can get the actual load address of the kernel, but I'm not sure if that's part of the community version of lkcd yet.

Jesse

#16 lore raw
In reply to David Mosberger
Quoted 9 lines · Jesse Barnes
Quoted 4 lines · David Mosberger

Keith> ksymoops (user space), kdb, kksymoops (kernel).

What about crash-dump tools such as lkcd? Do they depend on absolute addresses?

We've added an ioctl to the lkcd device so the user level tools can get the actual load address of the kernel, but I'm not sure if that's part of the community version of lkcd yet.

I send the patch to the lkcd list yesterday, no response yet.

#17 lore raw
In reply to David Mosberger
Quoted 7 lines · David Mosberger
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines · David Mosberger

On Wed, 7 May 2003 17:00:45 -0700, Jesse Barnes <[email protected]> said:

Jesse> Ahh, this might be a good way to go. We'd basically be Jesse> relinking the kernel at load time with a new KERNEL_START, Jesse> right?

Quoted 5 lines

David> Yup.

On second thought, "relinking" might be confusing. "Relocating" is more accurate (we don't rearrange anything within the kernel, just moving the whole thing around, which is a lot easier).

Using what data? vmlinux does not contain any relocation data, everything is converted to absolute addresses in the the final link stage. If you only use standard ld output then elilo will have to handle all the relocations, messy.

One possibility is to link vmlinux to a temporary file, using -r to preserve the relocation data, followed by a link to the real vmlinux, without -r. From the temporary file, extract the information that is required to perform boot time relocation and append that data to vmlinux, at _end. The kernel startup code (PIC assembler) runs the additional table, adjusts the relocations then discards the table.

A quick check of a 2.4 ia64 kernel shows only these relocation types:

DIR32LSB
DIR64LSB
FPTR64LSB
GPREL22
IMM64
LTOFF22
LTOFF_FPTR22
PCREL21B
PCREL60B
SEGREL64LSB

GPREL22, LTOFF22, LTOFF_FPTR22, PCREL21B, PCREL60B, SEGREL64LSB are not a problem, they are already PIC. DIR32LSB, DIR64LSB, FPTR64LSB are easy to adjust. IMM64 is the only messy bit of code, lots of shifts. Even IMM64 is not that hard to do in PIC asm.

This approach keeps all the kernel relocation code inside the ia64 tree, it does not rely on keeping elilo in sync with future kernel and/or gcc changes. By extracting and formatting the relocation data at build time, it simplifies and speeds up the load process.

#18 lore raw
In reply to David Mosberger
Quoted 5 lines
Quoted 5 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line · Keith Owens

On second thought, "relinking" might be confusing. "Relocating"
is more accurate (we don't rearrange anything within the kernel, just moving the whole thing around, which is a lot easier).

Keith> Using what data? vmlinux does not contain any relocation Keith> data, everything is converted to absolute addresses in the Keith> the final link stage.

Oh, I would recommend to build the kernel as a shared object. That's what we do for EFI apps under GNU EFI and it works well. (There are some ugly corners in GNU EFI, but they have to do with converting the ELF shared object into PE+ format.)

Keith> One possibility is to link vmlinux to a temporary file, using Keith> -r to preserve the relocation data, followed by a link to the Keith> real vmlinux, without -r. From the temporary file, extract Keith> the information that is required to perform boot time Keith> relocation and append that data to vmlinux, at _end. The Keith> kernel startup code (PIC assembler) runs the additional Keith> table, adjusts the relocations then discards the table.

Sounds rather fragile to me. Relocating shared objects is quite easy actually. GNU EFI does it in 102 lines of ia64 assembly code. That's probably pretty hard to beat.

Keith> A quick check of a 2.4 ia64 kernel shows only these Keith> relocation types:

Keith> DIR32LSB DIR64LSB FPTR64LSB GPREL22 IMM64 LTOFF22 Keith> LTOFF_FPTR22 PCREL21B PCREL60B SEGREL64LSB

Keith> GPREL22, LTOFF22, LTOFF_FPTR22, PCREL21B, PCREL60B, Keith> SEGREL64LSB are not a problem, they are already PIC. Keith> DIR32LSB, DIR64LSB, FPTR64LSB are easy to adjust. IMM64 is Keith> the only messy bit of code, lots of shifts. Even IMM64 is Keith> not that hard to do in PIC asm.

Remember, we already have the in-kernel module loader, which has to deal with "ld -r" modules. I'd have preferred if those had been shared objects, too, but apparently the toolchains on some other platforms is sufficiently broken that this wasn't a feasible option (not for 2.6, anyhow).

	--david
#19 lore raw
In reply to David Mosberger
Quoted 11 lines · David Mosberger

Keith> GPREL22, LTOFF22, LTOFF_FPTR22, PCREL21B, PCREL60B, Keith> SEGREL64LSB are not a problem, they are already PIC. Keith> DIR32LSB, DIR64LSB, FPTR64LSB are easy to adjust. IMM64 is Keith> the only messy bit of code, lots of shifts. Even IMM64 is Keith> not that hard to do in PIC asm.

Remember, we already have the in-kernel module loader, which has to deal with "ld -r" modules. I'd have preferred if those had been shared objects, too, but apparently the toolchains on some other platforms is sufficiently broken that this wasn't a feasible option (not for 2.6, anyhow).

So simply linking with 'ld -q' wouldn't be sufficient? Doesn't that produce a binary that will boot w/o elilo changes, but can also be relocated?

Thanks,
Jesse

#20 lore raw
In reply to David Mosberger
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · Jesse Barnes

Jesse> So simply linking with 'ld -q' wouldn't be sufficient? Doesn't that Jesse> produce a binary that will boot w/o elilo changes, but can also be Jesse> relocated?

Ah, yes, I had forgotten about -q. It probably would be sufficient. And the backwards-compatibility it would achieve would definitely be a plus.

A new concern though: I don't think text-replication will work well with this scheme. If each replica is linked for a different address, function pointers become a performance problem: whenever you call through a function pointer, you'll end up executing on whatever replica initialized the function pointer. Not good.

Unless I'm missing something, kernel relocation is therefore a bit of a stillborn idea (unless text-replication really isn't all that important because we all have humongous caches between nodes...).

If we do have to go the virtual remapping route, my preference would be to stick the kernel somewhere in region 5 (0xa..). Has anyone tried that? It should work fine in principle (modules already live in that space).

	--david
#21 lore raw
In reply to David Mosberger
Quoted 3 lines · David Mosberger

Ah, yes, I had forgotten about -q. It probably would be sufficient. And the backwards-compatibility it would achieve would definitely be a plus.

I thought so too.

Quoted 5 lines

A new concern though: I don't think text-replication will work well with this scheme. If each replica is linked for a different address, function pointers become a performance problem: whenever you call through a function pointer, you'll end up executing on whatever replica initialized the function pointer. Not good.

Right, I thought about that. I don't think we need text replication yet though anyway (at least our platform doesn't).

Quoted 8 lines

Unless I'm missing something, kernel relocation is therefore a bit of a stillborn idea (unless text-replication really isn't all that important because we all have humongous caches between nodes...).

If we do have to go the virtual remapping route, my preference would be to stick the kernel somewhere in region 5 (0xa..). Has anyone tried that? It should work fine in principle (modules already live in that space).

I guess we can revisit that if we need/want to implement text replication at some point in the future. It might not be that bad though--I don't envision relocating each replica, but rather just seperating the kernel text and data with the right translation registers that point to local text and global data, but I haven't thought about it much (this is what Tony's original patch did, and it seemed to work well).

Jesse

#22 lore raw
In reply to David Mosberger
Quoted 7 lines
Quoted 7 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line · Jesse Barnes

A new concern though: I don't think text-replication will work well with this scheme. If each replica is linked for a different address, function pointers become a performance problem: whenever you call through a function pointer, you'll end up executing on whatever replica initialized the function pointer. Not good.

Jesse> Right, I thought about that. I don't think we need text Jesse> replication yet though anyway (at least our platform Jesse> doesn't).

That's what I would have guessed. I think it might be different for the 8870 chipset though. Or does it have a huge L4 cache, too?

Quoted 4 lines
Quoted 4 lines

If we do have to go the virtual remapping route, my preference would be to stick the kernel somewhere in region 5 (0xa..). Has anyone tried that? It should work fine in principle (modules already live in that space).

Jesse> I guess we can revisit that if we need/want to implement text Jesse> replication at some point in the future. It might not be Jesse> that bad though--I don't envision relocating each replica, Jesse> but rather just seperating the kernel text and data with the Jesse> right translation registers that point to local text and Jesse> global data, but I haven't thought about it much (this is Jesse> what Tony's original patch did, and it seemed to work well).

But it would be rather painful to switch to the "kernel may live at any address" model just to discover that a year later we're going to map it virtually anyhow (in which case, the kernel could live at a fixed address again).

	--david
#23 lore raw
In reply to David Mosberger
Quoted 4 lines

If we do have to go the virtual remapping route, my preference would be to stick the kernel somewhere in region 5 (0xa..). Has anyone tried that? It should work fine in principle (modules already live in that space).

I didn't try region 5, but my patch didn't glitch when I moved from text at 0xe002000000000000 data at 0xe0021000000000000000 to text at 0xfffffffe00000000 and data at 0xffffffff00000000 (though apparently the kdb patch didn't play well with a kernel linked at these addresses), so there is a good chance that a move to region 5 wouldn't take much
effort. In fact it might clear up the long standing issue with
/proc/kcore, if we put the kernel at the low end of region 5 all the assumptions that module addresses are higher than kernel addresses will be valid for ia64 too :-)

How does this look for an address map?

0xA000000000000000 kernel text
0xA000000100000000 kernel data
0xA000000200000000 percpu area
0xA000000300000000 vmalloc & kernel modules
0xBFFFFFFxxxxxxxxx CONFIG_VIRTUAL_MEM_MAP

Reserving an almost arbitrary 4GB for each of kernel text/data/percpu (I picked 4GB, since it is the biggest page size supported by ia64 ... but other larger boundaries might make sense to make the upper level page tables for the vmalloc area start on a natural boundary).

-Tony

#24 lore raw
In reply to David Mosberger
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · Tony

Tony> In fact it might clear up the long standing issue with Tony> /proc/kcore, if we put the kernel at the low end of region 5 Tony> all the assumptions that module addresses are higher than Tony> kernel addresses will be valid for ia64 too :-)

Yes, indeed.

Tony> How does this look for an address map?

Tony> 0xA000000000000000 kernel text Tony> 0xA000000100000000 kernel data Tony> 0xA000000200000000 percpu area Tony> 0xA000000300000000 vmalloc & kernel modules Tony> 0xBFFFFFFxxxxxxxxx CONFIG_VIRTUAL_MEM_MAP

Tony> Reserving an almost arbitrary 4GB for each of kernel Tony> text/data/percpu (I picked 4GB, since it is the biggest page Tony> size supported by ia64 ... but other larger boundaries might Tony> make sense to make the upper level page tables for the vmalloc Tony> area start on a natural boundary).

I think we may want to reserve the first 4GB for miscellaneous stuff, such as the start-of-kernel-space-hole, the gate page (and probably soon a read-only page), and the percpu area. In particular the guaranteed-not-to-be-mapped page needs to be right at the end of user space.

	--david
#25 lore raw
In reply to David Mosberger
Quoted 4 lines · David Mosberger

If we do have to go the virtual remapping route, my preference would be to stick the kernel somewhere in region 5 (0xa..). Has anyone tried that? It should work fine in principle (modules already live in that space).

That loses the alt[id]tlb handling for the kernel code and data. Is that going to be a performance problem?

#26 lore raw
In reply to David Mosberger
Quoted 10 lines
Quoted 3 lines · David Mosberger

If we do have to go the virtual remapping route, my preference would be to stick the kernel somewhere in region 5 (0xa..). Has anyone tried that? It should work fine in principle (modules

already live in

Quoted 1 line

that space).

That loses the alt[id]tlb handling for the kernel code and data. Is that going to be a performance problem?

I assume that we are still planning to lock the translations for the kernel into ITR[0] and DTR[0] ... we can still do this with the kernel mapped in region 5.

-Tony

#27 lore raw
In reply to David Mosberger
Quoted 6 lines · David Mosberger

Jesse> Right, I thought about that. I don't think we need text Jesse> replication yet though anyway (at least our platform Jesse> doesn't).

That's what I would have guessed. I think it might be different for the 8870 chipset though. Or does it have a huge L4 cache, too?

If they don't need it, would you be happy taking the simple reloc code in elilo? And it seems simple enough, so even if we have to throw it away, no big loss.

Thanks,
Jesse

#28 lore raw
In reply to David Mosberger
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · Keith Owens

Keith> On Thu, 8 May 2003 10:07:49 -0700,

Quoted 4 lines · Keith> David Mosberger <[email protected]> wrote:
Quoted 4 lines

If we do have to go the virtual remapping route, my preference would be to stick the kernel somewhere in region 5 (0xa..). Has anyone tried that? It should work fine in principle (modules already live in that space).

Keith> That loses the alt[id]tlb handling for the kernel code and data. Is Keith> that going to be a performance problem?

Should be OK: I'm assuming you'd use a single (large) pinned TLB entry to map the entire kernel. So no, if anything, performance improves for the kernel itself.

	--david
#29 lore raw
In reply to David Mosberger
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · Jesse Barnes

Jesse> On Thu, May 08, 2003 at 10:50:22AM -0700, David Mosberger wrote:
Jesse> Right, I thought about that. I don't think we need text Jesse> replication yet though anyway (at least our platform Jesse> doesn't).

Quoted 2 lines
Quoted 2 lines

That's what I would have guessed. I think it might be different for the 8870 chipset though. Or does it have a huge L4 cache, too?

Jesse> If they don't need it, would you be happy taking the simple reloc code Jesse> in elilo? And it seems simple enough, so even if we have to throw it Jesse> away, no big loss.

I'm confused. Last time we talked about this, you said something along the lines that you couldn't find the reloc code. In any case, for elilo changes, you have to talk to Stephane.

	--david
#30 lore raw
In reply to David Mosberger
Quoted 7 lines · David Mosberger

Jesse> If they don't need it, would you be happy taking the simple reloc code Jesse> in elilo? And it seems simple enough, so even if we have to throw it Jesse> away, no big loss.

I'm confused. Last time we talked about this, you said something along the lines that you couldn't find the reloc code. In any case, for elilo changes, you have to talk to Stephane.

Um, now I'm confused. Couldn't find what? You're right though, I guess the only kernel change we'd need is adding '-q' to the LDFLAGS.

Thanks,
Jesse

#31 lore raw
In reply to David Mosberger
Quoted 11 lines · Jesse Barnes
Quoted 7 lines · David Mosberger

Jesse> If they don't need it, would you be happy taking the simple reloc code Jesse> in elilo? And it seems simple enough, so even if we have to throw it Jesse> away, no big loss.

I'm confused. Last time we talked about this, you said something along the lines that you couldn't find the reloc code. In any case, for elilo changes, you have to talk to Stephane.

Um, now I'm confused. Couldn't find what? You're right though, I guess the only kernel change we'd need is adding '-q' to the LDFLAGS.

Ah, now I remember--elilo failing when kernels were stripped a certain way. No longer a problem...

Thanks,
Jesse

#32 lore raw
In reply to David Mosberger
Quoted 25 lines · Tony

1) My patch (posted around October last year) which picked virtual addresses in the wild blue yonder (initial versions used 0xe002000000000000, later ones used 0xffffffff00000000) for the link address for the kernel. Elilo can load kernel at any suitably aligned physical address, and head.S establishes the mappings using itr[0] and dtr[0].

pros) provided separate maps for kernel text and data, so supported kernel text
replication too.
cons) __pa() no longer works on kernel addresses, use new __tpa() instead.
Some ugly runtime patching of kernel code to get physical address of swapper_pg_dir into the TLB miss code.

2) I think SGI are currently running a modified version of #1 without the text replication support, and that provides a mapping from the normal virtual address that the kernel is linked for (0xe00000000044000000) to whatever physical address it was actually loaded at ... at least I think that's what Jack said.

pros) simpler than my patch

cons) Still needs __tpa() instead of __pa() for kernel addresses.

3) David's suggestion of boot-time relocation. Probably simplest to implement this in elilo, but if you are really good at PIC asm code it could be done in the kernel startup sequence.

Quoted 6 lines

pros) Just like linking kernel at a new address.
Avoids the __tpa() issue.
Doesn't invalidate any assumptions about how to get from virtual to physical addresses and back again.

cons) Nobody has implemented it.

doesn't address text replication concerns, while (1) and (2) do

So, is there any consensus on the best path to pursue? Chris Wedgwood is working on option #3, and I've got Tony's patch trimmed down to #2 (with one piece missing--ia64_switch_to runtime patching), but none of these are in either 2.4 or 2.5 yet. Maybe for 2.4 we should do #2 or #3 and for 2.5 we could implement #1 with the virtual offsets Tony mentioned earlier?

Thanks,
Jesse

#33 lore raw
In reply to David Mosberger
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · Jesse Barnes

Jesse> So, is there any consensus on the best path to pursue? Chris Wedgwood Jesse> is working on option #3, and I've got Tony's patch trimmed down to #2 Jesse> (with one piece missing--ia64_switch_to runtime patching), but none of Jesse> these are in either 2.4 or 2.5 yet. Maybe for 2.4 we should do #2 or Jesse> #3 and for 2.5 we could implement #1 with the virtual offsets Tony Jesse> mentioned earlier?

I'm not sure. I got the impression Tony may be looking at the virtual remapping in region 5. I haven't heard whether text replication turned out to be important for 8870, but I'm starting to lean towards virtual remapping because it is more versatile (can handle both "strange" physical memory layouts and kernel replication). This, coupled with the fact that it doesn't break any of the existing tools makes it pretty compelling. Also, my primary objection about making the kernel model more complicated doesn't hold much water if we move everything to region 5.

Would there be a downside to this on SGI's machines?

	--david
#34 lore raw
In reply to David Mosberger
Quoted 11 lines · David Mosberger

I'm not sure. I got the impression Tony may be looking at the virtual remapping in region 5. I haven't heard whether text replication turned out to be important for 8870, but I'm starting to lean towards virtual remapping because it is more versatile (can handle both "strange" physical memory layouts and kernel replication). This, coupled with the fact that it doesn't break any of the existing tools makes it pretty compelling. Also, my primary objection about making the kernel model more complicated doesn't hold much water if we move everything to region 5.

Would there be a downside to this on SGI's machines?

Not that I can see--we've been using that method for awhile now with good success, and I'd be happy to test any 2.5 patches that implement this feature. So I guess we should go with virtual remapping? Tony?

Thanks,
Jesse

#35 lore raw
In reply to David Mosberger
Quoted 8 lines · Tony
Quoted 6 lines

1) My patch (posted around October last year) which picked virtual addresses in the wild blue yonder (initial versions used 0xe002000000000000, later ones used 0xffffffff00000000) for the link address for the kernel. Elilo can load kernel at any suitably aligned physical address, and head.S establishes the mappings using itr[0] and dtr[0].

Quoted 5 lines
Quoted 5 lines

pros) provided separate maps for kernel text and data, so supported kernel text
replication too.
cons) __pa() no longer works on kernel addresses, use new __tpa() instead.
Some ugly runtime patching of kernel code to get physical address of swapper_pg_dir into the TLB miss code.

The __tpa macros are ugly but they are fully contained within the ia64 part of the tree. (IIRC, the old scheduler had a reference but the O(1) scheduler doe not). In our tree, there are currently only 12 references to __tpa. All are
in boottime initialization code., mostly in mca.c. Although I would rather not have __tpa, this doesnt seem too bad.

Quoted 5 lines
Quoted 5 lines

2) I think SGI are currently running a modified version of #1 without the text replication support, and that provides a mapping from the normal virtual address that the kernel is linked for (0xe00000000044000000) to whatever physical address it was actually loaded at ... at least I think that's what Jack said.

Right.

Quoted 18 lines
Quoted 9 lines

pros) simpler than my patch

cons) Still needs __tpa() instead of __pa() for kernel addresses.

3) David's suggestion of boot-time relocation. Probably simplest to implement this in elilo, but if you are really good at PIC asm code it could be done in the kernel startup sequence.

Quoted 6 lines

pros) Just like linking kernel at a new address.
Avoids the __tpa() issue.
Doesn't invalidate any assumptions about how to get from virtual to physical addresses and back again.

cons) Nobody has implemented it.

doesn't address text replication concerns, while (1) and (2) do

Quoted 6 lines

So, is there any consensus on the best path to pursue? Chris Wedgwood is working on option #3, and I've got Tony's patch trimmed down to #2 (with one piece missing--ia64_switch_to runtime patching), but none of these are in either 2.4 or 2.5 yet. Maybe for 2.4 we should do #2 or #3 and for 2.5 we could implement #1 with the virtual offsets Tony mentioned earlier?

As far as I can tell, #1 is the only solution that will support kernel text replication. We did experiments to measure the effect of kernel text replication. On AIM7, (granted, not the best benchmark), we see a small but consistent improvement in performance with text replication enabled. (Data attached below). The biggest difference is cputime, not throughput.

This was from a relatively small system with very good remote-to-local latency ratios. As system sizes increase, I expect the benefit of text replication will increase.

I think that whatever solution is adopted, it need to accommadate text replication.

If we are going to do #1 for 2.5, it seems like #2 is the best solution for 2.4.

#3 requires changes elilo & the way System.map is used. These changes wont apply to 2.5. #3 also will introduce some confusion since the System.map that is generated at build time cant be used without knowing the physical address where elilo actually loaded the kernel. The address could change based on minor changes in the configuration (amount of memory, devices, nodes, etc).

------

AIM7
Kernel Text replication:

        Tasks   Jobs/Min        JTI     Real    CPU     Jobs/sec/task
        200     18110.2         84      64.3    619.6   1.5092
        500     23932.5         76      121.6   2947.1  0.7977
        1000    24402.0         71      238.5   9890.6  0.4067
        2000    23895.4         71      487.1   25537.8 0.1991
        3000    22848.8         75      764.2   42549.7 0.1269
        4000    20420.4         78      1140.0  64237.4 0.0851

Baseline

        Tasks   Jobs/Min        JTI     Real    CPU     Jobs/sec/task
        200     18008.8         84      64.6    624.1   1.5007
        500     23102.2         76      126.0   4238.1  0.7701                                      
        1000    23886.4         71      243.7   10507.3 0.3981                                      
        2000    23669.9         72      491.8   26120.2 0.1972                                      
        3000    22344.9         75      781.4   42965.0 0.1241
        4000    20256.9         78      1149.2  64711.0 0.0844                                      
Quoted 9 lines

Thanks,
Jesse

_______________________________________________
Linux-IA64 mailing list
[email protected]
http://lists.linuxia64.org/lists/listinfo/linux-ia64

Signature · 3 lines
Thanks

Jack Steiner    (651-683-5302)   (vnet 233-5302)      [email protected]
#36 lore raw
In reply to David Mosberger
Quoted 20 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines · Jesse Barnes

Jesse> So, is there any consensus on the best path to pursue? Chris Wedgwood Jesse> is working on option #3, and I've got Tony's patch trimmed down to #2 Jesse> (with one piece missing--ia64_switch_to runtime patching), but none of Jesse> these are in either 2.4 or 2.5 yet. Maybe for 2.4 we should do #2 or Jesse> #3 and for 2.5 we could implement #1 with the virtual offsets Tony Jesse> mentioned earlier?

I'm not sure. I got the impression Tony may be looking at the virtual remapping in region 5. I haven't heard whether text replication turned out to be important for 8870, but I'm starting to lean towards virtual remapping because it is more versatile (can handle both "strange" physical memory layouts and kernel replication). This, coupled with the fact that it doesn't break any of the existing tools makes it pretty compelling. Also, my primary objection about making the kernel model more complicated doesn't hold much water if we move everything to region 5.

Quoted 1 line

Would there be a downside to this on SGI's machines?

I dont see any significant problems. It actually seems easy.

I think we still need to use __tpa() for addresses assigned by the loader. The standard __pa() macros wont work in region 5.

I dont have any objections to __tpa. We have had them in the kernel since ~2.3.42 & have not had any problems with them. On occasion, when we upgrade, we have to add/delete a couple of references but these are always easy to find. I dont recall any changes for the last couple of upgrades but maybe we were just lucky.

As I mention in mail earlier,

Quoted 16 lines
Quoted 5 lines

The __tpa macros are ugly but they are fully contained within the ia64 part of the tree. (IIRC, the old scheduler had a reference but the O(1) scheduler doe not). In our tree, there are currently only 12 references to __tpa. All are
in boottime initialization code, mostly in mca.c. Although I would rather not have __tpa, this doesnt seem too bad.

	--david

_______________________________________________
Linux-IA64 mailing list
[email protected]
http://lists.linuxia64.org/lists/listinfo/linux-ia64

Signature · 3 lines
Thanks

Jack Steiner    (651-683-5302)   (vnet 233-5302)      [email protected]
#37 lore raw
In reply to David Mosberger
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line · Jack Steiner

Would there be a downside to this on SGI's machines?

Jack> I dont see any significant problems. It actually seems easy.

Good.

Jack> I think we still need to use __tpa() for addresses assigned by Jack> the loader. The standard __pa() macros wont work in region 5.

That's why I don't mind: nobody can use __pa() on region 5 anyhow, so using something different (page table walk or __tpa()) is OK. I was real uneasy with having a "magic" address range inside region 7, where __pa() wouldn't work. But in region 5, no problem.

It might be good to call __tpa() something different: it's too close to __pa() and the difference may easily be overlooked. For example, ia64_tpa() would make it obvious that we're talking about an ia64 instruction.

	--david
#38 lore raw
In reply to David Mosberger
Quoted 3 lines

Not that I can see--we've been using that method for awhile now with good success, and I'd be happy to test any 2.5 patches that implement this feature. So I guess we should go with virtual remapping? Tony?

I started looking at porting the most recent version of my patch (last seen around 2.5.39 ... only has the relocation, but once that is it, adding kernel text replication is a relatively simple evolutionary step).

I've been teaching a class all morning, and part of the afternoon, so no demonstrable progress ... but most of the merge errors have been cleaned up. Now looking last (and biggest) reject in head.S.

-Tony

#39 lore raw
In reply to David Mosberger
Quoted 17 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines · Jack Steiner

Would there be a downside to this on SGI's machines?

Jack> I dont see any significant problems. It actually seems easy.

Good.

Jack> I think we still need to use __tpa() for addresses assigned by Jack> the loader. The standard __pa() macros wont work in region 5.

That's why I don't mind: nobody can use __pa() on region 5 anyhow, so using something different (page table walk or __tpa()) is OK. I was real uneasy with having a "magic" address range inside region 7, where __pa() wouldn't work. But in region 5, no problem.

Quoted 4 lines

It might be good to call __tpa() something different: it's too close to __pa() and the difference may easily be overlooked. For example, ia64_tpa() would make it obvious that we're talking about an ia64 instruction.

Seems reasonable.....

Quoted 8 lines
	--david

_______________________________________________
Linux-IA64 mailing list
[email protected]
http://lists.linuxia64.org/lists/listinfo/linux-ia64

Signature · 3 lines
Thanks

Jack Steiner    (651-683-5302)   (vnet 233-5302)      [email protected]
#40 lore raw
In reply to David Mosberger

Here's a proof of concept patch (against 2.5.67) that covers most of the features we've been talking about in this thread. This builds and boots both UP and SMP on a Tiger.

Kernel text and data are linked into region 5 at address 0xA000000100000000, leaving the bottom 4G of region 5 available for miscellaneous stuff as suggested by David. It will be possible to extend this patch to split text and data into separate sections to allow kernel text replication, but I left that out for now to keep this patch to the bare minimum.

This version still uses the __tpa() macro, but converting it to use the ia64_tpa() inline function is just a matter of getting all the types (argument and return value) so that the compiler doesn't spit warnings all over the screen during build.

This patch doesn't fixup fs/proc/kcore.c (my old patch didn't apply cleanly ... and much of the changes it would have made are no longer needed as kernel is now at a lower address than modules).

Here's a file by file description of the changes:

arch/ia64/kernel/efi_stub.S
calls to ia64_switch_mode replaced by calls to ia64_switch_mode_phys or ia64_switch_mode_virt
as appropriate
arch/ia64/kernel/entry.S
ia64_switch_to() doesn't need to test whether stack overlaps DTR[0] (it can't, kernel and stack are in different regions now).
arch/ia64/kernel/head.S
Initialize all the kernel region registers here (we now have to do rr[5] and rr[7], so I moved rr[6] up to the top and dropped the EARLY_PRINTK #ifdef for symmetry). Map itr[0]/dtr[0] based on actual load address. Map dtr[2] to the region 7 address of the stack, and set IA64_KR(CURRENT_STACK) to correct granule number.
Replace ia64_switch_mode() from a function that toggles virtual mode on/off with separate functions to go from virt to phys mode, and from phys to virt mode.
arch/ia64/kernel/ia64_ksyms.c
Export zero_page_memmap_ptr
arch/ia64/kernel/ivt.S
Provide labels on code that needs to be patched with the physical address of swapper_pg_dir
arch/ia64/kernel/mca.c
Lots of __pa() need to be __tpa()
arch/ia64/kernel/pal.S
calls to ia64_switch_mode replaced by calls to ia64_switch_mode_phys or ia64_switch_mode_virt
as appropriate
arch/ia64/kernel/setup.c
Get correct page numbers when marking start/end of kernel. Code to patch ivt.S with physical address of swapper_pg_dir. Pass region 7 virtual address of per-cpu area to ia64_mmu_init() [UP code would have passed a region 5 kernel address, which chokes the __pa() call in ia64_mmu_init()]
arch/ia64/kernel/smpboot.c
Use __tpa() to get physical address of entry point to start other cpus
arch/ia64/mm/init.c
free_initmem() needs to be smarter about addresses initialization of rr[5] and rr[6] moved to head.S setup zero_page_memmap_ptr
arch/ia64/vmlinux.lds.S
Set LOAD_OFFSET to a sane default value for DIG machines, kernel loaded at 64MB ... on machines where this patch is really needed, elilo will have to ignore the load address and put the kernel anyplace there is suitably aligned memory. Use LOAD_OFFSET rather than PAGE_OFFSET throughout the rest of the file.
include/asm-ia64/page.h
define __tpa() and __imva() macros
include/asm-ia64/pgtable.h
Move VMALLOC_START up above kernel (region 5 base + 8GB) New definition of ZERO_PAGE uses zero_page_memmap_ptr Drop KERNEL_TR_PAGE_NUM define, it is meaningless now.
include/asm-ia64/system.h
KERNEL_START moves to region 5 base + 4GB

arch/ia64/kernel/efi_stub.S +2 -2
diff -ru l2567-ref/arch/ia64/kernel/efi_stub.S l2567-reloc/arch/ia64/kernel/efi_stub.S
@@ -62,7 +62,7 @@
 	mov b6=r2
 	;;
 	andcm r16=loc3,r16		// get psr with IT, DT, and RT bits cleared
-	br.call.sptk.many rp=ia64_switch_mode
+	br.call.sptk.many rp=ia64_switch_mode_phys
 .ret0:	mov out4=in5
 	mov out0=in1
 	mov out1=in2
@@ -73,7 +73,7 @@
 	br.call.sptk.many rp=b6		// call the EFI function
 .ret1:	mov ar.rsc=0			// put RSE in enforced lazy, LE mode
 	mov r16=loc3
-	br.call.sptk.many rp=ia64_switch_mode // return to virtual mode
+	br.call.sptk.many rp=ia64_switch_mode_virt // return to virtual mode
 .ret2:	mov ar.rsc=loc4			// restore RSE configuration
 	mov ar.pfs=loc1
 	mov rp=loc0
arch/ia64/kernel/entry.S +1 -4
diff -ru l2567-ref/arch/ia64/kernel/entry.S l2567-reloc/arch/ia64/kernel/entry.S
@@ -178,15 +178,12 @@
 	;;
 	st8 [r22]=sp			// save kernel stack pointer of old task
 	shr.u r26=r20,IA64_GRANULE_SHIFT
-	shr.u r17=r20,KERNEL_TR_PAGE_SHIFT
-	;;
-	cmp.ne p6,p7=KERNEL_TR_PAGE_NUM,r17
 	adds r21=IA64_TASK_THREAD_KSP_OFFSET,in0
 	;;
 	/*
 	 * If we've already mapped this task's page, we can skip doing it again.
 	 */
-(p6)	cmp.eq p7,p6=r26,r27
+	cmp.eq p7,p6=r26,r27
 (p6)	br.cond.dpnt .map
 	;;
 .done:
arch/ia64/kernel/head.S +116 -31

215 lines not on this page · raw message

arch/ia64/kernel/ia64_ksyms.c +1 -0
diff -ru l2567-ref/arch/ia64/kernel/ia64_ksyms.c l2567-reloc/arch/ia64/kernel/ia64_ksyms.c
@@ -146,6 +146,7 @@
 EXPORT_SYMBOL(ia64_mv);
 #endif
 EXPORT_SYMBOL(machvec_noop);
+EXPORT_SYMBOL(zero_page_memmap_ptr);
 #ifdef CONFIG_PERFMON
 #include <asm/perfmon.h>
 EXPORT_SYMBOL(pfm_install_alternate_syswide_subsystem);
arch/ia64/kernel/ivt.S +13 -3
diff -ru l2567-ref/arch/ia64/kernel/ivt.S l2567-reloc/arch/ia64/kernel/ivt.S
@@ -122,8 +122,13 @@
 	shr.u r18=r22,PGDIR_SHIFT		// get bits 33-63 of the faulting address
 	;;
 (p7)	dep r17=r17,r19,(PAGE_SHIFT-3),3	// put region number bits in place
+	.global ia64_ivt_patch1
+ia64_ivt_patch1:
+{	.mlx // we patch this bundle to include physical address of swapper_pg_dir
 	srlz.d					// ensure "rsm psr.dt" has taken effect
-(p6)	movl r19=__pa(swapper_pg_dir)		// region 5 is rooted at swapper_pg_dir
+(p6)	movl r19=swapper_pg_dir			// region 5 is rooted at swapper_pg_dir
+}
+	.pred.rel "mutex", p6, p7
 (p6)	shr.u r21=r21,PGDIR_SHIFT+PAGE_SHIFT
 (p7)	shr.u r21=r21,PGDIR_SHIFT+PAGE_SHIFT-3
 	;;
@@ -415,8 +420,13 @@
 	shr.u r18=r16,PGDIR_SHIFT		// get bits 33-63 of faulting address
 	;;
 (p7)	dep r17=r17,r19,(PAGE_SHIFT-3),3	// put region number bits in place
-	srlz.d
-(p6)	movl r19=__pa(swapper_pg_dir)		// region 5 is rooted at swapper_pg_dir
+	.global ia64_ivt_patch2
+ia64_ivt_patch2:
+{	.mlx // we patch this bundle to include physical address of swapper_pg_dir
+	srlz.d					// ensure "rsm psr.dt" has taken effect
+(p6)	movl r19=swapper_pg_dir			// region 5 is rooted at swapper_pg_dir
+}
+	.pred.rel "mutex", p6, p7
 (p6)	shr.u r21=r21,PGDIR_SHIFT+PAGE_SHIFT
 (p7)	shr.u r21=r21,PGDIR_SHIFT+PAGE_SHIFT-3
 	;;
arch/ia64/kernel/mca.c +8 -8
diff -ru l2567-ref/arch/ia64/kernel/mca.c l2567-reloc/arch/ia64/kernel/mca.c
@@ -641,17 +641,17 @@
 
 	IA64_MCA_DEBUG("ia64_mca_init: registered mca rendezvous spinloop and wakeup mech.\n");
 
-	ia64_mc_info.imi_mca_handler        = __pa(mca_hldlr_ptr->fp);
+	ia64_mc_info.imi_mca_handler        = __tpa(mca_hldlr_ptr->fp);
 	/*
 	 * XXX - disable SAL checksum by setting size to 0; should be
-	 *	__pa(ia64_os_mca_dispatch_end) - __pa(ia64_os_mca_dispatch);
+	 *	__tpa(ia64_os_mca_dispatch_end) - __tpa(ia64_os_mca_dispatch);
 	 */
 	ia64_mc_info.imi_mca_handler_size	= 0;
 
 	/* Register the os mca handler with SAL */
 	if ((rc = ia64_sal_set_vectors(SAL_VECTOR_OS_MCA,
 				       ia64_mc_info.imi_mca_handler,
-				       mca_hldlr_ptr->gp,
+				       __tpa(mca_hldlr_ptr->gp),
 				       ia64_mc_info.imi_mca_handler_size,
 				       0, 0, 0)))
 	{
@@ -661,15 +661,15 @@
 	}
 
 	IA64_MCA_DEBUG("ia64_mca_init: registered os mca handler with SAL at 0x%lx, gp = 0x%lx\n",
-		       ia64_mc_info.imi_mca_handler, mca_hldlr_ptr->gp);
+		       ia64_mc_info.imi_mca_handler, __tpa(mca_hldlr_ptr->gp));
 
 	/*
 	 * XXX - disable SAL checksum by setting size to 0, should be
 	 * IA64_INIT_HANDLER_SIZE
 	 */
-	ia64_mc_info.imi_monarch_init_handler		= __pa(mon_init_ptr->fp);
+	ia64_mc_info.imi_monarch_init_handler		= __tpa(mon_init_ptr->fp);
 	ia64_mc_info.imi_monarch_init_handler_size	= 0;
-	ia64_mc_info.imi_slave_init_handler		= __pa(slave_init_ptr->fp);
+	ia64_mc_info.imi_slave_init_handler		= __tpa(slave_init_ptr->fp);
 	ia64_mc_info.imi_slave_init_handler_size	= 0;
 
 	IA64_MCA_DEBUG("ia64_mca_init: os init handler at %lx\n",
@@ -678,10 +678,10 @@
 	/* Register the os init handler with SAL */
 	if ((rc = ia64_sal_set_vectors(SAL_VECTOR_OS_INIT,
 				       ia64_mc_info.imi_monarch_init_handler,
-				       __pa(ia64_get_gp()),
+				       __tpa(ia64_get_gp()),
 				       ia64_mc_info.imi_monarch_init_handler_size,
 				       ia64_mc_info.imi_slave_init_handler,
-				       __pa(ia64_get_gp()),
+				       __tpa(ia64_get_gp()),
 				       ia64_mc_info.imi_slave_init_handler_size)))
 	{
 		printk(KERN_ERR "ia64_mca_init: Failed to register m/s init handlers with SAL. "
arch/ia64/kernel/pal.S +5 -5
diff -ru l2567-ref/arch/ia64/kernel/pal.S l2567-reloc/arch/ia64/kernel/pal.S
@@ -164,7 +164,7 @@
 	;;
 	mov loc4=ar.rsc			// save RSE configuration
 	dep.z loc2=loc2,0,61		// convert pal entry point to physical
-	dep.z r8=r8,0,61		// convert rp to physical
+	tpa r8=r8			// convert rp to physical
 	;;
 	mov b7 = loc2			// install target to branch reg
 	mov ar.rsc=0			// put RSE in enforced lazy, LE mode
@@ -174,13 +174,13 @@
 	or loc3=loc3,r17		// add in psr the bits to set
 	;;
 	andcm r16=loc3,r16		// removes bits to clear from psr
-	br.call.sptk.many rp=ia64_switch_mode
+	br.call.sptk.many rp=ia64_switch_mode_phys
 .ret1:	mov rp = r8			// install return address (physical)
 	br.cond.sptk.many b7
 1:
 	mov ar.rsc=0			// put RSE in enforced lazy, LE mode
 	mov r16=loc3			// r16= original psr
-	br.call.sptk.many rp=ia64_switch_mode // return to virtual mode
+	br.call.sptk.many rp=ia64_switch_mode_virt // return to virtual mode
 .ret2:
 	mov psr.l = loc3		// restore init PSR
 
@@ -228,13 +228,13 @@
 	mov b7 = loc2			// install target to branch reg
 	;;
 	andcm r16=loc3,r16		// removes bits to clear from psr
-	br.call.sptk.many rp=ia64_switch_mode
+	br.call.sptk.many rp=ia64_switch_mode_phys
 .ret6:
 	br.call.sptk.many rp=b7		// now make the call
 .ret7:
 	mov ar.rsc=0			// put RSE in enforced lazy, LE mode
 	mov r16=loc3			// r16= original psr
-	br.call.sptk.many rp=ia64_switch_mode	// return to virtual mode
+	br.call.sptk.many rp=ia64_switch_mode_virt	// return to virtual mode
 
 .ret8:	mov psr.l  = loc3		// restore init PSR
 	mov ar.pfs = loc1
arch/ia64/kernel/setup.c +46 -3

73 lines not on this page · raw message

arch/ia64/kernel/smpboot.c +1 -1
diff -ru l2567-ref/arch/ia64/kernel/smpboot.c l2567-reloc/arch/ia64/kernel/smpboot.c
@@ -574,7 +574,7 @@
 	/* Tell SAL where to drop the AP's.  */
 	ap_startup = (struct fptr *) start_ap;
 	sal_ret = ia64_sal_set_vectors(SAL_VECTOR_OS_BOOT_RENDEZ,
-				       __pa(ap_startup->fp), __pa(ap_startup->gp), 0, 0, 0, 0);
+				       __tpa(ap_startup->fp), __tpa(ap_startup->gp), 0, 0, 0, 0);
 	if (sal_ret < 0)
 		printk(KERN_ERR "SMP: Can't set SAL AP Boot Rendezvous: %s\n",
 		       ia64_sal_strerror(sal_ret));
arch/ia64/mm/init.c +12 -19
diff -ru l2567-ref/arch/ia64/mm/init.c l2567-reloc/arch/ia64/mm/init.c
@@ -47,6 +47,8 @@
 
 static int pgt_cache_water[2] = { 25, 50 };
 
+struct page *zero_page_memmap_ptr;		/* map entry for zero page */
+
 void
 check_pgt_cache (void)
 {
@@ -112,14 +114,16 @@
 void
 free_initmem (void)
 {
-	unsigned long addr;
+	unsigned long addr, eaddr;
 
-	addr = (unsigned long) &__init_begin;
-	for (; addr < (unsigned long) &__init_end; addr += PAGE_SIZE) {
+	addr = (unsigned long)__imva(&__init_begin);
+	eaddr = (unsigned long)__imva(&__init_end);
+	while (addr < eaddr) {
 		ClearPageReserved(virt_to_page(addr));
 		set_page_count(virt_to_page(addr), 1);
 		free_page(addr);
 		++totalram_pages;
+		addr += PAGE_SIZE;
 	}
 	printk(KERN_INFO "Freeing unused kernel memory: %ldkB freed\n",
 	       (&__init_end - &__init_begin) >> 10);
@@ -270,7 +274,7 @@
 void __init
 ia64_mmu_init (void *my_cpu_data)
 {
-	unsigned long psr, rid, pta, impl_va_bits;
+	unsigned long psr, pta, impl_va_bits;
 	extern void __init tlb_init (void);
 #ifdef CONFIG_DISABLE_VHPT
 #	define VHPT_ENABLE_BIT	0
@@ -278,21 +282,8 @@
 #	define VHPT_ENABLE_BIT	1
 #endif
 
-	/*
-	 * Set up the kernel identity mapping for regions 6 and 5.  The mapping for region
-	 * 7 is setup up in _start().
-	 */
+	/* Pin mapping for percpu area into TLB */
 	psr = ia64_clear_ic();
-
-	rid = ia64_rid(IA64_REGION_ID_KERNEL, __IA64_UNCACHED_OFFSET);
-	ia64_set_rr(__IA64_UNCACHED_OFFSET, (rid << 8) | (IA64_GRANULE_SHIFT << 2));
-
-	rid = ia64_rid(IA64_REGION_ID_KERNEL, VMALLOC_START);
-	ia64_set_rr(VMALLOC_START, (rid << 8) | (PAGE_SHIFT << 2) | 1);
-
-	/* ensure rr6 is up-to-date before inserting the PERCPU_ADDR translation: */
-	ia64_srlz_d();
-
 	ia64_itr(0x2, IA64_TR_PERCPU_DATA, PERCPU_ADDR,
 		 pte_val(pfn_pte(__pa(my_cpu_data) >> PAGE_SHIFT, PAGE_KERNEL)),
 		 PERCPU_PAGE_SHIFT);
@@ -495,6 +486,7 @@
 
 	discontig_paging_init();
 	efi_memmap_walk(count_pages, &num_physpages);
+	zero_page_memmap_ptr = virt_to_page(__imva(empty_zero_page));
 }
 #else /* !CONFIG_DISCONTIGMEM */
 void
@@ -567,6 +559,7 @@
 	}
 	free_area_init(zones_size);
 #  endif /* !CONFIG_VIRTUAL_MEM_MAP */
+	zero_page_memmap_ptr = virt_to_page(__imva(empty_zero_page));
 }
 #endif /* !CONFIG_DISCONTIGMEM */
 
@@ -637,7 +630,7 @@
 		pgt_cache_water[1] = num_pgt_pages;
 
 	/* install the gate page in the global page table: */
-	put_gate_page(virt_to_page(__start_gate_section), GATE_ADDR);
+	put_gate_page(virt_to_page(__imva(__start_gate_section)), GATE_ADDR);
 
 #ifdef CONFIG_IA32_SUPPORT
 	ia32_gdt_init();
arch/ia64/vmlinux.lds.S +28 -27

181 lines not on this page · raw message

include/asm-ia64/page.h +2 -0
diff -ru l2567-ref/include/asm-ia64/page.h l2567-reloc/include/asm-ia64/page.h
@@ -118,6 +118,8 @@
  */
 #define __pa(x)		({ia64_va _v; _v.l = (long) (x); _v.f.reg = 0; _v.l;})
 #define __va(x)		({ia64_va _v; _v.l = (long) (x); _v.f.reg = -1; _v.p;})
+#define __tpa(x)	({ia64_va _v; asm("tpa %0=%1" : "=r"(_v.l) : "r"(x)); _v.l;})
+#define __imva(x)	((long)__va(__tpa(x)))
 
 #define REGION_NUMBER(x)	({ia64_va _v; _v.l = (long) (x); _v.f.reg;})
 #define REGION_OFFSET(x)	({ia64_va _v; _v.l = (long) (x); _v.f.off;})
include/asm-ia64/pgtable.h +3 -3
diff -ru l2567-ref/include/asm-ia64/pgtable.h l2567-reloc/include/asm-ia64/pgtable.h
@@ -205,7 +205,7 @@
 #define RGN_MAP_LIMIT	((1UL << (4*PAGE_SHIFT - 12)) - PAGE_SIZE)	/* per region addr limit */
 #define RGN_KERNEL	7
 
-#define VMALLOC_START		(0xa000000000000000 + 3*PERCPU_PAGE_SIZE)
+#define VMALLOC_START		0xa000000200000000
 #define VMALLOC_VMADDR(x)	((unsigned long)(x))
 #ifdef CONFIG_VIRTUAL_MEM_MAP
 # define VMALLOC_END_INIT	(0xa000000000000000 + (1UL << (4*PAGE_SHIFT - 9)))
@@ -448,7 +448,8 @@
  * for zero-mapped memory areas etc..
  */
 extern unsigned long empty_zero_page[PAGE_SIZE/sizeof(unsigned long)];
-#define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page))
+extern struct page *zero_page_memmap_ptr;
+#define ZERO_PAGE(vaddr) (zero_page_memmap_ptr)
 
 /* We provide our own get_unmapped_area to cope with VA holes for userland */
 #define HAVE_ARCH_UNMAPPED_AREA
@@ -485,7 +486,6 @@
  */
 #define KERNEL_TR_PAGE_SHIFT	_PAGE_SIZE_64M
 #define KERNEL_TR_PAGE_SIZE	(1 << KERNEL_TR_PAGE_SHIFT)
-#define KERNEL_TR_PAGE_NUM	((KERNEL_START - PAGE_OFFSET) / KERNEL_TR_PAGE_SIZE)
 
 /*
  * No page table caches to initialise
include/asm-ia64/system.h +1 -1
diff -ru l2567-ref/include/asm-ia64/system.h l2567-reloc/include/asm-ia64/system.h
@@ -19,7 +19,7 @@
 #include <asm/pal.h>
 #include <asm/percpu.h>
 
-#define KERNEL_START		(PAGE_OFFSET + 68*1024*1024)
+#define KERNEL_START		(0xA000000100000000)
 
 /* 0xa000000000000000 - 0xa000000000000000+PERCPU_MAX_SIZE remain unmapped */
 #define PERCPU_ADDR		(0xa000000000000000 + PERCPU_PAGE_SIZE)
#41 lore raw
In reply to David Mosberger

Great! I'm working on a 2.5.69 SN update now, so hopefully I'll have a chance to test your patch a little soon.

Thanks,
Jesse

Quoted 19 lines · Tony

Here's a proof of concept patch (against 2.5.67) that covers most of the features we've been talking about in this thread. This builds and boots both UP and SMP on a Tiger.

Kernel text and data are linked into region 5 at address 0xA000000100000000, leaving the bottom 4G of region 5 available for miscellaneous stuff as suggested by David. It will be possible to extend this patch to split text and data into separate sections to allow kernel text replication, but I left that out for now to keep this patch to the bare minimum.

This version still uses the __tpa() macro, but converting it to use the ia64_tpa() inline function is just a matter of getting all the types (argument and return value) so that the compiler doesn't spit warnings all over the screen during build.

This patch doesn't fixup fs/proc/kcore.c (my old patch didn't apply cleanly ... and much of the changes it would have made are no longer needed as kernel is now at a lower address than modules).

#42 lore raw
In reply to David Mosberger
Quoted 4 lines · [email protected] schrieb:

It will be possible to extend this patch to split text and data into separate sections to allow kernel text replication, but I left that out for now to keep this patch to the bare minimum.

If you plan to separate text and data of the kernel be aware of tpa only translating data addresses and not instruction addresses. We would need a tpa.d and tpa.i. I am wondering about the lack of "tpa.i" in the itanium architecture design.

Christian

#43 lore raw
In reply to David Mosberger
Quoted 4 lines

If you plan to separate text and data of the kernel be aware of tpa only translating data addresses and not instruction addresses. We would need a tpa.d and tpa.i. I am wondering about the lack of "tpa.i" in the itanium architecture design.

The previous incarnations of the replicate kernel text patch all provided both an ITR and DTR mapping for the replicated area ... but I don't recall that tpa was the issue, I think that there are various data-ish blobs in amongst the code that need to be mapped ... there is definitely the .rodata

Here's some ASCII-art that shows physical layout to the left, and virtual layout on the right. Sections in () show up at the virtual addresses indicated, but aren't referenced by those addresses.

We use ITR[0] and DTR[0] to map what is labelled as the PERNODE area (each node gets a copy of the bottom sections of the kernel, so these mappings are different for each node), and DTR[3] to map the GLOBAL area (same mapping on all nodes).

                          GLOBAL AREA
                        +------------+
                        | .bss       |
                        |            |
                        | .data      |
                        |            |
                        | .init.data |
                        |            |
                        |(.init.text)|
   PHYSICAL             |            |
  +------------+        | (.rodata)  |
  | .bss       |        |            |
  |            |        | (.text)    |
  | .data      |        +------------+ Region5 + 8G
  |            |
  | .init.data |
  |            |
  | .init.text |
  |            |        PERNODE AREA
  | .rodata    |        +------------+
  |            |        | (.bss)     |
  | .text      |        |            |
  +------------+        | (.data)    |
                        |            |
                        |(.init.data)|
                        |            |
                        | .init.text |
                        |            |
                        | .rodata    |
                        |            |
                        | .text      |
                        +------------+ Region5 + 4G

-Tony

#44 lore raw
In reply to David Mosberger

The patch looks mostly fine to me. I'm not too fond of the __tpa() and __imva() macros, but that may be mainly a matter of preference. What I definitely don't like is that the casting seems rather confused and that the patch is adding __tpa() when we already have ia64_tpa(). As an example of the casting issues: __imva() returns a long, but at times it's cast to "unsigned long" which doesn't make a lot of sense (for assignments, anyhow). Moreover, we should stick to the Linux principle that kernel-space pointers have a type of "void *".

	--david
#45 lore raw
In reply to David Mosberger
Quoted 8 lines

The patch looks mostly fine to me. I'm not too fond of the __tpa() and __imva() macros, but that may be mainly a matter of preference. What I definitely don't like is that the casting seems rather confused and that the patch is adding __tpa() when we already have ia64_tpa(). As an example of the casting issues: __imva() returns a long, but at times it's cast to "unsigned long" which doesn't make a lot of sense (for assignments, anyhow). Moreover, we should stick to the Linux principle that kernel-space pointers have a type of "void *".

I can get rid of the __tpa() easily by using ia64_tpa() ... I'll fix the type-casting fiasco while making those changes.

Do you have some direction for the __imva() macro? The acronym stands for "Identity Mapped Virtual Address", and its purpose is to provide the region 7 address for an object, so that the existing code can continue to work without a whole lot of run-on changes. If you just don't like the name, then it's easy to change to something else. If it's the typecast issue, then I can switch over to void *. If it just makes your head hurt coping with schizophrenic dual mapping that the kernel gets with this patch, then you'll just have to take a couple of aspirin and look at the patch again in the morning :-)

-Tony

#46 lore raw
In reply to David Mosberger
Quoted 13 lines
Quoted 9 lines

The patch looks mostly fine to me. I'm not too fond of the __tpa() and __imva() macros, but that may be mainly a matter of preference. What I definitely don't like is that the casting seems rather confused and that the patch is adding __tpa() when we already have ia64_tpa(). As an example of the casting issues: __imva() returns a long, but at times it's cast to "unsigned long" which doesn't make a lot of sense (for assignments, anyhow). Moreover, we should stick to the Linux principle that kernel-space pointers have a type of "void *".

I can get rid of the __tpa() easily by using ia64_tpa() ... I'll fix the type-casting fiasco while making those changes.

Quoted 10 lines

Do you have some direction for the __imva() macro? The acronym stands for "Identity Mapped Virtual Address", and its purpose is to provide the region 7 address for an object, so that the existing code can continue to work without a whole lot of run-on changes. If you just don't like the name, then it's easy to change to something else. If it's the typecast issue, then I can switch over to void *. If it just makes your head hurt coping with schizophrenic dual mapping that the kernel gets with this patch, then you'll just have to take a couple of aspirin and look at the patch again in the morning :-)

You can always replace __imva(x) with __va(ia64_tpa(x)). This looks very strange but is equivalent. The disadvantage is that it obscures the conversion that is taking place.

Seem to me that a special macro (any name is fine) makes it easier to understand the reason for the conversion.

Quoted 4 lines

-Tony

Signature · 3 lines
Thanks

Jack Steiner    (651-683-5302)   (vnet 233-5302)      [email protected]
#47 lore raw
In reply to David Mosberger
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · Tony

Tony> Do you have some direction for the __imva() macro? The Tony> acronym stands for "Identity Mapped Virtual Address", and its Tony> purpose is to provide the region 7 address for an object, so Tony> that the existing code can continue to work without a whole Tony> lot of run-on changes. If you just don't like the name, then Tony> it's easy to change to something else. If it's the typecast Tony> issue, then I can switch over to void *. If it just makes Tony> your head hurt coping with schizophrenic dual mapping that the Tony> kernel gets with this patch, then you'll just have to take a Tony> couple of aspirin and look at the patch again in the morning Tony> :-)

It's a bit of "all of the above":

- The name isn't all that great, but since it _is_ doing something rather strange, a strange names seems quite appropriate. The patch should definitely add a brief (one-liner?) explanation of what __imva() stands for and what it does. Also, I really dislike the underscore silliness; let's just use ia64_imva() or some such, so it's obvious that it is ia64-specific (there is no namespace-pollution issue as there would be, say, in a user-level library, so there is really no reason for using an underscore prefix).

- the casting should be fixed

- instead of aspirins, it might be good to add the ASCII art you posted recently in an appropriate place (either a header-file or perhaps a Documentation/ia64 file); of course, the picture you drew included text-replication, so we may want to hold off with this until that part of the patch is in, too

	--david
#48 lore raw
In reply to David Mosberger
Quoted 12 lines

It's a bit of "all of the above":

- The name isn't all that great, but since it _is_ doing something rather strange, a strange names seems quite appropriate. The patch should definitely add a brief (one-liner?) explanation of what __imva() stands for and what it does. Also, I really dislike the underscore silliness; let's just use ia64_imva() or some such, so it's obvious that it is ia64-specific (there is no namespace-pollution issue as there would be, say, in a user-level library, so there is really no reason for using an underscore prefix).

Quoted 7 lines

- the casting should be fixed

- instead of aspirins, it might be good to add the ASCII art you posted recently in an appropriate place (either a header-file or perhaps a Documentation/ia64 file); of course, the picture you drew included text-replication, so we may want to hold off with this until that part of the patch is in, too

Ok. Here's a new patch (against a snapshot pulled from
http://lia64.bkbits.net:8080/linux-ia64-2.5 at about 9:30 this morning). Builds and boots SMP on Tiger.

The __tpa() and __imva() macros are gone (along with their accursed double underscore prefixes).

Types are cleaned up somewhat, there may be a couple of questionable casts, but this looks to be as close to clean as I can make it.

The pre-existing ia64_tpa() function takes a __u64 argument, and returns a __u64 value ... which matches nicely with all the uses in mca.c, setup.c and smpboot.c which all use and return "unsigned long" (which is close enough to __u64 that the compiler doesn't complain).

I've added a new function ia64_imva() which takes a "void *" argument and returns a "void *" ... which matches with most of the uses, there are some places that want an "unsigned long" return, so I still have some typecasts. There's a two-line comment explaining what it does.

No ascii art in this patch, it isn't quite at head-ache complexity yet. But I'll definitely put some pictures in when we get to replication patches.

-Tony

arch/ia64/kernel/efi_stub.S +2 -2
diff -ru l2569-mosberger/arch/ia64/kernel/efi_stub.S l2569-aegl/arch/ia64/kernel/efi_stub.S
@@ -62,7 +62,7 @@
 	mov b6=r2
 	;;
 	andcm r16=loc3,r16		// get psr with IT, DT, and RT bits cleared
-	br.call.sptk.many rp=ia64_switch_mode
+	br.call.sptk.many rp=ia64_switch_mode_phys
 .ret0:	mov out4=in5
 	mov out0=in1
 	mov out1=in2
@@ -73,7 +73,7 @@
 	br.call.sptk.many rp=b6		// call the EFI function
 .ret1:	mov ar.rsc=0			// put RSE in enforced lazy, LE mode
 	mov r16=loc3
-	br.call.sptk.many rp=ia64_switch_mode // return to virtual mode
+	br.call.sptk.many rp=ia64_switch_mode_virt // return to virtual mode
 .ret2:	mov ar.rsc=loc4			// restore RSE configuration
 	mov ar.pfs=loc1
 	mov rp=loc0
arch/ia64/kernel/entry.S +1 -4
diff -ru l2569-mosberger/arch/ia64/kernel/entry.S l2569-aegl/arch/ia64/kernel/entry.S
@@ -178,15 +178,12 @@
 	;;
 	st8 [r22]=sp			// save kernel stack pointer of old task
 	shr.u r26=r20,IA64_GRANULE_SHIFT
-	shr.u r17=r20,KERNEL_TR_PAGE_SHIFT
-	;;
-	cmp.ne p6,p7=KERNEL_TR_PAGE_NUM,r17
 	adds r21=IA64_TASK_THREAD_KSP_OFFSET,in0
 	;;
 	/*
 	 * If we've already mapped this task's page, we can skip doing it again.
 	 */
-(p6)	cmp.eq p7,p6=r26,r27
+	cmp.eq p7,p6=r26,r27
 (p6)	br.cond.dpnt .map
 	;;
 .done:
arch/ia64/kernel/head.S +116 -31

215 lines not on this page · raw message

arch/ia64/kernel/ia64_ksyms.c +1 -0
diff -ru l2569-mosberger/arch/ia64/kernel/ia64_ksyms.c l2569-aegl/arch/ia64/kernel/ia64_ksyms.c
@@ -159,6 +159,7 @@
 EXPORT_SYMBOL(ia64_mv);
 #endif
 EXPORT_SYMBOL(machvec_noop);
+EXPORT_SYMBOL(zero_page_memmap_ptr);
 #ifdef CONFIG_PERFMON
 #include <asm/perfmon.h>
 EXPORT_SYMBOL(pfm_install_alternate_syswide_subsystem);
arch/ia64/kernel/ivt.S +13 -3
diff -ru l2569-mosberger/arch/ia64/kernel/ivt.S l2569-aegl/arch/ia64/kernel/ivt.S
@@ -122,8 +122,13 @@
 	shr.u r18=r22,PGDIR_SHIFT		// get bits 33-63 of the faulting address
 	;;
 (p7)	dep r17=r17,r19,(PAGE_SHIFT-3),3	// put region number bits in place
+	.global ia64_ivt_patch1
+ia64_ivt_patch1:
+{	.mlx // we patch this bundle to include physical address of swapper_pg_dir
 	srlz.d					// ensure "rsm psr.dt" has taken effect
-(p6)	movl r19=__pa(swapper_pg_dir)		// region 5 is rooted at swapper_pg_dir
+(p6)	movl r19=swapper_pg_dir			// region 5 is rooted at swapper_pg_dir
+}
+	.pred.rel "mutex", p6, p7
 (p6)	shr.u r21=r21,PGDIR_SHIFT+PAGE_SHIFT
 (p7)	shr.u r21=r21,PGDIR_SHIFT+PAGE_SHIFT-3
 	;;
@@ -415,8 +420,13 @@
 	shr.u r18=r16,PGDIR_SHIFT		// get bits 33-63 of faulting address
 	;;
 (p7)	dep r17=r17,r19,(PAGE_SHIFT-3),3	// put region number bits in place
-	srlz.d
-(p6)	movl r19=__pa(swapper_pg_dir)		// region 5 is rooted at swapper_pg_dir
+	.global ia64_ivt_patch2
+ia64_ivt_patch2:
+{	.mlx // we patch this bundle to include physical address of swapper_pg_dir
+	srlz.d					// ensure "rsm psr.dt" has taken effect
+(p6)	movl r19=swapper_pg_dir			// region 5 is rooted at swapper_pg_dir
+}
+	.pred.rel "mutex", p6, p7
 (p6)	shr.u r21=r21,PGDIR_SHIFT+PAGE_SHIFT
 (p7)	shr.u r21=r21,PGDIR_SHIFT+PAGE_SHIFT-3
 	;;
arch/ia64/kernel/mca.c +8 -8
diff -ru l2569-mosberger/arch/ia64/kernel/mca.c l2569-aegl/arch/ia64/kernel/mca.c
@@ -662,17 +662,17 @@
 
 	IA64_MCA_DEBUG("ia64_mca_init: registered mca rendezvous spinloop and wakeup mech.\n");
 
-	ia64_mc_info.imi_mca_handler        = __pa(mca_hldlr_ptr->fp);
+	ia64_mc_info.imi_mca_handler        = ia64_tpa(mca_hldlr_ptr->fp);
 	/*
 	 * XXX - disable SAL checksum by setting size to 0; should be
-	 *	__pa(ia64_os_mca_dispatch_end) - __pa(ia64_os_mca_dispatch);
+	 *	ia64_tpa(ia64_os_mca_dispatch_end) - ia64_tpa(ia64_os_mca_dispatch);
 	 */
 	ia64_mc_info.imi_mca_handler_size	= 0;
 
 	/* Register the os mca handler with SAL */
 	if ((rc = ia64_sal_set_vectors(SAL_VECTOR_OS_MCA,
 				       ia64_mc_info.imi_mca_handler,
-				       mca_hldlr_ptr->gp,
+				       ia64_tpa(mca_hldlr_ptr->gp),
 				       ia64_mc_info.imi_mca_handler_size,
 				       0, 0, 0)))
 	{
@@ -682,15 +682,15 @@
 	}
 
 	IA64_MCA_DEBUG("ia64_mca_init: registered os mca handler with SAL at 0x%lx, gp = 0x%lx\n",
-		       ia64_mc_info.imi_mca_handler, mca_hldlr_ptr->gp);
+		       ia64_mc_info.imi_mca_handler, ia64_tpa(mca_hldlr_ptr->gp));
 
 	/*
 	 * XXX - disable SAL checksum by setting size to 0, should be
 	 * IA64_INIT_HANDLER_SIZE
 	 */
-	ia64_mc_info.imi_monarch_init_handler		= __pa(mon_init_ptr->fp);
+	ia64_mc_info.imi_monarch_init_handler		= ia64_tpa(mon_init_ptr->fp);
 	ia64_mc_info.imi_monarch_init_handler_size	= 0;
-	ia64_mc_info.imi_slave_init_handler		= __pa(slave_init_ptr->fp);
+	ia64_mc_info.imi_slave_init_handler		= ia64_tpa(slave_init_ptr->fp);
 	ia64_mc_info.imi_slave_init_handler_size	= 0;
 
 	IA64_MCA_DEBUG("ia64_mca_init: os init handler at %lx\n",
@@ -699,10 +699,10 @@
 	/* Register the os init handler with SAL */
 	if ((rc = ia64_sal_set_vectors(SAL_VECTOR_OS_INIT,
 				       ia64_mc_info.imi_monarch_init_handler,
-				       __pa(ia64_get_gp()),
+				       ia64_tpa(ia64_get_gp()),
 				       ia64_mc_info.imi_monarch_init_handler_size,
 				       ia64_mc_info.imi_slave_init_handler,
-				       __pa(ia64_get_gp()),
+				       ia64_tpa(ia64_get_gp()),
 				       ia64_mc_info.imi_slave_init_handler_size)))
 	{
 		printk(KERN_ERR "ia64_mca_init: Failed to register m/s init handlers with SAL. "
arch/ia64/kernel/pal.S +5 -5
diff -ru l2569-mosberger/arch/ia64/kernel/pal.S l2569-aegl/arch/ia64/kernel/pal.S
@@ -164,7 +164,7 @@
 	;;
 	mov loc4=ar.rsc			// save RSE configuration
 	dep.z loc2=loc2,0,61		// convert pal entry point to physical
-	dep.z r8=r8,0,61		// convert rp to physical
+	tpa r8=r8			// convert rp to physical
 	;;
 	mov b7 = loc2			// install target to branch reg
 	mov ar.rsc=0			// put RSE in enforced lazy, LE mode
@@ -174,13 +174,13 @@
 	or loc3=loc3,r17		// add in psr the bits to set
 	;;
 	andcm r16=loc3,r16		// removes bits to clear from psr
-	br.call.sptk.many rp=ia64_switch_mode
+	br.call.sptk.many rp=ia64_switch_mode_phys
 .ret1:	mov rp = r8			// install return address (physical)
 	br.cond.sptk.many b7
 1:
 	mov ar.rsc=0			// put RSE in enforced lazy, LE mode
 	mov r16=loc3			// r16= original psr
-	br.call.sptk.many rp=ia64_switch_mode // return to virtual mode
+	br.call.sptk.many rp=ia64_switch_mode_virt // return to virtual mode
 .ret2:
 	mov psr.l = loc3		// restore init PSR
 
@@ -228,13 +228,13 @@
 	mov b7 = loc2			// install target to branch reg
 	;;
 	andcm r16=loc3,r16		// removes bits to clear from psr
-	br.call.sptk.many rp=ia64_switch_mode
+	br.call.sptk.many rp=ia64_switch_mode_phys
 .ret6:
 	br.call.sptk.many rp=b7		// now make the call
 .ret7:
 	mov ar.rsc=0			// put RSE in enforced lazy, LE mode
 	mov r16=loc3			// r16= original psr
-	br.call.sptk.many rp=ia64_switch_mode	// return to virtual mode
+	br.call.sptk.many rp=ia64_switch_mode_virt	// return to virtual mode
 
 .ret8:	mov psr.l  = loc3		// restore init PSR
 	mov ar.pfs = loc1
arch/ia64/kernel/setup.c +47 -4

81 lines not on this page · raw message

arch/ia64/kernel/smpboot.c +1 -1
diff -ru l2569-mosberger/arch/ia64/kernel/smpboot.c l2569-aegl/arch/ia64/kernel/smpboot.c
@@ -598,7 +598,7 @@
 	/* Tell SAL where to drop the AP's.  */
 	ap_startup = (struct fptr *) start_ap;
 	sal_ret = ia64_sal_set_vectors(SAL_VECTOR_OS_BOOT_RENDEZ,
-				       __pa(ap_startup->fp), __pa(ap_startup->gp), 0, 0, 0, 0);
+				       ia64_tpa(ap_startup->fp), ia64_tpa(ap_startup->gp), 0, 0, 0, 0);
 	if (sal_ret < 0)
 		printk(KERN_ERR "SMP: Can't set SAL AP Boot Rendezvous: %s\n",
 		       ia64_sal_strerror(sal_ret));
arch/ia64/mm/init.c +12 -19
diff -ru l2569-mosberger/arch/ia64/mm/init.c l2569-aegl/arch/ia64/mm/init.c
@@ -47,6 +47,8 @@
 
 static int pgt_cache_water[2] = { 25, 50 };
 
+struct page *zero_page_memmap_ptr;		/* map entry for zero page */
+
 void
 check_pgt_cache (void)
 {
@@ -112,14 +114,16 @@
 void
 free_initmem (void)
 {
-	unsigned long addr;
+	unsigned long addr, eaddr;
 
-	addr = (unsigned long) &__init_begin;
-	for (; addr < (unsigned long) &__init_end; addr += PAGE_SIZE) {
+	addr = (unsigned long) ia64_imva(&__init_begin);
+	eaddr = (unsigned long) ia64_imva(&__init_end);
+	while (addr < eaddr) {
 		ClearPageReserved(virt_to_page(addr));
 		set_page_count(virt_to_page(addr), 1);
 		free_page(addr);
 		++totalram_pages;
+		addr += PAGE_SIZE;
 	}
 	printk(KERN_INFO "Freeing unused kernel memory: %ldkB freed\n",
 	       (&__init_end - &__init_begin) >> 10);
@@ -269,7 +273,7 @@
 void __init
 ia64_mmu_init (void *my_cpu_data)
 {
-	unsigned long psr, rid, pta, impl_va_bits;
+	unsigned long psr, pta, impl_va_bits;
 	extern void __init tlb_init (void);
 #ifdef CONFIG_DISABLE_VHPT
 #	define VHPT_ENABLE_BIT	0
@@ -277,21 +281,8 @@
 #	define VHPT_ENABLE_BIT	1
 #endif
 
-	/*
-	 * Set up the kernel identity mapping for regions 6 and 5.  The mapping for region
-	 * 7 is setup up in _start().
-	 */
+	/* Pin mapping for percpu area into TLB */
 	psr = ia64_clear_ic();
-
-	rid = ia64_rid(IA64_REGION_ID_KERNEL, __IA64_UNCACHED_OFFSET);
-	ia64_set_rr(__IA64_UNCACHED_OFFSET, (rid << 8) | (IA64_GRANULE_SHIFT << 2));
-
-	rid = ia64_rid(IA64_REGION_ID_KERNEL, VMALLOC_START);
-	ia64_set_rr(VMALLOC_START, (rid << 8) | (PAGE_SHIFT << 2) | 1);
-
-	/* ensure rr6 is up-to-date before inserting the PERCPU_ADDR translation: */
-	ia64_srlz_d();
-
 	ia64_itr(0x2, IA64_TR_PERCPU_DATA, PERCPU_ADDR,
 		 pte_val(pfn_pte(__pa(my_cpu_data) >> PAGE_SHIFT, PAGE_KERNEL)),
 		 PERCPU_PAGE_SHIFT);
@@ -489,6 +480,7 @@
 
 	discontig_paging_init();
 	efi_memmap_walk(count_pages, &num_physpages);
+	zero_page_memmap_ptr = virt_to_page(ia64_imva(empty_zero_page));
 }
 #else /* !CONFIG_DISCONTIGMEM */
 void
@@ -560,6 +552,7 @@
 	}
 	free_area_init(zones_size);
 #  endif /* !CONFIG_VIRTUAL_MEM_MAP */
+	zero_page_memmap_ptr = virt_to_page(ia64_imva(empty_zero_page));
 }
 #endif /* !CONFIG_DISCONTIGMEM */
 
@@ -630,7 +623,7 @@
 		pgt_cache_water[1] = num_pgt_pages;
 
 	/* install the gate page in the global page table: */
-	put_gate_page(virt_to_page(__start_gate_section), GATE_ADDR);
+	put_gate_page(virt_to_page(ia64_imva(__start_gate_section)), GATE_ADDR);
 
 #ifdef CONFIG_IA32_SUPPORT
 	ia32_gdt_init();
arch/ia64/vmlinux.lds.S +28 -27

185 lines not on this page · raw message

include/asm-ia64/pgtable.h +3 -3
diff -ru l2569-mosberger/include/asm-ia64/pgtable.h l2569-aegl/include/asm-ia64/pgtable.h
@@ -207,7 +207,7 @@
 #define RGN_MAP_LIMIT	((1UL << (4*PAGE_SHIFT - 12)) - PAGE_SIZE)	/* per region addr limit */
 #define RGN_KERNEL	7
 
-#define VMALLOC_START		(0xa000000000000000 + 3*PERCPU_PAGE_SIZE)
+#define VMALLOC_START		0xa000000200000000
 #define VMALLOC_VMADDR(x)	((unsigned long)(x))
 #ifdef CONFIG_VIRTUAL_MEM_MAP
 # define VMALLOC_END_INIT	(0xa000000000000000 + (1UL << (4*PAGE_SHIFT - 9)))
@@ -450,7 +450,8 @@
  * for zero-mapped memory areas etc..
  */
 extern unsigned long empty_zero_page[PAGE_SIZE/sizeof(unsigned long)];
-#define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page))
+extern struct page *zero_page_memmap_ptr;
+#define ZERO_PAGE(vaddr) (zero_page_memmap_ptr)
 
 /* We provide our own get_unmapped_area to cope with VA holes for userland */
 #define HAVE_ARCH_UNMAPPED_AREA
@@ -481,7 +482,6 @@
  */
 #define KERNEL_TR_PAGE_SHIFT	_PAGE_SIZE_64M
 #define KERNEL_TR_PAGE_SIZE	(1 << KERNEL_TR_PAGE_SHIFT)
-#define KERNEL_TR_PAGE_NUM	((KERNEL_START - PAGE_OFFSET) / KERNEL_TR_PAGE_SIZE)
 
 /*
  * No page table caches to initialise
include/asm-ia64/processor.h +12 -0
diff -ru l2569-mosberger/include/asm-ia64/processor.h l2569-aegl/include/asm-ia64/processor.h
@@ -929,6 +929,18 @@
 	return result;
 }
 
+/*
+ * Take a mapped kernel address and return the equivalent address
+ * in the region 7 identity mapped virtual area.
+ */
+static inline void *
+ia64_imva (void *addr)
+{
+	void *result;
+	asm ("tpa %0=%1" : "=r"(result) : "r"(addr));
+	return __va(result);
+}
+
 #define ARCH_HAS_PREFETCH
 #define ARCH_HAS_PREFETCHW
 #define ARCH_HAS_SPINLOCK_PREFETCH
include/asm-ia64/system.h +1 -1
diff -ru l2569-mosberger/include/asm-ia64/system.h l2569-aegl/include/asm-ia64/system.h
@@ -19,7 +19,7 @@
 #include <asm/pal.h>
 #include <asm/percpu.h>
 
-#define KERNEL_START		(PAGE_OFFSET + 68*1024*1024)
+#define KERNEL_START		(0xA000000100000000)
 
 /* 0xa000000000000000 - 0xa000000000000000+PERCPU_MAX_SIZE remain unmapped */
 #define PERCPU_ADDR		(0xa000000000000000 + PERCPU_PAGE_SIZE)
#49 lore raw
In reply to David Mosberger

Here's a first crack at the missing fs/proc/kcore.c part of relocating the kernel.

Not as pretty as I'd hoped ... just having your kernel at a lower address than your modules isn't sufficient to fit with what the code currently does (which is to assume that your kernel is in the 1-1 area above PAGE_OFFSET).

Perhaps it might be cleaner to add the kernel to the vmlist (as somebody suggested before)? That would get rid of almost all the changes except one ... we'd still need to set KCORE_BASE to the start address of region 5, so any suggestions on how to do that in a cleaner way than #ifdef CONFIG_IA64 gratefully accepted.

-Tony

#50 lore raw
In reply to David Mosberger
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · Tony

Tony> Here's a first crack at the missing fs/proc/kcore.c part of Tony> relocating the kernel.

Tony> Not as pretty as I'd hoped ... just having your kernel at a Tony> lower address than your modules isn't sufficient to fit with Tony> what the code currently does (which is to assume that your Tony> kernel is in the 1-1 area above PAGE_OFFSET).

Tony> Perhaps it might be cleaner to add the kernel to the vmlist Tony> (as somebody suggested before)? That would get rid of almost Tony> all the changes except one ... we'd still need to set Tony> KCORE_BASE to the start address of region 5, so any Tony> suggestions on how to do that in a cleaner way than #ifdef Tony> CONFIG_IA64 gratefully accepted.

Well, the patch looks fine to me, so I'm probably the wrong person to ask. Might be good to bring this up on linux-kernel.

Was there a particular reason to send the full file instead of just a diff? Also, your file seems to revert the ANSI 99 initializer changes for no good reason.

	--david
#51 lore raw
In reply to David Mosberger
Quoted 6 lines

Well, the patch looks fine to me, so I'm probably the wrong person to ask. Might be good to bring this up on linux-kernel.

Was there a particular reason to send the full file instead of just a diff? Also, your file seems to revert the ANSI 99 initializer changes for no good reason.

It's the wrong file ... that's from last November ... it just happened to be in the folder on my PC where I dump things to attach to e-mail. I meant to pick up the kcore.diff (now attached).

-Tony

fs/proc/kcore.c +38 -2
diff -ru l2569-mosberger/fs/proc/kcore.c l2569-aegl/fs/proc/kcore.c
@@ -99,7 +99,13 @@
 }
 #else /* CONFIG_KCORE_AOUT */
 
+#ifdef	CONFIG_IA64
+#define	KCORE_BASE	0xA000000000000000UL
+#else
 #define	KCORE_BASE	PAGE_OFFSET
+#endif
+
+extern char _stext[], _end[];
 
 #define roundup(x, y)  ((((x)+((y)-1))/(y))*(y))
 
@@ -133,7 +139,7 @@
 		*num_vma = *num_vma + 1;
 	}
 	*elf_buflen =	sizeof(struct elfhdr) + 
-			(*num_vma + 2)*sizeof(struct elf_phdr) + 
+			(*num_vma + 3)*sizeof(struct elf_phdr) + 
 			3 * sizeof(struct memelfnote);
 	*elf_buflen = PAGE_ALIGN(*elf_buflen);
 	return size + *elf_buflen;
@@ -214,7 +220,7 @@
 	elf->e_flags	= 0;
 	elf->e_ehsize	= sizeof(struct elfhdr);
 	elf->e_phentsize= sizeof(struct elf_phdr);
-	elf->e_phnum	= 2 + num_vma;
+	elf->e_phnum	= 3 + num_vma;
 	elf->e_shentsize= 0;
 	elf->e_shnum	= 0;
 	elf->e_shstrndx	= 0;
@@ -245,6 +251,27 @@
 	phdr->p_filesz	= phdr->p_memsz = ((unsigned long)high_memory - PAGE_OFFSET);
 	phdr->p_align	= PAGE_SIZE;
 
+	phdr = (struct elf_phdr *) bufp;
+	bufp += sizeof(struct elf_phdr);
+	offset += sizeof(struct elf_phdr);
+	if ((unsigned long)_end < PAGE_OFFSET) {
+		phdr->p_type	= PT_LOAD;
+		phdr->p_flags	= PF_R|PF_W|PF_X;
+		phdr->p_offset	= (unsigned long)_stext - KCORE_BASE + dataoff;
+		phdr->p_vaddr	= (unsigned long)_stext;
+		phdr->p_paddr	= ia64_tpa((unsigned long)_stext);
+		phdr->p_filesz	= phdr->p_memsz = _end - _stext;
+		phdr->p_align	= PAGE_SIZE;
+	} else {
+		phdr->p_type	= PT_NULL;
+		phdr->p_flags	= 0;
+		phdr->p_offset	= 0;
+		phdr->p_vaddr	= 0;
+		phdr->p_paddr	= 0;
+		phdr->p_filesz	= 0;
+		phdr->p_align	= 0;
+	}
+
 	/* setup ELF PT_LOAD program header for every vmalloc'd area */
 	for (m=vmlist; m; m=m->next) {
 		if (m->flags & VM_IOREMAP) /* don't dump ioremap'd stuff! (TA) */
@@ -444,6 +471,15 @@
 			if (kern_addr_valid(start)) {
 				if (copy_to_user(buffer, (char *)start, tsz))
 					return -EFAULT;
+			} else {
+				if (clear_user(buffer, tsz))
+					return -EFAULT;
+			}
+		} else if ((start > (unsigned long)_stext) && (start <
+						(unsigned long)_end)) {
+			if (kern_addr_valid(start)) {
+				if (copy_to_user(buffer, (char *)start, tsz))
+					return -EFAULT;
 			} else {
 				if (clear_user(buffer, tsz))
 					return -EFAULT;
#52 lore raw
In reply to David Mosberger
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · Tony

Tony> It's the wrong file ... that's from last November ... it just Tony> happened to be in the folder on my PC where I dump things to Tony> attach to e-mail. I meant to pick up the kcore.diff (now Tony> attached).

Ah, I see.

Definitely something to be discussed on the lkml. I suspect it would be better to avoid creating the PT_NULL header when it's not needed.

	--david
#53 lore raw
In reply to David Mosberger

Here's what the kcore change looks like if I take the suggestion that Andi Kleen made on LKML
http://marc.theaimsgroup.com/?l=linux-kernel&m=103556903730989&w=2
to add the kernel to the vmlist. Combined with the KCORE_BASE change (which is 98% included) we avoid the negative addresses that required a bunch more changes in Andi's patch.

I've juggled the addresses around again, moving the kernel up to 0xA000004000000000 and VMALLOC_START back down to 0xA000000000030000 so that the entry for the kernel goes on the *end* of the vmlist, so we don't have to uselessly step over it on every call to vmalloc().

I picked that kernel start address as it is half-way between VMALLOC_START and VMALLOC_END for a PAGE_SIZE=4k kernel. There are many alternatives ... choose a different one (between VMALLOC_START and VMALLOC_END) if you come up with a good reason for a different address.

This builds and boots on Tiger, and now I can run:

	# gdb vmlinux /proc/kcore
	(gdb) x/s log_buf

and see the contents of kernel memory.

-Tony

arch/ia64/kernel/setup.c +14 -1
diff -ru l2569-mosberger/arch/ia64/kernel/setup.c l2569-aegl/arch/ia64/kernel/setup.c
@@ -32,6 +32,7 @@
 #include <linux/tty.h>
 #include <linux/efi.h>
 #include <linux/initrd.h>
+#include <linux/vmalloc.h>
 
 #include <asm/ia32.h>
 #include <asm/page.h>
@@ -47,7 +48,7 @@
 # error "struct cpuinfo_ia64 too big!"
 #endif
 
-extern char _end;
+extern char _stext, _end;
 
 #ifdef CONFIG_SMP
 unsigned long __per_cpu_offset[NR_CPUS];
@@ -393,6 +394,18 @@
 {
 	extern unsigned long ia64_iobase;
 	unsigned long phys_iobase;
+	static struct vm_struct kern;
+	unsigned long s, e;
+
+	/* Add entry to vmlist for the kernel (round out to how much is mapped) */
+	s = (unsigned long)&_stext;
+	s &= ~(KERNEL_TR_PAGE_SIZE-1);
+	e = (unsigned long)&_end;
+	e = (e + KERNEL_TR_PAGE_SIZE-1) & ~(KERNEL_TR_PAGE_SIZE-1);
+	kern.addr = (void *)s;
+	kern.size = e - s;
+	kern.next = vmlist;
+	vmlist = &kern;
 
 	unw_init();
 
fs/proc/kcore.c +2 -0
diff -ru l2569-mosberger/fs/proc/kcore.c l2569-aegl/fs/proc/kcore.c
@@ -99,7 +99,9 @@
 }
 #else /* CONFIG_KCORE_AOUT */
 
+#ifndef KCORE_BASE
 #define	KCORE_BASE	PAGE_OFFSET
+#endif
 
 #define roundup(x, y)  ((((x)+((y)-1))/(y))*(y))
 
include/asm-ia64/pgtable.h +2 -1
diff -ru l2569-mosberger/include/asm-ia64/pgtable.h l2569-aegl/include/asm-ia64/pgtable.h
@@ -207,7 +207,8 @@
 #define RGN_MAP_LIMIT	((1UL << (4*PAGE_SHIFT - 12)) - PAGE_SIZE)	/* per region addr limit */
 #define RGN_KERNEL	7
 
-#define VMALLOC_START		0xa000000200000000
+#define	KCORE_BASE		0xa000000000000000
+#define VMALLOC_START		(0xa000000000000000 + 3*PERCPU_PAGE_SIZE)
 #define VMALLOC_VMADDR(x)	((unsigned long)(x))
 #ifdef CONFIG_VIRTUAL_MEM_MAP
 # define VMALLOC_END_INIT	(0xa000000000000000 + (1UL << (4*PAGE_SHIFT - 9)))
include/asm-ia64/system.h +1 -1
diff -ru l2569-mosberger/include/asm-ia64/system.h l2569-aegl/include/asm-ia64/system.h
@@ -19,7 +19,7 @@
 #include <asm/pal.h>
 #include <asm/percpu.h>
 
-#define KERNEL_START		(0xa000000100000000)
+#define KERNEL_START		(0xa000004000000000)
 
 /* 0xa000000000000000 - 0xa000000000000000+PERCPU_MAX_SIZE remain unmapped */
 #define PERCPU_ADDR		(0xa000000000000000 + PERCPU_PAGE_SIZE)
#54 lore raw
In reply to David Mosberger

Btw, last Friday I tested David's bk tree (plus one additional console driver patch) on an sn2, and it booted to the point where we got lots of printks, so your head.S stuff seems fine for us so far. I'll let you know if I run into anything more, but I won't be able to test the kcore stuff until I have it booting and mounting root.

Thanks,
Jesse

Quoted 26 lines · Tony

Here's what the kcore change looks like if I take the suggestion that Andi Kleen made on LKML
http://marc.theaimsgroup.com/?l=linux-kernel&m3556903730989&w=2
to add the kernel to the vmlist. Combined with the KCORE_BASE change (which is 98% included) we avoid the negative addresses that required a bunch more changes in Andi's patch.

I've juggled the addresses around again, moving the kernel up to 0xA000004000000000 and VMALLOC_START back down to 0xA000000000030000 so that the entry for the kernel goes on the *end* of the vmlist, so we don't have to uselessly step over it on every call to vmalloc().

I picked that kernel start address as it is half-way between VMALLOC_START and VMALLOC_END for a PAGE_SIZE=4k kernel. There are many alternatives ... choose a different one (between VMALLOC_START and VMALLOC_END) if you come up with a good reason for a different address.

This builds and boots on Tiger, and now I can run:

	# gdb vmlinux /proc/kcore
	(gdb) x/s log_buf

and see the contents of kernel memory.

-Tony

#55 lore raw
In reply to David Mosberger
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · Tony

Tony> I've juggled the addresses around again, moving the kernel up to Tony> 0xA000004000000000 and VMALLOC_START back down to 0xA000000000030000 Tony> so that the entry for the kernel goes on the *end* of the vmlist, Tony> so we don't have to uselessly step over it on every call to vmalloc().

I don't want the kernel layout to be constrained by something as esoteric as kcore. Let's fix kcore for good.

	--david
#56 lore raw
In reply to David Mosberger
Quoted 2 lines

I don't want the kernel layout to be constrained by something as esoteric as kcore. Let's fix kcore for good.

I like the vmlist solution because it is extensible (e.g. when I add another address range to the kernel map to split text and data so that I can replicate the text across nodes, I'll just add a new entry to vmlist, and the kcore.c code won't be changed at all). But as you point out, this also puts some limits on kernel layout as objects on the vmlist have to be bounded by VMALLOC_START and VMALLOC_END.

To remove this constraint, we either:
1) need a parallel list to keep tabs on interesting objects that are not in vmlist.

2) need to remove the restriction that objects on vmlist are in the [VMALLOC_START, VMALLOC_END) address range.

Answer #1 seems like overkill since we only have one object for the list now, with a tentative plan for a second when kernel text replication gets implemented. It also ends up duplicating all the code in kcore.c that walks vmlist.

Answer #2 would end up with more extensive changes to fs/proc/kcore.c and also changes to another generic file (mm.vmalloc.c) to make sure that the out-of-range items on vmlist didn't confuse vmalloc().

I think that #2 looks less messy ... unless someone comes up with answer #3

-Tony

#57 lore raw
In reply to David Mosberger

This patch provides a more general mechanism for replacing a virtual address with physical in a

movl reg=object

instruction. The two existing instances in ivt.S where the address of swapper_pg_dir are converted to use the new mechanism.

More instances are going to be needed in the MCA code, where it may not be safe to use "tpa" instruction.

-Tony

arch/ia64/kernel/ivt.S +6 -12
diff -ru l2569-mosberger/arch/ia64/kernel/ivt.S l2569-reloc/arch/ia64/kernel/ivt.S
@@ -122,12 +122,9 @@
 	shr.u r18=r22,PGDIR_SHIFT		// get bits 33-63 of the faulting address
 	;;
 (p7)	dep r17=r17,r19,(PAGE_SHIFT-3),3	// put region number bits in place
-	.global ia64_ivt_patch1
-ia64_ivt_patch1:
-{	.mlx // we patch this bundle to include physical address of swapper_pg_dir
-	srlz.d					// ensure "rsm psr.dt" has taken effect
-(p6)	movl r19=swapper_pg_dir			// region 5 is rooted at swapper_pg_dir
-}
+
+	LOAD_PHYSICAL(srlz.d, p6, r19, swapper_pg_dir)	// region 5 is rooted at swapper_pg_dir
+
 	.pred.rel "mutex", p6, p7
 (p6)	shr.u r21=r21,PGDIR_SHIFT+PAGE_SHIFT
 (p7)	shr.u r21=r21,PGDIR_SHIFT+PAGE_SHIFT-3
@@ -420,12 +417,9 @@
 	shr.u r18=r16,PGDIR_SHIFT		// get bits 33-63 of faulting address
 	;;
 (p7)	dep r17=r17,r19,(PAGE_SHIFT-3),3	// put region number bits in place
-	.global ia64_ivt_patch2
-ia64_ivt_patch2:
-{	.mlx // we patch this bundle to include physical address of swapper_pg_dir
-	srlz.d					// ensure "rsm psr.dt" has taken effect
-(p6)	movl r19=swapper_pg_dir			// region 5 is rooted at swapper_pg_dir
-}
+
+	LOAD_PHYSICAL(srlz.d, p6, r19, swapper_pg_dir)	// region 5 is rooted at swapper_pg_dir
+
 	.pred.rel "mutex", p6, p7
 (p6)	shr.u r21=r21,PGDIR_SHIFT+PAGE_SHIFT
 (p7)	shr.u r21=r21,PGDIR_SHIFT+PAGE_SHIFT-3
arch/ia64/kernel/setup.c +29 -31

73 lines not on this page · raw message

arch/ia64/vmlinux.lds.S +7 -0
diff -ru l2569-mosberger/arch/ia64/vmlinux.lds.S l2569-reloc/arch/ia64/vmlinux.lds.S
@@ -55,6 +55,13 @@
 	  __stop___ex_table = .;
 	}
 
+  __vtop_patchlist : AT(ADDR(__vtop_patchlist) - LOAD_OFFSET)
+	{
+	  __start___vtop_patchlist = .;
+	  *(__vtop_patchlist)
+	  __end____vtop_patchlist = .;
+	}
+
   __mckinley_e9_bundles : AT(ADDR(__mckinley_e9_bundles) - LOAD_OFFSET)
 	{
 	  __start___mckinley_e9_bundles = .;
include/asm-ia64/asmmacro.h +16 -0
diff -ru l2569-mosberger/include/asm-ia64/asmmacro.h l2569-reloc/include/asm-ia64/asmmacro.h
@@ -51,6 +51,22 @@
   [99:]	x
 
 /*
+ * Mark instructions that need a load of a virtual address patched to be
+ * a load of a physical address.  We use this either in critical performance
+ * path (ivt.S - TLB miss processing) or in places where it might not be
+ * safe to use a "tpa" instruction (mca_asm.S - error recovery).
+ */
+	.section "__vtop_patchlist", "a"	// declare section & section attributes
+	.previous
+
+#define	LOAD_PHYSICAL(op, preg, reg, obj)	\
+1: {	.mlx;					\
+	op;					\
+(preg)	movl reg = obj;				\
+   };						\
+	.xdata8 "__vtop_patchlist", 1b
+
+/*
  * For now, we always put in the McKinley E9 workaround.  On CPUs that don't need it,
  * we'll patch out the work-around bundles with NOPs, so their impact is minimal.
  */
#58 lore raw
In reply to David Mosberger

Patch in previous post is incomplete ... here's the full version.

-Tony

arch/ia64/kernel/ivt.S +6 -12
diff -ru l2569-mosberger/arch/ia64/kernel/ivt.S l2569-reloc/arch/ia64/kernel/ivt.S
@@ -122,12 +122,9 @@
 	shr.u r18=r22,PGDIR_SHIFT		// get bits 33-63 of the faulting address
 	;;
 (p7)	dep r17=r17,r19,(PAGE_SHIFT-3),3	// put region number bits in place
-	.global ia64_ivt_patch1
-ia64_ivt_patch1:
-{	.mlx // we patch this bundle to include physical address of swapper_pg_dir
-	srlz.d					// ensure "rsm psr.dt" has taken effect
-(p6)	movl r19=swapper_pg_dir			// region 5 is rooted at swapper_pg_dir
-}
+
+	LOAD_PHYSICAL(srlz.d, p6, r19, swapper_pg_dir)	// region 5 is rooted at swapper_pg_dir
+
 	.pred.rel "mutex", p6, p7
 (p6)	shr.u r21=r21,PGDIR_SHIFT+PAGE_SHIFT
 (p7)	shr.u r21=r21,PGDIR_SHIFT+PAGE_SHIFT-3
@@ -420,12 +417,9 @@
 	shr.u r18=r16,PGDIR_SHIFT		// get bits 33-63 of faulting address
 	;;
 (p7)	dep r17=r17,r19,(PAGE_SHIFT-3),3	// put region number bits in place
-	.global ia64_ivt_patch2
-ia64_ivt_patch2:
-{	.mlx // we patch this bundle to include physical address of swapper_pg_dir
-	srlz.d					// ensure "rsm psr.dt" has taken effect
-(p6)	movl r19=swapper_pg_dir			// region 5 is rooted at swapper_pg_dir
-}
+
+	LOAD_PHYSICAL(srlz.d, p6, r19, swapper_pg_dir)	// region 5 is rooted at swapper_pg_dir
+
 	.pred.rel "mutex", p6, p7
 (p6)	shr.u r21=r21,PGDIR_SHIFT+PAGE_SHIFT
 (p7)	shr.u r21=r21,PGDIR_SHIFT+PAGE_SHIFT-3
arch/ia64/kernel/setup.c +43 -37

101 lines not on this page · raw message

arch/ia64/vmlinux.lds.S +7 -0
diff -ru l2569-mosberger/arch/ia64/vmlinux.lds.S l2569-reloc/arch/ia64/vmlinux.lds.S
@@ -55,6 +55,13 @@
 	  __stop___ex_table = .;
 	}
 
+  __vtop_patchlist : AT(ADDR(__vtop_patchlist) - LOAD_OFFSET)
+	{
+	  __start___vtop_patchlist = .;
+	  *(__vtop_patchlist)
+	  __end____vtop_patchlist = .;
+	}
+
   __mckinley_e9_bundles : AT(ADDR(__mckinley_e9_bundles) - LOAD_OFFSET)
 	{
 	  __start___mckinley_e9_bundles = .;
include/asm-ia64/asmmacro.h +16 -0
diff -ru l2569-mosberger/include/asm-ia64/asmmacro.h l2569-reloc/include/asm-ia64/asmmacro.h
@@ -51,6 +51,22 @@
   [99:]	x
 
 /*
+ * Mark instructions that need a load of a virtual address patched to be
+ * a load of a physical address.  We use this either in critical performance
+ * path (ivt.S - TLB miss processing) or in places where it might not be
+ * safe to use a "tpa" instruction (mca_asm.S - error recovery).
+ */
+	.section "__vtop_patchlist", "a"	// declare section & section attributes
+	.previous
+
+#define	LOAD_PHYSICAL(op, preg, reg, obj)	\
+1: {	.mlx;					\
+	op;					\
+(preg)	movl reg = obj;				\
+   };						\
+	.xdata8 "__vtop_patchlist", 1b
+
+/*
  * For now, we always put in the McKinley E9 workaround.  On CPUs that don't need it,
  * we'll patch out the work-around bundles with NOPs, so their impact is minimal.
  */
#59 lore raw
In reply to David Mosberger

Aaargh! Still not right. That includes a spurious hunk that backout out part of the FP fix. Don't apply this bit!

@@ -779,8 +787,6 @@
/* Clear the stack memory reserved for pt_regs: */ memset(ia64_task_regs(current), 0, sizeof(struct pt_regs));

- ia64_set_kr(IA64_KR_FPU_OWNER, 0);
-
/*
* Initialize default control register to defer all speculative faults. The
* kernel MUST NOT depend on a particular setting of these bits (in other words,

-Tony