Skip to content

Commit d5072d1

Browse files
Andrew Boienashif
authored andcommitted
tests: x86: pagetables: show user thread tables
Show the page table layout for a user thread. This may be somewhat different from a supervisor thread especially if KPTI is enabled. Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
1 parent 3605832 commit d5072d1

File tree

3 files changed

+32
-2
lines changed

3 files changed

+32
-2
lines changed

tests/arch/x86/pagetables/prj.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ CONFIG_ZTEST=y
22
CONFIG_TEST_HW_STACK_PROTECTION=n
33
CONFIG_TEST_USERSPACE=y
44
CONFIG_EXCEPTION_DEBUG=y
5+
CONFIG_APPLICATION_DEFINED_SYSCALL=y

tests/arch/x86/pagetables/src/main.c

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <arch/x86/mmustructs.h>
1616
#include <x86_mmu.h>
1717
#include <linker/linker-defs.h>
18+
#include "main.h"
1819

1920
#define VM_BASE ((uint8_t *)CONFIG_KERNEL_VM_BASE)
2021
#define VM_LIMIT (VM_BASE + CONFIG_KERNEL_RAM_SIZE)
@@ -146,6 +147,20 @@ void test_null_map(void)
146147
zassert_true((entry & MMU_P) == 0, "present NULL entry");
147148
}
148149

150+
void z_impl_dump_my_ptables(void)
151+
{
152+
struct k_thread *cur = k_current_get();
153+
154+
printk("Page tables for thread %p\n", cur);
155+
z_x86_dump_page_tables(z_x86_thread_page_tables_get(cur));
156+
}
157+
158+
void z_vrfy_dump_my_ptables(void)
159+
{
160+
z_impl_dump_my_ptables();
161+
}
162+
#include <syscalls/dump_my_ptables_mrsh.c>
163+
149164
/**
150165
* Dump kernel's page tables to console
151166
*
@@ -162,7 +177,7 @@ void test_dump_ptables(void)
162177
*/
163178
ztest_test_skip();
164179
#else
165-
z_x86_dump_page_tables(z_x86_page_tables_get());
180+
dump_my_ptables();
166181
#endif
167182
}
168183

@@ -171,7 +186,8 @@ void test_main(void)
171186
ztest_test_suite(x86_pagetables,
172187
ztest_unit_test(test_ram_perms),
173188
ztest_unit_test(test_null_map),
174-
ztest_unit_test(test_dump_ptables)
189+
ztest_unit_test(test_dump_ptables),
190+
ztest_user_unit_test(test_dump_ptables)
175191
);
176192
ztest_run_test_suite(x86_pagetables);
177193
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*
2+
* Copyright (c) 2020 Intel Corporation.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
#ifndef MAIN_H
7+
#define MAIN_H
8+
9+
__syscall void dump_my_ptables(void);
10+
11+
#include <syscalls/main.h>
12+
13+
#endif

0 commit comments

Comments
 (0)