diff options
-rw-r--r-- | arch/x86/include/asm/pgtable_types.h | 2 | ||||
-rw-r--r-- | arch/x86/mm/fault.c | 7 | ||||
-rw-r--r-- | arch/x86/mm/pageattr.c | 12 |
3 files changed, 16 insertions, 5 deletions
diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h index 1aa9ccd43223..24ae4211ba34 100644 --- a/arch/x86/include/asm/pgtable_types.h +++ b/arch/x86/include/asm/pgtable_types.h | |||
@@ -382,6 +382,8 @@ static inline void update_page_count(int level, unsigned long pages) { } | |||
382 | * as a pte too. | 382 | * as a pte too. |
383 | */ | 383 | */ |
384 | extern pte_t *lookup_address(unsigned long address, unsigned int *level); | 384 | extern pte_t *lookup_address(unsigned long address, unsigned int *level); |
385 | extern pte_t *lookup_address_in_pgd(pgd_t *pgd, unsigned long address, | ||
386 | unsigned int *level); | ||
385 | extern phys_addr_t slow_virt_to_phys(void *__address); | 387 | extern phys_addr_t slow_virt_to_phys(void *__address); |
386 | extern int kernel_map_pages_in_pgd(pgd_t *pgd, u64 pfn, unsigned long address, | 388 | extern int kernel_map_pages_in_pgd(pgd_t *pgd, u64 pfn, unsigned long address, |
387 | unsigned numpages, unsigned long page_flags); | 389 | unsigned numpages, unsigned long page_flags); |
diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c index 6dea040cc3a1..6055a2001b27 100644 --- a/arch/x86/mm/fault.c +++ b/arch/x86/mm/fault.c | |||
@@ -584,8 +584,13 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code, | |||
584 | 584 | ||
585 | if (error_code & PF_INSTR) { | 585 | if (error_code & PF_INSTR) { |
586 | unsigned int level; | 586 | unsigned int level; |
587 | pgd_t *pgd; | ||
588 | pte_t *pte; | ||
587 | 589 | ||
588 | pte_t *pte = lookup_address(address, &level); | 590 | pgd = __va(read_cr3() & PHYSICAL_PAGE_MASK); |
591 | pgd += pgd_index(address); | ||
592 | |||
593 | pte = lookup_address_in_pgd(pgd, address, &level); | ||
589 | 594 | ||
590 | if (pte && pte_present(*pte) && !pte_exec(*pte)) | 595 | if (pte && pte_present(*pte) && !pte_exec(*pte)) |
591 | printk(nx_warning, from_kuid(&init_user_ns, current_uid())); | 596 | printk(nx_warning, from_kuid(&init_user_ns, current_uid())); |
diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c index b3b19f46c016..14c656f0483b 100644 --- a/arch/x86/mm/pageattr.c +++ b/arch/x86/mm/pageattr.c | |||
@@ -323,8 +323,12 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address, | |||
323 | return prot; | 323 | return prot; |
324 | } | 324 | } |
325 | 325 | ||
326 | static pte_t *__lookup_address_in_pgd(pgd_t *pgd, unsigned long address, | 326 | /* |
327 | unsigned int *level) | 327 | * Lookup the page table entry for a virtual address in a specific pgd. |
328 | * Return a pointer to the entry and the level of the mapping. | ||
329 | */ | ||
330 | pte_t *lookup_address_in_pgd(pgd_t *pgd, unsigned long address, | ||
331 | unsigned int *level) | ||
328 | { | 332 | { |
329 | pud_t *pud; | 333 | pud_t *pud; |
330 | pmd_t *pmd; | 334 | pmd_t *pmd; |
@@ -365,7 +369,7 @@ static pte_t *__lookup_address_in_pgd(pgd_t *pgd, unsigned long address, | |||
365 | */ | 369 | */ |
366 | pte_t *lookup_address(unsigned long address, unsigned int *level) | 370 | pte_t *lookup_address(unsigned long address, unsigned int *level) |
367 | { | 371 | { |
368 | return __lookup_address_in_pgd(pgd_offset_k(address), address, level); | 372 | return lookup_address_in_pgd(pgd_offset_k(address), address, level); |
369 | } | 373 | } |
370 | EXPORT_SYMBOL_GPL(lookup_address); | 374 | EXPORT_SYMBOL_GPL(lookup_address); |
371 | 375 | ||
@@ -373,7 +377,7 @@ static pte_t *_lookup_address_cpa(struct cpa_data *cpa, unsigned long address, | |||
373 | unsigned int *level) | 377 | unsigned int *level) |
374 | { | 378 | { |
375 | if (cpa->pgd) | 379 | if (cpa->pgd) |
376 | return __lookup_address_in_pgd(cpa->pgd + pgd_index(address), | 380 | return lookup_address_in_pgd(cpa->pgd + pgd_index(address), |
377 | address, level); | 381 | address, level); |
378 | 382 | ||
379 | return lookup_address(address, level); | 383 | return lookup_address(address, level); |