svn commit: r240894 - in projects/bhyve/sys/amd64: include vmm
vmm/amd vmm/intel
Neel Natu
neel at FreeBSD.org
Mon Sep 24 19:32:25 UTC 2012
Author: neel
Date: Mon Sep 24 19:32:24 2012
New Revision: 240894
URL: http://svn.freebsd.org/changeset/base/240894
Log:
Stash the 'vm_exit' information in each 'struct vcpu'.
There is no functional change at this time but this paves the way for vm exit
handler functions to easily modify the exit reason going forward.
Modified:
projects/bhyve/sys/amd64/include/vmm.h
projects/bhyve/sys/amd64/vmm/amd/amdv.c
projects/bhyve/sys/amd64/vmm/intel/vmx.c
projects/bhyve/sys/amd64/vmm/vmm.c
Modified: projects/bhyve/sys/amd64/include/vmm.h
==============================================================================
--- projects/bhyve/sys/amd64/include/vmm.h Mon Sep 24 17:34:30 2012 (r240893)
+++ projects/bhyve/sys/amd64/include/vmm.h Mon Sep 24 19:32:24 2012 (r240894)
@@ -43,8 +43,7 @@ struct vlapic;
typedef int (*vmm_init_func_t)(void);
typedef int (*vmm_cleanup_func_t)(void);
typedef void * (*vmi_init_func_t)(struct vm *vm); /* instance specific apis */
-typedef int (*vmi_run_func_t)(void *vmi, int vcpu, register_t rip,
- struct vm_exit *vmexit);
+typedef int (*vmi_run_func_t)(void *vmi, int vcpu, register_t rip);
typedef void (*vmi_cleanup_func_t)(void *vmi);
typedef int (*vmi_mmap_func_t)(void *vmi, vm_paddr_t gpa, vm_paddr_t hpa,
size_t length, vm_memattr_t attr,
@@ -112,6 +111,7 @@ int vm_get_capability(struct vm *vm, int
int vm_set_capability(struct vm *vm, int vcpu, int type, int val);
void vm_activate_cpu(struct vm *vm, int vcpu);
cpuset_t vm_active_cpus(struct vm *vm);
+struct vm_exit *vm_exitinfo(struct vm *vm, int vcpuid);
/*
* Return 1 if device indicated by bus/slot/func is supposed to be a
Modified: projects/bhyve/sys/amd64/vmm/amd/amdv.c
==============================================================================
--- projects/bhyve/sys/amd64/vmm/amd/amdv.c Mon Sep 24 17:34:30 2012 (r240893)
+++ projects/bhyve/sys/amd64/vmm/amd/amdv.c Mon Sep 24 19:32:24 2012 (r240894)
@@ -62,7 +62,7 @@ amdv_vminit(struct vm *vm)
}
static int
-amdv_vmrun(void *arg, int vcpu, register_t rip, struct vm_exit *vmexit)
+amdv_vmrun(void *arg, int vcpu, register_t rip)
{
printf("amdv_vmrun: not implemented\n");
Modified: projects/bhyve/sys/amd64/vmm/intel/vmx.c
==============================================================================
--- projects/bhyve/sys/amd64/vmm/intel/vmx.c Mon Sep 24 17:34:30 2012 (r240893)
+++ projects/bhyve/sys/amd64/vmm/intel/vmx.c Mon Sep 24 19:32:24 2012 (r240894)
@@ -1272,19 +1272,22 @@ vmx_exit_process(struct vmx *vmx, int vc
}
static int
-vmx_run(void *arg, int vcpu, register_t rip, struct vm_exit *vmexit)
+vmx_run(void *arg, int vcpu, register_t rip)
{
int error, vie, rc, handled, astpending;
uint32_t exit_reason;
struct vmx *vmx;
struct vmxctx *vmxctx;
struct vmcs *vmcs;
+ struct vm_exit *vmexit;
vmx = arg;
vmcs = &vmx->vmcs[vcpu];
vmxctx = &vmx->ctx[vcpu];
vmxctx->launched = 0;
+ vmexit = vm_exitinfo(vmx->vm, vcpu);
+
/*
* XXX Can we avoid doing this every time we do a vm run?
*/
Modified: projects/bhyve/sys/amd64/vmm/vmm.c
==============================================================================
--- projects/bhyve/sys/amd64/vmm/vmm.c Mon Sep 24 17:34:30 2012 (r240893)
+++ projects/bhyve/sys/amd64/vmm/vmm.c Mon Sep 24 19:32:24 2012 (r240894)
@@ -72,6 +72,7 @@ struct vcpu {
int vcpuid;
struct savefpu *guestfpu; /* guest fpu state */
void *stats;
+ struct vm_exit exitinfo;
};
#define VCPU_F_PINNED 0x0001
#define VCPU_F_RUNNING 0x0002
@@ -110,8 +111,8 @@ static struct vmm_ops *ops;
#define VMM_CLEANUP() (ops != NULL ? (*ops->cleanup)() : 0)
#define VMINIT(vm) (ops != NULL ? (*ops->vminit)(vm): NULL)
-#define VMRUN(vmi, vcpu, rip, vmexit) \
- (ops != NULL ? (*ops->vmrun)(vmi, vcpu, rip, vmexit) : ENXIO)
+#define VMRUN(vmi, vcpu, rip) \
+ (ops != NULL ? (*ops->vmrun)(vmi, vcpu, rip) : ENXIO)
#define VMCLEANUP(vmi) (ops != NULL ? (*ops->vmcleanup)(vmi) : NULL)
#define VMMMAP(vmi, gpa, hpa, len, attr, prot, spm) \
(ops != NULL ? (*ops->vmmmap)(vmi, gpa, hpa, len, attr, prot, spm) : ENXIO)
@@ -164,6 +165,19 @@ vcpu_init(struct vm *vm, uint32_t vcpu_i
vcpu->stats = vmm_stat_alloc();
}
+struct vm_exit *
+vm_exitinfo(struct vm *vm, int cpuid)
+{
+ struct vcpu *vcpu;
+
+ if (cpuid < 0 || cpuid >= VM_MAXCPU)
+ panic("vm_exitinfo: invalid cpuid %d", cpuid);
+
+ vcpu = &vm->vcpu[cpuid];
+
+ return (&vcpu->exitinfo);
+}
+
static int
vmm_init(void)
{
@@ -545,12 +559,15 @@ vm_run(struct vm *vm, struct vm_run *vmr
restore_guest_msrs(vm, vcpuid);
restore_guest_fpustate(vcpu);
- error = VMRUN(vm->cookie, vcpuid, vmrun->rip, &vmrun->vm_exit);
+ error = VMRUN(vm->cookie, vcpuid, vmrun->rip);
save_guest_fpustate(vcpu);
restore_host_msrs(vm, vcpuid);
vmm_stat_incr(vm, vcpuid, VCPU_TOTAL_RUNTIME, rdtsc() - tscval);
+ /* copy the exit information */
+ bcopy(&vcpu->exitinfo, &vmrun->vm_exit, sizeof(struct vm_exit));
+
critical_exit();
return (error);
More information about the svn-src-projects
mailing list