1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-16 10:20:30 +00:00

Implement the protection check required by the pmap_extract_and_hold()

specification.  This enables the elimination of Giant from that function.

Reviewed by:	tegge@
This commit is contained in:
Alan Cox 2004-06-22 19:35:43 +00:00
parent 114bf09149
commit 9eb31321cf
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=130932

View File

@ -860,18 +860,34 @@ pmap_extract(pmap, va)
vm_page_t
pmap_extract_and_hold(pmap_t pmap, vm_offset_t va, vm_prot_t prot)
{
vm_paddr_t pa;
pd_entry_t pde;
pt_entry_t pte;
vm_page_t m;
m = NULL;
mtx_lock(&Giant);
if ((pa = pmap_extract(pmap, va)) != 0) {
m = PHYS_TO_VM_PAGE(pa);
vm_page_lock_queues();
vm_page_hold(m);
vm_page_unlock_queues();
if (pmap == NULL)
return (m);
vm_page_lock_queues();
PMAP_LOCK(pmap);
pde = *pmap_pde(pmap, va);
if (pde != 0) {
if (pde & PG_PS) {
if ((pde & PG_RW) || (prot & VM_PROT_WRITE) == 0) {
m = PHYS_TO_VM_PAGE((pde & ~PDRMASK) |
(va & PDRMASK));
vm_page_hold(m);
}
} else {
pte = *pmap_pte_quick(pmap, va);
if (pte != 0 &&
((pte & PG_RW) || (prot & VM_PROT_WRITE) == 0)) {
m = PHYS_TO_VM_PAGE(pte & PG_FRAME);
vm_page_hold(m);
}
}
}
mtx_unlock(&Giant);
vm_page_unlock_queues();
PMAP_UNLOCK(pmap);
return (m);
}