diff options
| author | Louis Burda <quent.burda@gmail.com> | 2023-01-10 01:37:23 +0100 |
|---|---|---|
| committer | Louis Burda <quent.burda@gmail.com> | 2023-01-10 01:38:43 +0100 |
| commit | 252b11a01e061fd17821e53a41c8451a1d2c27bd (patch) | |
| tree | e887ead2faddc8691fc13da426655a0062351cdc /util | |
| parent | 864f5fa9d539734d823b3d0613dbf1a43beec334 (diff) | |
| download | cachepc-252b11a01e061fd17821e53a41c8451a1d2c27bd.tar.gz cachepc-252b11a01e061fd17821e53a41c8451a1d2c27bd.zip | |
Begin ioctl and test-case overhaul
Diffstat (limited to 'util')
| -rw-r--r-- | util/.gitignore | 1 | ||||
| -rw-r--r-- | util/debug.c | 9 | ||||
| -rw-r--r-- | util/reset.c | 13 | ||||
| -rw-r--r-- | util/svme.c | 25 |
4 files changed, 32 insertions, 16 deletions
diff --git a/util/.gitignore b/util/.gitignore index 52ab6d3..ef5bc67 100644 --- a/util/.gitignore +++ b/util/.gitignore @@ -1,2 +1,3 @@ debug +svme reset diff --git a/util/debug.c b/util/debug.c index 7a1e259..bfc8129 100644 --- a/util/debug.c +++ b/util/debug.c @@ -1,13 +1,12 @@ #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> +#include <stdint.h> +#include <stdlib.h> int main(int argc, const char **argv) @@ -18,9 +17,9 @@ main(int argc, const char **argv) fd = open("/dev/kvm", O_RDONLY); if (fd < 0) err(1, "open"); - arg = argc > 1 ? atoi(argv[1]) : 1; + arg = argc > 1 ? atoi(argv[1]) : 1; ret = ioctl(fd, KVM_CPC_DEBUG, &arg); - if (ret == -1) err(1, "ioctl DEBUG"); + if (ret == -1) err(1, "ioctl KVM_CPC_DEBUG"); close(fd); } diff --git a/util/reset.c b/util/reset.c index 125a2b6..6285149 100644 --- a/util/reset.c +++ b/util/reset.c @@ -1,29 +1,20 @@ #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"); + ret = ioctl(fd, KVM_CPC_RESET); + if (ret) warn("ioctl KVM_CPC_RESET"); close(fd); } diff --git a/util/svme.c b/util/svme.c new file mode 100644 index 0000000..4876ac4 --- /dev/null +++ b/util/svme.c @@ -0,0 +1,25 @@ +#include "cachepc/uapi.h" + +#include <sys/ioctl.h> +#include <err.h> +#include <fcntl.h> +#include <unistd.h> +#include <stdint.h> +#include <stdio.h> + +int +main(int argc, const char **argv) +{ + uint32_t svme; + int kvm_fd; + + kvm_fd = open("/dev/kvm", O_RDWR); + if (kvm_fd < 0) err(1, "open /dev/kvm"); + + if (ioctl(kvm_fd, KVM_CPC_SVME_READ, &svme)) + err(1, "ioctl KVM_CPC_SVME_READ"); + + printf("%u\n", svme); + + close(kvm_fd); +} |
