Implement the protection check required by the pmap_extract_and_hold()

specification.

Reviewed and tested by:	grehan@
This commit is contained in:
alc 2004-07-26 18:10:10 +00:00
parent 73a684d587
commit a47887d1fd
3 changed files with 18 additions and 9 deletions

View File

@ -1057,13 +1057,16 @@ pmap_extract(pmap_t pm, vm_offset_t va)
vm_page_t
pmap_extract_and_hold(pmap_t pmap, vm_offset_t va, vm_prot_t prot)
{
vm_paddr_t pa;
struct pvo_entry *pvo;
vm_page_t m;
m = NULL;
mtx_lock(&Giant);
if ((pa = pmap_extract(pmap, va)) != 0) {
m = PHYS_TO_VM_PAGE(pa);
pvo = pmap_pvo_find_va(pmap, va & ~ADDR_POFF, NULL);
if (pvo != NULL && (pvo->pvo_pte.pte_hi & PTE_VALID) &&
((pvo->pvo_pte.pte_lo & PTE_PP) == PTE_RW ||
(prot & VM_PROT_WRITE) == 0)) {
m = PHYS_TO_VM_PAGE(pvo->pvo_pte.pte_lo & PTE_RPGN);
vm_page_lock_queues();
vm_page_hold(m);
vm_page_unlock_queues();

View File

@ -1057,13 +1057,16 @@ pmap_extract(pmap_t pm, vm_offset_t va)
vm_page_t
pmap_extract_and_hold(pmap_t pmap, vm_offset_t va, vm_prot_t prot)
{
vm_paddr_t pa;
struct pvo_entry *pvo;
vm_page_t m;
m = NULL;
mtx_lock(&Giant);
if ((pa = pmap_extract(pmap, va)) != 0) {
m = PHYS_TO_VM_PAGE(pa);
pvo = pmap_pvo_find_va(pmap, va & ~ADDR_POFF, NULL);
if (pvo != NULL && (pvo->pvo_pte.pte_hi & PTE_VALID) &&
((pvo->pvo_pte.pte_lo & PTE_PP) == PTE_RW ||
(prot & VM_PROT_WRITE) == 0)) {
m = PHYS_TO_VM_PAGE(pvo->pvo_pte.pte_lo & PTE_RPGN);
vm_page_lock_queues();
vm_page_hold(m);
vm_page_unlock_queues();

View File

@ -1057,13 +1057,16 @@ pmap_extract(pmap_t pm, vm_offset_t va)
vm_page_t
pmap_extract_and_hold(pmap_t pmap, vm_offset_t va, vm_prot_t prot)
{
vm_paddr_t pa;
struct pvo_entry *pvo;
vm_page_t m;
m = NULL;
mtx_lock(&Giant);
if ((pa = pmap_extract(pmap, va)) != 0) {
m = PHYS_TO_VM_PAGE(pa);
pvo = pmap_pvo_find_va(pmap, va & ~ADDR_POFF, NULL);
if (pvo != NULL && (pvo->pvo_pte.pte_hi & PTE_VALID) &&
((pvo->pvo_pte.pte_lo & PTE_PP) == PTE_RW ||
(prot & VM_PROT_WRITE) == 0)) {
m = PHYS_TO_VM_PAGE(pvo->pvo_pte.pte_lo & PTE_RPGN);
vm_page_lock_queues();
vm_page_hold(m);
vm_page_unlock_queues();