diff options
author | Joerg Roedel <joerg.roedel@amd.com> | 2010-09-10 11:30:54 -0400 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2010-10-24 04:52:39 -0400 |
commit | 02f59dc9f1f51d2148d87d48f84adb455a4fd697 (patch) | |
tree | f1947e95af0dd4e2211c1b152e48f9784a749ebb /arch/x86/kvm/x86.c | |
parent | 3d06b8bfd44ec421c386241f7c5af66c8200cbf4 (diff) |
KVM: MMU: Introduce init_kvm_nested_mmu()
This patch introduces the init_kvm_nested_mmu() function
which is used to re-initialize the nested mmu when the l2
guest changes its paging mode.
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/x86/kvm/x86.c')
-rw-r--r-- | arch/x86/kvm/x86.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 46843ed36dc1..e4c76bf86081 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c | |||
@@ -3489,6 +3489,22 @@ static gpa_t translate_gpa(struct kvm_vcpu *vcpu, gpa_t gpa, u32 access) | |||
3489 | return gpa; | 3489 | return gpa; |
3490 | } | 3490 | } |
3491 | 3491 | ||
3492 | static gpa_t translate_nested_gpa(struct kvm_vcpu *vcpu, gpa_t gpa, u32 access) | ||
3493 | { | ||
3494 | gpa_t t_gpa; | ||
3495 | u32 error; | ||
3496 | |||
3497 | BUG_ON(!mmu_is_nested(vcpu)); | ||
3498 | |||
3499 | /* NPT walks are always user-walks */ | ||
3500 | access |= PFERR_USER_MASK; | ||
3501 | t_gpa = vcpu->arch.mmu.gva_to_gpa(vcpu, gpa, access, &error); | ||
3502 | if (t_gpa == UNMAPPED_GVA) | ||
3503 | vcpu->arch.fault.error_code |= PFERR_NESTED_MASK; | ||
3504 | |||
3505 | return t_gpa; | ||
3506 | } | ||
3507 | |||
3492 | gpa_t kvm_mmu_gva_to_gpa_read(struct kvm_vcpu *vcpu, gva_t gva, u32 *error) | 3508 | gpa_t kvm_mmu_gva_to_gpa_read(struct kvm_vcpu *vcpu, gva_t gva, u32 *error) |
3493 | { | 3509 | { |
3494 | u32 access = (kvm_x86_ops->get_cpl(vcpu) == 3) ? PFERR_USER_MASK : 0; | 3510 | u32 access = (kvm_x86_ops->get_cpl(vcpu) == 3) ? PFERR_USER_MASK : 0; |
@@ -5704,6 +5720,7 @@ int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu) | |||
5704 | vcpu->arch.walk_mmu = &vcpu->arch.mmu; | 5720 | vcpu->arch.walk_mmu = &vcpu->arch.mmu; |
5705 | vcpu->arch.mmu.root_hpa = INVALID_PAGE; | 5721 | vcpu->arch.mmu.root_hpa = INVALID_PAGE; |
5706 | vcpu->arch.mmu.translate_gpa = translate_gpa; | 5722 | vcpu->arch.mmu.translate_gpa = translate_gpa; |
5723 | vcpu->arch.nested_mmu.translate_gpa = translate_nested_gpa; | ||
5707 | if (!irqchip_in_kernel(kvm) || kvm_vcpu_is_bsp(vcpu)) | 5724 | if (!irqchip_in_kernel(kvm) || kvm_vcpu_is_bsp(vcpu)) |
5708 | vcpu->arch.mp_state = KVM_MP_STATE_RUNNABLE; | 5725 | vcpu->arch.mp_state = KVM_MP_STATE_RUNNABLE; |
5709 | else | 5726 | else |