[PATCH] ppc64: Move systemcfg out of head.S

Benjamin Herrenschmidt benh at kernel.crashing.org
Mon Jan 31 16:41:13 EST 2005


Hi !

The "systemcfg" data structure in the ppc64 kernel is something that used to be
defined to be at a hard-coded page number in the kernel image. This is not necessary
(at least not any more) and is a possible problem with future developements. This
patch removes that constraint, which also simplifies various bits of assembly
in head.S that were dealing with it.

This is the first step of a deeper cleanup of systemcfg definition of usage (and
ultimately removal in it's current incarnation).

Signed-off-by: Benjamin Herrenschmidt <benh at kernel.crashing.org>

Index: linux-work/arch/ppc64/kernel/head.S
===================================================================
--- linux-work.orig/arch/ppc64/kernel/head.S	2005-01-31 14:18:14.000000000 +1100
+++ linux-work/arch/ppc64/kernel/head.S	2005-01-31 16:19:44.000000000 +1100
@@ -517,16 +517,7 @@
 	.globl naca
 naca:
 	.llong itVpdAreas
-#endif
-
-	. = SYSTEMCFG_PHYS_ADDR
-	.globl __start_systemcfg
-__start_systemcfg:
-	. = (SYSTEMCFG_PHYS_ADDR + PAGE_SIZE)
-	.globl __end_systemcfg
-__end_systemcfg:
 
-#ifdef CONFIG_PPC_ISERIES
 	/*
 	 * The iSeries LPAR map is at this fixed address
 	 * so that the HvReleaseData structure can address
@@ -536,6 +527,8 @@
 	 * VSID generation algorithm.  See include/asm/mmu_context.h.
 	 */
 
+	. = 0x4800
+
 	.llong	2		/* # ESIDs to be mapped by hypervisor	 */
 	.llong	1		/* # memory ranges to be mapped by hypervisor */
 	.llong	STAB0_PAGE	/* Page # of segment table within load area	*/
@@ -1264,10 +1257,6 @@
 	addi	r2,r2,0x4000
 	addi	r2,r2,0x4000
 
-	LOADADDR(r9,systemcfg)
-	SET_REG_TO_CONST(r4, SYSTEMCFG_VIRT_ADDR)
-	std	r4,0(r9)		/* set the systemcfg pointer */
-
 	bl	.iSeries_early_setup
 
 	/* relocation is on at this point */
@@ -1772,7 +1761,7 @@
 	sc				/* HvCall_setASR */
 #else
 	/* set the ASR */
-	li	r3,SYSTEMCFG_PHYS_ADDR	/* r3 = ptr to systemcfg	 */
+	ld	r3,systemcfg at got(r2)	/* r3 = ptr to systemcfg	 */
 	lwz	r3,PLATFORM(r3)		/* r3 = platform flags		 */
 	cmpldi 	r3,PLATFORM_PSERIES_LPAR
 	bne	98f
@@ -1861,12 +1850,6 @@
 	ori	r6,r6,MSR_RI
 	mtmsrd	r6			/* RI on */
 
-	/* setup the systemcfg pointer which is needed by *tab_initialize	*/
-	LOADADDR(r6,systemcfg)
-	sub	r6,r6,r26		/* addr of the variable systemcfg */
-	li	r27,SYSTEMCFG_PHYS_ADDR
-	std	r27,0(r6)	 	/* set the value of systemcfg	*/
-
 #ifdef CONFIG_HMT
 	/* Start up the second thread on cpu 0 */
 	mfspr	r3,PVR
@@ -1941,7 +1924,7 @@
 	/* set the ASR */
 	ld	r3,PACASTABREAL(r13)
 	ori	r4,r3,1			/* turn on valid bit		 */
-	li	r3,SYSTEMCFG_PHYS_ADDR	/* r3 = ptr to systemcfg */
+	ld	r3,systemcfg at got(r2)	/* r3 = ptr to systemcfg */
 	lwz	r3,PLATFORM(r3)		/* r3 = platform flags */
 	cmpldi 	r3,PLATFORM_PSERIES_LPAR
 	bne	98f
@@ -1960,7 +1943,7 @@
 	mtasr	r4			/* set the stab location	*/
 99:
 	/* Set SDR1 (hash table pointer) */
-	li	r3,SYSTEMCFG_PHYS_ADDR	/* r3 = ptr to systemcfg */
+	ld	r3,systemcfg at got(r2)	/* r3 = ptr to systemcfg */
 	lwz	r3,PLATFORM(r3)		/* r3 = platform flags */
 	/* Test if bit 0 is set (LPAR bit) */
 	andi.	r3,r3,0x1
@@ -1998,11 +1981,6 @@
 	li	r3,0
 	bl	.do_cpu_ftr_fixups
 
-	/* setup the systemcfg pointer */
-	LOADADDR(r9,systemcfg)
-	SET_REG_TO_CONST(r8, SYSTEMCFG_VIRT_ADDR)
-	std	r8,0(r9)
-
 	LOADADDR(r26, boot_cpuid)
 	lwz	r26,0(r26)
 
Index: linux-work/arch/ppc64/kernel/pacaData.c
===================================================================
--- linux-work.orig/arch/ppc64/kernel/pacaData.c	2005-01-31 14:18:14.000000000 +1100
+++ linux-work/arch/ppc64/kernel/pacaData.c	2005-01-31 15:56:55.000000000 +1100
@@ -20,9 +20,14 @@
 #include <asm/iSeries/ItLpQueue.h>
 #include <asm/paca.h>
 
-struct systemcfg *systemcfg;
+static union {
+	struct systemcfg	data;
+	u8			page[PAGE_SIZE];
+} systemcfg_store __page_aligned;
+struct systemcfg *systemcfg = &systemcfg_store.data;
 EXPORT_SYMBOL(systemcfg);
 
+
 /* This symbol is provided by the linker - let it fill in the paca
  * field correctly */
 extern unsigned long __toc_start;
Index: linux-work/arch/ppc64/kernel/proc_ppc64.c
===================================================================
--- linux-work.orig/arch/ppc64/kernel/proc_ppc64.c	2005-01-31 14:18:14.000000000 +1100
+++ linux-work/arch/ppc64/kernel/proc_ppc64.c	2005-01-31 15:56:55.000000000 +1100
@@ -89,7 +89,7 @@
 		return 1;
 	pde->nlink = 1;
 	pde->data = systemcfg;
-	pde->size = 4096;
+	pde->size = PAGE_SIZE;
 	pde->proc_fops = &page_map_fops;
 
 #ifdef CONFIG_PPC_PSERIES
Index: linux-work/include/asm-ppc64/systemcfg.h
===================================================================
--- linux-work.orig/include/asm-ppc64/systemcfg.h	2005-01-31 14:18:44.000000000 +1100
+++ linux-work/include/asm-ppc64/systemcfg.h	2005-01-31 15:56:55.000000000 +1100
@@ -47,7 +47,6 @@
 	__u32 dcache_line_size;		/* L1 d-cache line size		0x64 */
 	__u32 icache_size;		/* L1 i-cache size		0x68 */
 	__u32 icache_line_size;		/* L1 i-cache line size		0x6C */
-	__u8  reserved0[3984];		/* Reserve rest of page		0x70 */
 };
 
 #ifdef __KERNEL__
