aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeandro Lupori <luporl@FreeBSD.org>2020-07-15 13:43:48 +0000
committerLeandro Lupori <luporl@FreeBSD.org>2020-07-15 13:43:48 +0000
commit4c0c2fb1ad104accd933525e60f0a65f120a47be (patch)
tree97637a058be06775e1435d3da63ec5bd4274e964
parent8ca1ed33ec8ae8f1ae2737930d15ce3efab07292 (diff)
downloadsrc-4c0c2fb1ad104accd933525e60f0a65f120a47be.tar.gz
src-4c0c2fb1ad104accd933525e60f0a65f120a47be.zip
[PowerPC] Use PVO_PADDR to get the PA from PVO
Use PVO_PADDR macro to get the physical address from a PVO, instead of explicitly ANDing pvo_pte.pa with LPTE_RPGN where it is needed. Besides improving readability, this is needed to support superpages (D25237), where the steps to get the PA from a PVO are different. Reviewed by: markj Sponsored by: Eldorado Research Institute (eldorado.org.br) Differential Revision: https://reviews.freebsd.org/D25654
Notes
Notes: svn path=/head/; revision=363222
-rw-r--r--sys/powerpc/aim/mmu_oea64.c31
1 files changed, 17 insertions, 14 deletions
diff --git a/sys/powerpc/aim/mmu_oea64.c b/sys/powerpc/aim/mmu_oea64.c
index d3703496d027..1310f4992170 100644
--- a/sys/powerpc/aim/mmu_oea64.c
+++ b/sys/powerpc/aim/mmu_oea64.c
@@ -108,6 +108,9 @@ uintptr_t moea64_get_unique_vsid(void);
#define VSID_TO_HASH(vsid) (((vsid) >> 4) & 0xfffff)
#define VSID_HASH_MASK 0x0000007fffffffffULL
+/* Get physical address from PVO. */
+#define PVO_PADDR(pvo) ((pvo)->pvo_pte.pa & LPTE_RPGN)
+
/*
* Locking semantics:
*
@@ -1207,7 +1210,7 @@ moea64_unwire(pmap_t pm, vm_offset_t sva, vm_offset_t eva)
(pvo->pvo_pte.prot & VM_PROT_WRITE)) {
if (refchg < 0)
refchg = LPTE_CHG;
- m = PHYS_TO_VM_PAGE(pvo->pvo_pte.pa & LPTE_RPGN);
+ m = PHYS_TO_VM_PAGE(PVO_PADDR(pvo));
refchg |= atomic_readandclear_32(&m->md.mdpg_attrs);
if (refchg & LPTE_CHG)
@@ -1615,7 +1618,7 @@ moea64_extract(pmap_t pm, vm_offset_t va)
if (pvo == NULL)
pa = 0;
else
- pa = (pvo->pvo_pte.pa & LPTE_RPGN) | (va - PVO_VADDR(pvo));
+ pa = PVO_PADDR(pvo) | (va - PVO_VADDR(pvo));
PMAP_UNLOCK(pm);
return (pa);
@@ -1636,7 +1639,7 @@ moea64_extract_and_hold(pmap_t pmap, vm_offset_t va, vm_prot_t prot)
PMAP_LOCK(pmap);
pvo = moea64_pvo_find_va(pmap, va & ~ADDR_POFF);
if (pvo != NULL && (pvo->pvo_pte.prot & prot) == prot) {
- m = PHYS_TO_VM_PAGE(pvo->pvo_pte.pa & LPTE_RPGN);
+ m = PHYS_TO_VM_PAGE(PVO_PADDR(pvo));
if (!vm_page_wire_mapped(m))
m = NULL;
}
@@ -1943,7 +1946,7 @@ moea64_kextract(vm_offset_t va)
pvo = moea64_pvo_find_va(kernel_pmap, va);
KASSERT(pvo != NULL, ("moea64_kextract: no addr found for %#" PRIxPTR,
va));
- pa = (pvo->pvo_pte.pa & LPTE_RPGN) | (va - PVO_VADDR(pvo));
+ pa = PVO_PADDR(pvo) | (va - PVO_VADDR(pvo));
PMAP_UNLOCK(kernel_pmap);
return (pa);
}
@@ -2269,7 +2272,7 @@ moea64_pvo_protect( pmap_t pm, struct pvo_entry *pvo, vm_prot_t prot)
*/
oldprot = pvo->pvo_pte.prot;
pvo->pvo_pte.prot = prot;
- pg = PHYS_TO_VM_PAGE(pvo->pvo_pte.pa & LPTE_RPGN);
+ pg = PHYS_TO_VM_PAGE(PVO_PADDR(pvo));
/*
* If the PVO is in the page table, update mapping
@@ -2284,7 +2287,7 @@ moea64_pvo_protect( pmap_t pm, struct pvo_entry *pvo, vm_prot_t prot)
if ((pg->oflags & VPO_UNMANAGED) == 0)
vm_page_aflag_set(pg, PGA_EXECUTABLE);
moea64_syncicache(pm, PVO_VADDR(pvo),
- pvo->pvo_pte.pa & LPTE_RPGN, PAGE_SIZE);
+ PVO_PADDR(pvo), PAGE_SIZE);
}
/*
@@ -2648,7 +2651,7 @@ moea64_pvo_remove_from_pmap(struct pvo_entry *pvo)
/* Send RC bits to VM */
if ((pvo->pvo_vaddr & PVO_MANAGED) &&
(pvo->pvo_pte.prot & VM_PROT_WRITE)) {
- pg = PHYS_TO_VM_PAGE(pvo->pvo_pte.pa & LPTE_RPGN);
+ pg = PHYS_TO_VM_PAGE(PVO_PADDR(pvo));
if (pg != NULL) {
refchg |= atomic_readandclear_32(&pg->md.mdpg_attrs);
if (refchg & LPTE_CHG)
@@ -2674,7 +2677,7 @@ moea64_pvo_remove_from_page_locked(struct pvo_entry *pvo,
/*
* Update vm about page writeability/executability if managed
*/
- PV_LOCKASSERT(pvo->pvo_pte.pa & LPTE_RPGN);
+ PV_LOCKASSERT(PVO_PADDR(pvo));
if (pvo->pvo_vaddr & PVO_MANAGED) {
if (m != NULL) {
LIST_REMOVE(pvo, pvo_vlink);
@@ -2694,11 +2697,11 @@ moea64_pvo_remove_from_page(struct pvo_entry *pvo)
vm_page_t pg = NULL;
if (pvo->pvo_vaddr & PVO_MANAGED)
- pg = PHYS_TO_VM_PAGE(pvo->pvo_pte.pa & LPTE_RPGN);
+ pg = PHYS_TO_VM_PAGE(PVO_PADDR(pvo));
- PV_LOCK(pvo->pvo_pte.pa & LPTE_RPGN);
+ PV_LOCK(PVO_PADDR(pvo));
moea64_pvo_remove_from_page_locked(pvo, pg);
- PV_UNLOCK(pvo->pvo_pte.pa & LPTE_RPGN);
+ PV_UNLOCK(PVO_PADDR(pvo));
}
static struct pvo_entry *
@@ -2810,7 +2813,7 @@ moea64_dev_direct_mapped(vm_paddr_t pa, vm_size_t size)
for (pvo = RB_FIND(pvo_tree, &kernel_pmap->pmap_pvo, &key);
ppa < pa + size; ppa += PAGE_SIZE,
pvo = RB_NEXT(pvo_tree, &kernel_pmap->pmap_pvo, pvo)) {
- if (pvo == NULL || (pvo->pvo_pte.pa & LPTE_RPGN) != ppa) {
+ if (pvo == NULL || PVO_PADDR(pvo) != ppa) {
error = EFAULT;
break;
}
@@ -2886,7 +2889,7 @@ moea64_sync_icache(pmap_t pm, vm_offset_t va, vm_size_t sz)
len = MIN(lim - va, sz);
pvo = moea64_pvo_find_va(pm, va & ~ADDR_POFF);
if (pvo != NULL && !(pvo->pvo_pte.pa & LPTE_I)) {
- pa = (pvo->pvo_pte.pa & LPTE_RPGN) | (va & ADDR_POFF);
+ pa = PVO_PADDR(pvo) | (va & ADDR_POFF);
moea64_syncicache(pm, va, pa, len);
}
va += len;
@@ -3005,7 +3008,7 @@ moea64_scan_pmap()
}
}
- pa = pvo->pvo_pte.pa & LPTE_RPGN;
+ pa = PVO_PADDR(pvo);
if (va & PVO_LARGE) {
pa_end = pa + lpsize;