Commit 426e34cc authored by Matt Fleming's avatar Matt Fleming

x86/mm/pageattr: Always dump the right page table in an oops

Now that we have EFI-specific page tables we need to lookup the pgd when
dumping those page tables, rather than assuming that swapper_pgdir is
the current pgdir.

Remove the double underscore prefix, which is usually reserved for
static functions.
Acked-by: default avatarBorislav Petkov <bp@suse.de>
Signed-off-by: default avatarMatt Fleming <matt.fleming@intel.com>
parent 993c30a0
...@@ -382,6 +382,8 @@ static inline void update_page_count(int level, unsigned long pages) { } ...@@ -382,6 +382,8 @@ static inline void update_page_count(int level, unsigned long pages) { }
* as a pte too. * as a pte too.
*/ */
extern pte_t *lookup_address(unsigned long address, unsigned int *level); extern pte_t *lookup_address(unsigned long address, unsigned int *level);
extern pte_t *lookup_address_in_pgd(pgd_t *pgd, unsigned long address,
unsigned int *level);
extern phys_addr_t slow_virt_to_phys(void *__address); extern phys_addr_t slow_virt_to_phys(void *__address);
extern int kernel_map_pages_in_pgd(pgd_t *pgd, u64 pfn, unsigned long address, extern int kernel_map_pages_in_pgd(pgd_t *pgd, u64 pfn, unsigned long address,
unsigned numpages, unsigned long page_flags); unsigned numpages, unsigned long page_flags);
......
...@@ -584,8 +584,13 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code, ...@@ -584,8 +584,13 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code,
if (error_code & PF_INSTR) { if (error_code & PF_INSTR) {
unsigned int level; unsigned int level;
pgd_t *pgd;
pte_t *pte;
pgd = __va(read_cr3() & PHYSICAL_PAGE_MASK);
pgd += pgd_index(address);
pte_t *pte = lookup_address(address, &level); pte = lookup_address_in_pgd(pgd, address, &level);
if (pte && pte_present(*pte) && !pte_exec(*pte)) if (pte && pte_present(*pte) && !pte_exec(*pte))
printk(nx_warning, from_kuid(&init_user_ns, current_uid())); printk(nx_warning, from_kuid(&init_user_ns, current_uid()));
......
...@@ -323,7 +323,11 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address, ...@@ -323,7 +323,11 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
return prot; return prot;
} }
static pte_t *__lookup_address_in_pgd(pgd_t *pgd, unsigned long address, /*
* Lookup the page table entry for a virtual address in a specific pgd.
* Return a pointer to the entry and the level of the mapping.
*/
pte_t *lookup_address_in_pgd(pgd_t *pgd, unsigned long address,
unsigned int *level) unsigned int *level)
{ {
pud_t *pud; pud_t *pud;
...@@ -365,7 +369,7 @@ static pte_t *__lookup_address_in_pgd(pgd_t *pgd, unsigned long address, ...@@ -365,7 +369,7 @@ static pte_t *__lookup_address_in_pgd(pgd_t *pgd, unsigned long address,
*/ */
pte_t *lookup_address(unsigned long address, unsigned int *level) pte_t *lookup_address(unsigned long address, unsigned int *level)
{ {
return __lookup_address_in_pgd(pgd_offset_k(address), address, level); return lookup_address_in_pgd(pgd_offset_k(address), address, level);
} }
EXPORT_SYMBOL_GPL(lookup_address); EXPORT_SYMBOL_GPL(lookup_address);
...@@ -373,7 +377,7 @@ static pte_t *_lookup_address_cpa(struct cpa_data *cpa, unsigned long address, ...@@ -373,7 +377,7 @@ static pte_t *_lookup_address_cpa(struct cpa_data *cpa, unsigned long address,
unsigned int *level) unsigned int *level)
{ {
if (cpa->pgd) if (cpa->pgd)
return __lookup_address_in_pgd(cpa->pgd + pgd_index(address), return lookup_address_in_pgd(cpa->pgd + pgd_index(address),
address, level); address, level);
return lookup_address(address, level); return lookup_address(address, level);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment