struct guest_info;
struct v3_vm_info;
+
+
+typedef enum {
+ TEST_HCALL = 0x0001,
+ SYMCALL_RET_HCALL = 0x0535, // args in GPRs
+ SYMCALL_ERR_HCALL = 0x0536, // RBX: error code
+ MEM_OFFSET_HCALL = 0x1000, // RBX: base addr(out)
+ GUEST_INFO_HCALL = 0x3000, // no args
+ TELEMETRY_HCALL = 0x3001, // no args
+ BALLOON_START_HCALL = 0xba00, // RAX: size
+ BALLOON_QUERY_HCALL = 0xba01, // RCX: req_pgs(out), RDX: alloc_pgs(out)
+ OS_DEBUG_HCALL = 0xc0c0 // RBX: msg_gpa, RCX: msg_len, RDX: buf_is_va (flag)
+} hcall_id_t;
+
+
+
+
void v3_init_hypercall_map(struct v3_vm_info * vm);
-int v3_register_hypercall(struct v3_vm_info * vm, uint_t hypercall_id,
- int (*hypercall)(struct guest_info * info , uint_t hcall_id, void * priv_data),
+int v3_register_hypercall(struct v3_vm_info * vm, hcall_id_t hypercall_id,
+ int (*hypercall)(struct guest_info * info , hcall_id_t hcall_id, void * priv_data),
void * priv_data);
-typedef enum {
- MEM_OFFSET_HCALL = 0x1000,
- GUEST_INFO_HCALL = 0x3000,
- TELEMETRY_HCALL = 0x3001,
- OS_DEBUG_HCALL = 0xc0c0
-} hcall_id_t;
-
-
#endif
#define PAGE_SIZE 4096
-#define BALLOON_START_HCALL 0xba00 // size in rax
-#define BALLOON_QUERY_HCALL 0xba01 // req_pgs in rcx, alloc_pgs in rdx
struct balloon_config {
uint32_t requested_pages;
#define BUF_SIZE 1024
#define DEBUG_PORT1 0xc0c0
-#define DEBUG_HCALL 0xc0c0
struct debug_state {
char debug_buf[BUF_SIZE];
}
v3_dev_hook_io(dev, DEBUG_PORT1, NULL, &handle_gen_write);
- v3_register_hypercall(vm, DEBUG_HCALL, handle_hcall, dev);
+ v3_register_hypercall(vm, OS_DEBUG_HCALL, handle_hcall, dev);
state->debug_offset = 0;
memset(state->debug_buf, 0, BUF_SIZE);
#include <palacios/vm_guest.h>
-#define HYPERCALL_TEST_HCALL 0x1
-
-static int hcall_test(struct guest_info * info, uint_t hcall_id, void * private_data) {
+static int hcall_test(struct guest_info * info, hcall_id_t hcall_id, void * private_data) {
info->vm_regs.rbx = 0x1111;
info->vm_regs.rcx = 0x2222;
info->vm_regs.rdx = 0x3333;
void v3_init_hypercall_map(struct v3_vm_info * vm) {
vm->hcall_map.rb_node = NULL;
- v3_register_hypercall(vm, HYPERCALL_TEST_HCALL, hcall_test, NULL);
+ v3_register_hypercall(vm, TEST_HCALL, hcall_test, NULL);
}
struct hypercall {
uint_t id;
- int (*hcall_fn)(struct guest_info * info, uint_t hcall_id, void * priv_data);
+ int (*hcall_fn)(struct guest_info * info, hcall_id_t hcall_id, void * priv_data);
void * priv_data;
struct rb_node tree_node;
}
-static struct hypercall * get_hypercall(struct v3_vm_info * vm, uint_t id) {
+static struct hypercall * get_hypercall(struct v3_vm_info * vm, hcall_id_t id) {
struct rb_node * n = vm->hcall_map.rb_node;
struct hypercall * hcall = NULL;
}
-int v3_register_hypercall(struct v3_vm_info * vm, uint_t hypercall_id,
- int (*hypercall)(struct guest_info * info, uint_t hcall_id, void * priv_data),
+int v3_register_hypercall(struct v3_vm_info * vm, hcall_id_t hypercall_id,
+ int (*hypercall)(struct guest_info * info, hcall_id_t hcall_id, void * priv_data),
void * priv_data) {
struct hypercall * hcall = (struct hypercall *)V3_Malloc(sizeof(struct hypercall));
int v3_handle_hypercall(struct guest_info * info) {
- uint_t hypercall_id = *(uint_t *)&info->vm_regs.rax;
-
+ hcall_id_t hypercall_id = *(uint_t *)&info->vm_regs.rax;
struct hypercall * hcall = get_hypercall(info->vm_info, hypercall_id);
if (!hcall) {
#include <palacios/vmm_shadow_paging.h>
#include <palacios/vmm_direct_paging.h>
-#define MEM_OFFSET_HCALL 0x1000
-
static inline
struct v3_shadow_region * insert_shadow_region(struct v3_vm_info * vm,
// A succesfull symcall returns via the RET_HCALL, with the return values in registers
// A symcall error returns via the ERR_HCALL with the error code in rbx
-#define SYM_CALL_RET_HCALL 0x535
-#define SYM_CALL_ERR_HCALL 0x536
/* Notes: We use a combination of SYSCALL and SYSENTER Semantics
v3_hook_msr(vm, SYMCALL_GS_MSR, symcall_msr_read, symcall_msr_write, NULL);
v3_hook_msr(vm, SYMCALL_FS_MSR, symcall_msr_read, symcall_msr_write, NULL);
- v3_register_hypercall(vm, SYM_CALL_RET_HCALL, sym_call_ret, NULL);
- v3_register_hypercall(vm, SYM_CALL_ERR_HCALL, sym_call_err, NULL);
+ v3_register_hypercall(vm, SYMCALL_RET_HCALL, sym_call_ret, NULL);
+ v3_register_hypercall(vm, SYMCALL_ERR_HCALL, sym_call_err, NULL);
return 0;
}