diff options
Diffstat (limited to 'util')
| -rw-r--r-- | util/.gitignore | 2 | ||||
| -rw-r--r-- | util/debug.c | 26 | ||||
| -rw-r--r-- | util/reset.c | 29 |
3 files changed, 57 insertions, 0 deletions
diff --git a/util/.gitignore b/util/.gitignore new file mode 100644 index 0000000..52ab6d3 --- /dev/null +++ b/util/.gitignore @@ -0,0 +1,2 @@ +debug +reset diff --git a/util/debug.c b/util/debug.c new file mode 100644 index 0000000..7a1e259 --- /dev/null +++ b/util/debug.c @@ -0,0 +1,26 @@ +#include "cachepc/uapi.h" + +#include <sys/ioctl.h> +#include <stdlib.h> +#include <stdio.h> +#include <fcntl.h> +#include <stdint.h> +#include <err.h> +#include <fcntl.h> +#include <unistd.h> + +int +main(int argc, const char **argv) +{ + uint32_t arg; + int fd, ret; + + fd = open("/dev/kvm", O_RDONLY); + if (fd < 0) err(1, "open"); + + arg = argc > 1 ? atoi(argv[1]) : 1; + ret = ioctl(fd, KVM_CPC_DEBUG, &arg); + if (ret == -1) err(1, "ioctl DEBUG"); + + close(fd); +} diff --git a/util/reset.c b/util/reset.c new file mode 100644 index 0000000..125a2b6 --- /dev/null +++ b/util/reset.c @@ -0,0 +1,29 @@ +#include "cachepc/uapi.h" + +#include <sys/ioctl.h> +#include <stdlib.h> +#include <stdio.h> +#include <fcntl.h> +#include <stdint.h> +#include <err.h> +#include <fcntl.h> +#include <unistd.h> + +int +main(int argc, const char **argv) +{ + uint64_t arg; + int fd, ret; + + fd = open("/dev/kvm", O_RDONLY); + if (fd < 0) err(1, "open"); + + ret = ioctl(fd, KVM_CPC_RESET_TRACKING); + if (ret) warn("ioctl RESET_TRACKING"); + + arg = 0; + ret = ioctl(fd, KVM_CPC_ACK_EVENT, &arg); + if (ret) warn("ioctl ACK_EVENT"); + + close(fd); +} |
