Only do the cache flush when there's a p2m type change to propagate,
otherwise there's no change in the p2m effective caching attributes.
If the p2m memory_type_changed hook is not set p2m_memory_type_changed() is
a no-op, no recalculation of caching attributes is needed, nor flushing of
the previous cache contents.
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
void memory_type_changed(struct domain *d)
{
if ( (is_iommu_enabled(d) || cache_flush_permitted(d)) &&
- d->vcpu && d->vcpu[0] )
+ d->vcpu && d->vcpu[0] && p2m_memory_type_changed(d) )
{
- p2m_memory_type_changed(d);
flush_all(FLUSH_CACHE);
}
}
#ifdef CONFIG_HVM
/* Report a change affecting memory types. */
-void p2m_memory_type_changed(struct domain *d);
+bool p2m_memory_type_changed(struct domain *d);
/* Called by p2m code when demand-populating a PoD page */
bool
{
if ( p2m->memory_type_changed )
p2m->memory_type_changed(p2m);
+ else
+ ASSERT_UNREACHABLE();
}
-void p2m_memory_type_changed(struct domain *d)
+bool p2m_memory_type_changed(struct domain *d)
{
struct p2m_domain *hostp2m = p2m_get_hostp2m(d);
+ /*
+ * The p2m memory_type_changed hook will be the same for the host p2m or
+ * the altp2ms, do the check early and return if not set.
+ */
+ if ( !hostp2m->memory_type_changed )
+ return false;
+
p2m_lock(hostp2m);
_memory_type_changed(hostp2m);
}
p2m_unlock(hostp2m);
+
+ return true;
}
int p2m_set_ioreq_server(struct domain *d,