]> xenbits.xensource.com Git - xen.git/commitdiff
xen/arch/arm: add XSM hook to HVMOP_{get,set}_param
authorDaniel De Graaf <dgdegra@tycho.nsa.gov>
Wed, 30 Jan 2013 10:36:40 +0000 (02:36 -0800)
committerDaniel De Graaf <dgdegra@tycho.nsa.gov>
Wed, 30 Jan 2013 10:36:40 +0000 (02:36 -0800)
This hook is not x86-specific; move it out of CONFIG_X86.

Signed-off-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Keir Fraser <keir@xen.org>
xen/arch/arm/hvm.c
xen/include/xsm/dummy.h
xen/include/xsm/xsm.h
xen/xsm/dummy.c
xen/xsm/flask/hooks.c

index 40f519ef3c8b64414261f7516993b795ba9bef50..63ac79325024b4099ed7c27af348884920dab594 100644 (file)
@@ -30,9 +30,13 @@ long do_hvm_op(unsigned long op, XEN_GUEST_HANDLE_PARAM(void) arg)
         if ( a.index >= HVM_NR_PARAMS )
             return -EINVAL;
 
-        rc = rcu_lock_target_domain_by_id(a.domid, &d);
-        if ( rc != 0 )
-            return rc;
+        d = rcu_lock_domain_by_any_id(a.domid);
+        if ( d == NULL )
+            return -ESRCH;
+
+        rc = xsm_hvm_param(XSM_TARGET, d, op);
+        if ( rc )
+            goto param_fail;
 
         if ( op == HVMOP_set_param )
         {
@@ -44,6 +48,7 @@ long do_hvm_op(unsigned long op, XEN_GUEST_HANDLE_PARAM(void) arg)
             rc = copy_to_guest(arg, &a, 1) ? -EFAULT : 0;
         }
 
+    param_fail:
         rcu_unlock_domain(d);
         break;
     }
index 19bbe19415b07694fab0d95cd83f3aef7181e8b2..025936a5a1f9649a7431ad1c3b2e32e39b0e2348 100644 (file)
@@ -467,16 +467,16 @@ static XSM_INLINE int xsm_remove_from_physmap(XSM_DEFAULT_ARG struct domain *d1,
     return xsm_default_action(action, d1, d2);
 }
 
-#ifdef CONFIG_X86
-static XSM_INLINE int xsm_shadow_control(XSM_DEFAULT_ARG struct domain *d, uint32_t op)
+static XSM_INLINE int xsm_hvm_param(XSM_DEFAULT_ARG struct domain *d, unsigned long op)
 {
-    XSM_ASSERT_ACTION(XSM_HOOK);
+    XSM_ASSERT_ACTION(XSM_TARGET);
     return xsm_default_action(action, current->domain, d);
 }
 
-static XSM_INLINE int xsm_hvm_param(XSM_DEFAULT_ARG struct domain *d, unsigned long op)
+#ifdef CONFIG_X86
+static XSM_INLINE int xsm_shadow_control(XSM_DEFAULT_ARG struct domain *d, uint32_t op)
 {
-    XSM_ASSERT_ACTION(XSM_TARGET);
+    XSM_ASSERT_ACTION(XSM_HOOK);
     return xsm_default_action(action, current->domain, d);
 }
 
index 2399da0a6d0aa5d06775c7b6a9efa87a9fb15631..cba744ce1acb4a2252df5855ae0de23e069613e0 100644 (file)
@@ -129,9 +129,10 @@ struct xsm_operations {
 
     long (*do_xsm_op) (XEN_GUEST_HANDLE_PARAM(xsm_op_t) op);
 
+    int (*hvm_param) (struct domain *d, unsigned long op);
+
 #ifdef CONFIG_X86
     int (*shadow_control) (struct domain *d, uint32_t op);
-    int (*hvm_param) (struct domain *d, unsigned long op);
     int (*hvm_set_pci_intx_level) (struct domain *d);
     int (*hvm_set_isa_irq_level) (struct domain *d);
     int (*hvm_set_pci_link_route) (struct domain *d);
@@ -487,15 +488,15 @@ static inline long xsm_do_xsm_op (XEN_GUEST_HANDLE_PARAM(xsm_op_t) op)
     return xsm_ops->do_xsm_op(op);
 }
 
-#ifdef CONFIG_X86
-static inline int xsm_shadow_control (xsm_default_t def, struct domain *d, uint32_t op)
+static inline int xsm_hvm_param (xsm_default_t def, struct domain *d, unsigned long op)
 {
-    return xsm_ops->shadow_control(d, op);
+    return xsm_ops->hvm_param(d, op);
 }
 
