@@ -1032,7 +1032,7 @@ static int xenmem_add_to_physmap_one(
return rc;
}
- maddr = p2m_lookup(od, pfn_to_paddr(idx));
+ maddr = p2m_lookup(od, pfn_to_paddr(idx), NULL);
if ( maddr == INVALID_PADDR )
{
dump_p2m_lookup(od, pfn_to_paddr(idx));
@@ -72,11 +72,17 @@ static lpae_t *p2m_map_first(struct p2m_domain *p2m, paddr_t addr)
* There are no processor functions to do a stage 2 only lookup therefore we
* do a a software walk.
*/
-paddr_t p2m_lookup(struct domain *d, paddr_t paddr)
+paddr_t p2m_lookup(struct domain *d, paddr_t paddr, p2m_type_t *t)
{
struct p2m_domain *p2m = &d->arch.p2m;
lpae_t pte, *first = NULL, *second = NULL, *third = NULL;
paddr_t maddr = INVALID_PADDR;
+ p2m_type_t _t;
+
+ /* Allow t to be NULL */
+ t = t ?: &_t;
+
+ *t = p2m_invalid;
spin_lock(&p2m->lock);
@@ -102,7 +108,10 @@ paddr_t p2m_lookup(struct domain *d, paddr_t paddr)
done:
if ( pte.p2m.valid )
+ {
maddr = (pte.bits & PADDR_MASK & PAGE_MASK) | (paddr & ~PAGE_MASK);
+ *t = pte.p2m.type;
+ }
if (third) unmap_domain_page(third);
if (second) unmap_domain_page(second);
@@ -511,7 +520,7 @@ err:
unsigned long gmfn_to_mfn(struct domain *d, unsigned long gpfn)
{
- paddr_t p = p2m_lookup(d, pfn_to_paddr(gpfn));
+ paddr_t p = p2m_lookup(d, pfn_to_paddr(gpfn), NULL);
return p >> PAGE_SHIFT;
}
@@ -1267,7 +1267,7 @@ void dump_guest_s1_walk(struct domain *d, vaddr_t addr)
printk("dom%d VA 0x%08"PRIvaddr"\n", d->domain_id, addr);
printk(" TTBCR: 0x%08"PRIregister"\n", ttbcr);
printk(" TTBR0: 0x%016"PRIx64" = 0x%"PRIpaddr"\n",
- ttbr0, p2m_lookup(d, ttbr0 & PAGE_MASK));
+ ttbr0, p2m_lookup(d, ttbr0 & PAGE_MASK, NULL));
if ( ttbcr & TTBCR_EAE )
{
@@ -1280,7 +1280,7 @@ void dump_guest_s1_walk(struct domain *d, vaddr_t addr)
return;
}
- paddr = p2m_lookup(d, ttbr0 & PAGE_MASK);
+ paddr = p2m_lookup(d, ttbr0 & PAGE_MASK, NULL);
if ( paddr == INVALID_PADDR )
{
printk("Failed TTBR0 maddr lookup\n");
@@ -1295,7 +1295,7 @@ void dump_guest_s1_walk(struct domain *d, vaddr_t addr)
!(first[offset] & 0x2) )
goto done;
- paddr = p2m_lookup(d, first[offset] & PAGE_MASK);
+ paddr = p2m_lookup(d, first[offset] & PAGE_MASK, NULL);
if ( paddr == INVALID_PADDR )
{
@@ -58,7 +58,7 @@ int p2m_alloc_table(struct domain *d);
void p2m_load_VTTBR(struct domain *d);
/* Look up the MFN corresponding to a domain's PFN. */
-paddr_t p2m_lookup(struct domain *d, paddr_t gpfn);
+paddr_t p2m_lookup(struct domain *d, paddr_t gpfn, p2m_type_t *t);
/* Setup p2m RAM mapping for domain d from start-end. */
int p2m_populate_ram(struct domain *d, paddr_t start, paddr_t end);