#ifdef V3_CONFIG_CHECKPOINT
int v3_svm_save_core(struct guest_info * core, void * ctx){
- if (v3_chkpt_save_8(ctx, "cpl", &(core->cpl)) == -1) {
- PrintError("Could not save SVM cpl\n");
- return -1;
- }
-
- if (v3_chkpt_save(ctx, "vmcb_data", PAGE_SIZE, core->vmm_data) == -1) {
- PrintError("Could not save SVM vmcb\n");
- return -1;
- }
+ if (V3_CHKPT_SAVE(ctx, "cpl", core->cpl)) {
+ PrintError("Could not save SVM cpl\n");
+ return -1;
+ }
- return 0;
+ if (v3_chkpt_save(ctx, "vmcb_data", PAGE_SIZE, core->vmm_data)) {
+ PrintError("Could not save SVM vmcb\n");
+ return -1;
+ }
+
+ return 0;
}
int v3_svm_load_core(struct guest_info * core, void * ctx){
- if (v3_chkpt_load_8(ctx, "cpl", &(core->cpl)) == -1) {
- PrintError("Could not load SVM cpl\n");
- return -1;
- }
-
- if (v3_chkpt_load(ctx, "vmcb_data", PAGE_SIZE, core->vmm_data) == -1) {
- return -1;
- }
+ if (V3_CHKPT_LOAD(ctx, "cpl", core->cpl)) {
+ PrintError("Could not load SVM cpl\n");
+ return -1;
+ }
- return 0;
+ if (v3_chkpt_load(ctx, "vmcb_data", PAGE_SIZE, core->vmm_data) == -1) {
+ return -1;
+ }
+
+ return 0;
}
#endif
* JRL: This is broken
*/
int v3_vmx_save_core(struct guest_info * core, void * ctx){
- struct vmx_data * vmx_info = (struct vmx_data *)(core->vmm_data);
-
- // note that the vmcs pointer is an HPA, but we need an HVA
- if (v3_chkpt_save(ctx, "vmcs_data", PAGE_SIZE_4KB,
- V3_VAddr((void*) (vmx_info->vmcs_ptr_phys))) ==-1) {
- PrintError("Could not save vmcs data for VMX\n");
- return -1;
- }
-
- return 0;
+ struct vmx_data * vmx_info = (struct vmx_data *)(core->vmm_data);
+
+ // note that the vmcs pointer is an HPA, but we need an HVA
+ if (v3_chkpt_save(ctx, "vmcs_data", PAGE_SIZE_4KB,
+ V3_VAddr((void*) (vmx_info->vmcs_ptr_phys)))) {
+ PrintError("Could not save vmcs data for VMX\n");
+ return -1;
+ }
+
+ return 0;
}
int v3_vmx_load_core(struct guest_info * core, void * ctx){
- struct vmx_data * vmx_info = (struct vmx_data *)(core->vmm_data);
- struct cr0_32 * shadow_cr0;
- addr_t vmcs_page_paddr; //HPA
-
- vmcs_page_paddr = (addr_t) V3_AllocPages(1);
-
- if (!vmcs_page_paddr) {
- PrintError("Could not allocate space for a vmcs in VMX\n");
- return -1;
- }
-
- if (v3_chkpt_load(ctx, "vmcs_data", PAGE_SIZE_4KB,
- V3_VAddr((void *)vmcs_page_paddr)) == -1) {
- PrintError("Could not load vmcs data for VMX\n");
- return -1;
- }
-
- vmcs_clear(vmx_info->vmcs_ptr_phys);
-
- // Probably need to delete the old one...
- V3_FreePages((void*)(vmx_info->vmcs_ptr_phys),1);
-
- vmcs_load(vmcs_page_paddr);
-
- v3_vmx_save_vmcs(core);
-
- shadow_cr0 = (struct cr0_32 *)&(core->ctrl_regs.cr0);
+ struct vmx_data * vmx_info = (struct vmx_data *)(core->vmm_data);
+ struct cr0_32 * shadow_cr0;
+ addr_t vmcs_page_paddr; //HPA
+
+ vmcs_page_paddr = (addr_t) V3_AllocPages(1);
+
+ if (!vmcs_page_paddr) {
+ PrintError("Could not allocate space for a vmcs in VMX\n");
+ return -1;
+ }
+
+ if (v3_chkpt_load(ctx, "vmcs_data", PAGE_SIZE_4KB,
+ V3_VAddr((void *)vmcs_page_paddr)) == -1) {
+ PrintError("Could not load vmcs data for VMX\n");
+ V3_FreePages((void*)vmcs_page_paddr,1);
+ return -1;
+ }
+
+ vmcs_clear(vmx_info->vmcs_ptr_phys);
+
+ // Probably need to delete the old one...
+ V3_FreePages((void*)(vmx_info->vmcs_ptr_phys),1);
+
+ vmcs_load(vmcs_page_paddr);
+
+ v3_vmx_save_vmcs(core);
+ shadow_cr0 = (struct cr0_32 *)&(core->ctrl_regs.cr0);
- /* Get the CPU mode to set the guest_ia32e entry ctrl */
- if (core->shdw_pg_mode == SHADOW_PAGING) {
- if (v3_get_vm_mem_mode(core) == VIRTUAL_MEM) {
- if (v3_activate_shadow_pt(core) == -1) {
- PrintError("Failed to activate shadow page tables\n");
- return -1;
- }
- } else {
- if (v3_activate_passthrough_pt(core) == -1) {
- PrintError("Failed to activate passthrough page tables\n");
- return -1;
- }
- }
+ /* Get the CPU mode to set the guest_ia32e entry ctrl */
+
+ if (core->shdw_pg_mode == SHADOW_PAGING) {
+ if (v3_get_vm_mem_mode(core) == VIRTUAL_MEM) {
+ if (v3_activate_shadow_pt(core) == -1) {
+ PrintError("Failed to activate shadow page tables\n");
+ return -1;
+ }
+ } else {
+ if (v3_activate_passthrough_pt(core) == -1) {
+ PrintError("Failed to activate passthrough page tables\n");
+ return -1;
+ }
}
-
- return 0;
+ }
+
+ return 0;
}
#endif