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

[Xen-changelog] [xen-unstable] arch/x86: convert platform_hypercall to use XSM


  • To: xen-changelog@xxxxxxxxxxxxxxxxxxx
  • From: Xen patchbot-unstable <patchbot@xxxxxxx>
  • Date: Wed, 16 Jan 2013 08:22:10 +0000
  • Delivery-date: Wed, 16 Jan 2013 08:22:34 +0000
  • List-id: "Change log for Mercurial \(receive only\)" <xen-changelog.lists.xen.org>

# HG changeset patch
# User Daniel De Graaf <dgdegra@xxxxxxxxxxxxx>
# Date 1357899062 0
# Node ID f8156587c7fafb1d708553e83ca569ed8172050b
# Parent  6be26b7bda2f0c2cc86a8c68d0a302fffdeac7ae
arch/x86: convert platform_hypercall to use XSM

The newly introduced xsm_platform_op hook addresses new sub-ops, while
most ops already have their own XSM hooks.

Signed-off-by: Daniel De Graaf <dgdegra@xxxxxxxxxxxxx>
Acked-by: Jan Beulich <jbeulich@xxxxxxxx>
Committed-by: Keir Fraser <keir@xxxxxxx>
---


diff -r 6be26b7bda2f -r f8156587c7fa xen/arch/x86/platform_hypercall.c
--- a/xen/arch/x86/platform_hypercall.c Fri Jan 11 10:10:21 2013 +0000
+++ b/xen/arch/x86/platform_hypercall.c Fri Jan 11 10:11:02 2013 +0000
@@ -66,15 +66,16 @@ ret_t do_platform_op(XEN_GUEST_HANDLE_PA
     ret_t ret = 0;
     struct xen_platform_op curop, *op = &curop;
 
-    if ( !IS_PRIV(current->domain) )
-        return -EPERM;
-
     if ( copy_from_guest(op, u_xenpf_op, 1) )
         return -EFAULT;
 
     if ( op->interface_version != XENPF_INTERFACE_VERSION )
         return -EACCES;
 
+    ret = xsm_platform_op(op->cmd);
+    if ( ret )
+        return ret;
+
     /*
      * Trylock here avoids deadlock with an existing platform critical section
      * which might (for some current or future reason) want to synchronise
@@ -513,6 +514,10 @@ ret_t do_platform_op(XEN_GUEST_HANDLE_PA
     {
         struct xenpf_pcpu_version *ver = &op->u.pcpu_version;
 
+        ret = xsm_getcpuinfo();
+        if ( ret )
+            break;
+
         if ( !get_cpu_maps() )
         {
             ret = -EBUSY;
diff -r 6be26b7bda2f -r f8156587c7fa xen/include/xsm/dummy.h
--- a/xen/include/xsm/dummy.h   Fri Jan 11 10:10:21 2013 +0000
+++ b/xen/include/xsm/dummy.h   Fri Jan 11 10:11:02 2013 +0000
@@ -593,6 +593,13 @@ static XSM_INLINE int xsm_platform_quirk
     return 0;
 }
 
+static XSM_INLINE int xsm_platform_op(uint32_t op)
+{
+    if ( !IS_PRIV(current->domain) )
+        return -EPERM;
+    return 0;
+}
+
 static XSM_INLINE int xsm_firmware_info(void)
 {
     return 0;
diff -r 6be26b7bda2f -r f8156587c7fa xen/include/xsm/xsm.h
--- a/xen/include/xsm/xsm.h     Fri Jan 11 10:10:21 2013 +0000
+++ b/xen/include/xsm/xsm.h     Fri Jan 11 10:11:02 2013 +0000
@@ -159,6 +159,7 @@ struct xsm_operations {
     int (*microcode) (void);
     int (*physinfo) (void);
     int (*platform_quirk) (uint32_t);
+    int (*platform_op) (uint32_t cmd);
     int (*firmware_info) (void);
     int (*efi_call) (void);
     int (*acpi_sleep) (void);
@@ -704,6 +705,11 @@ static inline int xsm_platform_quirk (ui
     return xsm_ops->platform_quirk(quirk);
 }
 
+static inline int xsm_platform_op (uint32_t op)
+{
+    return xsm_ops->platform_op(op);
+}
+
 static inline int xsm_firmware_info (void)
 {
     return xsm_ops->firmware_info();
diff -r 6be26b7bda2f -r f8156587c7fa xen/xsm/dummy.c
--- a/xen/xsm/dummy.c   Fri Jan 11 10:10:21 2013 +0000
+++ b/xen/xsm/dummy.c   Fri Jan 11 10:11:02 2013 +0000
@@ -144,6 +144,7 @@ void xsm_fixup_ops (struct xsm_operation
     set_to_dummy_if_null(ops, microcode);
     set_to_dummy_if_null(ops, physinfo);
     set_to_dummy_if_null(ops, platform_quirk);
+    set_to_dummy_if_null(ops, platform_op);
     set_to_dummy_if_null(ops, firmware_info);
     set_to_dummy_if_null(ops, efi_call);
     set_to_dummy_if_null(ops, acpi_sleep);
diff -r 6be26b7bda2f -r f8156587c7fa xen/xsm/flask/hooks.c
--- a/xen/xsm/flask/hooks.c     Fri Jan 11 10:10:21 2013 +0000
+++ b/xen/xsm/flask/hooks.c     Fri Jan 11 10:11:02 2013 +0000
@@ -1316,6 +1316,38 @@ static int flask_platform_quirk(uint32_t
                         XEN__QUIRK, NULL);
 }
 
+static int flask_platform_op(uint32_t op)
+{
+    switch ( op )
+    {
+    case XENPF_settime:
+    case XENPF_add_memtype:
+    case XENPF_del_memtype:
+    case XENPF_read_memtype:
+    case XENPF_microcode_update:
+    case XENPF_platform_quirk:
+    case XENPF_firmware_info:
+    case XENPF_efi_runtime_call:
+    case XENPF_enter_acpi_sleep:
+    case XENPF_change_freq:
+    case XENPF_getidletime:
+    case XENPF_set_processor_pminfo:
+    case XENPF_get_cpuinfo:
+    case XENPF_get_cpu_version:
+    case XENPF_cpu_online:
+    case XENPF_cpu_offline:
+    case XENPF_cpu_hotadd:
+    case XENPF_mem_hotadd:
+        /* These operations have their own XSM hooks */
+        return 0;
+    case XENPF_core_parking:
+        return domain_has_xen(current->domain, XEN__PM_OP);
+    default:
+        printk("flask_platform_op: Unknown op %d\n", op);
+        return -EPERM;
+    }
+}
+
 static int flask_firmware_info(void)
 {
     return domain_has_xen(current->domain, XEN__FIRMWARE);
@@ -1687,6 +1719,7 @@ static struct xsm_operations flask_ops =
     .microcode = flask_microcode,
     .physinfo = flask_physinfo,
     .platform_quirk = flask_platform_quirk,
+    .platform_op = flask_platform_op,
     .firmware_info = flask_firmware_info,
     .efi_call = flask_efi_call,
     .acpi_sleep = flask_acpi_sleep,

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

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