From: Jan Beulich <jbeulich@suse.com>
To: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Cc: "Daniel Smith" <dpsmith@apertussolutions.com>,
"Andrew Cooper" <andrew.cooper3@citrix.com>,
"Teddy Astie" <teddy.astie@vates.tech>,
"Roger Pau Monné" <roger@xenproject.org>
Subject: [PATCH v2 09/14] XSM: fold xsm_{,un}map_domain_irq() hooks
Date: Mon, 17 Aug 2026 10:55:34 +0200 [thread overview]
Message-ID: <9fa10fe2-8bd6-4652-b3ff-0aa49005e411@suse.com> (raw)
In-Reply-To: <ef09b072-c935-459e-bf8b-81c96ff9cc46@suse.com>
Like other resource management hooks they are (now) mainly different in
"add resource" vs "remove resource". Hence like in other cases a single
hook can easily serve both purposes, with minor tweaking of
flask_map_domain_irq(). While adjusting that function, also defer the
setting of local variables only needed in the "map" case.
Rename hook and functions to fit xsm_{io{mem,port},pirq}_mapping().
Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
v2: Fix inverted part of conditional in flask_map_domain_irq(). Rename
hook, functions, and new parameter.
--- a/xen/arch/arm/domctl.c
+++ b/xen/arch/arm/domctl.c
@@ -100,7 +100,7 @@ long arch_do_domctl(struct xen_domctl *d
* done by the 2 hypercalls for consistency with other
* architectures.
*/
- rc = xsm_map_domain_irq(XSM_HOOK, d, irq, NULL);
+ rc = xsm_irq_mapping(XSM_HOOK, d, irq, NULL, true);
if ( rc )
return rc;
--- a/xen/arch/x86/irq.c
+++ b/xen/arch/x86/irq.c
@@ -2214,7 +2214,7 @@ int map_domain_pirq(
return 0;
}
- ret = xsm_map_domain_irq(XSM_HOOK, d, irq, msi ? &msi->sbdf : NULL);
+ ret = xsm_irq_mapping(XSM_HOOK, d, irq, msi ? &msi->sbdf : NULL, true);
if ( ret )
{
dprintk(XENLOG_G_ERR, "dom%d: could not permit access to irq %d mapping to pirq %d\n",
@@ -2441,8 +2441,8 @@ int unmap_domain_pirq(struct domain *d,
* domain. Skip the XSM check since this is a Xen-initiated action.
*/
if ( !d->is_dying )
- ret = xsm_unmap_domain_irq(XSM_HOOK, d, irq,
- msi_desc ? &msi_desc->dev->sbdf : NULL);
+ ret = xsm_irq_mapping(XSM_HOOK, d, irq,
+ msi_desc ? &msi_desc->dev->sbdf : NULL, false);
if ( ret )
goto done;
--- a/xen/include/xsm/dummy.h
+++ b/xen/include/xsm/dummy.h
@@ -469,8 +469,9 @@ static XSM_INLINE int xsm_pirq_mapping(
#endif /* CONFIG_HAS_PIRQ */
-static XSM_INLINE int xsm_map_domain_irq(
- XSM_DEFAULT_ARG struct domain *d, int irq, const pci_sbdf_t *sbdf)
+static XSM_INLINE int xsm_irq_mapping(
+ XSM_DEFAULT_ARG struct domain *d, int irq, const pci_sbdf_t *sbdf,
+ bool map)
{
XSM_ASSERT_ACTION(XSM_HOOK);
return xsm_default_action(action, current->domain, d);
@@ -490,13 +491,6 @@ static XSM_INLINE int xsm_unbind_pt_irq(
return xsm_default_action(action, current->domain, d);
}
-static XSM_INLINE int xsm_unmap_domain_irq(
- XSM_DEFAULT_ARG struct domain *d, int irq, const pci_sbdf_t *sbdf)
-{
- XSM_ASSERT_ACTION(XSM_HOOK);
- return xsm_default_action(action, current->domain, d);
-}
-
static XSM_INLINE int xsm_irq_permission(
XSM_DEFAULT_ARG struct domain *d, int pirq, bool allow)
{
--- a/xen/include/xsm/hooks.h
+++ b/xen/include/xsm/hooks.h
@@ -71,8 +71,7 @@ XSM_HOOK(int, schedop_shutdown, struct d
XSM_HOOK(int, pirq_mapping, struct domain *, bool)
#endif
-XSM_HOOK(int, map_domain_irq, struct domain *, int, const pci_sbdf_t *)
-XSM_HOOK(int, unmap_domain_irq, struct domain *, int, const pci_sbdf_t *)
+XSM_HOOK(int, irq_mapping, struct domain *, int, const pci_sbdf_t *, bool)
XSM_HOOK(int, bind_pt_irq, struct domain *, struct xen_domctl_bind_pt_irq *)
XSM_HOOK(int, unbind_pt_irq, struct domain *, struct xen_domctl_bind_pt_irq *)
--- a/xen/xsm/flask/hooks.c
+++ b/xen/xsm/flask/hooks.c
@@ -1062,13 +1062,12 @@ static uint32_t flask_iommu_resource_use
return perm;
}
-static int cf_check flask_map_domain_irq(
- struct domain *d, int irq, const pci_sbdf_t *sbdf)
+static int cf_check flask_irq_mapping(
+ struct domain *d, int irq, const pci_sbdf_t *sbdf, bool map)
{
- uint32_t sid, dsid;
+ uint32_t sid, dsid, dperm;
int rc = -EPERM;
struct avc_audit_data ad;
- uint32_t dperm = flask_iommu_resource_use_perm(d);
if ( irq >= nr_static_irqs && sbdf )
rc = flask_map_domain_msi(d, irq, *sbdf, &sid, &ad);
@@ -1078,33 +1077,16 @@ static int cf_check flask_map_domain_irq
if ( rc )
return rc;
- dsid = domain_sid(d);
-
- rc = avc_current_has_perm(sid, SECCLASS_RESOURCE, RESOURCE__ADD_IRQ, &ad);
- if ( rc )
+ rc = avc_current_has_perm(sid, SECCLASS_RESOURCE,
+ map ? RESOURCE__ADD_IRQ : RESOURCE__REMOVE_IRQ,
+ &ad);
+ if ( rc || !map )
return rc;
- rc = avc_has_perm(dsid, sid, SECCLASS_RESOURCE, dperm, &ad);
- return rc;
-}
-
-static int cf_check flask_unmap_domain_irq(
- struct domain *d, int irq, const pci_sbdf_t *sbdf)
-{
- uint32_t sid;
- int rc = -EPERM;
- struct avc_audit_data ad;
-
- if ( irq >= nr_static_irqs && sbdf )
- rc = flask_map_domain_msi(d, irq, *sbdf, &sid, &ad);
- else
- rc = get_irq_sid(irq, &sid, &ad);
-
- if ( rc )
- return rc;
+ dsid = domain_sid(d);
+ dperm = flask_iommu_resource_use_perm(d);
- rc = avc_current_has_perm(sid, SECCLASS_RESOURCE, RESOURCE__REMOVE_IRQ, &ad);
- return rc;
+ return avc_has_perm(dsid, sid, SECCLASS_RESOURCE, dperm, &ad);
}
static int cf_check flask_bind_pt_irq(
next prev parent reply other threads:[~2026-08-17 8:55 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-17 8:49 [PATCH v2 00/14] XSM: follow-on to XSAs 492 and 499 Jan Beulich
2026-08-17 8:51 ` [PATCH v2 01/14] XSM: make xsm_default_action() const-correct Jan Beulich
2026-08-17 8:51 ` [PATCH v2 02/14] XSM: convert "allow" (Flask: "access") parameters to bool Jan Beulich
2026-08-17 8:52 ` [PATCH v2 03/14] x86/mm: get_page_from_l1e() is PV-or-shadow-only Jan Beulich
2026-08-17 8:52 ` [PATCH v2 04/14] x86: restrict PHYSDEVOP_* when PV=n Jan Beulich
2026-08-17 8:53 ` [PATCH v2 05/14] XSM: make Argo hooks well-formed ones Jan Beulich
2026-08-17 8:53 ` [PATCH v2 06/14] XSM: fold xsm_{,un}map_domain_pirq() hooks Jan Beulich
2026-08-17 8:54 ` [PATCH v2 07/14] x86: type-correct last parameter of map_domain_pirq() Jan Beulich
2026-08-17 8:54 ` [PATCH v2 08/14] XSM: pass just SBDF to xsm_{,un}map_domain_irq() Jan Beulich
2026-08-17 8:55 ` Jan Beulich [this message]
2026-08-17 8:56 ` [PATCH v2 10/14] XSM: fold xsm_{,un}bind_pt_irq() hooks Jan Beulich
2026-08-17 8:56 ` [PATCH v2 11/14] XSM: convert remaining event channel hooks Jan Beulich
2026-08-17 8:57 ` [PATCH v2 12/14] XSM: convert remaining domain-related hooks Jan Beulich
2026-08-17 8:58 ` [PATCH v2 13/14] XSM: convert remaining miscellaneous hooks Jan Beulich
2026-08-17 8:58 ` [PATCH RFC v2 14/14] XSM: avoid fragile assumptions in xsm_fixup_ops() Jan Beulich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9fa10fe2-8bd6-4652-b3ff-0aa49005e411@suse.com \
--to=jbeulich@suse.com \
--cc=andrew.cooper3@citrix.com \
--cc=dpsmith@apertussolutions.com \
--cc=roger@xenproject.org \
--cc=teddy.astie@vates.tech \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.