summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Mustacchi <rm@joyent.com>2012-08-28 16:29:54 +0000
committerRobert Mustacchi <rm@joyent.com>2012-08-28 16:29:54 +0000
commita28b557f30616c2780163ea7a52aa72477f89ad9 (patch)
tree7bb45329be161697f7a9e7957d4bb2874057a044
parentbacaa89de738eb247571353feefc280727fd26e8 (diff)
downloadillumos-kvm-cmd-a28b557f30616c2780163ea7a52aa72477f89ad9.tar.gz
HVM-747 add dmods to get event indexes2012092020120906
-rw-r--r--qemu_mdb.c135
1 files changed, 128 insertions, 7 deletions
diff --git a/qemu_mdb.c b/qemu_mdb.c
index 69b33db..96fcef5 100644
--- a/qemu_mdb.c
+++ b/qemu_mdb.c
@@ -78,6 +78,42 @@ typedef struct RAMList {
QLIST_HEAD(ram, RAMBlock) blocks;
} RAMList;
+typedef struct VRingDesc
+{
+ uint64_t addr;
+ uint32_t len;
+ uint16_t flags;
+ uint16_t next;
+} VRingDesc;
+
+typedef struct VRingAvail
+{
+ uint16_t flags;
+ uint16_t idx;
+ uint16_t ring[0];
+} VRingAvail;
+
+typedef struct VRingUsedElem
+{
+ uint32_t id;
+ uint32_t len;
+} VRingUsedElem;
+
+typedef struct VRingUsed
+{
+ uint16_t flags;
+ uint16_t idx;
+ VRingUsedElem ring[0];
+} VRingUsed;
+
+typedef struct VRing
+{
+ unsigned int num;
+ target_phys_addr_t desc;
+ target_phys_addr_t avail;
+ target_phys_addr_t used;
+} VRing;
+
/*
* NDEVICES comes from the PCIDevice structure and should be changed if this
* does ever change.
@@ -438,7 +474,7 @@ qemu_mdb_get_ram_ptr(uintptr_t addr)
}
static int
-qemu_mdb_tpa2qva(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
+internal_tpa2qva(uintptr_t addr, uintptr_t *res)
{
GElf_Sym sym;
void **lp, **p;
@@ -446,12 +482,6 @@ qemu_mdb_tpa2qva(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
PhysPageDesc *pdp, pd;
uintptr_t paddr, pfaddr, vptr;
- if (!(flags & DCMD_ADDRSPEC))
- return (DCMD_USAGE);
-
- if (argc > 1)
- return (DCMD_USAGE);
-
if (mdb_lookup_by_name("l1_phys_map", &sym) != 0) {
mdb_warn("unable to locate host_buse");
return (DCMD_ERR);
@@ -502,16 +532,107 @@ qemu_mdb_tpa2qva(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
if (vptr == 0)
return (DCMD_ERR);
vptr += addr & ~MDB_TARGET_PAGE_MASK;
+ *res = vptr;
+
+ return (DCMD_OK);
+}
+
+static int
+qemu_mdb_tpa2qva(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
+{
+ uintptr_t vptr;
+
+ if (!(flags & DCMD_ADDRSPEC))
+ return (DCMD_USAGE);
+
+ if (argc > 1)
+ return (DCMD_USAGE);
+
+ if (internal_tpa2qva(addr, &vptr) != DCMD_OK)
+ return (DCMD_ERR);
+
mdb_printf("%lr\n", vptr);
return (DCMD_OK);
}
+static int
+qemu_mdb_vrused(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
+{
+ VRing ring;
+ uintptr_t avaddr;
+ uint16_t index;
+
+ if (!(flags & DCMD_ADDRSPEC))
+ return (DCMD_USAGE);
+
+ if (argc > 1)
+ return (DCMD_USAGE);
+
+ if (mdb_vread(&ring, sizeof (ring), addr) != sizeof (ring)) {
+ mdb_warn("failed to read VRing");
+ return (DCMD_ERR);
+ }
+
+ if (internal_tpa2qva(ring.avail, &avaddr) != DCMD_OK) {
+ mdb_warn("failed to translate available ring to VA");
+ return (DCMD_ERR);
+ }
+
+ /* Account for offset */
+ avaddr += ring.num * sizeof (uint16_t) + 0x4;
+ if (mdb_vread(&index, sizeof (index), avaddr) != sizeof (index)) {
+ mdb_warn("failed to read index value");
+ return (DCMD_ERR);
+ }
+
+ mdb_printf("%lr\n", index);
+ return (DCMD_OK);
+}
+
+static int
+qemu_mdb_vravail(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
+{
+ VRing ring;
+ uintptr_t avaddr;
+ uint16_t index;
+
+ if (!(flags & DCMD_ADDRSPEC))
+ return (DCMD_USAGE);
+
+ if (argc > 1)
+ return (DCMD_USAGE);
+
+ if (mdb_vread(&ring, sizeof (ring), addr) != sizeof (ring)) {
+ mdb_warn("failed to read VRing");
+ return (DCMD_ERR);
+ }
+
+ if (internal_tpa2qva(ring.used, &avaddr) != DCMD_OK) {
+ mdb_warn("failed to translate available ring to VA");
+ return (DCMD_ERR);
+ }
+
+ /* Account for offset */
+ avaddr += ring.num * sizeof (uint64_t) + 0x4;
+ if (mdb_vread(&index, sizeof (index), avaddr) != sizeof (index)) {
+ mdb_warn("failed to read index value");
+ return (DCMD_ERR);
+ }
+
+ mdb_printf("%lr\n", index);
+ return (DCMD_OK);
+}
+
static const mdb_dcmd_t qemu_dcmds[] = {
{ "pcidev2virtio", NULL, "translate a virtio PCI device to its "
"virtio equivalent", qemu_mdb_pcidev2virtio },
{ "qemu_tpa2qva", NULL, "translate a target physical address to a "
"QEMU virtual address", qemu_mdb_tpa2qva },
+ { "qemu_vrused", NULL, "Spit out the used event of the vring",
+ qemu_mdb_vrused },
+ { "qemu_vravail", NULL, "Spit out the avail event of the vring",
+ qemu_mdb_vravail },
{ NULL }
};