|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH for-4.22? 9/9] x86/HVM: more checking for XEN_DOMCTL_ioport_mapping
When adding ranges, only alter existing ones when there is an exact match.
Don't accept ranges overlapping existing ones.
When removing ranges, only remove a range if there's an exact match.
Return an error when the range isn't found, and also don't call
ioports_deny_access() in that case.
Fixes: 192c4dabc344 ("domctl and p2m changes for PCI passthru")
Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
---
Should "exact match" perhaps also include the guest port number? I'm
uncertain here as that kind of conflicts with "add" being treated as
"change" when the host port (and now count) match.
--- a/xen/arch/x86/domctl.c
+++ b/xen/arch/x86/domctl.c
@@ -731,14 +731,21 @@ long arch_do_domctl(
write_lock(&hvm->g2m_ioport_lock);
list_for_each_entry(g2m_ioport, &hvm->g2m_ioport_list, list)
- if (g2m_ioport->mport == fmp )
+ {
+ if ( g2m_ioport->mport == fmp && g2m_ioport->np == np )
{
g2m_ioport->gport = fgp;
- g2m_ioport->np = np;
found = 1;
break;
}
- if ( !found )
+ if ( fmp + np >= g2m_ioport->mport &&
+ g2m_ioport->mport + g2m_ioport->np >= fmp )
+ {
+ ret = -EBUSY;
+ break;
+ }
+ }
+ if ( !found && !ret )
{
g2m_ioport = xmalloc(struct g2m_ioport);
if ( !g2m_ioport )
@@ -759,12 +766,14 @@ long arch_do_domctl(
"ioport_map:remove: dom%d gport=%x mport=%x nr=%x\n",
d->domain_id, fgp, fmp, np);
+ ret = -ENOENT;
write_lock(&hvm->g2m_ioport_lock);
list_for_each_entry(g2m_ioport, &hvm->g2m_ioport_list, list)
- if ( g2m_ioport->mport == fmp )
+ if ( g2m_ioport->mport == fmp && g2m_ioport->np == np )
{
list_del(&g2m_ioport->list);
xfree(g2m_ioport);
+ ret = 0;
break;
}
write_unlock(&hvm->g2m_ioport_lock);
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |