Defintion of kernstart_addr
Hi Kumar,
I have been working on the CONFIG_RELOCATABLE support for PPC44x, trying to process the relocations generated by the compiler. Since the TLB size is 256M, we cannot enforce a page aligned kernel load address.
I came across some issues with the __va() / __pa() translations, while the kernel load address is not page aligned.
We have the following definition :
#define __va(x) ((void *)(unsigned long)((phys_addr_t)(x) -
PHYSICAL_START + KERNELBASE)
where,
PHYSICAL_START is #define'd to kernstart_addr variable, updated at boot
time.
I would like to know the exact meaning of the value in kerstart_addr.
For e.g:
When we have :
PAGE_OFFSET = KERNELBASE = 0xc0000000,
and
kernel loaded at 64M (0x4000000)
and
we map Physical address 0 to Virtual address 0xc0000000.
What should be the value of kernstart_addr ? Should it be 0 ? Or should it be 0x4000000 ?
If we choose, 0x4000000, we get the translations wrong :
__va(0x1) = 0x1 - 0x4000000 + 0xc0000000
= 0xbc000001
If we select 0, we have problems at other places where we assume, PHYSICAL_START to be the va() of _stext.
Thanks
Suzuki
Quoted 5 lines · Suzuki Poulose
#define
__va(x)((void *)(unsigned long)((phys_addr_t)(x) -
PHYSICAL_START+ KERNELBASE)where,
PHYSICAL_STARTis #define'd tokernstart_addrvariable, updated at boot
Where kernstart_addr is the physical address of where we loaded the kernel. But, this has the side-effect of also shifting the kernel's identity mapping (the 1:1 virtual-to-physical map) up by that amount.
I'm unconvinced that this movement of the identity mapping is necessary.
Even if it is, Suzuki mentions:
Quoted 8 lines
#define
__va(x)((void *)(unsigned long)((phys_addr_t)(x) -
PHYSICAL_START+ KERNELBASE)
where:
PHYSICAL_STARTiskernstart_addr- a variable updated at runtime.
KERNELBASE is the compile time Virtual base address of kernel.This won't work for us, as the
kernstart_addrmay change at runtime, even though the mapping doesn't change.
That seems to tell me that PHYSICAL_START and kernstart_addr shouldn't be the same variable. We should break them apart so that we can move the kernel's starting physical address without changing the virt/phys mapping.
Which, I'm fearing, was what Suzuki's first patch did, and I failed to grok it.
-- Dave