ofmem was fixed at 0x05400000, followed by the malloc zone. The latter was bounded by the stack (now client stack), relative to the top of RAM. An increase of RAM would therefore only enlarge the malloc zone.
Move the malloc zone below the client stack, with a fixed size of 2 MiB. The size is derived from the memory map depicted in ofmem.c; having a fixed size leaves room for memory claim'ed by clients and by OpenBIOS.
v2: * Through the preceding patch the malloc zone goes below the client stack rather than below the stack. Adjust and prettify the illustration.
Cc: Alexander Graf agraf@suse.de Signed-off-by: Andreas Färber andreas.faerber@web.de --- arch/ppc/qemu/ofmem.c | 19 +++++++++---------- arch/ppc/qemu/start.S | 8 ++++++-- 2 files changed, 15 insertions(+), 12 deletions(-)
diff --git a/arch/ppc/qemu/ofmem.c b/arch/ppc/qemu/ofmem.c index 4c813a0..afd5808 100644 --- a/arch/ppc/qemu/ofmem.c +++ b/arch/ppc/qemu/ofmem.c @@ -47,11 +47,9 @@ extern void setup_mmu( unsigned long code_base ); #define FREE_BASE 0x00004000 #define OF_CODE_START 0xfff00000UL #define IO_BASE 0x80000000 -#define OFMEM ((ofmem_t*)0x05400000) - -#define OF_MALLOC_BASE ((char*)OFMEM + ((sizeof(ofmem_t) + 3) & ~3))
#define HASH_SIZE (2 << 15) +#define OFMEM_SIZE (2 * 1024 * 1024)
#define SEGR_USER BIT(2) #define SEGR_BASE 0x0400 @@ -86,7 +84,7 @@ get_rom_base( void ) unsigned long get_ram_top( void ) { - return get_hash_base() - (32 + 64 + 64) * 1024; + return get_hash_base() - (32 + 64 + 64) * 1024 - OFMEM_SIZE; }
unsigned long @@ -107,12 +105,12 @@ static inline size_t ALIGN_SIZE(size_t x, size_t a)
ofmem_t* ofmem_arch_get_private(void) { - return OFMEM; + return (ofmem_t*)(get_heap_top() - OFMEM_SIZE); }
void* ofmem_arch_get_malloc_base(void) { - return OF_MALLOC_BASE; + return (char*)ofmem_arch_get_private() + ALIGN_SIZE(sizeof(ofmem_t), 4); }
ucell ofmem_arch_get_heap_top(void) @@ -388,15 +386,12 @@ isi_exception( void ) void setup_mmu( unsigned long ramsize ) { - ofmem_t *ofmem = OFMEM; + ofmem_t *ofmem; unsigned long sdr1, sr_base, msr; unsigned long hash_base; unsigned long hash_mask = 0xffff0000; int i;
- memset(ofmem, 0, sizeof(ofmem_t)); - ofmem->ramsize = ramsize; - /* SDR1: Storage Description Register 1 */
if(is_ppc64()) @@ -415,6 +410,10 @@ setup_mmu( unsigned long ramsize ) asm volatile("mtsrin %0,%1" :: "r" (sr_base + i), "r" (j) ); }
+ ofmem = ofmem_arch_get_private(); + memset(ofmem, 0, sizeof(ofmem_t)); + ofmem->ramsize = ramsize; + memcpy((void *)get_rom_base(), (void *)OF_CODE_START, 0x00100000);
/* Enable MMU */ diff --git a/arch/ppc/qemu/start.S b/arch/ppc/qemu/start.S index d74fb9c..d0d51b5 100644 --- a/arch/ppc/qemu/start.S +++ b/arch/ppc/qemu/start.S @@ -313,17 +313,21 @@ GLOBL(_entry): * | | * +-------------------------+ * | | - * | Exception Stack (32 kB) + * | Exception Stack (32 kB) | * | | * +-------------------------+ * | | - * | Stack (64 kB) + * | Stack (64 kB) | * | | * +-------------------------+ * | | * | Client Stack (64 kB) | * | | * +-------------------------+ + * | | + * | Malloc Zone (2 MiB) | + * | | + * +-------------------------+ * : : * Bottom */