summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/kvm-eviction.c3
-rw-r--r--test/kvm-pagestep.c4
-rw-r--r--test/kvm-step.c5
-rw-r--r--test/qemu-eviction.c12
-rw-r--r--test/qemu-eviction_guest.c13
-rwxr-xr-xtest/qemu-pagestepbin0 -> 98560 bytes
-rw-r--r--test/qemu-pagestep.c63
-rw-r--r--test/util.h3
8 files changed, 83 insertions, 20 deletions
diff --git a/test/kvm-eviction.c b/test/kvm-eviction.c
index 02830fd..efb9554 100644
--- a/test/kvm-eviction.c
+++ b/test/kvm-eviction.c
@@ -15,9 +15,6 @@
#define SAMPLE_COUNT 64
-#define TARGET_CORE 2
-#define SECONDARY_CORE 3
-
void
collect(struct kvm *kvm, uint8_t *counts)
{
diff --git a/test/kvm-pagestep.c b/test/kvm-pagestep.c
index 4bd4ac0..9bbb7bc 100644
--- a/test/kvm-pagestep.c
+++ b/test/kvm-pagestep.c
@@ -15,9 +15,6 @@
#include <stdio.h>
#include <stdlib.h>
-#define TARGET_CORE 2
-#define SECONDARY_CORE 3
-
static int child;
uint64_t
@@ -26,7 +23,6 @@ monitor(struct kvm *kvm, bool baseline)
struct cpc_event event;
int ret;
- /* Get page fault info */
ret = ioctl(kvm_dev, KVM_CPC_POLL_EVENT, &event);
if (ret && errno == EAGAIN) return 0;
if (ret) err(1, "KVM_CPC_POLL_EVENT");
diff --git a/test/kvm-step.c b/test/kvm-step.c
index aec1aaf..a79b04f 100644
--- a/test/kvm-step.c
+++ b/test/kvm-step.c
@@ -15,9 +15,6 @@
#include <stdio.h>
#include <stdlib.h>
-#define TARGET_CORE 2
-#define SECONDARY_CORE 3
-
static int child;
static struct cpc_event event;
@@ -123,7 +120,7 @@ main(int argc, const char **argv)
printf("Monitor start\n");
/* single step and log all accessed pages */
- arg = CPC_TRACK_STEPS;
+ arg = CPC_TRACK_STEPS_AND_FAULTS;
ret = ioctl(kvm_dev, KVM_CPC_TRACK_MODE, &arg);
if (ret) err(1, "KVM_CPC_TRACK_MODE");
diff --git a/test/qemu-eviction.c b/test/qemu-eviction.c
index a602bef..016ee9e 100644
--- a/test/qemu-eviction.c
+++ b/test/qemu-eviction.c
@@ -15,9 +15,6 @@
#include <stdio.h>
#include <stdlib.h>
-#define TARGET_CORE 2
-#define SECONDARY_CORE 3
-
static struct cpc_event event;
int
@@ -32,6 +29,7 @@ monitor(bool baseline)
switch (event.type) {
case CPC_EVENT_GUEST:
+ printf("Guest event: %i\n", event.guest.type);
if (event.guest.type == CPC_GUEST_STOP_TRACK)
return 2;
break;
@@ -40,7 +38,7 @@ monitor(bool baseline)
if (ret) err(1, "KVM_CPC_READ_COUNTS");
printf("Event: rip:%016llx cnt:%llu "
- "inst:%08llu data:%08llx ret:%llu\n",
+ "inst:%08llx data:%08llx ret:%llu\n",
vm_get_rip(), event.step.fault_count,
event.step.fault_gfns[0], event.step.fault_gfns[1],
event.step.retinst);
@@ -74,12 +72,8 @@ main(int argc, const char **argv)
uint8_t baseline[L1_SETS];
uint32_t eventcnt;
uint32_t arg;
- pid_t qemu;
int ret;
- qemu = pgrep("qemu-system-x86_64");
- if (!qemu) errx(1, "pgrep failed");
-
pin_process(0, SECONDARY_CORE, true);
setvbuf(stdout, NULL, _IONBF, 0);
@@ -93,7 +87,7 @@ main(int argc, const char **argv)
ret = ioctl(kvm_dev, KVM_CPC_CALC_BASELINE, &arg);
if (ret) err(1, "KVM_CPC_CALC_BASELINE");
- arg = CPC_TRACK_STEPS;
+ arg = CPC_TRACK_STEPS_AND_FAULTS;
ret = ioctl(kvm_dev, KVM_CPC_TRACK_MODE, &arg);
if (ret) err(1, "KVM_CPC_RESET");
diff --git a/test/qemu-eviction_guest.c b/test/qemu-eviction_guest.c
index b2586a9..086fee5 100644
--- a/test/qemu-eviction_guest.c
+++ b/test/qemu-eviction_guest.c
@@ -25,6 +25,19 @@ main(int argc, const char **argv)
printf("LOOP\n");
CPC_DO_VMMCALL(KVM_HC_CPC_VMMCALL_SIGNAL,
CPC_GUEST_START_TRACK, 0);
+ *(uint8_t *)(buf + L1_LINESIZE * 9) = 1;
+ *(uint8_t *)(buf + L1_LINESIZE * 10) = 1;
+ *(uint8_t *)(buf + L1_LINESIZE * 11) = 1;
+ *(uint8_t *)(buf + L1_LINESIZE * 12) = 1;
+ *(uint8_t *)(buf + L1_LINESIZE * 13) = 1;
+ *(uint8_t *)(buf + L1_LINESIZE * 14) = 1;
+ *(uint8_t *)(buf + L1_LINESIZE * 15) = 1;
+ *(uint8_t *)(buf + L1_LINESIZE * 9) = 1;
+ *(uint8_t *)(buf + L1_LINESIZE * 10) = 1;
+ *(uint8_t *)(buf + L1_LINESIZE * 11) = 1;
+ *(uint8_t *)(buf + L1_LINESIZE * 12) = 1;
+ *(uint8_t *)(buf + L1_LINESIZE * 13) = 1;
+ *(uint8_t *)(buf + L1_LINESIZE * 14) = 1;
*(uint8_t *)(buf + L1_LINESIZE * 15) = 1;
CPC_DO_VMMCALL(KVM_HC_CPC_VMMCALL_SIGNAL,
CPC_GUEST_STOP_TRACK, 0);
diff --git a/test/qemu-pagestep b/test/qemu-pagestep
new file mode 100755
index 0000000..320190d
--- /dev/null
+++ b/test/qemu-pagestep
Binary files differ
diff --git a/test/qemu-pagestep.c b/test/qemu-pagestep.c
new file mode 100644
index 0000000..4e54161
--- /dev/null
+++ b/test/qemu-pagestep.c
@@ -0,0 +1,63 @@
+#include "test/kvm-eviction.h"
+#include "test/kvm.h"
+#include "test/util.h"
+#include "cachepc/uapi.h"
+
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#include <signal.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <err.h>
+#include <string.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+void
+monitor(void)
+{
+ struct cpc_event event;
+ int ret;
+
+ ret = ioctl(kvm_dev, KVM_CPC_POLL_EVENT, &event);
+ if (ret && errno == EAGAIN) return;
+ if (ret) err(1, "KVM_CPC_POLL_EVENT");
+
+ if (event.type != CPC_EVENT_TRACK_PAGE)
+ errx(1, "unexpected event type %i", event.type);
+
+ printf("Event: rip:%016llx prev:%08llx next:%08llx ret:%llu\n",
+ vm_get_rip(), event.page.inst_gfn_prev,
+ event.page.inst_gfn, event.page.retinst);
+ printf("\n");
+
+ ret = ioctl(kvm_dev, KVM_CPC_ACK_EVENT, &event.id);
+ if (ret) err(1, "KVM_CPC_ACK_EVENT");
+}
+
+int
+main(int argc, const char **argv)
+{
+ uint32_t arg;
+ int ret;
+
+ setvbuf(stdout, NULL, _IONBF, 0);
+
+ kvm_setup_init();
+
+ pin_process(0, SECONDARY_CORE, true);
+
+ ret = ioctl(kvm_dev, KVM_CPC_RESET);
+ if (ret) err(1, "KVM_CPC_RESET");
+
+ arg = CPC_TRACK_PAGES_RESOLVE;
+ ret = ioctl(kvm_dev, KVM_CPC_TRACK_MODE, &arg);
+ if (ret) err(1, "KVM_CPC_TRACK_MODE");
+
+ while (1) monitor();
+
+ kvm_setup_deinit();
+}
+
diff --git a/test/util.h b/test/util.h
index 7163238..799e55b 100644
--- a/test/util.h
+++ b/test/util.h
@@ -7,6 +7,9 @@
#define ARRLEN(x) (sizeof(x) / sizeof((x)[0]))
#define MIN(a,b) ((a) > (b) ? (b) : (a))
+#define TARGET_CORE 2
+#define SECONDARY_CORE 3
+
struct ipc {
pthread_mutex_t lock;
pthread_cond_t sig_parent;