WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] Merge

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] Merge
From: Xen patchbot-unstable <patchbot@xxxxxxx>
Date: Thu, 16 Jun 2011 11:11:57 +0100
Delivery-date: Thu, 16 Jun 2011 03:19:05 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
# Date 1306418924 -3600
# Node ID dedbda000c249e79d56893c1d14a6858306fd53d
# Parent  183c1a134e7bea18637e6d37b95a945c2d60907d
# Parent  9672195337ae7248353aaaeadd0e8d4304c2fd8e
Merge
---


diff -r 183c1a134e7b -r dedbda000c24 tools/libxc/xc_misc.c
--- a/tools/libxc/xc_misc.c     Thu May 26 15:05:47 2011 +0100
+++ b/tools/libxc/xc_misc.c     Thu May 26 15:08:44 2011 +0100
@@ -417,6 +417,35 @@
     return rc;
 }
 
+int xc_hvm_inject_msi(
+    xc_interface *xch, domid_t dom, uint64_t addr, uint32_t data)
+{
+    DECLARE_HYPERCALL;
+    DECLARE_HYPERCALL_BUFFER(struct xen_hvm_inject_msi, arg);
+    int rc;
+
+    arg = xc_hypercall_buffer_alloc(xch, arg, sizeof(*arg));
+    if ( arg == NULL )
+    {
+        PERROR("Could not allocate memory for xc_hvm_inject_msi hypercall");
+        return -1;
+    }
+
+    hypercall.op     = __HYPERVISOR_hvm_op;
+    hypercall.arg[0] = HVMOP_inject_msi;
+    hypercall.arg[1] = HYPERCALL_BUFFER_AS_ARG(arg);
+
+    arg->domid = dom;
+    arg->addr  = addr;
+    arg->data  = data;
+
+    rc = do_xen_hypercall(xch, &hypercall);
+
+    xc_hypercall_buffer_free(xch, arg);
+
+    return rc;
+}
+
 int xc_hvm_track_dirty_vram(
     xc_interface *xch, domid_t dom,
     uint64_t first_pfn, uint64_t nr,
diff -r 183c1a134e7b -r dedbda000c24 tools/libxc/xenctrl.h
--- a/tools/libxc/xenctrl.h     Thu May 26 15:05:47 2011 +0100
+++ b/tools/libxc/xenctrl.h     Thu May 26 15:08:44 2011 +0100
@@ -1398,6 +1398,8 @@
 int xc_hvm_set_pci_link_route(
     xc_interface *xch, domid_t dom, uint8_t link, uint8_t isa_irq);
 
+int xc_hvm_inject_msi(
+    xc_interface *xch, domid_t dom, uint64_t addr, uint32_t data);
 
 /*
  * Track dirty bit changes in the VRAM area
diff -r 183c1a134e7b -r dedbda000c24 xen/arch/x86/hvm/hvm.c
--- a/xen/arch/x86/hvm/hvm.c    Thu May 26 15:05:47 2011 +0100
+++ b/xen/arch/x86/hvm/hvm.c    Thu May 26 15:08:44 2011 +0100
@@ -3285,6 +3285,35 @@
     return rc;
 }
 
+static int hvmop_inject_msi(
+    XEN_GUEST_HANDLE(xen_hvm_inject_msi_t) uop)
+{
+    struct xen_hvm_inject_msi op;
+    struct domain *d;
+    int rc;
+
+    if ( copy_from_guest(&op, uop, 1) )
+        return -EFAULT;
+
+    rc = rcu_lock_remote_target_domain_by_id(op.domid, &d);
+    if ( rc != 0 )
+        return rc;
+
+    rc = -EINVAL;
+    if ( !is_hvm_domain(d) )
+        goto out;
+
+    rc = xsm_hvm_inject_msi(d);
+    if ( rc )
+        goto out;
+
+    hvm_inject_msi(d, op.addr, op.data);
+
+ out:
+    rcu_unlock_domain(d);
+    return rc;
+}
+
 static int hvmop_flush_tlb_all(void)
 {
     struct domain *d = current->domain;
@@ -3563,6 +3592,11 @@
             guest_handle_cast(arg, xen_hvm_set_isa_irq_level_t));
         break;
 
+    case HVMOP_inject_msi:
+        rc = hvmop_inject_msi(
+            guest_handle_cast(arg, xen_hvm_inject_msi_t));
+        break;
+
     case HVMOP_set_pci_link_route:
         rc = hvmop_set_pci_link_route(
             guest_handle_cast(arg, xen_hvm_set_pci_link_route_t));
diff -r 183c1a134e7b -r dedbda000c24 xen/arch/x86/hvm/irq.c
--- a/xen/arch/x86/hvm/irq.c    Thu May 26 15:05:47 2011 +0100
+++ b/xen/arch/x86/hvm/irq.c    Thu May 26 15:08:44 2011 +0100
@@ -26,6 +26,7 @@
 #include <xen/irq.h>
 #include <asm/hvm/domain.h>
 #include <asm/hvm/support.h>
+#include <asm/msi.h>
 
 /* Must be called with hvm_domain->irq_lock hold */
 static void assert_irq(struct domain *d, unsigned ioapic_gsi, unsigned pic_irq)
@@ -259,6 +260,20 @@
             d->domain_id, link, old_isa_irq, isa_irq);
 }
 
