struct kvm_vcpu;
+struct nested_state {
+ struct vmcb *hsave;
+ u64 hsave_msr;
+ u64 vmcb;
+
+ /* These are the merged vectors */
+ u32 *msrpm;
+
+ /* gpa pointers to the real vectors */
+ u64 vmcb_msrpm;
+};
+
struct vcpu_svm {
struct kvm_vcpu vcpu;
struct vmcb *vmcb;
u64 host_gs_base;
u32 *msrpm;
- struct vmcb *hsave;
- u64 hsave_msr;
-
- u64 nested_vmcb;
- /* These are the merged vectors */
- u32 *nested_msrpm;
-
- /* gpa pointers to the real vectors */
- u64 nested_vmcb_msrpm;
+ struct nested_state nested;
};
/* enable NPT for AMD64 and X86 with PAE */
static inline bool is_nested(struct vcpu_svm *svm)
{
- return svm->nested_vmcb;
+ return svm->nested.vmcb;
}
static inline void enable_gif(struct vcpu_svm *svm)
}
force_new_asid(&svm->vcpu);
- svm->nested_vmcb = 0;
+ svm->nested.vmcb = 0;
svm->vcpu.arch.hflags = 0;
enable_gif(svm);
hsave_page = alloc_page(GFP_KERNEL);
if (!hsave_page)
goto uninit;
- svm->hsave = page_address(hsave_page);
+ svm->nested.hsave = page_address(hsave_page);
- svm->nested_msrpm = page_address(nested_msrpm_pages);
+ svm->nested.msrpm = page_address(nested_msrpm_pages);
svm->vmcb = page_address(page);
clear_page(svm->vmcb);
__free_page(pfn_to_page(svm->vmcb_pa >> PAGE_SHIFT));
__free_pages(virt_to_page(svm->msrpm), MSRPM_ALLOC_ORDER);
- __free_page(virt_to_page(svm->hsave));
- __free_pages(virt_to_page(svm->nested_msrpm), MSRPM_ALLOC_ORDER);
+ __free_page(virt_to_page(svm->nested.hsave));
+ __free_pages(virt_to_page(svm->nested.msrpm), MSRPM_ALLOC_ORDER);
kvm_vcpu_uninit(vcpu);
kmem_cache_free(kvm_vcpu_cache, svm);
}
switch (svm->vmcb->control.exit_code) {
case SVM_EXIT_MSR:
- return nested_svm_do(svm, svm->nested_vmcb,
- svm->nested_vmcb_msrpm, NULL,
+ return nested_svm_do(svm, svm->nested.vmcb,
+ svm->nested.vmcb_msrpm, NULL,
nested_svm_exit_handled_msr);
default: break;
}
- return nested_svm_do(svm, svm->nested_vmcb, 0, &k,
+ return nested_svm_do(svm, svm->nested.vmcb, 0, &k,
nested_svm_exit_handled_real);
}
void *arg2, void *opaque)
{
struct vmcb *nested_vmcb = (struct vmcb *)arg1;
- struct vmcb *hsave = svm->hsave;
+ struct vmcb *hsave = svm->nested.hsave;
struct vmcb *vmcb = svm->vmcb;
/* Give the current vmcb to the guest */
svm->vmcb->control.exit_int_info = 0;
/* Exit nested SVM mode */
- svm->nested_vmcb = 0;
+ svm->nested.vmcb = 0;
return 0;
}
static int nested_svm_vmexit(struct vcpu_svm *svm)
{
nsvm_printk("VMexit\n");
- if (nested_svm_do(svm, svm->nested_vmcb, 0,
+ if (nested_svm_do(svm, svm->nested.vmcb, 0,
NULL, nested_svm_vmexit_real))
return 1;
int i;
u32 *nested_msrpm = (u32*)arg1;
for (i=0; i< PAGE_SIZE * (1 << MSRPM_ALLOC_ORDER) / 4; i++)
- svm->nested_msrpm[i] = svm->msrpm[i] | nested_msrpm[i];
- svm->vmcb->control.msrpm_base_pa = __pa(svm->nested_msrpm);
+ svm->nested.msrpm[i] = svm->msrpm[i] | nested_msrpm[i];
+ svm->vmcb->control.msrpm_base_pa = __pa(svm->nested.msrpm);
return 0;
}
void *arg2, void *opaque)
{
struct vmcb *nested_vmcb = (struct vmcb *)arg1;
- struct vmcb *hsave = svm->hsave;
+ struct vmcb *hsave = svm->nested.hsave;
struct vmcb *vmcb = svm->vmcb;
/* nested_vmcb is our indicator if nested SVM is activated */
- svm->nested_vmcb = svm->vmcb->save.rax;
+ svm->nested.vmcb = svm->vmcb->save.rax;
/* Clear internal status */
kvm_clear_exception_queue(&svm->vcpu);
svm->vmcb->control.intercept |= nested_vmcb->control.intercept;
- svm->nested_vmcb_msrpm = nested_vmcb->control.msrpm_base_pa;
+ svm->nested.vmcb_msrpm = nested_vmcb->control.msrpm_base_pa;
force_new_asid(&svm->vcpu);
svm->vmcb->control.exit_int_info = nested_vmcb->control.exit_int_info;
NULL, nested_svm_vmrun))
return 1;
- if (nested_svm_do(svm, svm->nested_vmcb_msrpm, 0,
+ if (nested_svm_do(svm, svm->nested.vmcb_msrpm, 0,
NULL, nested_svm_vmrun_msrpm))
return 1;
*data = svm->vmcb->save.last_excp_to;
break;
case MSR_VM_HSAVE_PA:
- *data = svm->hsave_msr;
+ *data = svm->nested.hsave_msr;
break;
case MSR_VM_CR:
*data = 0;
svm_disable_lbrv(svm);
break;
case MSR_VM_HSAVE_PA:
- svm->hsave_msr = data;
+ svm->nested.hsave_msr = data;
break;
case MSR_VM_CR:
case MSR_VM_IGNNE: