summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorLouis Burda <quent.burda@gmail.com>2022-10-05 15:05:19 +0200
committerLouis Burda <quent.burda@gmail.com>2022-10-05 15:05:19 +0200
commit58d8565f015f9e06e1e51a0fe4654b966b2c27c0 (patch)
treee862ba1491cb114be46e98022ce8feaf98f8eca2 /test
parent8b1535789509812763de132f877b596d01861714 (diff)
downloadcachepc-58d8565f015f9e06e1e51a0fe4654b966b2c27c0.tar.gz
cachepc-58d8565f015f9e06e1e51a0fe4654b966b2c27c0.zip
Refactor sevstep kernel patch into repository
Diffstat (limited to 'test')
-rw-r--r--[-rwxr-xr-x]test/access.c2
-rw-r--r--[-rwxr-xr-x]test/eviction.c2
-rw-r--r--[-rwxr-xr-x]test/kvm.c3
-rw-r--r--[-rwxr-xr-x]test/sev-es.c3
-rw-r--r--[-rwxr-xr-x]test/sev.c3
-rw-r--r--test/sevstep.c32
6 files changed, 37 insertions, 8 deletions
diff --git a/test/access.c b/test/access.c
index 22e2fb8..1e38e1e 100755..100644
--- a/test/access.c
+++ b/test/access.c
@@ -1,4 +1,4 @@
-#include "cachepc_user.h"
+#include "cachepc/uapi.h"
#include <sys/ioctl.h>
#include <stdlib.h>
diff --git a/test/eviction.c b/test/eviction.c
index e68132b..9fb57b5 100755..100644
--- a/test/eviction.c
+++ b/test/eviction.c
@@ -1,4 +1,4 @@
-#include "cachepc_user.h"
+#include "cachepc/uapi.h"
#include <sys/ioctl.h>
#include <fcntl.h>
diff --git a/test/kvm.c b/test/kvm.c
index 42d7f5a..cd0dd4d 100755..100644
--- a/test/kvm.c
+++ b/test/kvm.c
@@ -1,7 +1,6 @@
-/* for CPU_ZERO macros.. */
#define _GNU_SOURCE
-#include "cachepc_user.h"
+#include "cachepc/uapi.h"
#include <linux/kvm.h>
#include <sys/syscall.h>
diff --git a/test/sev-es.c b/test/sev-es.c
index 17cb72c..f2a6f5c 100755..100644
--- a/test/sev-es.c
+++ b/test/sev-es.c
@@ -1,7 +1,6 @@
-/* for CPU_ZERO macros.. */
#define _GNU_SOURCE
-#include "cachepc_user.h"
+#include "cachepc/uapi.h"
#include <linux/psp-sev.h>
#include <linux/kvm.h>
diff --git a/test/sev.c b/test/sev.c
index e6da94c..73bb91f 100755..100644
--- a/test/sev.c
+++ b/test/sev.c
@@ -1,7 +1,6 @@
-/* for CPU_ZERO macros.. */
#define _GNU_SOURCE
-#include "cachepc_user.h"
+#include "cachepc/uapi.h"
#include <linux/psp-sev.h>
#include <linux/kvm.h>
diff --git a/test/sevstep.c b/test/sevstep.c
new file mode 100644
index 0000000..3ca7f03
--- /dev/null
+++ b/test/sevstep.c
@@ -0,0 +1,32 @@
+#include "sevstep/uapi.h"
+
+#include <linux/kvm.h>
+#include <sys/ioctl.h>
+
+#include <err.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+int
+main(int argc, const char **argv)
+{
+ track_all_pages_t tracking;
+ int ret, fd;
+
+ fd = open("/proc/cachepc");
+ if (!fd) err(1, "open");
+
+ tracking.track_mode = KVM_PAGE_TRACK_ACCESS;
+ ret = ioctl(fd, KVM_USPT_TRACK_ALL, &tracking);
+ if (ret == -1) err(1, "ioctl TRACK_ALL ACCESS");
+
+
+ tracking.track_mode = KVM_PAGE_TRACK_RESET_ACCESSED;
+ ret = ioctl(fd, KVM_USPT_TRACK_ALL, &tracking);
+ if (ret == -1) err(1, "ioctl TRACK_ALL RESET_ACCESSED");
+
+ ret = ioctl(fd, KVM_USPT_UNTRACK_ALL, &tracking);
+ if (ret == -1) err(1, "ioctl UNTRACK_ALL");
+
+ close(fd);
+}