]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
fdtdec: optionally add property no-map to created reserved memory node
authorEtienne Carriere <etienne.carriere@st.com>
Thu, 10 Sep 2020 08:49:59 +0000 (10:49 +0200)
committerSimon Glass <sjg@chromium.org>
Tue, 22 Sep 2020 18:54:13 +0000 (12:54 -0600)
Add boolean input argument @no_map to helper function
fdtdec_add_reserved_memory() to add or not "no-map" property
for an added reserved memory node.

Property no-map is used by the Linux kernel to not not map memory
in its static memory mapping. It is needed for example for the|
consistency of system non-cached memory and to prevent speculative
accesses to some firewalled memory.

No functional change. A later change will update to OPTEE library to
add no-map property to OP-TEE reserved memory nodes.

Signed-off-by: Etienne Carriere <etienne.carriere@st.com>
Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
arch/riscv/lib/fdt_fixup.c
include/fdtdec.h
lib/fdtdec.c
lib/optee/optee.c
test/dm/fdtdec.c

index 5b2420243fccc8d0144d7af13d73dc4e1bcbd1dc..d02062fd5bd69748b80f195674bc365e93be7f53 100644 (file)
@@ -75,7 +75,7 @@ int riscv_fdt_copy_resv_mem_node(const void *src, void *dst)
                pmp_mem.start = addr;
                pmp_mem.end = addr + size - 1;
                err = fdtdec_add_reserved_memory(dst, basename, &pmp_mem,
-                                                &phandle);
+                                                &phandle, false);
                if (err < 0 && err != -FDT_ERR_EXISTS) {
                        log_err("failed to add reserved memory: %d\n", err);
                        return err;
index 152eb07b9e0eab0face72ef1501feb7eac4d0a9b..62d166097329187578c0bf23760e9403e6cc70ee 100644 (file)
@@ -1029,7 +1029,7 @@ static inline int fdtdec_set_phandle(void *blob, int node, uint32_t phandle)
  *     };
  *     uint32_t phandle;
  *
- *     fdtdec_add_reserved_memory(fdt, "framebuffer", &fb, &phandle);
+ *     fdtdec_add_reserved_memory(fdt, "framebuffer", &fb, &phandle, false);
  *
  * This results in the following subnode being added to the top-level
  * /reserved-memory node:
@@ -1056,11 +1056,12 @@ static inline int fdtdec_set_phandle(void *blob, int node, uint32_t phandle)
  * @param carveout     information about the carveout region
  * @param phandlep     return location for the phandle of the carveout region
  *                     can be NULL if no phandle should be added
+ * @param no_map       add "no-map" property if true
  * @return 0 on success or a negative error code on failure
  */
 int fdtdec_add_reserved_memory(void *blob, const char *basename,
                               const struct fdt_memory *carveout,
-                              uint32_t *phandlep);
+                              uint32_t *phandlep, bool no_map);
 
 /**
  * fdtdec_get_carveout() - reads a carveout from an FDT
index 56bf9fcc793a770a7701e4503c437ce8ff339bde..b8fc5e2bff0f7fbaf0646fe8849da31543765745 100644 (file)
@@ -1316,7 +1316,7 @@ static int fdtdec_init_reserved_memory(void *blob)
 
 int fdtdec_add_reserved_memory(void *blob, const char *basename,
                               const struct fdt_memory *carveout,
-                              uint32_t *phandlep)
+                              uint32_t *phandlep, bool no_map)
 {
        fdt32_t cells[4] = {}, *ptr = cells;
        uint32_t upper, lower, phandle;
@@ -1416,6 +1416,12 @@ int fdtdec_add_reserved_memory(void *blob, const char *basename,
        if (err < 0)
                return err;
 
+       if (no_map) {
+               err = fdt_setprop(blob, node, "no-map", NULL, 0);
+               if (err < 0)
+                       return err;
+       }
+
        /* return the phandle for the new node for the caller to use */
        if (phandlep)
                *phandlep = phandle;
@@ -1481,7 +1487,7 @@ int fdtdec_set_carveout(void *blob, const char *node, const char *prop_name,
        fdt32_t value;
        void *prop;
 
-       err = fdtdec_add_reserved_memory(blob, name, carveout, &phandle);
+       err = fdtdec_add_reserved_memory(blob, name, carveout, &phandle, false);
        if (err < 0) {
                debug("failed to add reserved memory: %d\n", err);
                return err;
index 457d4cca8a0ad597f21314db1df3dacc581c1328..963c2ff4304eadee618486cb87a372f9a0c76b77 100644 (file)
@@ -192,7 +192,7 @@ int optee_copy_fdt_nodes(const void *old_blob, void *new_blob)
                                ret = fdtdec_add_reserved_memory(new_blob,
                                                                 nodename,
                                                                 &carveout,
-                                                                NULL);
+                                                                NULL, false);
                                free(oldname);
 
                                if (ret < 0)
index 716993f706fb3a59e21e196b8eb5b2c05cf186ff..4119003041e694f9dabe815831089ae363821db9 100644 (file)
@@ -80,7 +80,7 @@ static int dm_test_fdtdec_add_reserved_memory(struct unit_test_state *uts)
        resv.start = 0x1000;
        resv.end = 0x1fff;
        ut_assertok(fdtdec_add_reserved_memory(blob, "rsvd_region",
-                                              &resv, &phandle));
+                                              &resv, &phandle, false));
 
        /* Test /reserve-memory and its subnode should exist */
        parent = fdt_path_offset(blob, "/reserved-memory");
@@ -101,7 +101,7 @@ static int dm_test_fdtdec_add_reserved_memory(struct unit_test_state *uts)
        resv.start = 0x2000;
        resv.end = 0x2fff;
        ut_assertok(fdtdec_add_reserved_memory(blob, "rsvd_region1",
-                                              &resv, &phandle1));
+                                              &resv, &phandle1, false));
        subnode = fdt_path_offset(blob, "/reserved-memory/rsvd_region1");
        ut_assert(subnode > 0);
 
@@ -115,7 +115,7 @@ static int dm_test_fdtdec_add_reserved_memory(struct unit_test_state *uts)
        resv.start = 0x1000;
        resv.end = 0x1fff;
        ut_assertok(fdtdec_add_reserved_memory(blob, "rsvd_region2",
-                                              &resv, &phandle1));
+                                              &resv, &phandle1, false));
        subnode = fdt_path_offset(blob, "/reserved-memory/rsvd_region2");
        ut_assert(subnode < 0);