commit 7772e36f54534aeefe70c01e77bbc1a5f07b2508
parent c1cc24c1e78f9c67bda882f2ee096fb8d6578cf0
Author: Louis Burda <quent.burda@gmail.com>
Date: Mon, 9 Jan 2023 12:38:14 +0100
Stash minor fixes
Diffstat:
5 files changed, 27 insertions(+), 20 deletions(-)
diff --git a/Makefile b/Makefile
@@ -10,7 +10,7 @@ BINS += test/readsvme util/debug util/reset
CFLAGS = -I . -I test -Wunused-variable -Wunknown-pragmas
-all: cachepc $(BINS)
+all: build $(BINS)
clean:
$(MAKE) -C $(LINUX) SUBDIRS=arch/x86/kvm clean
@@ -32,7 +32,7 @@ host:
git -C $(LINUX) checkout HEAD
git -C $(LINUX) stash pop
-cachepc: $(LINUX)/arch/x86/kvm/cachepc
+build: $(LINUX)/arch/x86/kvm/cachepc
$(MAKE) -C $(LINUX) -j $(JOBS) M=arch/x86/kvm modules
$(MAKE) -C $(LINUX) -j $(JOBS) M=crypto modules
diff --git a/cachepc/cachepc.c b/cachepc/cachepc.c
@@ -163,7 +163,7 @@ cache_ctx *
cachepc_get_ctx(int cache_level)
{
cache_ctx *ctx;
-
+
ctx = kzalloc(sizeof(cache_ctx), GFP_KERNEL);
BUG_ON(ctx == NULL);
diff --git a/cachepc/uapi.h b/cachepc/uapi.h
@@ -30,28 +30,37 @@
#define KVM_CPC_TEST_ACCESS _IOWR(KVMIO, 0x20, __u32)
#define KVM_CPC_TEST_EVICTION _IOWR(KVMIO, 0x21, __u32)
-#define KVM_CPC_INIT_PMC _IOW(KVMIO, 0x22, __u32)
-#define KVM_CPC_READ_PMC _IOWR(KVMIO, 0x23, __u32)
-#define KVM_CPC_READ_COUNTS _IOR(KVMIO, 0x24, __u64)
-#define KVM_CPC_SETUP_PMC _IO(KVMIO, 0x25)
-#define KVM_CPC_MEASURE_BASELINE _IOW(KVMIO, 0x26, __u32)
-#define KVM_CPC_READ_BASELINE _IOR(KVMIO, 0x27, __u64)
-#define KVM_CPC_SUB_BASELINE _IOR(KVMIO, 0x28, __u32)
+
+#define KVM_CPC_SETUP_PMC _IO(KVMIO, 0x22)
+#define KVM_CPC_INIT_PMC _IOW(KVMIO, 0x23, __u32)
+#define KVM_CPC_READ_PMC _IOWR(KVMIO, 0x24, __u32)
+
+#define KVM_CPC_READ_COUNTS _IOR(KVMIO, 0x25, __u64)
+
+#define KVM_CPC_RESET_BASELINE _IO(KVMIO, 0x26)
+#define KVM_CPC_MEASURE_BASELINE _IOW(KVMIO, 0x27, __u32)
+#define KVM_CPC_READ_BASELINE _IOR(KVMIO, 0x28, __u64)
+#define KVM_CPC_SUB_BASELINE _IOR(KVMIO, 0x29, __u32)
+
#define KVM_CPC_SINGLE_STEP _IO(KVMIO, 0x29)
+
#define KVM_CPC_TRACK_MODE _IOWR(KVMIO, 0x2A, __u32)
+
#define KVM_CPC_VMSA_READ _IOR(KVMIO, 0x2B, __u64)
#define KVM_CPC_SVME_READ _IOR(KVMIO, 0x2C, __u32)
+
#define KVM_CPC_DEBUG _IOW(KVMIO, 0x2D, __u32)
#define KVM_CPC_TRACK_PAGE _IOWR(KVMIO, 0x30, struct cpc_track_config)
#define KVM_CPC_TRACK_ALL _IOWR(KVMIO, 0x31, __u32)
#define KVM_CPC_UNTRACK_ALL _IOWR(KVMIO, 0x32, __u32)
#define KVM_CPC_RESET_TRACKING _IO(KVMIO, 0x33)
-#define KVM_CPC_POLL_EVENT _IOWR(KVMIO, 0x34, struct cpc_event)
-#define KVM_CPC_ACK_EVENT _IOWR(KVMIO, 0x35, __u64)
-#define KVM_CPC_TRACK_RANGE_START _IOWR(KVMIO, 0x36, __u64)
-#define KVM_CPC_TRACK_RANGE_END _IOWR(KVMIO, 0x37, __u64)
-#define KVM_CPC_TRACK_EXEC_CUR _IOWR(KVMIO, 0x38, __u64)
+#define KVM_CPC_TRACK_RANGE_START _IOWR(KVMIO, 0x34, __u64)
+#define KVM_CPC_TRACK_RANGE_END _IOWR(KVMIO, 0x35, __u64)
+#define KVM_CPC_TRACK_EXEC_CUR _IOWR(KVMIO, 0x36, __u64)
+
+#define KVM_CPC_POLL_EVENT _IOWR(KVMIO, 0x37, struct cpc_event)
+#define KVM_CPC_ACK_EVENT _IOWR(KVMIO, 0x38, __u64)
enum {
CPC_EVENT_NONE,
diff --git a/test/aes-detect_guest.c b/test/aes-detect_guest.c
@@ -40,10 +40,8 @@ main(int argc, const char **argv)
while (1) {
CPC_DO_VMMCALL(CPC_GUEST_START_TRACK, 0);
-
buf[L1_LINESIZE * 5] += 1;
-
- CPC_DO_VMMCALL(CPC_GUEST_START_TRACK, 0);
+ CPC_DO_VMMCALL(CPC_GUEST_STOP_TRACK, 0);
}
return 0;
diff --git a/test/fullstep.c b/test/fullstep.c
@@ -460,8 +460,8 @@ monitor(struct kvm *kvm, bool baseline)
ret = ioctl(kvm_dev, KVM_CPC_READ_COUNTS, counts);
if (ret == -1) err(1, "ioctl READ_COUNTS");
- rip = 0; // snp_dbg_rip(kvm->vmfd);
if (!baseline) {
+ rip = snp_dbg_rip(kvm->vmfd);
printf("Event: cnt:%llu inst:%llu data:%llu retired:%llu rip:%lu\n",
event.step.fault_count,
event.step.fault_gfns[0],
@@ -542,7 +542,7 @@ main(int argc, const char **argv)
if ((pid = fork())) {
if (pid < 0) err(1, "fork");
- sleep(1); /* give time for child to pin other core */
+ sleep(1); /* wait for child to pin other core */
printf("VMRUN\n");
runonce(&kvm_with_access);