Skip to content

Commit

Permalink
x86/mm/32: implement arch_sync_kernel_mappings()
Browse files Browse the repository at this point in the history
Implement the function to sync changes in vmalloc and ioremap ranges to
all page-tables.

Signed-off-by: Joerg Roedel <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Acked-by: Andy Lutomirski <[email protected]>
Acked-by: Peter Zijlstra (Intel) <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: Christoph Hellwig <[email protected]>
Cc: Dave Hansen <[email protected]>
Cc: "H . Peter Anvin" <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Matthew Wilcox (Oracle) <[email protected]>
Cc: Michal Hocko <[email protected]>
Cc: "Rafael J. Wysocki" <[email protected]>
Cc: Steven Rostedt (VMware) <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Vlastimil Babka <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
joergroedel authored and torvalds committed Jun 2, 2020
1 parent 8e19843 commit 86cf69f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
2 changes: 2 additions & 0 deletions arch/x86/include/asm/pgtable-2level_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ typedef union {

#define SHARED_KERNEL_PMD 0

#define ARCH_PAGE_TABLE_SYNC_MASK PGTBL_PMD_MODIFIED

/*
* traditional i386 two-level paging structure:
*/
Expand Down
2 changes: 2 additions & 0 deletions arch/x86/include/asm/pgtable-3level_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ typedef union {
#define SHARED_KERNEL_PMD (!static_cpu_has(X86_FEATURE_PTI))
#endif

#define ARCH_PAGE_TABLE_SYNC_MASK (SHARED_KERNEL_PMD ? 0 : PGTBL_PMD_MODIFIED)

/*
* PGDIR_SHIFT determines what a top-level page table entry can map
*/
Expand Down
25 changes: 16 additions & 9 deletions arch/x86/mm/fault.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,16 +190,13 @@ static inline pmd_t *vmalloc_sync_one(pgd_t *pgd, unsigned long address)
return pmd_k;
}

static void vmalloc_sync(void)
void arch_sync_kernel_mappings(unsigned long start, unsigned long end)
{
unsigned long address;

if (SHARED_KERNEL_PMD)
return;
unsigned long addr;

for (address = VMALLOC_START & PMD_MASK;
address >= TASK_SIZE_MAX && address < VMALLOC_END;
address += PMD_SIZE) {
for (addr = start & PMD_MASK;
addr >= TASK_SIZE_MAX && addr < VMALLOC_END;
addr += PMD_SIZE) {
struct page *page;

spin_lock(&pgd_lock);
Expand All @@ -210,13 +207,23 @@ static void vmalloc_sync(void)
pgt_lock = &pgd_page_get_mm(page)->page_table_lock;

spin_lock(pgt_lock);
vmalloc_sync_one(page_address(page), address);
vmalloc_sync_one(page_address(page), addr);
spin_unlock(pgt_lock);
}
spin_unlock(&pgd_lock);
}
}

static void vmalloc_sync(void)
{
unsigned long address;

if (SHARED_KERNEL_PMD)
return;

arch_sync_kernel_mappings(VMALLOC_START, VMALLOC_END);
}

void vmalloc_sync_mappings(void)
{
vmalloc_sync();
Expand Down

0 comments on commit 86cf69f

Please sign in to comment.