-/* $OpenBSD: vmm.c,v 1.28 2017/04/26 08:02:14 mlarkin Exp $ */
+/* $OpenBSD: vmm.c,v 1.29 2017/05/02 07:18:19 mlarkin Exp $ */
/*
* Copyright (c) 2014 Mike Larkin <mlarkin@openbsd.org>
*
uint32_t sel, limit, ar;
uint32_t *gprs = vrs->vrs_gprs;
uint32_t *crs = vrs->vrs_crs;
+ uint32_t *msrs = vrs->vrs_msrs;
struct vcpu_segment_info *sregs = vrs->vrs_sregs;
+ struct vmx_msr_store *msr_store;
if (vcpu_reload_vmcs_vmx(&vcpu->vc_control_pa))
return (EINVAL);
goto errout;
}
+ msr_store = (struct vmx_msr_store *)vcpu->vc_vmx_msr_exit_save_va;
+
+ if (regmask & VM_RWREGS_MSRS) {
+ for (i = 0; i < VCPU_REGS_NMSRS; i++) {
+ msrs[i] = msr_store[i].vms_data;
+ }
+ }
+
goto out;
errout:
uint32_t limit, ar;
uint32_t *gprs = vrs->vrs_gprs;
uint32_t *crs = vrs->vrs_crs;
+ uint32_t *msrs = vrs->vrs_msrs;
struct vcpu_segment_info *sregs = vrs->vrs_sregs;
+ struct vmx_msr_store *msr_store;
if (loadvmcs) {
if (vcpu_reload_vmcs_vmx(&vcpu->vc_control_pa))
goto errout;
}
+ msr_store = (struct vmx_msr_store *)vcpu->vc_vmx_msr_exit_save_va;
+
+ if (regmask & VM_RWREGS_MSRS) {
+ for (i = 0; i < VCPU_REGS_NMSRS; i++) {
+ msr_store[i].vms_data = msrs[i];
+ }
+ }
+
goto out;
errout:
msr_store = (struct vmx_msr_store *)vcpu->vc_vmx_msr_exit_save_va;
msr_store[0].vms_index = MSR_EFER;
- msr_store[0].vms_data = 0ULL; /* Initial value */
/*
* Currently we have the same count of entry/exit MSRs loads/stores
#define VCPU_REGS_TR 7
#define VCPU_REGS_NSREGS (VCPU_REGS_TR + 1)
+#define VCPU_REGS_EFER 0
+#define VCPU_REGS_NMSRS (VCPU_REGS_EFER + 1)
+
struct vcpu_reg_state {
uint32_t vrs_gprs[VCPU_REGS_NGPRS];
uint32_t vrs_crs[VCPU_REGS_NCRS];
+ uint32_t vrs_msrs[VCPU_REGS_NMSRS];
struct vcpu_segment_info vrs_sregs[VCPU_REGS_NSREGS];
struct vcpu_segment_info vrs_gdtr;
struct vcpu_segment_info vrs_idtr;
#define VM_RWREGS_GPRS 0x1 /* read/write GPRs */
#define VM_RWREGS_SREGS 0x2 /* read/write segment registers */
#define VM_RWREGS_CRS 0x4 /* read/write CRs */
-#define VM_RWREGS_ALL (VM_RWREGS_GPRS | VM_RWREGS_SREGS | VM_RWREGS_CRS)
+#define VM_RWREGS_MSRS 0x8 /* read/write MSRs */
+#define VM_RWREGS_ALL (VM_RWREGS_GPRS | VM_RWREGS_SREGS | VM_RWREGS_CRS | \
+ VM_RWREGS_MSRS)
struct vm_rwregs_params {
uint32_t vrwp_vm_id;