Return -EOPNOTSUPP when XEN_DOMCTL_set_access_required command is invoked
while VM events and monitoring support is disabled.

Signed-off-by: Milan Djokic <[email protected]>
---
 xen/common/domctl.c | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/xen/common/domctl.c b/xen/common/domctl.c
index 159864bc99..5284524b42 100644
--- a/xen/common/domctl.c
+++ b/xen/common/domctl.c
@@ -787,19 +787,22 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) 
u_domctl)
             copyback = true;
         break;
 
-#ifdef CONFIG_VM_EVENT
     case XEN_DOMCTL_set_access_required:
-        if ( unlikely(current->domain == d) ) /* no domain_pause() */
-            ret = -EPERM;
+        if ( !IS_ENABLED(CONFIG_VM_EVENT) )
+            ret = -EOPNOTSUPP;
         else
         {
-            domain_pause(d);
-            arch_p2m_set_access_required(d,
-                op->u.access_required.access_required);
-            domain_unpause(d);
+            if ( unlikely(current->domain == d) ) /* no domain_pause() */
+                ret = -EPERM;
+            else
+            {
+                domain_pause(d);
+                arch_p2m_set_access_required(d,
+                    op->u.access_required.access_required);
+                domain_unpause(d);
+            }
         }
         break;
-#endif
 
     case XEN_DOMCTL_set_virq_handler:
         ret = set_global_virq_handler(d, op->u.set_virq_handler.virq);
-- 
2.43.0

Reply via email to