summaryrefslogtreecommitdiffstats
path: root/sevstep
diff options
context:
space:
mode:
authorLouis Burda <quent.burda@gmail.com>2022-10-05 15:33:22 +0200
committerLouis Burda <quent.burda@gmail.com>2022-10-05 15:33:32 +0200
commitda76c11f2059a8696a3df41844d49f82e6988843 (patch)
tree908ee65da099e713b6986434472485f57d6a00ea /sevstep
parent58d8565f015f9e06e1e51a0fe4654b966b2c27c0 (diff)
downloadcachepc-da76c11f2059a8696a3df41844d49f82e6988843.tar.gz
cachepc-da76c11f2059a8696a3df41844d49f82e6988843.zip
Fix uapi types and expose KVM_TRACK enum
Diffstat (limited to 'sevstep')
-rw-r--r--sevstep/kvm.h2
-rw-r--r--sevstep/uapi.h77
2 files changed, 44 insertions, 35 deletions
diff --git a/sevstep/kvm.h b/sevstep/kvm.h
index 35cb4d5..2c4dc5e 100644
--- a/sevstep/kvm.h
+++ b/sevstep/kvm.h
@@ -1,4 +1,4 @@
#pragma once
-#include "sev-step.h"
+#include "sevstep.h"
#include "uapi.h"
diff --git a/sevstep/uapi.h b/sevstep/uapi.h
index e41a036..5129750 100644
--- a/sevstep/uapi.h
+++ b/sevstep/uapi.h
@@ -12,75 +12,84 @@
#define KVM_USPT_RESET _IO(KVMIO, 0x26)
#define KVM_USPT_TRACK_ALL _IOWR(KVMIO, 0x27, track_all_pages_t)
#define KVM_USPT_UNTRACK_ALL _IOWR(KVMIO, 0x28, track_all_pages_t)
-#define KVM_USPT_SETUP_RETINSTR_PERF _IOWR(KVMIO, 0x30,retired_instr_perf_config_t)
-#define KVM_USPT_READ_RETINSTR_PERF _IOWR(KVMIO,0x31, retired_instr_perf_t)
-#define KVM_USPT_BATCH_TRACK_START _IOWR(KVMIO,0x32,batch_track_config_t)
-#define KVM_USPT_BATCH_TRACK_STOP _IOWR(KVMIO,0x33,batch_track_stop_and_get_t)
-#define KVM_USPT_BATCH_TRACK_EVENT_COUNT _IOWR(KVMIO,0x34,batch_track_event_count_t)
+#define KVM_USPT_SETUP_RETINSTR_PERF _IOWR(KVMIO, 0x30, retired_instr_perf_config_t)
+#define KVM_USPT_READ_RETINSTR_PERF _IOWR(KVMIO, 0x31, retired_instr_perf_t)
+#define KVM_USPT_BATCH_TRACK_START _IOWR(KVMIO, 0x32, batch_track_config_t)
+#define KVM_USPT_BATCH_TRACK_STOP _IOWR(KVMIO, 0x33, batch_track_stop_and_get_t)
+#define KVM_USPT_BATCH_TRACK_EVENT_COUNT _IOWR(KVMIO, 0x34, batch_track_event_count_t)
#define KVM_USPT_POLL_EVENT_NO_EVENT 1000
#define KVM_USPT_POLL_EVENT_GOT_EVENT 0
+enum kvm_page_track_mode {
+ KVM_PAGE_TRACK_WRITE,
+ KVM_PAGE_TRACK_ACCESS,
+ KVM_PAGE_TRACK_RESET_ACCESSED,
+ KVM_PAGE_TRACK_EXEC,
+ KVM_PAGE_TRACK_RESET_EXEC,
+ KVM_PAGE_TRACK_MAX,
+};
+
typedef struct {
- uint64_t id; // filled automatically
- uint64_t faulted_gpa;
- uint32_t error_code;
- bool have_rip_info;
- uint64_t rip;
- uint64_t ns_timestamp;
- bool have_retired_instructions;
- uint64_t retired_instructions;
+ __u64 id; // filled automatically
+ __u64 faulted_gpa;
+ __u32 error_code;
+ __u8 have_rip_info;
+ __u64 rip;
+ __u64 ns_timestamp;
+ __u8 have_retired_instructions;
+ __u64 retired_instructions;
} page_fault_event_t;
typedef struct {
- int tracking_type;
- uint64_t expected_events;
- int perf_cpu;
- bool retrack;
+ __s32 tracking_type;
+ __u64 expected_events;
+ __s32 perf_cpu;
+ __u8 retrack;
} batch_track_config_t;
typedef struct {
- uint64_t event_count;
+ __u64 event_count;
} batch_track_event_count_t;
typedef struct {
page_fault_event_t* out_buf;
- uint64_t len;
- bool error_during_batch;
+ __u64 len;
+ __u8 error_during_batch;
} batch_track_stop_and_get_t;
typedef struct {
- int cpu; // cpu on which we want to read the counter
- uint64_t retired_instruction_count; // result param
+ __s32 cpu; // cpu on which we want to read the counter
+ __u64 retired_instruction_count; // result param
} retired_instr_perf_t;
typedef struct {
- int cpu; // cpu on which counter should be programmed
+ __s32 cpu; // cpu on which counter should be programmed
} retired_instr_perf_config_t;
typedef struct {
- uint64_t gpa;
- uint64_t len;
- bool decrypt_with_host_key;
- int wbinvd_cpu; // -1: do not flush; else logical cpu on which we flush
- void* output_buffer;
+ __u64 gpa;
+ __u64 len;
+ __u8 decrypt_with_host_key;
+ __s32 wbinvd_cpu; // -1: do not flush; else logical cpu on which we flush
+ __u64 output_buffer;
} read_guest_memory_t;
typedef struct {
- int pid;
- bool get_rip;
+ __s32 pid;
+ __u8 get_rip;
} userspace_ctx_t;
typedef struct {
- uint64_t id;
+ __u64 id;
} ack_event_t;
typedef struct {
- uint64_t gpa;
- int track_mode;
+ __u64 gpa;
+ __s32 track_mode;
} track_page_param_t;
typedef struct {
- int track_mode;
+ __s32 track_mode;
} track_all_pages_t;