+void hvm_inject_msi(struct domain *d, uint64_t addr, uint32_t data)
+{
+    uint32_t tmp = (uint32_t) addr;
+    uint8_t  dest = (tmp & MSI_ADDR_DEST_ID_MASK) >> MSI_ADDR_DEST_ID_SHIFT;
+    uint8_t  dest_mode = !!(tmp & MSI_ADDR_DESTMODE_MASK);
+    uint8_t  delivery_mode = (data & MSI_DATA_DELIVERY_MODE_MASK)
+        >> MSI_DATA_DELIVERY_MODE_SHIFT;
+    uint8_t trig_mode = (data & MSI_DATA_TRIGGER_MASK)
+        >> MSI_DATA_TRIGGER_SHIFT;
+    uint8_t vector = data & MSI_DATA_VECTOR_MASK;
+
+    vmsi_deliver(d, vector, dest, dest_mode, delivery_mode, trig_mode);
+}
+
 void hvm_set_callback_via(struct domain *d, uint64_t via)
 {
     struct hvm_irq *hvm_irq = &d->arch.hvm_domain.irq;
diff -r 183c1a134e7b -r dedbda000c24 xen/arch/x86/hvm/vmsi.c
--- a/xen/arch/x86/hvm/vmsi.c   Thu May 26 15:05:47 2011 +0100
+++ b/xen/arch/x86/hvm/vmsi.c   Thu May 26 15:08:44 2011 +0100
@@ -65,29 +65,14 @@
     }
 }
 
