|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH v3 2/2] 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.
Fixes: 192c4dabc344 ("domctl and p2m changes for PCI passthru")
Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
Acked-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
---
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.
---
v2: Re-base over change to earlier patch.
--- a/xen/arch/x86/domctl.c
+++ b/xen/arch/x86/domctl.c
@@ -728,12 +728,14 @@ long arch_do_domctl(
"ioport_map:remove: %pd gport=%x mport=%x nr=%x\n",
d, 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);
@@ -746,14 +748,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 )
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |