Skip to content

Question : PLIC address check at fdt node parse #412

@vmorales-oc

Description

@vmorales-oc

Hi,

I would like to ask about a check that is performed during FDT parsing, specifically for the PLIC node. The check in question is:

if (rc < 0 || !reg_addr || !reg_size)
                return SBI_ENODEV;

This code is located in lib/utils/fdt/fdt_helper.c:

int fdt_parse_plic_node(const void *fdt, int nodeoffset, struct plic_data *plic)
{
        int len, rc;
        const fdt32_t *val;
        uint64_t reg_addr, reg_size;

        if (nodeoffset < 0 || !plic || !fdt)
                return SBI_ENODEV;

        rc = fdt_get_node_addr_size(fdt, nodeoffset, 0,
                                    &reg_addr, &reg_size);
        if (rc < 0 || !reg_addr || !reg_size)
                return SBI_ENODEV;
        plic->addr = reg_addr;
        plic->size = reg_size;

        val = fdt_getprop(fdt, nodeoffset, "riscv,ndev", &len);
        if (len > 0)
                plic->num_src = fdt32_to_cpu(*val);

        return 0;
}

My question concerns the need to check reg_addr != 0. This condition causes an error when the PLIC base address is 0x0.

I am aware that placing the PLIC at address 0x0 is generally not considered good practice, but has this possibility been explicitly considered? As far as I know, there is no restriction in the PLIC specification that forbids a base address of zero.

Thank you in advance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions