While in most cases code ahead of the invocation of set_gpfn_from_mfn()
deals with shared pages, at least in set_typed_p2m_entry() I can't spot
such handling (it's entirely possible there's code missing there). Let's
try to play safe and add an extra check.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
void set_gpfn_from_mfn(unsigned long mfn, unsigned long pfn)
{
- const struct domain *d = page_get_owner(mfn_to_page(_mfn(mfn)));
- unsigned long entry = (d && (d == dom_cow)) ? SHARED_M2P_ENTRY : pfn;
+ unsigned long entry = pfn;
if ( unlikely(!machine_to_phys_mapping_valid) )
return;
+ if ( entry != INVALID_M2P_ENTRY )
+ {
+ const struct domain *d = page_get_owner(mfn_to_page(_mfn(mfn)));
+
+ if ( d && (d == dom_cow) )
+ entry = SHARED_M2P_ENTRY;
+ }
+
if ( opt_pv32 &&
mfn < (RDWR_COMPAT_MPT_VIRT_END - RDWR_COMPAT_MPT_VIRT_START) / 4 )
compat_machine_to_phys_mapping[mfn] = entry;