-int vmsi_deliver(struct domain *d, int pirq)
+int vmsi_deliver(
+    struct domain *d, int vector,
+    uint8_t dest, uint8_t dest_mode,
+    uint8_t delivery_mode, uint8_t trig_mode)
 {
-    struct hvm_irq_dpci *hvm_irq_dpci = d->arch.hvm_domain.irq.dpci;
-    uint32_t flags = hvm_irq_dpci->mirq[pirq].gmsi.gflags;
-    int vector = hvm_irq_dpci->mirq[pirq].gmsi.gvec;
-    uint8_t dest = (uint8_t)flags;
-    uint8_t dest_mode = !!(flags & VMSI_DM_MASK);
-    uint8_t delivery_mode = (flags & VMSI_DELIV_MASK) >> 
GFLAGS_SHIFT_DELIV_MODE;
-    uint8_t trig_mode = (flags & VMSI_TRIG_MODE) >> GFLAGS_SHIFT_TRG_MODE;
     struct vlapic *target;
     struct vcpu *v;
 
-    HVM_DBG_LOG(DBG_LEVEL_IOAPIC,
-                "msi: dest=%x dest_mode=%x delivery_mode=%x "
-                "vector=%x trig_mode=%x\n",
-                dest, dest_mode, delivery_mode, vector, trig_mode);
-
-    if ( !( hvm_irq_dpci->mirq[pirq].flags & HVM_IRQ_DPCI_GUEST_MSI ) )
-    {
-        gdprintk(XENLOG_WARNING, "pirq %x not msi \n", pirq);
-        return 0;
-    }
-
     switch ( delivery_mode )
     {
     case dest_LowestPrio:
@@ -125,6 +110,32 @@
     return 1;
 }
 
+int vmsi_deliver_pirq(struct domain *d, int pirq)
+{
+    struct hvm_irq_dpci *hvm_irq_dpci = d->arch.hvm_domain.irq.dpci;
+    uint32_t flags = hvm_irq_dpci->mirq[pirq].gmsi.gflags;
+    int vector = hvm_irq_dpci->mirq[pirq].gmsi.gvec;
+    uint8_t dest = (uint8_t)flags;
+    uint8_t dest_mode = !!(flags & VMSI_DM_MASK);
+    uint8_t delivery_mode = (flags & VMSI_DELIV_MASK)
+        >> GFLAGS_SHIFT_DELIV_MODE;
+    uint8_t trig_mode = (flags&VMSI_TRIG_MODE) >> GFLAGS_SHIFT_TRG_MODE;
+
+    HVM_DBG_LOG(DBG_LEVEL_IOAPIC,
+                "msi: dest=%x dest_mode=%x delivery_mode=%x "
+                "vector=%x trig_mode=%x\n",
+                dest, dest_mode, delivery_mode, vector, trig_mode);
+
+    if ( !(hvm_irq_dpci->mirq[pirq].flags & HVM_IRQ_DPCI_GUEST_MSI) )
+    {
+        gdprintk(XENLOG_WARNING, "pirq %x not msi \n", pirq);
+        return 0;
+    }
+
+    vmsi_deliver(d, vector, dest, dest_mode, delivery_mode, trig_mode);
+    return 1;
+}
+
 /* Return value, -1 : multi-dests, non-negative value: dest_vcpu_id */
 int hvm_girq_dest_2_vcpu_id(struct domain *d, uint8_t dest, uint8_t dest_mode)
 {
diff -r 183c1a134e7b -r dedbda000c24 xen/drivers/passthrough/io.c
--- a/xen/drivers/passthrough/io.c      Thu May 26 15:05:47 2011 +0100
+++ b/xen/drivers/passthrough/io.c      Thu May 26 15:08:44 2011 +0100
@@ -454,10 +454,9 @@
 
 static int hvm_pci_msi_assert(struct domain *d, int pirq)
 {
-    if ( hvm_domain_use_pirq(d, pirq) )
-        return send_guest_pirq(d, pirq);
-    else
-        return vmsi_deliver(d, pirq);
+    return (hvm_domain_use_pirq(d, pirq)
+            ? send_guest_pirq(d, pirq)
+            : vmsi_deliver_pirq(d, pirq));
 }
 #endif
 
diff -r 183c1a134e7b -r dedbda000c24 xen/include/asm-x86/hvm/hvm.h
--- a/xen/include/asm-x86/hvm/hvm.h     Thu May 26 15:05:47 2011 +0100
+++ b/xen/include/asm-x86/hvm/hvm.h     Thu May 26 15:08:44 2011 +0100
@@ -199,7 +199,11 @@
 void hvm_set_guest_time(struct vcpu *v, u64 guest_time);
 u64 hvm_get_guest_time(struct vcpu *v);
 
-int vmsi_deliver(struct domain *d, int pirq);
+int vmsi_deliver(
+    struct domain *d, int vector,
+    uint8_t dest, uint8_t dest_mode,
+    uint8_t delivery_mode, uint8_t trig_mode);
+int vmsi_deliver_pirq(struct domain *d, int pirq);
 int hvm_girq_dest_2_vcpu_id(struct domain *d, uint8_t dest, uint8_t dest_mode);
 
 #define hvm_paging_enabled(v) \
diff -r 183c1a134e7b -r dedbda000c24 xen/include/asm-x86/msi.h
--- a/xen/include/asm-x86/msi.h Thu May 26 15:05:47 2011 +0100
+++ b/xen/include/asm-x86/msi.h Thu May 26 15:08:44 2011 +0100
@@ -19,6 +19,7 @@
 #define MSI_DATA_DELIVERY_MODE_SHIFT   8
 #define  MSI_DATA_DELIVERY_FIXED       (0 << MSI_DATA_DELIVERY_MODE_SHIFT)
 #define  MSI_DATA_DELIVERY_LOWPRI      (1 << MSI_DATA_DELIVERY_MODE_SHIFT)
+#define  MSI_DATA_DELIVERY_MODE_MASK    0x00000700
 
 #define MSI_DATA_LEVEL_SHIFT           14
 #define         MSI_DATA_LEVEL_DEASSERT        (0 << MSI_DATA_LEVEL_SHIFT)
@@ -27,6 +28,7 @@
 #define MSI_DATA_TRIGGER_SHIFT         15
 #define  MSI_DATA_TRIGGER_EDGE         (0 << MSI_DATA_TRIGGER_SHIFT)
 #define  MSI_DATA_TRIGGER_LEVEL                (1 << MSI_DATA_TRIGGER_SHIFT)
+#define  MSI_DATA_TRIGGER_MASK          0x00008000
 
 /*
  * Shift/mask fields for msi address
@@ -39,6 +41,7 @@
 #define MSI_ADDR_DESTMODE_SHIFT     2
 #define MSI_ADDR_DESTMODE_PHYS      (0 << MSI_ADDR_DESTMODE_SHIFT)
 #define MSI_ADDR_DESTMODE_LOGIC     (1 << MSI_ADDR_DESTMODE_SHIFT)
+#define MSI_ADDR_DESTMODE_MASK      0x4
 
 #define MSI_ADDR_REDIRECTION_SHIFT  3
 #define MSI_ADDR_REDIRECTION_CPU    (0 << MSI_ADDR_REDIRECTION_SHIFT)
diff -r 183c1a134e7b -r dedbda000c24 xen/include/public/hvm/hvm_op.h
--- a/xen/include/public/hvm/hvm_op.h   Thu May 26 15:05:47 2011 +0100
+++ b/xen/include/public/hvm/hvm_op.h   Thu May 26 15:08:44 2011 +0100
@@ -240,4 +240,22 @@
 typedef struct xen_hvm_get_mem_type xen_hvm_get_mem_type_t;
 DEFINE_XEN_GUEST_HANDLE(xen_hvm_get_mem_type_t);
 
+/* Following tools-only interfaces may change in future. */
+#if defined(__XEN__) || defined(__XEN_TOOLS__)
+
+/* MSI injection for emulated devices */
+#define HVMOP_inject_msi         16
+struct xen_hvm_inject_msi {
+    /* Domain to be injected */
+    domid_t   domid;
+    /* Data -- lower 32 bits */
+    uint32_t  data;
+    /* Address (0xfeexxxxx) */
+    uint64_t  addr;
+};
+typedef struct xen_hvm_inject_msi xen_hvm_inject_msi_t;
+DEFINE_XEN_GUEST_HANDLE(xen_hvm_inject_msi_t);
+
+#endif /* defined(__XEN__) || defined(__XEN_TOOLS__) */
+
 #endif /* __XEN_PUBLIC_HVM_HVM_OP_H__ */
diff -r 183c1a134e7b -r dedbda000c24 xen/include/xen/hvm/irq.h
--- a/xen/include/xen/hvm/irq.h Thu May 26 15:05:47 2011 +0100
+++ b/xen/include/xen/hvm/irq.h Thu May 26 15:08:44 2011 +0100
@@ -116,6 +116,8 @@
 
 void hvm_set_pci_link_route(struct domain *d, u8 link, u8 isa_irq);
 
+void hvm_inject_msi(struct domain *d, uint64_t addr, uint32_t data);
+
 void hvm_maybe_deassert_evtchn_irq(void);
 void hvm_assert_evtchn_irq(struct vcpu *v);
 void hvm_set_callback_via(struct domain *d, uint64_t via);
diff -r 183c1a134e7b -r dedbda000c24 xen/include/xsm/xsm.h
--- a/xen/include/xsm/xsm.h     Thu May 26 15:05:47 2011 +0100
+++ b/xen/include/xsm/xsm.h     Thu May 26 15:08:44 2011 +0100
@@ -123,6 +123,7 @@
     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);
+    int (*hvm_inject_msi) (struct domain *d);
     int (*apic) (struct domain *d, int cmd);
     int (*assign_vector) (struct domain *d, uint32_t pirq);
     int (*xen_settime) (void);
@@ -507,6 +508,11 @@
     return xsm_call(hvm_set_pci_link_route(d));
 }
 
+static inline int xsm_hvm_inject_msi (struct domain *d)
+{
+    return xsm_call(hvm_inject_msi(d));
+}
+
 static inline int xsm_apic (struct domain *d, int cmd)
 {
     return xsm_call(apic(d, cmd));

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

<Prev in Thread] Current Thread [Next in Thread>