x86/p2m: limit cache flush in memory_type_changed()

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>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
This commit is contained in:
Roger Pau Monne committed 2025-05-15 10:20:14 +02:00
1 parent b7b0459864
commit 50bbacacb8
3 files changed
+14 -4

No files matched your search

+1 -2
View File
@@ -783,9 +783,8 @@ HVM_REGISTER_SAVE_RESTORE(MTRR, hvm_save_mtrr_msr, NULL, hvm_load_mtrr_msr, 1,
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);
}
}
+1 -1
View File
@@ -700,7 +700,7 @@ void p2m_pod_dump_data(struct domain *d);
#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
+12 -1
View File
@@ -126,12 +126,21 @@ static void _memory_type_changed(struct p2m_domain *p2m)
{
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);
@@ -154,6 +163,8 @@ void p2m_memory_type_changed(struct domain *d)
}
p2m_unlock(hostp2m);
return true;
}
int p2m_set_ioreq_server(struct domain *d,
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.