xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: xen-devel@lists.xenproject.org
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
	boris.ostrovsky@oracle.com, Keir Fraser <keir@xen.org>,
	Jan Beulich <jbeulich@suse.com>,
	Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Subject: [PATCH] x86: Update HVM_PARAM_CALLBACK_IRQ
Date: Mon, 29 Feb 2016 15:39:36 -0500	[thread overview]
Message-ID: <1456778376-2983-1-git-send-email-konrad.wilk@oracle.com> (raw)

Couple of updates:
 - Add an macro to make it easier to use the vector callback.

 - Fix the odditity in Xen internal usage of an enum which offset
   by one compared to the #defines. Make it the same.

 - This also clears up the printing of the Callback in the
   irq_dump() to match up with the #defines.

Reported-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
---
 xen/arch/x86/hvm/irq.c          |  2 +-
 xen/include/asm-x86/hvm/irq.h   | 12 ++++++++----
 xen/include/public/hvm/hvm_op.h |  3 ++-
 xen/include/public/hvm/params.h | 15 +++++++++++++++
 4 files changed, 26 insertions(+), 6 deletions(-)

diff --git a/xen/arch/x86/hvm/irq.c b/xen/arch/x86/hvm/irq.c
index 5323d7c..0c6ead4 100644
--- a/xen/arch/x86/hvm/irq.c
+++ b/xen/arch/x86/hvm/irq.c
@@ -325,7 +325,7 @@ void hvm_set_callback_via(struct domain *d, uint64_t via)
     unsigned int gsi=0, pdev=0, pintx=0;
     uint8_t via_type;
 
-    via_type = (uint8_t)(via >> 56) + 1;
+    via_type = (uint8_t)(via >> HVM_PARAM_CALLBACK_TYPE_SHIFT);
     if ( ((via_type == HVMIRQ_callback_gsi) && (via == 0)) ||
          (via_type > HVMIRQ_callback_vector) )
         via_type = HVMIRQ_callback_none;
diff --git a/xen/include/asm-x86/hvm/irq.h b/xen/include/asm-x86/hvm/irq.h
index 73b8fb0..2a301db 100644
--- a/xen/include/asm-x86/hvm/irq.h
+++ b/xen/include/asm-x86/hvm/irq.h
@@ -26,6 +26,8 @@
 #include <asm/hvm/vpic.h>
 #include <asm/hvm/vioapic.h>
 
+#include <public/hvm/params.h>
+
 struct hvm_irq {
     /*
      * Virtual interrupt wires for a single PCI bus.
@@ -50,11 +52,13 @@ struct hvm_irq {
     /* Virtual interrupt and via-link for paravirtual platform driver. */
     uint32_t callback_via_asserted;
     union {
+        /* These MUST match with HVM_PARAM_CALLBACK_IRQ types. */
         enum {
-            HVMIRQ_callback_none,
-            HVMIRQ_callback_gsi,
-            HVMIRQ_callback_pci_intx,
-            HVMIRQ_callback_vector
+            HVMIRQ_callback_gsi = HVM_PARAM_CALLBACK_TYPE_GSI,
+            HVMIRQ_callback_pci_intx = HVM_PARAM_CALLBACK_TYPE_PCI_INTX,
+            HVMIRQ_callback_vector = HVM_PARAM_CALLBACK_TYPE_VECTOR,
+            /* Will change if we add more types. */
+            HVMIRQ_callback_none = HVM_PARAM_CALLBACK_TYPE_NUM,
         } callback_via_type;
     };
     union {
diff --git a/xen/include/public/hvm/hvm_op.h b/xen/include/public/hvm/hvm_op.h
index 1606185..5908f39 100644
--- a/xen/include/public/hvm/hvm_op.h
+++ b/xen/include/public/hvm/hvm_op.h
@@ -386,7 +386,8 @@ DEFINE_XEN_GUEST_HANDLE(xen_hvm_set_ioreq_server_state_t);
  *                                 channel upcalls on the specified <vcpu>. If set,
  *                                 this vector will be used in preference to the
  *                                 domain global callback via (see
- *                                 HVM_PARAM_CALLBACK_IRQ).
+ *                                 HVM_PARAM_CALLBACK_IRQ and
+ *                                 HVM_PARAM_CALLBACK_VECTOR).
  */
 #define HVMOP_set_evtchn_upcall_vector 23
 struct xen_hvm_evtchn_upcall_vector {
diff --git a/xen/include/public/hvm/params.h b/xen/include/public/hvm/params.h
index 73d4718..5c7fbc5 100644
--- a/xen/include/public/hvm/params.h
+++ b/xen/include/public/hvm/params.h
@@ -56,6 +56,21 @@
  */
 
 /*
+ * In the future this may change.
+ */
+#define HVM_PARAM_CALLBACK_TYPE_NUM      HVM_PARAM_CALLBACK_TYPE_VECTOR + 1
+/*
+ * The val[63:56] convenience shift.
+ */
+#define HVM_PARAM_CALLBACK_TYPE_SHIFT 56
+
+/*
+ * Wrapper around for HVM_PARAM_CALLBACK_TYPE_VECTOR.
+ */
+#define HVM_PARAM_CALLBACK_VECTOR(x) \
+            (((uint64_t)HVM_PARAM_CALLBACK_TYPE_VECTOR) << \
+                        HVM_PARAM_CALLBACK_TYPE_SHIFT | (x))
+/*
  * These are not used by Xen. They are here for convenience of HVM-guest
  * xenbus implementations.
  */
-- 
2.4.3


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

             reply	other threads:[~2016-02-29 20:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-29 20:39 Konrad Rzeszutek Wilk [this message]
2016-02-29 20:42 ` [PATCH] x86: Update HVM_PARAM_CALLBACK_IRQ Konrad Rzeszutek Wilk
2016-03-01 10:25 ` Jan Beulich
2016-03-01 14:32   ` Konrad Rzeszutek Wilk

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=1456778376-2983-1-git-send-email-konrad.wilk@oracle.com \
    --to=konrad.wilk@oracle.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=jbeulich@suse.com \
    --cc=keir@xen.org \
    --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).