tests: mem_map: use physical address of test page

It may not be identity-mapped.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
Andrew Boie 2020-11-06 15:30:58 -08:00 committed by Anas Nashif
commit 2b48f591e1

View file

@ -55,7 +55,7 @@ void test_z_phys_map_rw(void)
expect_fault = false;
/* Map in a page that allows writes */
z_phys_map(&mapped_rw, (uintptr_t)buf,
z_phys_map(&mapped_rw, z_mem_phys_addr(buf),
BUF_SIZE, BASE_FLAGS | K_MEM_PERM_RW);
/* Initialize buf with some bytes */
@ -64,7 +64,7 @@ void test_z_phys_map_rw(void)
}
/* Map again this time only allowing reads */
z_phys_map(&mapped_ro, (uintptr_t)buf,
z_phys_map(&mapped_ro, z_mem_phys_addr(buf),
BUF_SIZE, BASE_FLAGS);
/* Check that the mapped area contains the expected data. */
@ -119,7 +119,7 @@ void test_z_phys_map_exec(void)
func = transplanted_function;
/* Now map with execution enabled and try to run the copied fn */
z_phys_map(&mapped_exec, (uintptr_t)__test_mem_map_start,
z_phys_map(&mapped_exec, z_mem_phys_addr(__test_mem_map_start),
(uintptr_t)(__test_mem_map_end - __test_mem_map_start),
BASE_FLAGS | K_MEM_PERM_EXEC);
@ -128,7 +128,7 @@ void test_z_phys_map_exec(void)
zassert_true(executed, "function did not execute");
/* Now map without execution and execution should now fail */
z_phys_map(&mapped_ro, (uintptr_t)__test_mem_map_start,
z_phys_map(&mapped_ro, z_mem_phys_addr(__test_mem_map_start),
(uintptr_t)(__test_mem_map_end - __test_mem_map_start), BASE_FLAGS);
func = (void (*)(bool *executed))mapped_ro;
@ -156,7 +156,7 @@ void test_z_phys_map_side_effect(void)
* Show that by mapping test_page to an RO region, we can still
* modify test_page.
*/
z_phys_map(&mapped, (uintptr_t)test_page,
z_phys_map(&mapped, z_mem_phys_addr(test_page),
sizeof(test_page), BASE_FLAGS);
/* Should NOT fault */