Remove another fixed address constraint
Presently the LparMap, one of the structures the kernel shares with the legacy iSeries hypervisor has a fixed offset address in head.S. This patch changes this so the LparMap is a normally initialized structure, without fixed address. This allows us to use macros to compute some of the values in the structure, which wasn't previously possible because the assembler always uses signed-% which gets the wrong answers for the computations in question.
Unfortunately, a gcc bug means that doing this requires another structure (hvReleaseData) to be initialized in asm instead of C, but on the whole the result is cleaner than before.
include/asm-ppc64/iSeries/LparMap.h +15 -8
@@ -49,19 +49,26 @@* entry to map the Esid to the Vsid. */ +#define HvEsidsToMap 2 +#define HvRangesToMap 1 +/* Hypervisor initially maps 32MB of the load area */ #define HvPagesToMap 8192struct LparMap { -u64 xNumberEsids;// Number of ESID/VSID pairs (1) -u64 xNumberRanges;// Number of VA ranges to map (1) -u64 xSegmentTableOffs;// Page number within load area of seg table (0) +u64 xNumberEsids;// Number of ESID/VSID pairs +u64 xNumberRanges;// Number of VA ranges to map +u64 xSegmentTableOffs;// Page number within load area of seg table u64 xRsvd[5 ]; -u64 xKernelEsid;// Esid used to map kernel load (0x0C00000000) -u64 xKernelVsid;// Vsid used to map kernel load (0x0C00000000) -u64 xPages;// Number of pages to be mapped (8192) -u64 xOffset;// Offset from start of load area (0) -u64 xVPN;// Virtual Page Number (0x000C000000000000) +struct { +u64 xKernelEsid;// Esid used to map kernel load +u64 xKernelVsid;// Vsid used to map kernel load + } xEsids[HvEsidsToMap]; +struct { +u64 xPages;// Number of pages to be mapped +u64 xOffset;// Offset from start of load area +u64 xVPN;// Virtual Page Number + } xRanges[HvRangesToMap]; };extern struct LparMap xLparMap;
include/asm-ppc64/iSeries/HvReleaseData.h +6 -5
@@ -39,6 +39,11 @@* know that this PLIC does not support running an OS "that old". */ +#define HVREL_TAGSINACTIVE 0x8000 +#define HVREL_32BIT 0x4000 +#define HVREL_NOSHAREDPROCS 0x2000 +#define HVREL_NOHMT 0x1000 +struct HvReleaseData {u32 xDesc;/* Descriptor "HvRD" ebcdic x00-x03 */ u16 xSize;/* Size of this control block x04-x05 */
@@ -46,11 +51,7 @@struct naca_struct *xSlicNacaAddr;/* Virt addr of SLIC NACA x08-x0F */ u32 xMsNucDataOffset;/* Offset of Linux Mapping Data x10-x13 */ u32 xRsvd1;/* Reserved x14-x17 */ - u16 xTagsMode:1; /* 0 == tags active, 1 == tags inactive */ - u16 xAddressSize:1; /* 0 == 64-bit, 1 == 32-bit */ - u16 xNoSharedProcs:1; /* 0 == shared procs, 1 == no shared */ - u16 xNoHMT:1; /* 0 == allow HMT, 1 == no HMT */ - u16 xRsvd2:12; /* Reserved x18-x19 */ +u16 xFlags;u16 xVrmIndex;/* VRM Index of OS image x1A-x1B */ u16 xMinSupportedPlicVrmIndex;/* Min PLIC level (soft) x1C-x1D */ u16 xMinCompatablePlicVrmIndex;/* Min PLIC levelP (hard) x1E-x1F */
arch/ppc64/kernel/LparData.c +82 -6
105 lines not on this page · raw message
include/asm-ppc64/mmu.h +3 -0
@@ -338,6 +338,9 @@ | (ea >> SID_SHIFT)); } +#define VSID_SCRAMBLE (pvsid) (((pvsid) * VSID_MULTIPLIER) % VSID_MODULUS) +#define KERNEL_VSID (ea) VSID_SCRAMBLE(GET_ESID(ea)) +#endif /* __ASSEMBLY */ #endif /* _PPC64_MMU_H_ */
arch/ppc64/kernel/head.S +3 -30
@@ -522,36 +522,9 @@ #ifdef CONFIG_PPC_ISERIES .globl naca naca: - .llong itVpdAreas - - /* - * The iSeries LPAR map is at this fixed address - * so that the HvReleaseData structure can address - * it with a 32-bit offset. - * - * The VSID values below are dependent on the - * 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 */ - .llong 0 /* Reserved */ - .llong 0 /* Reserved */ - .llong 0 /* Reserved */ - .llong 0 /* Reserved */ - .llong 0 /* Reserved */ - .llong (KERNELBASE>>SID_SHIFT) - .llong 0x408f92c94 /* KERNELBASE VSID */ - /* We have to list the bolted VMALLOC segment here, too, so that it - * will be restored on shared processor switch */ - .llong (VMALLOCBASE>>SID_SHIFT) - .llong 0xf09b89af5 /* VMALLOCBASE VSID */ - .llong 8192 /* # pages to map (32 MB) */ - .llong 0 /* Offset from start of loadarea to start of map */ - .llong 0x408f92c940000 /* VPN of first page to map */ + .llong itVpdAreas + .llong 0 /* xRamDisk */ + .llong 0 /* xRamDiskSize */ . = 0x6100
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/people/dgibson
Quoted 11 lines · David Gibson
Presently the LparMap, one of the structures the kernel shares with the legacy iSeries hypervisor has a fixed offset address in
head.S. This patch changes this so the LparMap is a normally initialized structure, without fixed address. This allows us to use macros to compute some of the values in the structure, which wasn't previously possible because the assembler always uses signed-% which gets the wrong answers for the computations in question.Unfortunately, a gcc bug means that doing this requires another structure (hvReleaseData) to be initialized in asm instead of C, but on the whole the result is cleaner than before.
I think this change caused this compile error in rc4:
{standard input}: Assembler messages:
{standard input}:254: Error: value of 4000000000002080 too large for field of 4 bytes at 0000000000002108 make[1]: *** [arch/ppc64/kernel/LparData.o] Error 1
binutils-2.16.91.0.2
gcc-4.0.2_20050727
Quoted 14 lines · Olaf Hering
Quoted 11 lines · David Gibson
Presently the LparMap, one of the structures the kernel shares with the legacy iSeries hypervisor has a fixed offset address in
head.S. This patch changes this so the LparMap is a normally initialized structure, without fixed address. This allows us to use macros to compute some of the values in the structure, which wasn't previously possible because the assembler always uses signed-% which gets the wrong answers for the computations in question.Unfortunately, a gcc bug means that doing this requires another structure (hvReleaseData) to be initialized in asm instead of C, but on the whole the result is cleaner than before.
Quoted 8 lines
I think this change caused this compile error in rc4:
{standard input}: Assembler messages:
{standard input}:254: Error: value of 4000000000002080 too large for field of 4 bytes at 0000000000002108 make[1]: *** [arch/ppc64/kernel/LparData.o] Error 1binutils-2.16.91.0.2
gcc-4.0.2_20050727
Hrm.. definitely works here. Is this with any other patches? Can you send the .s file? That might help be debug it.
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/people/dgibson
Quoted 2 lines · David Gibson
Hrm.. definitely works here. Is this with any other patches? Can you send the .s file? That might help be debug it.
It works with SLES9 gcc3, only gcc4 (or recent binutils) do not like it.
Quoted 7 lines · Olaf Hering
Quoted 2 lines · David Gibson
Hrm.. definitely works here. Is this with any other patches? Can you send the .s file? That might help be debug it.
It works with SLES9 gcc3, only gcc4 (or recent binutils) do not like it.
gcc4 can't be the problem; that's an assembler error. I am using:
sneetch:~/kernel$ powerpc64-linux-as --version GNU assembler 2.15.94 20041116 Copyright 2002 Free Software Foundation, Inc. This program is free software; you may redistribute it under the terms of the GNU General Public License. This program has absolutely no warranty. This assembler was configured for a target of `powerpc-linux'.
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/people/dgibson