[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH 2/4] x86/P2M: relax guarding of MMIO entries
On 30/08/2021 14:02, Jan Beulich wrote: > One of the changes comprising the fixes for XSA-378 disallows replacing > MMIO mappings by unintended (for this purpose) code paths. Drop the brackets. > At least in > the case of PVH Dom0 hitting an RMRR covered by an E820 ACPI region, > this is too strict. Generally short-circuit requests establishing the > same kind of mapping that's already in place. > > Further permit "access" to differ in the "executable" attribute. While > ideally only ROM regions would get mapped with X set, getting there is > quite a bit of work. Therefore, as a temporary measure, permit X to > vary. For Dom0 the more permissive of the types will be used, while for > DomU it'll be the more restrictive one. Split behaviour between dom0 and domU based on types alone cannot possibly be correct. DomU's need to execute ROMs too, and this looks like will malfunction if a ROM ends up in the region that HVMLoader relocated RAM from. As this is a temporary bodge emergency bugfix, don't try to be clever - just take the latest access. > While there, also add a log message to the other domain_crash() > invocation that did prevent PVH Dom0 from coming up after the XSA-378 > changes. > > Fixes: 753cb68e6530 ("x86/p2m: guard (in particular) identity mapping > entries") > Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx> > > --- a/xen/arch/x86/mm/p2m.c > +++ b/xen/arch/x86/mm/p2m.c > @@ -958,9 +958,13 @@ guest_physmap_add_entry(struct domain *d > if ( p2m_is_special(ot) ) > { > /* Don't permit unmapping grant/foreign/direct-MMIO this way. */ > - domain_crash(d); > p2m_unlock(p2m); > - > + printk(XENLOG_G_ERR > + "%pd: GFN %lx (%lx:%u:%u) -> (%lx:%u:%u) not permitted\n", type and access need to be rendered in hex, or you need to use 0x prefixes to distinguish the two bases. Also, use commas rather than colons. Visually, this is ambiguous with PCI BDFs, and commas match tuple notation in most programming languages which is the construct you're trying to represent. Same below. > + d, gfn_x(gfn) + i, > + mfn_x(omfn), ot, a, > + mfn_x(mfn) + i, t, p2m->default_access); > + domain_crash(d); > return -EPERM; > } > else if ( p2m_is_ram(ot) && !p2m_is_paged(ot) ) > @@ -1302,9 +1306,50 @@ static int set_typed_p2m_entry(struct do > } > if ( p2m_is_special(ot) ) > { > - gfn_unlock(p2m, gfn, order); > - domain_crash(d); > - return -EPERM; > + bool done = false, bad = true; > + > + /* Special-case (almost) identical mappings. */ > + if ( mfn_eq(mfn, omfn) && gfn_p2mt == ot ) > + { > + /* > + * For MMIO allow X to differ in the requests (to cover for > + * set_identity_p2m_entry() and set_mmio_p2m_entry() differing in > + * the way they specify "access"). For the hardware domain put > (or > + * leave) in place the more permissive of the two possibilities, > + * while for DomU-s go with the more restrictive variant. This comment needs to identify clearly that it is a temporary bodge intended to be removed. ~Andrew > + */ > + if ( gfn_p2mt == p2m_mmio_direct && > + access <= p2m_access_rwx && > + (access ^ a) == p2m_access_x ) > + { > + if ( is_hardware_domain(d) ) > + access |= p2m_access_x; > + else > + access &= ~p2m_access_x; > + bad = access == p2m_access_n; > + } > + > + if ( access == a ) > + done = true; > + } > + > + if ( done ) > + { > + gfn_unlock(p2m, gfn, order); > + return 0; > + } > + > + if ( bad ) > + { > + gfn_unlock(p2m, gfn, order); > + printk(XENLOG_G_ERR > + "%pd: GFN %lx (%lx:%u:%u:%u) -> (%lx:%u:%u:%u) not > permitted\n", > + d, gfn_l, > + mfn_x(omfn), cur_order, ot, a, > + mfn_x(mfn), order, gfn_p2mt, access); > + domain_crash(d); > + return -EPERM; > + } > } > else if ( p2m_is_ram(ot) ) > { >
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |