arch: x86: mmu: use z_x86_kernel_ptables as array.

Use z_x86_kernel_ptables as array to make Coverity happy.

Coverity-CID: 212957.
Fixes: 27832.

Signed-off-by: Wentong Wu <wentong.wu@intel.com>
This commit is contained in:
Wentong Wu 2020-09-21 15:41:39 +08:00 committed by Maureen Helm
commit 50252bbf92
2 changed files with 8 additions and 8 deletions

View file

@ -398,7 +398,7 @@ void z_x86_dump_page_tables(pentry_t *ptables)
#if DUMP_PAGE_TABLES
static int dump_kernel_tables(const struct device *unused)
{
z_x86_dump_page_tables(&z_x86_kernel_ptables);
z_x86_dump_page_tables(z_x86_kernel_ptables);
return 0;
}
@ -626,7 +626,7 @@ int arch_mem_map(void *virt, uintptr_t phys, size_t size, uint32_t flags)
* this for driver mappings. User mode mappings
* (and interactions with KPTI) not implemented yet.
*/
ptables = (pentry_t *)&z_x86_kernel_ptables;
ptables = z_x86_kernel_ptables;
/* Translate flags argument into HW-recognized entry flags.
*
@ -697,7 +697,7 @@ static void stack_guard_set(void *guard_page)
/* Always modify the kernel's page tables since this is for
* supervisor threads or handling syscalls
*/
ret = page_map_set(&z_x86_kernel_ptables, guard_page, pte,
ret = page_map_set(z_x86_kernel_ptables, guard_page, pte,
page_pool_get, NULL);
/* Literally should never happen */
__ASSERT(ret == 0, "stack guard mapping failed for %p", guard_page);
@ -858,7 +858,7 @@ static void thread_map(struct k_thread *thread, void *ptr, size_t size,
/* Get the kernel's PTE value for a particular virtual address */
static pentry_t kernel_page_map_get(void *virt)
{
pentry_t *table = &z_x86_kernel_ptables;
pentry_t *table = z_x86_kernel_ptables;
for (int level = 0; level < NUM_LEVELS; level++) {
pentry_t entry = get_entry(table, virt, level);
@ -961,7 +961,7 @@ static void setup_thread_tables(struct k_thread *thread,
pentry_t *thread_ptables)
{
/* Copy top-level structure verbatim */
(void)memcpy(thread_ptables, &z_x86_kernel_ptables, table_size(0));
(void)memcpy(thread_ptables, &z_x86_kernel_ptables[0], table_size(0));
/* Proceed through linked structure levels, and for all system RAM
* virtual addresses, create copies of all relevant tables.
@ -985,7 +985,7 @@ static void setup_thread_tables(struct k_thread *thread,
level - 1);
/* Master table contents, which we make a copy of */
master_table = page_table_get(&z_x86_kernel_ptables,
master_table = page_table_get(z_x86_kernel_ptables,
virt, level);
/* Pulled out of reserved memory in the stack object */

View file

@ -147,7 +147,7 @@ static inline pentry_t *z_x86_page_tables_get(void)
/* Kernel's page table. This is in CR3 for all supervisor threads.
* if KPTI is enabled, we switch to this when handling exceptions or syscalls
*/
extern pentry_t z_x86_kernel_ptables;
extern pentry_t z_x86_kernel_ptables[];
/* Get the page tables used by this thread during normal execution */
static inline pentry_t *z_x86_thread_page_tables_get(struct k_thread *thread)
@ -155,7 +155,7 @@ static inline pentry_t *z_x86_thread_page_tables_get(struct k_thread *thread)
#ifdef CONFIG_USERSPACE
return (pentry_t *)(thread->arch.ptables);
#else
return &z_x86_kernel_ptables;
return z_x86_kernel_ptables;
#endif
}
#endif /* ZEPHYR_ARCH_X86_INCLUDE_X86_MMU_H */