qemu-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Added on-chip ram, but can't load program there..


From: ckim
Subject: Added on-chip ram, but can't load program there..
Date: Thu, 25 Mar 2021 19:17:21 +0900

Hello all,

 

I have added iram (on-chip ram) to our machine (copy of ‘virt’) and intended the program #1 (containing .data, .bss and other read-write data sections) to be loaded on that memory.

The iram range is from 0x04000000 with size 0x80000 (it’s big enough).

But the program #1 is not loaded on iram. Using the gdb, when I examine the memory, (using compare-sections, and ‘x’ command) I can see that range (0x04000000 - ) has mismatch from the program start..

I checked the page table and it seems ok and I can see the memory is read-writeable (checked with simple assembly code during bootup).

I followed the elf loading (skipping the loading of program #0 which is read-only, it is provided by -device pflash.img option) but couldn’t follow up in the insert_rom part yet.

 

To add this internal ram (I name it tram, meaning trusted ram), I modified create_secure_ram function,(it’s originally in hw/arm/virt.c.  ab21q has separate file with name changes).

That function seemed to set memory region and add it to secure_sysmem as a subregion and make fdt entry.(and make secure_tag_mem).

So I added this code after that for the iram only chaning ‘secram’ to ‘tram,’ (ab21q is the machine name I used, and the system memory map had ranges defined for AB21Q_TMEM)

This is the create_secure_ram function.

 

static void create_secure_ram(Ab21qMachineState *vms,

                              MemoryRegion *secure_sysmem,

                              MemoryRegion *secure_tag_sysmem)

{

MemoryRegion *secram = g_new(MemoryRegion, 1);

    char *nodename;

    hwaddr base = vms->memmap[AB21Q_SECURE_MEM].base;

    hwaddr size = vms->memmap[AB21Q_SECURE_MEM].size;

 

    memory_region_init_ram(secram, NULL, "ab21q.secure-ram", size,

                           &error_fatal);

    memory_region_add_subregion(secure_sysmem, base, secram);

 

    nodename = g_strdup_printf("/secram@%" PRIx64, base);

    qemu_fdt_add_subnode(vms->fdt, nodename);

    qemu_fdt_setprop_string(vms->fdt, nodename, "device_type", "memory");

    qemu_fdt_setprop_sized_cells(vms->fdt, nodename, "reg", 2, base, 2, size);

    qemu_fdt_setprop_string(vms->fdt, nodename, "status", "disabled");

    qemu_fdt_setprop_string(vms->fdt, nodename, "secure-status", "okay");

 

    if (secure_tag_sysmem) {

        create_tag_ram(secure_tag_sysmem, base, size, "mach-ab21q.secure-tag");

    }

    g_free(nodename);

 

{ /*******  added part below *******/

    MemoryRegion *tram = g_new(MemoryRegion, 1);

    hwaddr base = vms->memmap[AB21Q_TMEM].base;

    hwaddr size = vms->memmap[AB21Q_TMEM].size;

 

    memory_region_init_ram(tram, NULL, "ab21q.tram", size,

                           &error_fatal);

    memory_region_add_subregion(secure_sysmem, base, tram);

 

    nodename = g_strdup_printf("/tram@%" PRIx64, base);

    qemu_fdt_add_subnode(vms->fdt, nodename);

    qemu_fdt_setprop_string(vms->fdt, nodename, "device_type", "memory");

    qemu_fdt_setprop_sized_cells(vms->fdt, nodename, "reg", 2, base, 2, size);

    qemu_fdt_setprop_string(vms->fdt, nodename, "status", "disabled");

    qemu_fdt_setprop_string(vms->fdt, nodename, "secure-status", "okay");

 

    if (secure_tag_sysmem) {

        create_tag_ram(secure_tag_sysmem, base, size, "mach-ab21q.tram-tag");

    }

 

    g_free(nodename);

    }

}

In what case could this problem arise? Can anyone find anything wrong here?

Any comment will be very much appreciated.

Thank you!

Chan Kim

 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]