powerpc/pmap: Tighten condition for removing tracked pages in Book-E pmap

There are cases where there's no vm_page_t structure for a given physical
address, such as the CCSR.  In this case, trying to obtain the
md.page_tracked struct member would lead to a NULL dereference, and panic.
Tighten this up by checking for kernel_pmap AND that the page structure
actually exists before dereferencing.  The flag can only be set when it's
tracked in the kernel pmap anyway.

MFC after:	3 weeks
This commit is contained in:
Justin Hibbits 2019-10-13 19:33:00 +00:00
parent d6e23cf0cf
commit ec17d5e06a
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=353481

View File

@ -1177,7 +1177,7 @@ pte_remove(mmu_t mmu, pmap_t pmap, vm_offset_t va, u_int8_t flags)
/* Remove pv_entry from pv_list. */
pv_remove(pmap, va, m);
} else if (m->md.pv_tracked) {
} else if (pmap == kernel_pmap && m && m->md.pv_tracked) {
pv_remove(pmap, va, m);
if (TAILQ_EMPTY(&m->md.pv_list))
m->md.pv_tracked = false;
@ -1373,7 +1373,7 @@ pte_remove(mmu_t mmu, pmap_t pmap, vm_offset_t va, uint8_t flags)
vm_page_aflag_set(m, PGA_REFERENCED);
pv_remove(pmap, va, m);
} else if (m->md.pv_tracked) {
} else if (pmap == kernel_pmap && m && m->md.pv_tracked) {
/*
* Always pv_insert()/pv_remove() on MPC85XX, in case DPAA is
* used. This is needed by the NCSW support code for fast