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.
This commit is contained in:
parent
2d3a73ed6d
commit
98ed632c63
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/projects/bhyve/; revision=240894
@ -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 vcpu, int type, int *val);
|
||||
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
|
||||
|
@ -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");
|
||||
|
@ -1272,19 +1272,22 @@ vmx_exit_process(struct vmx *vmx, int vcpu, struct vm_exit *vmexit)
|
||||
}
|
||||
|
||||
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?
|
||||
*/
|
||||
|
@ -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_id)
|
||||
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 *vmrun)
|
||||
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user