summaryrefslogtreecommitdiffstats
path: root/src/VBox/VMM/dtrace
diff options
context:
space:
mode:
Diffstat (limited to 'src/VBox/VMM/dtrace')
-rw-r--r--src/VBox/VMM/dtrace/int-1.d125
-rw-r--r--src/VBox/VMM/dtrace/lib/amd64/vbox-arch-types.d39
-rw-r--r--src/VBox/VMM/dtrace/lib/vbox-types.d58
-rw-r--r--src/VBox/VMM/dtrace/lib/x86/vbox-arch-types.d22
-rw-r--r--src/VBox/VMM/dtrace/return-to-ring-3-aggregation-1.d36
-rw-r--r--src/VBox/VMM/dtrace/vmexit-reason-aggregation-1.d36
-rw-r--r--src/VBox/VMM/dtrace/vmexit-rip-aggregation-1.d32
7 files changed, 348 insertions, 0 deletions
diff --git a/src/VBox/VMM/dtrace/int-1.d b/src/VBox/VMM/dtrace/int-1.d
new file mode 100644
index 00000000..a51f0334
--- /dev/null
+++ b/src/VBox/VMM/dtrace/int-1.d
@@ -0,0 +1,125 @@
+/* $Id: int-1.d $ */
+/** @file
+ * DTracing VBox - Interrupt Experiment #1.
+ */
+
+/*
+ * Copyright (C) 2012-2020 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ */
+
+#pragma D option quiet
+
+uint64_t g_aStarts[uint32_t];
+uint64_t g_cUntaggedHighs;
+uint64_t g_cUntaggedGets;
+uint64_t g_cMissedHighs;
+
+inline uint32_t kfDevIdMask = 0x3ff;
+
+
+/*
+ * Timestamp the when the device raises the IRQ.
+ */
+vboxvmm*:::pdm-irq-high,vboxvmm*:::pdm-irq-hilo
+/args[1] != 0/
+{
+ /*printf("high: tag=%#x src=%d %llx -> %llx\n", args[1], args[2], g_aStarts[args[1]], timestamp);*/
+ g_aStarts[args[1]] = timestamp;
+}
+
+vboxvmm*:::pdm-irq-high,vboxvmm*:::pdm-irq-hilo
+/args[1] == 0/
+{
+ g_cUntaggedHighs++;
+}
+
+/*
+ * Catch the CPU getting the IRQ from the (A)PIC and preparing for injection.
+ */
+vboxvmm*:::pdm-irq-get
+/g_aStarts[args[1]] == 0 && args[1] != 0/
+{
+ printf("get: tag=%#x src=%d %llx - %llx = %llx\n", args[1], args[2], timestamp, g_aStarts[args[1]], timestamp - g_aStarts[args[1]]);
+ @g_MissedHighs[args[3], args[2] & kfDevIdMask] = count();
+ g_cMissedHighs++;
+}
+
+vboxvmm*:::pdm-irq-get
+/g_aStarts[args[1]] > 0 && args[1] != 0/
+{
+ /*printf("get: tag=%#x src=%d %llx - %llx = %llx\n", args[1], args[2], timestamp, g_aStarts[args[1]], timestamp - g_aStarts[args[1]]);*/
+ @g_Interrupts[args[3], args[2] & kfDevIdMask] = count();
+ @g_DispAvg[ args[3], args[2] & kfDevIdMask] = avg(timestamp - g_aStarts[args[1]]);
+ @g_DispMax[ args[3], args[2] & kfDevIdMask] = max(timestamp - g_aStarts[args[1]]);
+ @g_DispMin[ args[3], args[2] & kfDevIdMask] = min(timestamp - g_aStarts[args[1]]);
+ g_aStarts[args[1]] = 0;
+ g_cHits++;
+}
+
+vboxvmm*:::pdm-irq-get
+/args[1] == 0/
+{
+ @g_UntaggedGets[args[3]] = count();
+ g_cUntaggedGets++;
+}
+
+vboxvmm*:::pdm-irq-get
+/args[2] > kfDevIdMask/
+{
+ @g_Shared[args[3], args[2] & kfDevIdMask] = count();
+}
+
+/* For the time being, quit after 256 interrupts. */
+vboxvmm*:::pdm-irq-get
+/g_cHits >= 256/
+{
+ exit(0);
+}
+
+/*
+ * Catch the device clearing the IRQ.
+ */
+
+
+/*
+ * Report.
+ */
+END
+{
+ printf("\nInterrupt distribution:\n");
+ printa(" irq %3d dev %2d %@12u\n", @g_Interrupts);
+ printf("Interrupt sharing (devices detect pushing a line high at the same time):\n");
+ printa(" irq %3d dev %2d %@12u\n", @g_Shared);
+ printf("Minimum dispatch latency:\n");
+ printa(" irq %3d dev %2d %@12u ns\n", @g_DispMin);
+ printf("Average dispatch latency:\n");
+ printa(" irq %3d dev %2d %@12u ns\n", @g_DispAvg);
+ printf("Maximum dispatch latency:\n");
+ printa(" irq %3d dev %2d %@12u ns\n", @g_DispMax);
+}
+END
+/g_cUntaggedHighs > 0/
+{
+ printf("Untagged highs: %u\n", g_cUntaggedHighs);
+}
+END
+/g_cUntaggedGets > 0/
+{
+ printf("Untagged gets: %u\n", g_cUntaggedGets);
+ printa(" irq %3d %@12u\n", @g_UntaggedGets);
+}
+END
+/g_cMissedHighs > 0/
+{
+ printf("Missed (or shared?) highs: %u\n", g_cMissedHighs);
+ printa(" irq %3d dev %2d %@12u\n", @g_MissedHighs);
+}
+
diff --git a/src/VBox/VMM/dtrace/lib/amd64/vbox-arch-types.d b/src/VBox/VMM/dtrace/lib/amd64/vbox-arch-types.d
new file mode 100644
index 00000000..fad47a3e
--- /dev/null
+++ b/src/VBox/VMM/dtrace/lib/amd64/vbox-arch-types.d
@@ -0,0 +1,39 @@
+/** @file
+ * VBox & DTrace - Types and Constants for AMD64.
+ */
+
+/*
+ * Copyright (C) 2012-2020 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ */
+
+
+inline unsigned HC_ARCH_BITS = 64;
+typedef uint64_t RTR3PTR;
+typedef void *RTR0PTR;
+typedef uint64_t RTHCPTR;
+
+
+
+typedef union RTFLOAT80U
+{
+ uint16_t au16[5];
+} RTFLOAT80U;
+
+typedef union RTFLOAT80U2
+{
+ uint16_t au16[5];
+} RTFLOAT80U2;
+
+typedef struct uint128_t
+{
+ uint64_t au64[2];
+} uint128_t;
+
diff --git a/src/VBox/VMM/dtrace/lib/vbox-types.d b/src/VBox/VMM/dtrace/lib/vbox-types.d
new file mode 100644
index 00000000..99762bd6
--- /dev/null
+++ b/src/VBox/VMM/dtrace/lib/vbox-types.d
@@ -0,0 +1,58 @@
+/** @file
+ * VBox & DTrace - Types and Constants.
+ */
+
+/*
+ * Copyright (C) 2012-2020 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ */
+
+
+/*
+ * Types used by the other D structure and type definitions.
+ *
+ * These are taken from a variation of VBox and IPRT headers.
+ */
+#pragma D depends_on library vbox-arch-types.d
+
+typedef uint64_t RTGCPHYS;
+typedef uint64_t RTHCPHYS;
+typedef uint16_t RTSEL;
+typedef uint32_t RTRCPTR;
+typedef uintptr_t RTNATIVETHREAD;
+typedef struct RTTHREADINT *RTTHREAD;
+typedef struct RTTRACEBUFINT *RTTRACEBUF;
+
+
+typedef uint32_t VMSTATE;
+typedef uint32_t VMCPUID;
+typedef uint32_t RTCPUID;
+typedef struct UVMCPU *PUVMCPU;
+typedef uintptr_t PVMR3;
+typedef uint32_t PVMRC;
+typedef struct VM *PVMR0;
+typedef struct SUPDRVSESSION *PSUPDRVSESSION;
+typedef struct UVM *PUVM;
+typedef struct CPUMCTXCORE *PCPUMCTXCORE;
+typedef struct SVMVMCB *PSVMVMCB;
+typedef uint32_t VMXVDIAG;
+typedef struct VMXVVMCS *PVMXVVMCS;
+
+typedef struct VBOXGDTR
+{
+ uint16_t cb;
+ uint16_t au16Addr[4];
+} VBOXGDTR, VBOXIDTR;
+
+typedef struct STAMPROFILEADV
+{
+ uint64_t au64[5];
+} STAMPROFILEADV;
+
diff --git a/src/VBox/VMM/dtrace/lib/x86/vbox-arch-types.d b/src/VBox/VMM/dtrace/lib/x86/vbox-arch-types.d
new file mode 100644
index 00000000..ae70f4db
--- /dev/null
+++ b/src/VBox/VMM/dtrace/lib/x86/vbox-arch-types.d
@@ -0,0 +1,22 @@
+/** @file
+ * VBox & DTrace - Types and Constants for X86.
+ */
+
+/*
+ * Copyright (C) 2012-2020 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ */
+
+
+inline unsigned HC_ARCH_BITS = 32;
+typedef uint32_t RTR3PTR;
+typedef uint32_t RTHCPTR;
+typedef void *RTR0PTR;
+
diff --git a/src/VBox/VMM/dtrace/return-to-ring-3-aggregation-1.d b/src/VBox/VMM/dtrace/return-to-ring-3-aggregation-1.d
new file mode 100644
index 00000000..a95c5abe
--- /dev/null
+++ b/src/VBox/VMM/dtrace/return-to-ring-3-aggregation-1.d
@@ -0,0 +1,36 @@
+/* $Id: return-to-ring-3-aggregation-1.d $ */
+/** @file
+ * DTracing VBox - return to ring-3 aggregation test \#1.
+ */
+
+/*
+ * Copyright (C) 2012-2020 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ */
+
+#pragma D option quiet
+
+
+vboxvmm:::r0-vmm-return-to-ring3-hm
+{
+ @g_aHmRcs[args[2]] = count();
+}
+
+vboxvmm:::r0-vmm-return-to-ring3-rc
+{
+ @g_aRawRcs[args[2]] = count();
+}
+
+END
+{
+ printa(" rcHm=%04d %@8u times\n", @g_aHmRcs);
+ printa(" rcRaw=%04d %@8u times\n", @g_aRawRcs);
+}
+
diff --git a/src/VBox/VMM/dtrace/vmexit-reason-aggregation-1.d b/src/VBox/VMM/dtrace/vmexit-reason-aggregation-1.d
new file mode 100644
index 00000000..38b72ab2
--- /dev/null
+++ b/src/VBox/VMM/dtrace/vmexit-reason-aggregation-1.d
@@ -0,0 +1,36 @@
+/* $Id: vmexit-reason-aggregation-1.d $ */
+/** @file
+ * DTracing VBox - vmexit reason aggregation test \#1.
+ */
+
+/*
+ * Copyright (C) 2012-2020 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ */
+
+#pragma D option quiet
+
+
+vboxvmm:::r0-hmsvm-vmexit
+{
+ @g_aSvmExits[args[2]] = count();
+}
+
+vboxvmm:::r0-hmvmx-vmexit-noctx
+{
+ @g_aVmxExits[args[2]] = count();
+}
+
+END
+{
+ printa(" svmexit=%#04llx %@10u times\n", @g_aSvmExits);
+ printa(" vmxexit=%#04llx %@10u times\n", @g_aVmxExits);
+}
+
diff --git a/src/VBox/VMM/dtrace/vmexit-rip-aggregation-1.d b/src/VBox/VMM/dtrace/vmexit-rip-aggregation-1.d
new file mode 100644
index 00000000..e0b1b6c2
--- /dev/null
+++ b/src/VBox/VMM/dtrace/vmexit-rip-aggregation-1.d
@@ -0,0 +1,32 @@
+/* $Id: vmexit-rip-aggregation-1.d $ */
+/** @file
+ * DTracing VBox - vmexit rip aggregation test \#1.
+ */
+
+/*
+ * Copyright (C) 2012-2020 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ */
+
+#pragma D option quiet
+
+
+vboxvmm:::r0-hmsvm-vmexit,vboxvmm:::r0-hmvmx-vmexit
+{
+ /*printf("cs:rip=%02x:%08llx", args[1]->cs.Sel, args[1]->rip.rip);*/
+ @g_aRips[args[1]->rip.rip] = count();
+ /*@g_aRips[args[0]->cpum.s.Guest.rip.rip] = count(); - alternative access route */
+}
+
+END
+{
+ printa(" rip=%#018llx %@4u times\n", @g_aRips);
+}
+