diff options
| author | Louis Burda <quent.burda@gmail.com> | 2023-01-27 00:01:09 +0100 |
|---|---|---|
| committer | Louis Burda <quent.burda@gmail.com> | 2023-01-27 00:55:29 +0100 |
| commit | 1f418a1c4480cef90b8596ae17bdca9cc7ca1b88 (patch) | |
| tree | b0358e4febd22c65612c80fa93cfaeb0a3510053 /test/qemu-pagestep.c | |
| parent | 5e21196a9c7ee8eee921d74f6b5eef2f1980ec97 (diff) | |
| download | cachepc-1f418a1c4480cef90b8596ae17bdca9cc7ca1b88.tar.gz cachepc-1f418a1c4480cef90b8596ae17bdca9cc7ca1b88.zip | |
Added initial qemu-eviction and qemu-pagestep
Qemu-eviction seems to get stuck somewhere, potentially in the VC-handler(?) since we use the active gfn after resuming execution. Added qemu-pagestep to show viability of page-stepping for later use.
Diffstat (limited to 'test/qemu-pagestep.c')
| -rw-r--r-- | test/qemu-pagestep.c | 63 |
1 files changed, 63 insertions, 0 deletions
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(); +} + |
