cachepc

Prime+Probe cache-based side-channel attack on AMD SEV-SNP protected virtual machines
git clone https://git.sinitax.com/sinitax/cachepc
Log | Files | Refs | Submodules | README | sfeed.txt

kvm.h (1279B)


      1#pragma once
      2
      3#include "util.h"
      4
      5#include <stdint.h>
      6#include <stdlib.h>
      7
      8#define MAIN_VMFD -0x42
      9
     10enum { WITH, WITHOUT };
     11
     12enum {
     13	GSTATE_UNINIT,
     14	GSTATE_LUPDATE,
     15	GSTATE_LSECRET,
     16	GSTATE_RUNNING,
     17	GSTATE_SUPDATE,
     18	GSTATE_RUPDATE,
     19	GSTATE_SENT
     20};
     21
     22struct kvm {
     23	int fd, vmfd, vcpufd;
     24	void *mem;
     25	size_t memsize, runsize;
     26	struct kvm_run *run;
     27};
     28
     29struct guest {
     30	void *code;
     31	size_t code_size;
     32	size_t mem_size;
     33};
     34
     35const char *sev_fwerr_str(int code);
     36const char *sev_gstate_str(int code);
     37
     38int sev_ioctl(int vmfd, int cmd, void *data, int *error);
     39void sev_get_measure(int vmfd);
     40uint8_t sev_guest_state(int vmfd, uint32_t handle);
     41
     42void guest_init(struct guest *guest, const char *filename);
     43void guest_deinit(struct guest *guest);
     44
     45void kvm_init(struct kvm *kvm, struct guest *guest);
     46void sev_kvm_init(struct kvm *kvm, struct guest *guest);
     47void sev_es_kvm_init(struct kvm *kvm, struct guest *guest);
     48void sev_snp_kvm_init(struct kvm *kvm, struct guest *guest);
     49void kvm_deinit(struct kvm *kvm);
     50
     51uint64_t vm_get_rip(void);
     52void parse_vmtype(int argc, const char **argv);
     53void vm_init(struct kvm *kvm, struct guest *guest);
     54void vm_deinit(struct kvm *kvm);
     55
     56void kvm_setup_init(void);
     57void kvm_setup_deinit(void);
     58
     59extern int kvm_dev, sev_dev;
     60extern const char *vmtype;
     61