@@ -56,8 +55,4 @@
 
 #endif /* __ASSEMBLY__ */
 
-#define SYSTEMCFG_PAGE      0x5
-#define SYSTEMCFG_PHYS_ADDR (SYSTEMCFG_PAGE<<PAGE_SHIFT)
-#define SYSTEMCFG_VIRT_ADDR (KERNELBASE+SYSTEMCFG_PHYS_ADDR)
-
 #endif /* _SYSTEMCFG_H */
Index: linux-work/arch/ppc64/kernel/LparData.c
===================================================================
--- linux-work.orig/arch/ppc64/kernel/LparData.c	2005-01-31 14:18:14.000000000 +1100
+++ linux-work/arch/ppc64/kernel/LparData.c	2005-01-31 16:19:50.000000000 +1100
@@ -45,7 +45,7 @@
 	.xSize = sizeof(struct HvReleaseData),
 	.xVpdAreasPtrOffset = offsetof(struct naca_struct, xItVpdAreas),
 	.xSlicNacaAddr = &naca,		/* 64-bit Naca address */
-	.xMsNucDataOffset = 0x6000,	/* offset of LparMap within loadarea (see head.S) */
+	.xMsNucDataOffset = 0x4800,	/* offset of LparMap within loadarea (see head.S) */
 	.xTagsMode = 1,			/* tags inactive       */
 	.xAddressSize = 0,		/* 64 bit              */
 	.xNoSharedProcs = 0,		/* shared processors   */





More information about the Linuxppc64-dev mailing list