|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen master] x86/HVM: more checking for XEN_DOMCTL_ioport_mapping
commit fa61af950bb468c1f2ffe879991316e78c7921e0
Author: Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Wed Jul 22 09:29:48 2026 +0200
Commit: Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Wed Jul 22 09:29:48 2026 +0200
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>
---
xen/arch/x86/domctl.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/xen/arch/x86/domctl.c b/xen/arch/x86/domctl.c
index 3100f4283c..f26990208d 100644
--- 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 )
--
generated by git-patchbot for /home/xen/git/xen.git#master
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |