summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorLouis Burda <quent.burda@gmail.com>2022-10-05 15:03:22 +0200
committerLouis Burda <quent.burda@gmail.com>2022-10-05 15:03:22 +0200
commitf7ca163ec9da35ec4021eaf1f1d72a0db9eaf86c (patch)
tree376c1c05f639334bd92009e70a25cb44ac91cfd4 /include
parent53ba88082be0d1562fa57c3fb61522b0a0dc4541 (diff)
downloadcachepc-linux-f7ca163ec9da35ec4021eaf1f1d72a0db9eaf86c.tar.gz
cachepc-linux-f7ca163ec9da35ec4021eaf1f1d72a0db9eaf86c.zip
Refactor out sevstep into cachepc repository
Diffstat (limited to 'include')
-rwxr-xr-xinclude/linux/sev-step.h68
-rwxr-xr-xinclude/linux/userspace_page_track_signals.h59
-rw-r--r--[-rwxr-xr-x]include/uapi/linux/kvm.h95
3 files changed, 0 insertions, 222 deletions
diff --git a/include/linux/sev-step.h b/include/linux/sev-step.h
deleted file mode 100755
index ec49e5526edd..000000000000
--- a/include/linux/sev-step.h
+++ /dev/null
@@ -1,68 +0,0 @@
-#ifndef SEV_STEP_H
-#define SEV_STEP_H
-
-#include <linux/types.h>
-#include <linux/spinlock_types.h>
-#include <asm/atomic.h>
-#include <linux/kvm_types.h>
-#include <asm/kvm_page_track.h>
-
-#include <linux/kvm_host.h> //struct kvm
-#include <linux/pid.h>
-#include <linux/psp-sev.h>
-
-
-
-
-
-#define CTL_MSR_0 0xc0010200ULL
-#define CTL_MSR_1 0xc0010202ULL
-#define CTL_MSR_2 0xc0010204ULL
-#define CTL_MSR_3 0xc0010206ULL
-#define CTL_MSR_4 0xc0010208ULL
-#define CTL_MSR_5 0xc001020aULL
-
-#define CTR_MSR_0 0xc0010201ULL
-#define CTR_MSR_1 0xc0010203ULL
-#define CTR_MSR_2 0xc0010205ULL
-#define CTR_MSR_3 0xc0010207ULL
-#define CTR_MSR_4 0xc0010209ULL
-#define CTR_MSR_5 0xc001020bULL
-
-typedef struct {
- uint64_t HostGuestOnly;
- uint64_t CntMask;
- uint64_t Inv;
- uint64_t En;
- uint64_t Int;
- uint64_t Edge;
- uint64_t OsUserMode;
- uint64_t UintMask;
- uint64_t EventSelect; //12 bits in total split in [11:8] and [7:0]
-
-} perf_ctl_config_t;
-
-
-extern struct kvm* main_vm;
-
-
-bool __untrack_single_page(struct kvm_vcpu *vcpu, gfn_t gfn,
- enum kvm_page_track_mode mode);//defined in x86.c
-
-bool __track_single_page(struct kvm_vcpu *vcpu, gfn_t gfn,
- enum kvm_page_track_mode mode); //defined in x86.c
-bool __reset_accessed_on_page(struct kvm_vcpu *vcpu, gfn_t gfn); //defined in x86.c
-bool __clear_nx_on_page(struct kvm_vcpu *vcpu, gfn_t gfn); //defined in x86.c
-long kvm_start_tracking(struct kvm_vcpu *vcpu,enum kvm_page_track_mode mode );
-long kvm_stop_tracking(struct kvm_vcpu *vcpu,enum kvm_page_track_mode mode );
-void sev_step_handle_callback(void);
-
-uint64_t perf_ctl_to_u64(perf_ctl_config_t * config);
-void write_ctl(perf_ctl_config_t * config, int cpu, uint64_t ctl_msr);
-void read_ctr(uint64_t ctr_msr, int cpu, uint64_t* result);
-void setup_perfs(void);
-
-
-int sev_step_get_rip_kvm_vcpu(struct kvm_vcpu* vcpu,uint64_t *rip);
-
-#endif
diff --git a/include/linux/userspace_page_track_signals.h b/include/linux/userspace_page_track_signals.h
deleted file mode 100755
index dc3fea4a9af7..000000000000
--- a/include/linux/userspace_page_track_signals.h
+++ /dev/null
@@ -1,59 +0,0 @@
-#ifndef USERSPACE_PAGE_TRACK_SIGNALS
-#define USERSPACE_PAGE_TRACK_SIGNALS
-
-#include<linux/kvm.h>
-#include<linux/kvm_host.h>
-#include<linux/types.h>
-
-
-//
-// User space signaling
-//
-
-int uspt_initialize(int pid,bool should_get_rip);
-int uspt_is_initialiized(void);
-void uspt_clear(void);
-
-bool uspt_should_get_rip(void);
-
-
-int uspt_send_and_block(uint64_t faulted_gpa, uint32_t error_code, bool have_rip,uint64_t rip);
-
-int uspt_is_event_done(uint64_t id);
-
-//prepare next event based on faulted_gpa and error_code. Notify process behind pid_number. Event must be polled
-//id is result param with the id used for the event. Can be used to call uspt_is_event_done
-int uspt_send_notification(int pid_number, uint64_t faulted_gpa, uint32_t error_code,uint64_t* id);
-
-//copy next event to userpace_mem
-int uspt_handle_poll_event(page_fault_event_t* userpace_mem);
-
-//acknowledge receival of event to event handling logic
-int uspt_handle_ack_event_ioctl(ack_event_t event);
-
-//
-// Batch Tracking
-//
-
-//should be called after "uspt_batch_tracking_save", "uspt_batch_tracking_handle_retrack" and any future custom logic
-//for an event is processed
-void uspt_batch_tracking_inc_event_idx(void);
-
-int uspt_batch_tracking_start(int tracking_type,uint64_t expected_events, int perf_cpu,bool retrack);
-
-int uspt_batch_tracking_save(uint64_t faulted_gpa, uint32_t error_code, bool have_rip,uint64_t rip);
-
-uint64_t uspt_batch_tracking_get_events_count(void);
-
-//Stops batch tracking on copies the first @len events into @result. If an error occured at some point
-//during the batch tracking, error_occured is set(there should also be a dmesg, but this allows programatic access);
-//Caller can use uspt_batch_tracking_get_events_count() to determine the amount of memory they should allocate for
-//@results
-int uspt_batch_tracking_stop(page_fault_event_t* results, uint64_t len,bool* error_occured);
-
-void uspt_batch_tracking_handle_retrack(struct kvm_vcpu* vcpu,uint64_t current_fault_gfn);
-
-void uspt_batch_tracking_get_retrack_gfns(uint64_t** gfns, uint64_t* len,int * tracking_type);
-
-bool uspt_batch_tracking_in_progress(void);
-#endif
diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h
index 81b232132f66..f288b421b603 100755..100644
--- a/include/uapi/linux/kvm.h
+++ b/include/uapi/linux/kvm.h
@@ -16,78 +16,6 @@
#define KVM_API_VERSION 12
-#define KVM_USPT_POLL_EVENT_NO_EVENT 1000
-#define KVM_USPT_POLL_EVENT_GOT_EVENT 0
-
-
-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;
-} page_fault_event_t;
-
-typedef struct {
- int tracking_type;
- uint64_t expected_events;
- int perf_cpu;
- bool retrack;
-} batch_track_config_t;
-
-typedef struct {
- uint64_t event_count;
-} batch_track_event_count_t;
-
-typedef struct {
- page_fault_event_t* out_buf;
- uint64_t len;
- bool 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
-} retired_instr_perf_t;
-
-typedef struct {
- int 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;
-}read_guest_memory_t;
-
-typedef struct {
- int pid;
- bool get_rip;
-} userspace_ctx_t;
-
-
-typedef struct {
- uint64_t id;
-} ack_event_t;
-
-
-typedef struct {
- uint64_t gpa;
- int track_mode;
-} track_page_param_t;
-
-
-typedef struct {
- int track_mode;
-} track_all_pages_t;
-
-
-
/* *** Deprecated interfaces *** */
#define KVM_TRC_SHIFT 16
@@ -993,29 +921,6 @@ struct kvm_ppc_resize_hpt {
#define KVM_GET_EMULATED_CPUID _IOWR(KVMIO, 0x09, struct kvm_cpuid2)
#define KVM_GET_MSR_FEATURE_INDEX_LIST _IOWR(KVMIO, 0x0a, struct kvm_msr_list)
-
-//
-// SNP ATTACK IOCTLS
-//
-
-#define KVM_TRACK_PAGE _IOWR(KVMIO, 0x20, track_page_param_t)
-#define KVM_USPT_REGISTER_PID _IOWR(KVMIO, 0x21, userspace_ctx_t)
-#define KVM_USPT_WAIT_AND_SEND _IO(KVMIO, 0x22)
-#define KVM_USPT_POLL_EVENT _IOWR(KVMIO, 0x23, page_fault_event_t)
-#define KVM_USPT_ACK_EVENT _IOWR(KVMIO, 0x24, ack_event_t)
-#define KVM_READ_GUEST_MEMORY _IOWR(KVMIO, 0x25, read_guest_memory_t)
-#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)
-
-
-
-
/*
* Extension capability list.
*/