]> xenbits.xensource.com Git - unikraft/unikraft.git/commitdiff
plat/drivers/ofw: Fix incorrect offset in `fdt_translate_one`
authorEduard Vintilă <eduard.vintila47@gmail.com>
Thu, 16 Mar 2023 12:10:46 +0000 (14:10 +0200)
committerUnikraft <monkey@unikraft.io>
Mon, 8 May 2023 06:32:28 +0000 (06:32 +0000)
When a node is missing the "ranges" property, offset should be set to 0.
The current implementation sets offset to the address to be translated,
which ignores the fact that `fdt_default_translate`  is later called.
The latter function adds the offset to the same address,
resulting in doubling the effective address, when in fact a 1-to-1
mapping is necessary.

Signed-off-by: Eduard Vintilă <eduard.vintila47@gmail.com>
Reviewed-by: Robert Kuban <robert.kuban@opensynergy.com>
Reviewed-by: Razvan Virtan <virtanrazvan@gmail.com>
Approved-by: Michalis Pappas <michalis@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #805

plat/drivers/ofw/fdt.c

index 41b74f4600d4aa6c322732a6537443765d577c56..2c6735bc0eba44900129b2d299350e34e833447c 100644 (file)
@@ -158,7 +158,7 @@ static int fdt_translate_one(const void *fdt, int parent, fdt32_t *addr,
        if (!ranges)
                return 1;
        if (rlen == 0) {
-               offset = fdt_reg_read_number(addr, na);
+               offset = 0;
                uk_pr_debug("empty ranges, 1:1 translation\n");
                goto finish;
        }
@@ -179,7 +179,7 @@ static int fdt_translate_one(const void *fdt, int parent, fdt32_t *addr,
        memcpy(addr, ranges + na, 4 * pna);
 
 finish:
-       uk_pr_info("parent translation for:%p %x", addr, pna);
+       uk_pr_info("parent translation for:%p %x\n", addr, pna);
 
        /* Translate it into parent bus space */
        return fdt_default_translate(addr, offset, pna);