From a525c5a04a8483ee9217b0be6deb12d665e3fd72 Mon Sep 17 00:00:00 2001 From: "Daniel P. Smith" Date: Thu, 31 Mar 2022 13:20:14 -0700 Subject: [PATCH 1/3] xsm: add ability to elevate a domain to privileged There are now instances where internal hypervisor logic needs to make resource allocation calls that are protected by XSM checks. The internal hypervisor logic is represented a number of system domains which by designed are represented by non-privileged struct domain instances. To enable these logic blocks to function correctly but in a controlled manner, this commit introduces a pair of privilege escalation and demotion functions that will make a system domain privileged and then remove that privilege. Signed-off-by: Daniel P. Smith --- xen/include/xsm/xsm.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/xen/include/xsm/xsm.h b/xen/include/xsm/xsm.h index 3e2b7fe3db..505dfd8308 100644 --- a/xen/include/xsm/xsm.h +++ b/xen/include/xsm/xsm.h @@ -202,6 +202,28 @@ struct xsm_ops { #endif }; +static always_inline int xsm_elevate_priv(struct domain *d) +{ + if ( is_system_domain(d) ) + { + d->is_privileged = true; + return 0; + } + + return -EPERM; +} + +static always_inline int xsm_demote_priv(struct domain *d) +{ + if ( is_system_domain(d) ) + { + d->is_privileged = false; + return 0; + } + + return -EPERM; +} + #ifdef CONFIG_XSM extern struct xsm_ops xsm_ops; -- 2.25.1