-static inline int xsm_hvm_param (xsm_default_t def, struct domain *d, unsigned long op)
+#ifdef CONFIG_X86
+static inline int xsm_shadow_control (xsm_default_t def, struct domain *d, uint32_t op)
 {
-    return xsm_ops->hvm_param(d, op);
+    return xsm_ops->shadow_control(d, op);
 }
 
 static inline int xsm_hvm_set_pci_intx_level (xsm_default_t def, struct domain *d)
index dcd3e3152636b23c4083564aa2098829ed92408f..6f1e0b4860a5c3635a5150e7a73bef1347815d3e 100644 (file)
@@ -100,6 +100,7 @@ void xsm_fixup_ops (struct xsm_operations *ops)
     set_to_dummy_if_null(ops, page_offline);
     set_to_dummy_if_null(ops, tmem_op);
     set_to_dummy_if_null(ops, tmem_control);
+    set_to_dummy_if_null(ops, hvm_param);
 
     set_to_dummy_if_null(ops, do_xsm_op);
 
@@ -108,7 +109,6 @@ void xsm_fixup_ops (struct xsm_operations *ops)
 
 #ifdef CONFIG_X86
     set_to_dummy_if_null(ops, shadow_control);
-    set_to_dummy_if_null(ops, hvm_param);
     set_to_dummy_if_null(ops, hvm_set_pci_intx_level);
     set_to_dummy_if_null(ops, hvm_set_isa_irq_level);
     set_to_dummy_if_null(ops, hvm_set_pci_link_route);
index 58695884ae0517cd525e71390a4ca2fcd3546f4c..85d009c42b03ec32b5ffed1913b683642d76cf37 100644 (file)
@@ -1068,6 +1068,28 @@ static int flask_remove_from_physmap(struct domain *d1, struct domain *d2)
     return domain_has_perm(d1, d2, SECCLASS_MMU, MMU__PHYSMAP);
 }
 
+static int flask_hvm_param(struct domain *d, unsigned long op)
+{
+    u32 perm;
+
+    switch ( op )
+    {
+    case HVMOP_set_param:
+        perm = HVM__SETPARAM;
+        break;
+    case HVMOP_get_param:
+        perm = HVM__GETPARAM;
+        break;
+    case HVMOP_track_dirty_vram:
+        perm = HVM__TRACKDIRTYVRAM;
+        break;
+    default:
+        perm = HVM__HVMCTL;
+    }
+
+    return current_has_perm(d, SECCLASS_HVM, perm);
+}
+
 #ifdef CONFIG_X86
 static int flask_shadow_control(struct domain *d, uint32_t op)
 {
@@ -1148,28 +1170,6 @@ static int flask_ioport_mapping(struct domain *d, uint32_t start, uint32_t end,
     return flask_ioport_permission(d, start, end, access);
 }
 
-static int flask_hvm_param(struct domain *d, unsigned long op)
-{
-    u32 perm;
-
-    switch ( op )
-    {
-    case HVMOP_set_param:
-        perm = HVM__SETPARAM;
-        break;
-    case HVMOP_get_param:
-        perm = HVM__GETPARAM;
-        break;
-    case HVMOP_track_dirty_vram:
-        perm = HVM__TRACKDIRTYVRAM;
-        break;
-    default:
-        perm = HVM__HVMCTL;
-    }
-
-    return current_has_perm(d, SECCLASS_HVM, perm);
-}
-
 static int flask_hvm_set_pci_intx_level(struct domain *d)
 {
     return current_has_perm(d, SECCLASS_HVM, HVM__PCILEVEL);
@@ -1503,6 +1503,7 @@ static struct xsm_operations flask_ops = {
     .page_offline = flask_page_offline,
     .tmem_op = flask_tmem_op,
     .tmem_control = flask_tmem_control,
+    .hvm_param = flask_hvm_param,
 
     .do_xsm_op = do_flask_op,
 
@@ -1511,7 +1512,6 @@ static struct xsm_operations flask_ops = {
 
 #ifdef CONFIG_X86
     .shadow_control = flask_shadow_control,
-    .hvm_param = flask_hvm_param,
     .hvm_set_pci_intx_level = flask_hvm_set_pci_intx_level,
     .hvm_set_isa_irq_level = flask_hvm_set_isa_irq_level,
     .hvm_set_pci_link_route = flask_hvm_set_pci_link_route,