* [RFC] Relocatable kernel for ppc44x @ 2011-06-16 14:14 Michal Simek 2011-06-16 14:14 ` [RFC PATCH 1/7] powerpc: ppc440 remove zero physical memory base assumption Michal Simek 0 siblings, 1 reply; 9+ messages in thread From: Michal Simek @ 2011-06-16 14:14 UTC (permalink / raw) To: linuxppc-dev; +Cc: arnd, tmarri, suzuki, john.williams Hi, John mentioned in his email that we have some patches. I am also sending them [patch 1/7-6/7]. It is support for non zero boot address for ppc44x. Patch 7/7 is relocatable support for ppc44x. All patches are against 2.6.31.13 but it shouldn't be big problem to port them to the latest and greatest. We are using 256MB alignment which is fine for our purposes. But I think it could be simple to change it to any different style. I have tested it on QEMU system emulator with u-boot. I have used its with vmlinux.bin.gz and DTB. Not sure about your configuration but the best is not to relocate DTB. Address of DTB should be in 256MB boundary to be able to access it in the first pinned 256MB tlb. I haven't tested any other configuration but I have tried not to break anyone. Not sure if I can use r25, r26 and r21 (I need two regs for storing temp values). I look forward on your recommendation. The idea of this patch is to find out where the kernel runs. Pinned 256MB in asm - setup memstart_addr and kernstart_addr in ASM and not to break generic PPC code. And also setup TLB for larger memories in mmu_mapin_ram. Have tested system till 768MB. Thanks for your comments, Michal P.S.: Sorry for faults in PPC asm - I am not PPC expert. ^ permalink raw reply [flat|nested] 9+ messages in thread
* [RFC PATCH 1/7] powerpc: ppc440 remove zero physical memory base assumption 2011-06-16 14:14 [RFC] Relocatable kernel for ppc44x Michal Simek @ 2011-06-16 14:14 ` Michal Simek 2011-06-16 14:14 ` [RFC PATCH 2/7] powerpc: Permit non-zero physical start address for PPC44x Michal Simek 0 siblings, 1 reply; 9+ messages in thread From: Michal Simek @ 2011-06-16 14:14 UTC (permalink / raw) To: linuxppc-dev; +Cc: arnd, tmarri, suzuki, john.williams From: John Williams <john.williams@petalogix.com> The macro PHYSICAL_START is available in this context, currently always with the value zero. However, that will change in a future patchset. For now, just remove the zero physical address start assumption in head_44x.S where we setup the initial TLB, and in the later MMU setup where we map in the remainder of low mem if required. Signed-off-by: John Williams <john.williams@petalogix.com> --- arch/powerpc/kernel/head_44x.S | 5 +++-- arch/powerpc/mm/44x_mmu.c | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/kernel/head_44x.S b/arch/powerpc/kernel/head_44x.S index 18d8a16..d80ce05 100644 --- a/arch/powerpc/kernel/head_44x.S +++ b/arch/powerpc/kernel/head_44x.S @@ -135,8 +135,9 @@ skpinv: addi r4,r4,1 /* Increment */ lis r3,PAGE_OFFSET@h ori r3,r3,PAGE_OFFSET@l - /* Kernel is at the base of RAM */ - li r4, 0 /* Load the kernel physical address */ + /* Kernel is at PHYSICAL_START */ + lis r4,PHYSICAL_START@h + ori r4,r4,PHYSICAL_START@l /* Load the kernel PID = 0 */ li r0,0 diff --git a/arch/powerpc/mm/44x_mmu.c b/arch/powerpc/mm/44x_mmu.c index 98052ac..4a55061 100644 --- a/arch/powerpc/mm/44x_mmu.c +++ b/arch/powerpc/mm/44x_mmu.c @@ -94,7 +94,7 @@ unsigned long __init mmu_mapin_ram(void) /* Pin in enough TLBs to cover any lowmem not covered by the * initial 256M mapping established in head_44x.S */ - for (addr = PPC_PIN_SIZE; addr < lowmem_end_addr; + for (addr = PHYSICAL_START + PPC_PIN_SIZE; addr < lowmem_end_addr; addr += PPC_PIN_SIZE) ppc44x_pin_tlb(addr + PAGE_OFFSET, addr); -- 1.5.5.6 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* [RFC PATCH 2/7] powerpc: Permit non-zero physical start address for PPC44x 2011-06-16 14:14 ` [RFC PATCH 1/7] powerpc: ppc440 remove zero physical memory base assumption Michal Simek @ 2011-06-16 14:14 ` Michal Simek 2011-06-16 14:14 ` [RFC PATCH 3/7] powerpc: simpleboot get load address from ELF instead of assuming zero Michal Simek 0 siblings, 1 reply; 9+ messages in thread From: Michal Simek @ 2011-06-16 14:14 UTC (permalink / raw) To: linuxppc-dev; +Cc: arnd, tmarri, suzuki, john.williams From: John Williams <john.williams@petalogix.com> The initial TLB entry is 256M, meaning that the physical base address must be 256M aligned. Signed-off-by: John Williams <john.williams@petalogix.com> --- arch/powerpc/Kconfig | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index d00131c..45c9683 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -845,7 +845,7 @@ config KERNEL_START config PHYSICAL_START_BOOL bool "Set physical address where the kernel is loaded" - depends on ADVANCED_OPTIONS && FLATMEM && FSL_BOOKE + depends on ADVANCED_OPTIONS && FLATMEM && (FSL_BOOKE || 44x) help This gives the physical address where the kernel is loaded. @@ -858,6 +858,7 @@ config PHYSICAL_START config PHYSICAL_ALIGN hex + default "0x10000000" if 44x default "0x04000000" if FSL_BOOKE help This value puts the alignment restrictions on physical address -- 1.5.5.6 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* [RFC PATCH 3/7] powerpc: simpleboot get load address from ELF instead of assuming zero 2011-06-16 14:14 ` [RFC PATCH 2/7] powerpc: Permit non-zero physical start address for PPC44x Michal Simek @ 2011-06-16 14:14 ` Michal Simek 2011-06-16 14:14 ` [RFC PATCH 4/7] powerpc: Let simpleboot function with non zero-based memory maps Michal Simek 0 siblings, 1 reply; 9+ messages in thread From: Michal Simek @ 2011-06-16 14:14 UTC (permalink / raw) To: linuxppc-dev; +Cc: arnd, tmarri, suzuki, john.williams From: John Williams <john.williams@petalogix.com> simpleboot current assumes that the physical load address is zero, even if the ELF payload has a non-zero paddr. This is a simple fix that avoids a custom pltform_ops handler in this case. Signed-off-by: John Williams <john.williams@petalogix.com> --- arch/powerpc/boot/elf.h | 1 + arch/powerpc/boot/elf_util.c | 2 ++ arch/powerpc/boot/main.c | 1 + 3 files changed, 4 insertions(+), 0 deletions(-) diff --git a/arch/powerpc/boot/elf.h b/arch/powerpc/boot/elf.h index 1941bc5..39af242 100644 --- a/arch/powerpc/boot/elf.h +++ b/arch/powerpc/boot/elf.h @@ -150,6 +150,7 @@ struct elf_info { unsigned long loadsize; unsigned long memsize; unsigned long elfoffset; + unsigned long loadaddr; }; int parse_elf64(void *hdr, struct elf_info *info); int parse_elf32(void *hdr, struct elf_info *info); diff --git a/arch/powerpc/boot/elf_util.c b/arch/powerpc/boot/elf_util.c index 1567a0c..3aef4f0 100644 --- a/arch/powerpc/boot/elf_util.c +++ b/arch/powerpc/boot/elf_util.c @@ -43,6 +43,7 @@ int parse_elf64(void *hdr, struct elf_info *info) info->loadsize = (unsigned long)elf64ph->p_filesz; info->memsize = (unsigned long)elf64ph->p_memsz; info->elfoffset = (unsigned long)elf64ph->p_offset; + info->loadaddr = (unsigned long)elf64ph->p_paddr; return 1; } @@ -74,5 +75,6 @@ int parse_elf32(void *hdr, struct elf_info *info) info->loadsize = elf32ph->p_filesz; info->memsize = elf32ph->p_memsz; info->elfoffset = elf32ph->p_offset; + info->loadaddr = elf32ph->p_paddr; return 1; } diff --git a/arch/powerpc/boot/main.c b/arch/powerpc/boot/main.c index a28f021..fbbffa5 100644 --- a/arch/powerpc/boot/main.c +++ b/arch/powerpc/boot/main.c @@ -56,6 +56,7 @@ static struct addr_range prep_kernel(void) if (platform_ops.vmlinux_alloc) { addr = platform_ops.vmlinux_alloc(ei.memsize); } else { + addr = ei.loadaddr; /* * Check if the kernel image (without bss) would overwrite the * bootwrapper. The device tree has been moved in fdt_init() -- 1.5.5.6 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* [RFC PATCH 4/7] powerpc: Let simpleboot function with non zero-based memory maps 2011-06-16 14:14 ` [RFC PATCH 3/7] powerpc: simpleboot get load address from ELF instead of assuming zero Michal Simek @ 2011-06-16 14:14 ` Michal Simek 2011-06-16 14:14 ` [RFC PATCH 5/7] powerpc: Consider a non-zero boot address when computing the bootwrapper start Michal Simek 0 siblings, 1 reply; 9+ messages in thread From: Michal Simek @ 2011-06-16 14:14 UTC (permalink / raw) To: linuxppc-dev; +Cc: arnd, tmarri, suzuki, john.williams From: John Williams <john.williams@petalogix.com> It is unnecessarily restrictive to fatal() if there is physical memory at a non-zero base address. Signed-off-by: John Williams <john.williams@petalogix.com> --- arch/powerpc/boot/simpleboot.c | 5 ----- 1 files changed, 0 insertions(+), 5 deletions(-) diff --git a/arch/powerpc/boot/simpleboot.c b/arch/powerpc/boot/simpleboot.c index 21cd480..910ae05 100644 --- a/arch/powerpc/boot/simpleboot.c +++ b/arch/powerpc/boot/simpleboot.c @@ -56,11 +56,6 @@ void platform_init(unsigned long r3, unsigned long r4, unsigned long r5, if (size < (*na+*ns) * sizeof(u32)) fatal("cannot get memory range\n"); - /* Only interested in memory based at 0 */ - for (i = 0; i < *na; i++) - if (*reg++ != 0) - fatal("Memory range is not based at address 0\n"); - /* get the memsize and trucate it to under 4G on 32 bit machines */ memsize64 = 0; for (i = 0; i < *ns; i++) -- 1.5.5.6 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* [RFC PATCH 5/7] powerpc: Consider a non-zero boot address when computing the bootwrapper start 2011-06-16 14:14 ` [RFC PATCH 4/7] powerpc: Let simpleboot function with non zero-based memory maps Michal Simek @ 2011-06-16 14:14 ` Michal Simek 2011-06-16 14:14 ` [RFC PATCH 6/7] powerpc: Update the default FIT image to use the correct load/boot addresses Michal Simek 0 siblings, 1 reply; 9+ messages in thread From: Michal Simek @ 2011-06-16 14:14 UTC (permalink / raw) To: linuxppc-dev; +Cc: arnd, tmarri, suzuki, john.williams From: John Williams <john.williams@petalogix.com> There's no fundamental reason the bootwrapper can't boot off a non-zero base, we just need to make sure we account for it in the link. Do this by adding the (up-aligned) kernel size to membase, and using that as the link address. Signed-off-by: John Williams <john.williams@petalogix.com> --- arch/powerpc/boot/wrapper | 14 +++++++++----- 1 files changed, 9 insertions(+), 5 deletions(-) diff --git a/arch/powerpc/boot/wrapper b/arch/powerpc/boot/wrapper index e148053..594aa02 100755 --- a/arch/powerpc/boot/wrapper +++ b/arch/powerpc/boot/wrapper @@ -139,9 +139,16 @@ tmp=$tmpdir/zImage.$$.o ksection=.kernel:vmlinux.strip isection=.kernel:initrd -# default auto-calculate link_address to make room for the kernel +# physical offset of kernel image +membase=`${CROSS}objdump -p "$kernel" | grep -m 1 LOAD | awk '{print $7}'` + +# auto-calculate link_address to make room for the kernel # round up kernel image size to nearest megabyte -link_address=`${CROSS}size -x ${kernel} | grep ${kernel} | awk '{printf("0x%08x", and($4 + 0x0fffff, 0xfffe0000))}'` + +# don't forget to add membase for non-zero kernel boot +membase_dec=`printf "%d" $membase` + +link_address=`${CROSS}size -x ${kernel} | grep ${kernel} | awk -v membase=$membase_dec '{printf("0x%08x", membase + and($4 + 0x0fffff, 0xfffe0000))}'` case "$platform" in pseries) @@ -259,9 +266,6 @@ if [ -n "$version" ]; then uboot_version="-n Linux-$version" fi -# physical offset of kernel image -membase=`${CROSS}objdump -p "$kernel" | grep -m 1 LOAD | awk '{print $7}'` - case "$platform" in uboot) rm -f "$ofile" -- 1.5.5.6 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* [RFC PATCH 6/7] powerpc: Update the default FIT image to use the correct load/boot addresses 2011-06-16 14:14 ` [RFC PATCH 5/7] powerpc: Consider a non-zero boot address when computing the bootwrapper start Michal Simek @ 2011-06-16 14:14 ` Michal Simek 2011-06-16 14:14 ` [RFC PATCH 7/7] powerpc: Support RELOCATABLE kernel for PPC44x Michal Simek 0 siblings, 1 reply; 9+ messages in thread From: Michal Simek @ 2011-06-16 14:14 UTC (permalink / raw) To: linuxppc-dev; +Cc: arnd, tmarri, suzuki, john.williams From: John Williams <john.williams@petalogix.com> The default kernel_fdt.its hard codes zero load/start addresses, but this may no longer be true. As we copy the FIT tree descriptor, update these values based on the incoming ELF payload. Signed-off-by: John Williams <john.williams@petalogix.com> --- arch/powerpc/boot/wrapper | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-) diff --git a/arch/powerpc/boot/wrapper b/arch/powerpc/boot/wrapper index 594aa02..54fbc2e 100755 --- a/arch/powerpc/boot/wrapper +++ b/arch/powerpc/boot/wrapper @@ -281,7 +281,11 @@ uboot-fit) rm -f "$ofile" #[ "$vmz" != vmlinux.bin.gz ] && mv "$vmz" "vmlinux.bin.gz" mv "$dtb" "target.dtb" - cp arch/powerpc/boot/kernel_fdt.its . + # Check the ELF file for a non-zero load/entry address + membase=${membase:2:8} + sed -e "s/load = <.*$/load = <${membase}>;/g" \ + -e "s/entry = <.*$/entry = <${membase}>;/g" \ + arch/powerpc/boot/kernel_fdt.its > kernel_fdt.its mkimage -f kernel_fdt.its "$ofile" #rm kernet_fdt.its exit 0 -- 1.5.5.6 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* [RFC PATCH 7/7] powerpc: Support RELOCATABLE kernel for PPC44x 2011-06-16 14:14 ` [RFC PATCH 6/7] powerpc: Update the default FIT image to use the correct load/boot addresses Michal Simek @ 2011-06-16 14:14 ` Michal Simek 2011-07-12 11:09 ` Suzuki Poulose 0 siblings, 1 reply; 9+ messages in thread From: Michal Simek @ 2011-06-16 14:14 UTC (permalink / raw) To: linuxppc-dev; +Cc: Michal Simek, arnd, tmarri, suzuki, john.williams Changes: - Find out address where kernel runs - Create the first 256MB TLB from online detected address Limitations: - Kernel must be aligned to 256MB Backport: - Changes in page.h are backported from newer kernel version mmu_mapin_ram function has to reflect offset in memory start. memstart_addr and kernstart_addr are setup directly from asm code to ensure that only ppc44x is affected. Signed-off-by: Michal Simek <monstr@monstr.eu> --- arch/powerpc/Kconfig | 3 ++- arch/powerpc/include/asm/page.h | 7 ++++++- arch/powerpc/kernel/head_44x.S | 28 ++++++++++++++++++++++++++++ arch/powerpc/mm/44x_mmu.c | 6 +++++- 4 files changed, 41 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index 45c9683..34c521e 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -796,7 +796,8 @@ config LOWMEM_CAM_NUM config RELOCATABLE bool "Build a relocatable kernel (EXPERIMENTAL)" - depends on EXPERIMENTAL && ADVANCED_OPTIONS && FLATMEM && FSL_BOOKE + depends on EXPERIMENTAL && ADVANCED_OPTIONS && FLATMEM + depends on FSL_BOOKE || (44x && !SMP) help This builds a kernel image that is capable of running at the location the kernel is loaded at (some alignment restrictions may diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h index 4940662..e813cc2 100644 --- a/arch/powerpc/include/asm/page.h +++ b/arch/powerpc/include/asm/page.h @@ -108,8 +108,13 @@ extern phys_addr_t kernstart_addr; #define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT) #define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT) -#define __va(x) ((void *)((unsigned long)(x) + PAGE_OFFSET - MEMORY_START)) +#ifdef CONFIG_BOOKE +#define __va(x) ((void *)(unsigned long)((phys_addr_t)(x) - PHYSICAL_START + KERNELBASE)) +#define __pa(x) ((unsigned long)(x) + PHYSICAL_START - KERNELBASE) +#else +#define __va(x) ((void *)(unsigned long)((phys_addr_t)(x) + PAGE_OFFSET - MEMORY_START)) #define __pa(x) ((unsigned long)(x) - PAGE_OFFSET + MEMORY_START) +#endif /* * Unfortunately the PLT is in the BSS in the PPC32 ELF ABI, diff --git a/arch/powerpc/kernel/head_44x.S b/arch/powerpc/kernel/head_44x.S index d80ce05..6a63d32 100644 --- a/arch/powerpc/kernel/head_44x.S +++ b/arch/powerpc/kernel/head_44x.S @@ -59,6 +59,17 @@ _ENTRY(_start); * of abatron_pteptrs */ nop + +#ifdef CONFIG_RELOCATABLE + bl jump /* Find our address */ + nop +jump: mflr r25 /* Make it accessible */ + /* just for and */ + lis r26, 0xfffffff0@h + ori r26, r26, 0xfffffff0@l + and. r21, r25, r26 +#endif + /* * Save parameters we are passed */ @@ -135,9 +146,14 @@ skpinv: addi r4,r4,1 /* Increment */ lis r3,PAGE_OFFSET@h ori r3,r3,PAGE_OFFSET@l +#ifdef CONFIG_RELOCATABLE + /* load physical address where kernel runs */ + mr r4,r21 +#else /* Kernel is at PHYSICAL_START */ lis r4,PHYSICAL_START@h ori r4,r4,PHYSICAL_START@l +#endif /* Load the kernel PID = 0 */ li r0,0 @@ -258,6 +274,18 @@ skpinv: addi r4,r4,1 /* Increment */ mr r5,r29 mr r6,r28 mr r7,r27 + +#ifdef CONFIG_RELOCATABLE + /* save kernel and memory start */ + lis r25,kernstart_addr@h + ori r25,r25,kernstart_addr@l + stw r21,4(r25) + + lis r25,memstart_addr@h + ori r25,r25,memstart_addr@l + stw r21,4(r25) +#endif + bl machine_init bl MMU_init diff --git a/arch/powerpc/mm/44x_mmu.c b/arch/powerpc/mm/44x_mmu.c index 4a55061..ecf4a20 100644 --- a/arch/powerpc/mm/44x_mmu.c +++ b/arch/powerpc/mm/44x_mmu.c @@ -91,12 +91,16 @@ void __init MMU_init_hw(void) unsigned long __init mmu_mapin_ram(void) { unsigned long addr; + unsigned long offset = 0; +#if defined(CONFIG_RELOCATABLE) + offset = memstart_addr; +#endif /* Pin in enough TLBs to cover any lowmem not covered by the * initial 256M mapping established in head_44x.S */ for (addr = PHYSICAL_START + PPC_PIN_SIZE; addr < lowmem_end_addr; addr += PPC_PIN_SIZE) - ppc44x_pin_tlb(addr + PAGE_OFFSET, addr); + ppc44x_pin_tlb(addr + PAGE_OFFSET - offset, addr); return total_lowmem; } -- 1.5.5.6 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [RFC PATCH 7/7] powerpc: Support RELOCATABLE kernel for PPC44x 2011-06-16 14:14 ` [RFC PATCH 7/7] powerpc: Support RELOCATABLE kernel for PPC44x Michal Simek @ 2011-07-12 11:09 ` Suzuki Poulose 0 siblings, 0 replies; 9+ messages in thread From: Suzuki Poulose @ 2011-07-12 11:09 UTC (permalink / raw) To: Michal Simek; +Cc: tmarri, linuxppc-dev, john.williams, arnd On 06/16/11 19:44, Michal Simek wrote: > Changes: > - Find out address where kernel runs > - Create the first 256MB TLB from online detected address > > Limitations: > - Kernel must be aligned to 256MB > > Backport: > - Changes in page.h are backported from newer kernel version > > mmu_mapin_ram function has to reflect offset in memory start. > memstart_addr and kernstart_addr are setup directly from asm > code to ensure that only ppc44x is affected. > > Signed-off-by: Michal Simek<monstr@monstr.eu> > --- > arch/powerpc/Kconfig | 3 ++- > arch/powerpc/include/asm/page.h | 7 ++++++- > arch/powerpc/kernel/head_44x.S | 28 ++++++++++++++++++++++++++++ > arch/powerpc/mm/44x_mmu.c | 6 +++++- > 4 files changed, 41 insertions(+), 3 deletions(-) > > diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig > index 45c9683..34c521e 100644 > --- a/arch/powerpc/Kconfig > +++ b/arch/powerpc/Kconfig > @@ -796,7 +796,8 @@ config LOWMEM_CAM_NUM > > config RELOCATABLE > bool "Build a relocatable kernel (EXPERIMENTAL)" > - depends on EXPERIMENTAL&& ADVANCED_OPTIONS&& FLATMEM&& FSL_BOOKE > + depends on EXPERIMENTAL&& ADVANCED_OPTIONS&& FLATMEM > + depends on FSL_BOOKE || (44x&& !SMP) > help > This builds a kernel image that is capable of running at the > location the kernel is loaded at (some alignment restrictions may > diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h > index 4940662..e813cc2 100644 > --- a/arch/powerpc/include/asm/page.h > +++ b/arch/powerpc/include/asm/page.h > @@ -108,8 +108,13 @@ extern phys_addr_t kernstart_addr; > #define pfn_to_kaddr(pfn) __va((pfn)<< PAGE_SHIFT) > #define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr)>> PAGE_SHIFT) > > -#define __va(x) ((void *)((unsigned long)(x) + PAGE_OFFSET - MEMORY_START)) > +#ifdef CONFIG_BOOKE > +#define __va(x) ((void *)(unsigned long)((phys_addr_t)(x) - PHYSICAL_START + KERNELBASE)) > +#define __pa(x) ((unsigned long)(x) + PHYSICAL_START - KERNELBASE) > +#else > +#define __va(x) ((void *)(unsigned long)((phys_addr_t)(x) + PAGE_OFFSET - MEMORY_START)) > #define __pa(x) ((unsigned long)(x) - PAGE_OFFSET + MEMORY_START) > +#endif > > /* > * Unfortunately the PLT is in the BSS in the PPC32 ELF ABI, > diff --git a/arch/powerpc/kernel/head_44x.S b/arch/powerpc/kernel/head_44x.S > index d80ce05..6a63d32 100644 > --- a/arch/powerpc/kernel/head_44x.S > +++ b/arch/powerpc/kernel/head_44x.S > @@ -59,6 +59,17 @@ _ENTRY(_start); > * of abatron_pteptrs > */ > nop > + > +#ifdef CONFIG_RELOCATABLE > + bl jump /* Find our address */ > + nop > +jump: mflr r25 /* Make it accessible */ > + /* just for and */ > + lis r26, 0xfffffff0@h > + ori r26, r26, 0xfffffff0@l > + and. r21, r25, r26 > +#endif Hmm. So we are assuming we are running from a 1:1 mapping at the entry. It is much more safe to read our tlb entry and use the RPN instead. > +#ifdef CONFIG_RELOCATABLE > + /* load physical address where kernel runs */ > + mr r4,r21 > +#else > /* Kernel is at PHYSICAL_START */ > lis r4,PHYSICAL_START@h > ori r4,r4,PHYSICAL_START@l > +#endif > > /* Load the kernel PID = 0 */ > li r0,0 > @@ -258,6 +274,18 @@ skpinv: addi r4,r4,1 /* Increment */ > mr r5,r29 > mr r6,r28 > mr r7,r27 > + > +#ifdef CONFIG_RELOCATABLE > + /* save kernel and memory start */ > + lis r25,kernstart_addr@h > + ori r25,r25,kernstart_addr@l > + stw r21,4(r25) 1) You have to use ERPN value in the higher word of kernel_start_addr. 2) You have to account for the (KERNEL_BASE - PAGE_OFFSET) shift for kernel_start_addr. > + > + lis r25,memstart_addr@h > + ori r25,r25,memstart_addr@l > + stw r21,4(r25) > +#endif > + Suzuki ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2011-07-12 11:10 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2011-06-16 14:14 [RFC] Relocatable kernel for ppc44x Michal Simek 2011-06-16 14:14 ` [RFC PATCH 1/7] powerpc: ppc440 remove zero physical memory base assumption Michal Simek 2011-06-16 14:14 ` [RFC PATCH 2/7] powerpc: Permit non-zero physical start address for PPC44x Michal Simek 2011-06-16 14:14 ` [RFC PATCH 3/7] powerpc: simpleboot get load address from ELF instead of assuming zero Michal Simek 2011-06-16 14:14 ` [RFC PATCH 4/7] powerpc: Let simpleboot function with non zero-based memory maps Michal Simek 2011-06-16 14:14 ` [RFC PATCH 5/7] powerpc: Consider a non-zero boot address when computing the bootwrapper start Michal Simek 2011-06-16 14:14 ` [RFC PATCH 6/7] powerpc: Update the default FIT image to use the correct load/boot addresses Michal Simek 2011-06-16 14:14 ` [RFC PATCH 7/7] powerpc: Support RELOCATABLE kernel for PPC44x Michal Simek 2011-07-12 11:09 ` Suzuki Poulose
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).