[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 20/24] XSM: fold xsm_{,un}map_domain_pirq() hooks


  • To: Jan Beulich <jbeulich@xxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: "Daniel P. Smith" <dpsmith@xxxxxxxxxxxxxxxxxxxx>
  • Date: Wed, 5 Aug 2026 21:10:07 -0400
  • Arc-authentication-results: i=1; mx.zohomail.com; dkim=pass header.i=apertussolutions.com; spf=pass smtp.mailfrom=dpsmith@xxxxxxxxxxxxxxxxxxxx; dmarc=pass header.from=<dpsmith@xxxxxxxxxxxxxxxxxxxx>
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785978606; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:Subject:Subject:To:To:Message-Id:Reply-To; bh=WOVbCK6Sw64aXSe6a9720k6wPznzFto4aLH7lBPPGaE=; b=G1h2+wvyuBFGDSqU3NFu70bhzWaA3apVhXiJy6s+IK8aW1Dg/4Xd0sNFfbDX4nDJ8DNWDMX8FB6OKefUVh4IXYTIL74r6S/7tgFKdLt+9uqf6KZoatjMNox32KjlBFM2szcG1OjlZTJ6JnUI8BeqAWxafHqgPflBFxtRHFi2MOA=
  • Arc-seal: i=1; a=rsa-sha256; t=1785978606; cv=none; d=zohomail.com; s=zohoarc; b=BYDW82AB/c6PR6jHqfSPrXv/7tEAm9cd12rZVgegiYkRmLIT0aBa1eO7gHXtLY35eMuIwVkcGWTnQI9h6/c4lt8RGqEYxIROGdnNy7uzaXrw6iOO6SQY7rv2NZx2BKLDZuA4Nx+ajjZ19MFyWdsxeehjiegCV4dFRBYG3rwOpy0=
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=zoho header.d=apertussolutions.com header.i="dpsmith@xxxxxxxxxxxxxxxxxxxx" header.h="Message-ID:Date:MIME-Version:Subject:To:Cc:From:In-Reply-To:Content-Type:Content-Transfer-Encoding"
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Teddy Astie <teddy.astie@xxxxxxxxxx>, Roger Pau Monné <roger@xxxxxxxxxxxxxx>
  • Delivery-date: Thu, 06 Aug 2026 01:10:20 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 7/28/26 9:23 AM, Jan Beulich wrote:
Like other resource management hooks they are different in just "add
resource" vs "remove resource". Hence like in other cases a single hook
can easily serve both purposes.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>

--- a/xen/arch/x86/physdev.c
+++ b/xen/arch/x86/physdev.c
@@ -109,7 +109,7 @@ int physdev_map_pirq(struct domain *d, i
          return physdev_hvm_map_pirq(d, type, index, pirq_p);
      }
- ret = xsm_map_domain_pirq(XSM_DM_PRIV, d);
+    ret = xsm_map_domain_pirq(XSM_DM_PRIV, d, true);
      if ( ret )
          return ret;
@@ -142,7 +142,7 @@ int physdev_unmap_pirq(struct domain *d,
      int ret = 0;
if ( d != current->domain || !is_hvm_domain(d) || !has_pirq(d) )
-        ret = xsm_unmap_domain_pirq(XSM_DM_PRIV, d);
+        ret = xsm_map_domain_pirq(XSM_DM_PRIV, d, false);
      if ( ret )
          return ret;
--- a/xen/include/xsm/dummy.h
+++ b/xen/include/xsm/dummy.h
@@ -461,14 +461,7 @@ static XSM_INLINE char *xsm_show_irq_sid
#ifdef CONFIG_HAS_PIRQ static XSM_INLINE int xsm_map_domain_pirq(
-    XSM_DEFAULT_ARG struct domain *d)
-{
-    XSM_ASSERT_ACTION(XSM_DM_PRIV);
-    return xsm_default_action(action, current->domain, d);
-}
-
-static XSM_INLINE int xsm_unmap_domain_pirq(
-    XSM_DEFAULT_ARG struct domain *d)
+    XSM_DEFAULT_ARG struct domain *d, bool allow)
  {
      XSM_ASSERT_ACTION(XSM_DM_PRIV);
      return xsm_default_action(action, current->domain, d);
--- a/xen/include/xsm/hooks.h
+++ b/xen/include/xsm/hooks.h
@@ -68,8 +68,7 @@ XSM_HOOK(int, kexec)
  XSM_HOOK(int, schedop_shutdown, struct domain *, struct domain *)
#ifdef CONFIG_HAS_PIRQ
-XSM_HOOK(int, map_domain_pirq, struct domain *)
-XSM_HOOK(int, unmap_domain_pirq, struct domain *)
+XSM_HOOK(int, map_domain_pirq, struct domain *, bool)
  #endif
XSM_HOOK(int, map_domain_irq, struct domain *, int, const void *)
--- a/xen/xsm/flask/hooks.c
+++ b/xen/xsm/flask/hooks.c
@@ -1022,14 +1022,9 @@ static char *cf_check flask_show_irq_sid
#ifdef CONFIG_HAS_PIRQ -static int cf_check flask_map_domain_pirq(struct domain *d)
+static int cf_check flask_map_domain_pirq(struct domain *d, bool access)
  {
-    return current_has_perm(d, SECCLASS_RESOURCE, RESOURCE__ADD);
-}
-
-static int cf_check flask_unmap_domain_pirq(struct domain *d)
-{
-    return current_has_perm(d, SECCLASS_RESOURCE, RESOURCE__REMOVE);
+    return current_has_perm(d, SECCLASS_RESOURCE, resource_to_perm(access));
  }
#endif /* CONFIG_HAS_PIRQ */


I am not opposed to collapsing the calls as long as the semantic is not lost, which I feel the reuse of the xsm_map_domain_pirq does looses it much less provides an opportunity for confusion. Something like xsm_domain_pirq(..., access) makes more semantic sense to me, as it would read, grant domain pirq access T/F.

v/r,
dps





 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.