diff options
author | Sheng Yang <sheng@linux.intel.com> | 2009-07-20 22:42:48 -0400 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2009-09-10 01:33:16 -0400 |
commit | b927a3cec081a605142f5b7e90b730611bee28b1 (patch) | |
tree | ed7609e83e89c0830d568aa8304200cdb0c58736 /arch/x86/kvm/vmx.c | |
parent | b792c344dfd57ee2cf737440e4a9b4a5bc39d1db (diff) |
KVM: VMX: Introduce KVM_SET_IDENTITY_MAP_ADDR ioctl
Now KVM allow guest to modify guest's physical address of EPT's identity mapping page.
(change from v1, discard unnecessary check, change ioctl to accept parameter
address rather than value)
Signed-off-by: Sheng Yang <sheng@linux.intel.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Diffstat (limited to 'arch/x86/kvm/vmx.c')
-rw-r--r-- | arch/x86/kvm/vmx.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index c6256b98f078..686e1abb6816 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c | |||
@@ -1719,7 +1719,7 @@ static void vmx_set_cr3(struct kvm_vcpu *vcpu, unsigned long cr3) | |||
1719 | eptp = construct_eptp(cr3); | 1719 | eptp = construct_eptp(cr3); |
1720 | vmcs_write64(EPT_POINTER, eptp); | 1720 | vmcs_write64(EPT_POINTER, eptp); |
1721 | guest_cr3 = is_paging(vcpu) ? vcpu->arch.cr3 : | 1721 | guest_cr3 = is_paging(vcpu) ? vcpu->arch.cr3 : |
1722 | VMX_EPT_IDENTITY_PAGETABLE_ADDR; | 1722 | vcpu->kvm->arch.ept_identity_map_addr; |
1723 | } | 1723 | } |
1724 | 1724 | ||
1725 | vmx_flush_tlb(vcpu); | 1725 | vmx_flush_tlb(vcpu); |
@@ -2122,7 +2122,7 @@ static int init_rmode_identity_map(struct kvm *kvm) | |||
2122 | if (likely(kvm->arch.ept_identity_pagetable_done)) | 2122 | if (likely(kvm->arch.ept_identity_pagetable_done)) |
2123 | return 1; | 2123 | return 1; |
2124 | ret = 0; | 2124 | ret = 0; |
2125 | identity_map_pfn = VMX_EPT_IDENTITY_PAGETABLE_ADDR >> PAGE_SHIFT; | 2125 | identity_map_pfn = kvm->arch.ept_identity_map_addr >> PAGE_SHIFT; |
2126 | r = kvm_clear_guest_page(kvm, identity_map_pfn, 0, PAGE_SIZE); | 2126 | r = kvm_clear_guest_page(kvm, identity_map_pfn, 0, PAGE_SIZE); |
2127 | if (r < 0) | 2127 | if (r < 0) |
2128 | goto out; | 2128 | goto out; |
@@ -2191,14 +2191,15 @@ static int alloc_identity_pagetable(struct kvm *kvm) | |||
2191 | goto out; | 2191 | goto out; |
2192 | kvm_userspace_mem.slot = IDENTITY_PAGETABLE_PRIVATE_MEMSLOT; | 2192 | kvm_userspace_mem.slot = IDENTITY_PAGETABLE_PRIVATE_MEMSLOT; |
2193 | kvm_userspace_mem.flags = 0; | 2193 | kvm_userspace_mem.flags = 0; |
2194 | kvm_userspace_mem.guest_phys_addr = VMX_EPT_IDENTITY_PAGETABLE_ADDR; | 2194 | kvm_userspace_mem.guest_phys_addr = |
2195 | kvm->arch.ept_identity_map_addr; | ||
2195 | kvm_userspace_mem.memory_size = PAGE_SIZE; | 2196 | kvm_userspace_mem.memory_size = PAGE_SIZE; |
2196 | r = __kvm_set_memory_region(kvm, &kvm_userspace_mem, 0); | 2197 | r = __kvm_set_memory_region(kvm, &kvm_userspace_mem, 0); |
2197 | if (r) | 2198 | if (r) |
2198 | goto out; | 2199 | goto out; |
2199 | 2200 | ||
2200 | kvm->arch.ept_identity_pagetable = gfn_to_page(kvm, | 2201 | kvm->arch.ept_identity_pagetable = gfn_to_page(kvm, |
2201 | VMX_EPT_IDENTITY_PAGETABLE_ADDR >> PAGE_SHIFT); | 2202 | kvm->arch.ept_identity_map_addr >> PAGE_SHIFT); |
2202 | out: | 2203 | out: |
2203 | up_write(&kvm->slots_lock); | 2204 | up_write(&kvm->slots_lock); |
2204 | return r; | 2205 | return r; |
@@ -3814,9 +3815,13 @@ static struct kvm_vcpu *vmx_create_vcpu(struct kvm *kvm, unsigned int id) | |||
3814 | if (alloc_apic_access_page(kvm) != 0) | 3815 | if (alloc_apic_access_page(kvm) != 0) |
3815 | goto free_vmcs; | 3816 | goto free_vmcs; |
3816 | 3817 | ||
3817 | if (enable_ept) | 3818 | if (enable_ept) { |
3819 | if (!kvm->arch.ept_identity_map_addr) | ||
3820 | kvm->arch.ept_identity_map_addr = | ||
3821 | VMX_EPT_IDENTITY_PAGETABLE_ADDR; | ||
3818 | if (alloc_identity_pagetable(kvm) != 0) | 3822 | if (alloc_identity_pagetable(kvm) != 0) |
3819 | goto free_vmcs; | 3823 | goto free_vmcs; |
3824 | } | ||
3820 | 3825 | ||
3821 | return &vmx->vcpu; | 3826 | return &vmx->vcpu; |
3822 | 3827 | ||