This diff communicates an allocated IDT vector to the Hypervisor.

OK?

---
 sys/dev/pv/xen.c    | 34 ++++++++++++++++++++++++++++++++++
 sys/dev/pv/xenvar.h |  2 ++
 2 files changed, 36 insertions(+)

diff --git sys/dev/pv/xen.c sys/dev/pv/xen.c
index e8aeeb8..8643636 100644
--- sys/dev/pv/xen.c
+++ sys/dev/pv/xen.c
@@ -25,10 +25,12 @@
 #include <machine/cpu.h>
 #include <machine/cpufunc.h>
 
 #include <uvm/uvm_extern.h>
 
+#include <machine/i82489var.h>
+
 #include <dev/pv/pvvar.h>
 #include <dev/pv/xenreg.h>
 #include <dev/pv/xenvar.h>
 
 struct xen_softc *xen_sc;
@@ -36,10 +38,11 @@ struct xen_softc *xen_sc;
 void   xen_find_base(struct xen_softc *);
 int    xen_init_hypercall(struct xen_softc *);
 int    xen_getversion(struct xen_softc *);
 int    xen_getfeatures(struct xen_softc *);
 int    xen_init_info_page(struct xen_softc *);
+int    xen_init_cbvec(struct xen_softc *);
 
 int    xen_match(struct device *, void *, void *);
 void   xen_attach(struct device *, struct device *, void *);
 void   xen_resume(struct device *);
 int    xen_activate(struct device *, int);
@@ -88,10 +91,12 @@ xen_attach(struct device *parent, struct device *self, void 
*aux)
        if (xen_getfeatures(sc))
                return;
 
        if (xen_init_info_page(sc))
                return;
+
+       xen_init_cbvec(sc);
 }
 
 void
 xen_resume(struct device *self)
 {
@@ -418,5 +423,34 @@ xen_init_info_page(struct xen_softc *sc)
        }
        DPRINTF("%s: shared info page at va %p pa %#lx\n", sc->sc_dev.dv_xname,
            sc->sc_ipg, pa);
        return (0);
 }
+
+int
+xen_init_cbvec(struct xen_softc *sc)
+{
+       struct xen_hvm_param xhp;
+
+       if ((sc->sc_features & XENFEAT_CBVEC) == 0)
+               return (ENOENT);
+
+       xhp.domid = DOMID_SELF;
+       xhp.index = HVM_PARAM_CALLBACK_IRQ;
+       xhp.value = HVM_CALLBACK_VECTOR(LAPIC_XEN_VECTOR);
+       if (xen_hypercall(sc, hvm_op, 2, HVMOP_set_param, &xhp)) {
+               /* Will retry with the xspd(4) PCI interrupt */
+               return (ENOENT);
+       }
+       DPRINTF("%s: registered callback IDT vector %d\n",
+           sc->sc_dev.dv_xname, LAPIC_XEN_VECTOR);
+
+       sc->sc_cbvec = 1;
+
+       return (0);
+}
+
+void
+xen_intr(void)
+{
+       /* stub */
+}
diff --git sys/dev/pv/xenvar.h sys/dev/pv/xenvar.h
index b5db26d..7c5d244 100644
--- sys/dev/pv/xenvar.h
+++ sys/dev/pv/xenvar.h
@@ -31,10 +31,12 @@ struct xen_softc {
        void                    *sc_hc;
        uint32_t                 sc_features;
 #define  XENFEAT_CBVEC         (1<<8)
 
        struct shared_info      *sc_ipg;        /* HYPERVISOR_shared_info */
+
+       int                      sc_cbvec;      /* callback was installed */
 };
 
 extern struct xen_softc *xen_sc;
 
 /*
-- 
2.6.3

Reply via email to