RPi4B: an example of what RAM u-boot reserves during operation (not necessarily matching what it reports to the next stage) vs. armstub8-gic.bin

Mark Millard via freebsd-arm <[email protected]>
Newsgroups gmane.os.freebsd.devel.arm
Message-ID <[email protected]>
U-Boot> bdinfo
boot_params = 0x0000000000000100
. . .
lmb_dump_all:
    memory.cnt             = 0x2
    memory.size            = 0x0
    memory.reg[0x0].base   = 0x0
                   .size   = 0x3e000000
    memory.reg[0x1].base   = 0x40000000
                   .size   = 0xbc000000

    reserved.cnt           = 0x2
    reserved.size          = 0x0
    reserved.reg[0x0].base = 0x0
                     .size = 0x1000
    reserved.reg[0x1].base = 0x3db47b30
                     .size = 0x4b84d0
. . .

That:

    reserved.reg[0x0].base = 0x0
                     .size = 0x1000

means that armstub8-gic.bin is not fully
protected at this point in u-boot's execution.

Basically boot_fdt_add_mem_rsv_regions is all that
is used currently and it does not take into account
CONFIG_RPI_EFI_NR_SPIN_PAGES=2 :

/**
 * boot_fdt_add_mem_rsv_regions - Mark the memreserve and reserved-memory
 * sections as unusable
 * @lmb: pointer to lmb handle, will be used for memory mgmt
 * @fdt_blob: pointer to fdt blob base address
 *
 * Adds the and reserved-memorymemreserve regions in the dtb to the lmb block.
 * Adding the memreserve regions prevents u-boot from using them to store the
 * initrd or the fdt blob.
 */
void boot_fdt_add_mem_rsv_regions(struct lmb *lmb, void *fdt_blob)
{
        uint64_t addr, size;
        int i, total, ret;
        int nodeoffset, subnode;
        struct fdt_resource res;

        if (fdt_check_header(fdt_blob) != 0)
                return;

        /* process memreserve sections */
        total = fdt_num_mem_rsv(fdt_blob);
        for (i = 0; i < total; i++) {
                if (fdt_get_mem_rsv(fdt_blob, i, &addr, &size) != 0)
                        continue;
                boot_fdt_reserve_region(lmb, addr, size);
        }

        /* process reserved-memory */
        nodeoffset = fdt_subnode_offset(fdt_blob, 0, "reserved-memory");
        if (nodeoffset >= 0) {
                subnode = fdt_first_subnode(fdt_blob, nodeoffset);
                while (subnode >= 0) {
                        /* check if this subnode has a reg property */
                        ret = fdt_get_resource(fdt_blob, subnode, "reg", 0,
                                               &res);
                        if (!ret && fdtdec_get_is_enabled(fdt_blob, subnode)) {
                                addr = res.start;
                                size = res.end - res.start + 1;
                                boot_fdt_reserve_region(lmb, addr, size);
                        }

                        subnode = fdt_next_subnode(fdt_blob, subnode);
                }
        }
}


===
Mark Millard
marklmi at yahoo.com
( dsl-only.net went
away in early 2018-Mar)

_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-arm
To unsubscribe, send any mail to "[email protected]"
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.