xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: David Vrabel <david.vrabel@citrix.com>
To: xen-devel@lists.xenproject.org
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
	David Vrabel <david.vrabel@citrix.com>,
	Jan Beulich <jbeulich@suse.com>
Subject: [PATCHv1 1/5] domctl: Add op to get/set generic numeric parameters
Date: Thu, 18 Feb 2016 18:52:06 +0000	[thread overview]
Message-ID: <1455821530-4263-2-git-send-email-david.vrabel@citrix.com> (raw)
In-Reply-To: <1455821530-4263-1-git-send-email-david.vrabel@citrix.com>

Add XEN_DOMCTL_param to get/set generic numeric parameters for a domain.
This should reduce the number of specialized domctls that need to be
added.

Signed-off-by: David Vrabel <david.vrabel@citrix.com>
---
 xen/arch/x86/domctl.c       | 14 ++++++++++++++
 xen/common/domctl.c         | 11 +++++++++++
 xen/include/public/domctl.h | 21 +++++++++++++++++++++
 xen/include/xen/domain.h    |  3 +++
 4 files changed, 49 insertions(+)

diff --git a/xen/arch/x86/domctl.c b/xen/arch/x86/domctl.c
index 55aecdc..3a3ebbf 100644
--- a/xen/arch/x86/domctl.c
+++ b/xen/arch/x86/domctl.c
@@ -1408,6 +1408,20 @@ void arch_get_info_guest(struct vcpu *v, vcpu_guest_context_u c)
 #undef c
 }
 
+int arch_domctl_param(struct domain *d, uint32_t param, bool_t set,
+                      uint64_t *value)
+{
+    uint64_t new_value = *value;
+
+    switch ( param )
+    {
+    default:
+        return -EINVAL;
+    }
+
+    return 0;
+}
+
 /*
  * Local variables:
  * mode: C
diff --git a/xen/common/domctl.c b/xen/common/domctl.c
index 22fa5d5..54c51ba 100644
--- a/xen/common/domctl.c
+++ b/xen/common/domctl.c
@@ -1186,6 +1186,17 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl)
             copyback = 1;
         break;
 
+    case XEN_DOMCTL_param:
+    {
+        uint32_t param = op->u.param.param & ~XEN_DOMCTL_PARAM_SET;
+        bool_t set = !!(op->u.param.param & XEN_DOMCTL_PARAM_SET);
+
+        ret = arch_domctl_param(d, param, set, &op->u.param.value);
+        if ( ret == 0 )
+            copyback = 1;
+        break;
+    }
+
     default:
         ret = arch_do_domctl(op, d, u_domctl);
         break;
diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h
index a934318..330b3e7 100644
--- a/xen/include/public/domctl.h
+++ b/xen/include/public/domctl.h
@@ -1092,6 +1092,25 @@ struct xen_domctl_psr_cat_op {
 typedef struct xen_domctl_psr_cat_op xen_domctl_psr_cat_op_t;
 DEFINE_XEN_GUEST_HANDLE(xen_domctl_psr_cat_op_t);
 
+/*
+ * Get/set a per-domain numeric parameter.
+ *
+ * If bit 31 of @param is set, the original value is returned and the
+ * new value is written.  If bit 31 is clear, the value is returned.
+ *
+ * Not all parameters are valid for all architectures or domain types.
+ */
+#define XEN_DOMCTL_PARAM_SET (1u << 31)
+
+struct xen_domctl_param {
+    /* IN */
+    uint32_t param;
+    /* IN/OUT */
+    uint64_t value;
+};
+typedef struct xen_domctl_param xen_domctl_param;
+DEFINE_XEN_GUEST_HANDLE(xen_domctl_param);
+
 struct xen_domctl {
     uint32_t cmd;
 #define XEN_DOMCTL_createdomain                   1
@@ -1169,6 +1188,7 @@ struct xen_domctl {
 #define XEN_DOMCTL_monitor_op                    77
 #define XEN_DOMCTL_psr_cat_op                    78
 #define XEN_DOMCTL_soft_reset                    79
+#define XEN_DOMCTL_param                         80
 #define XEN_DOMCTL_gdbsx_guestmemio            1000
 #define XEN_DOMCTL_gdbsx_pausevcpu             1001
 #define XEN_DOMCTL_gdbsx_unpausevcpu           1002
@@ -1231,6 +1251,7 @@ struct xen_domctl {
         struct xen_domctl_psr_cmt_op        psr_cmt_op;
         struct xen_domctl_monitor_op        monitor_op;
         struct xen_domctl_psr_cat_op        psr_cat_op;
+        struct xen_domctl_param             param;
         uint8_t                             pad[128];
     } u;
 };
diff --git a/xen/include/xen/domain.h b/xen/include/xen/domain.h
index a1a6f25..a8a6d7d 100644
--- a/xen/include/xen/domain.h
+++ b/xen/include/xen/domain.h
@@ -77,6 +77,9 @@ void arch_dump_domain_info(struct domain *d);
 
 int arch_vcpu_reset(struct vcpu *);
 
+int arch_domctl_param(struct domain *d, uint32_t param, bool_t set,
+                      uint64_t *value);
+
 extern spinlock_t vcpu_alloc_lock;
 bool_t domctl_lock_acquire(void);
 void domctl_lock_release(void);
-- 
2.1.4

  reply	other threads:[~2016-02-18 18:52 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-18 18:52 [RFC PATCH 0/5] x86: workaround inability to fully restore FPU state David Vrabel
2016-02-18 18:52 ` David Vrabel [this message]
2016-02-18 19:02   ` [PATCHv1 1/5] domctl: Add op to get/set generic numeric parameters Andrew Cooper
2016-02-19 13:59   ` Jan Beulich
2016-02-18 18:52 ` [PATCHv1 2/5] tools/libxc: add xc_domain_get_param() and xc_domain_set_param() David Vrabel
2016-02-18 19:03   ` Andrew Cooper
2016-02-18 18:52 ` [PATCHv1 3/5] x86/fpu: Add a per-domain field to set the width of FIP/FDP David Vrabel
2016-02-18 19:13   ` Andrew Cooper
2016-02-19 10:03     ` David Vrabel
2016-02-19 14:08   ` Jan Beulich
2016-02-19 14:16     ` David Vrabel
2016-02-19 14:36       ` Jan Beulich
2016-02-19 14:49         ` David Vrabel
2016-02-19 15:14           ` Jan Beulich
2016-02-19 15:43             ` David Vrabel
2016-02-19 16:38               ` David Vrabel
2016-02-19 17:20                 ` Jan Beulich
2016-02-18 18:52 ` [PATCHv1 4/5] x86/viridian: set x87 FIP width to 4 for Windows guests David Vrabel
2016-02-18 19:19   ` Andrew Cooper
2016-02-19 14:11   ` Jan Beulich
2016-02-18 18:52 ` [PATCHv1 5/5] x86/domctl: Add XEN_DOMCTL_PARAM_ARCH_X86_FIP_WIDTH parameter David Vrabel
2016-02-19 10:05   ` David Vrabel
2016-02-19 14:13     ` Jan Beulich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1455821530-4263-2-git-send-email-david.vrabel@citrix.com \
    --to=david.vrabel@citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).