Skip to content

Commit df6ce24

Browse files
Eric Augerchazy
authored andcommitted
ARM: KVM: Unmap IPA on memslot delete/move
Currently when a KVM region is deleted or moved after KVM_SET_USER_MEMORY_REGION ioctl, the corresponding intermediate physical memory is not unmapped. This patch corrects this and unmaps the region's IPA range in kvm_arch_commit_memory_region using unmap_stage2_range. Signed-off-by: Eric Auger <eric.auger@linaro.org> Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
1 parent 4f853a7 commit df6ce24

2 files changed

Lines changed: 46 additions & 37 deletions

File tree

‎arch/arm/kvm/arm.c‎

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -155,16 +155,6 @@ int kvm_arch_vcpu_fault(struct kvm_vcpu *vcpu, struct vm_fault *vmf)
155155
return VM_FAULT_SIGBUS;
156156
}
157157

158-
void kvm_arch_free_memslot(struct kvm *kvm, struct kvm_memory_slot *free,
159-
struct kvm_memory_slot *dont)
160-
{
161-
}
162-
163-
int kvm_arch_create_memslot(struct kvm *kvm, struct kvm_memory_slot *slot,
164-
unsigned long npages)
165-
{
166-
return 0;
167-
}
168158

169159
/**
170160
* kvm_arch_destroy_vm - destroy the VM data structure
@@ -225,33 +215,6 @@ long kvm_arch_dev_ioctl(struct file *filp,
225215
return -EINVAL;
226216
}
227217

228-
void kvm_arch_memslots_updated(struct kvm *kvm)
229-
{
230-
}
231-
232-
int kvm_arch_prepare_memory_region(struct kvm *kvm,
233-
struct kvm_memory_slot *memslot,
234-
struct kvm_userspace_memory_region *mem,
235-
enum kvm_mr_change change)
236-
{
237-
return 0;
238-
}
239-
240-
void kvm_arch_commit_memory_region(struct kvm *kvm,
241-
struct kvm_userspace_memory_region *mem,
242-
const struct kvm_memory_slot *old,
243-
enum kvm_mr_change change)
244-
{
245-
}
246-
247-
void kvm_arch_flush_shadow_all(struct kvm *kvm)
248-
{
249-
}
250-
251-
void kvm_arch_flush_shadow_memslot(struct kvm *kvm,
252-
struct kvm_memory_slot *slot)
253-
{
254-
}
255218

256219
struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm, unsigned int id)
257220
{

‎arch/arm/kvm/mmu.c‎

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,3 +1111,49 @@ int kvm_mmu_init(void)
11111111
free_hyp_pgds();
11121112
return err;
11131113
}
1114+
1115+
void kvm_arch_commit_memory_region(struct kvm *kvm,
1116+
struct kvm_userspace_memory_region *mem,
1117+
const struct kvm_memory_slot *old,
1118+
enum kvm_mr_change change)
1119+
{
1120+
gpa_t gpa = old->base_gfn << PAGE_SHIFT;
1121+
phys_addr_t size = old->npages << PAGE_SHIFT;
1122+
if (change == KVM_MR_DELETE || change == KVM_MR_MOVE) {
1123+
spin_lock(&kvm->mmu_lock);
1124+
unmap_stage2_range(kvm, gpa, size);
1125+
spin_unlock(&kvm->mmu_lock);
1126+
}
1127+
}
1128+
1129+
int kvm_arch_prepare_memory_region(struct kvm *kvm,
1130+
struct kvm_memory_slot *memslot,
1131+
struct kvm_userspace_memory_region *mem,
1132+
enum kvm_mr_change change)
1133+
{
1134+
return 0;
1135+
}
1136+
1137+
void kvm_arch_free_memslot(struct kvm *kvm, struct kvm_memory_slot *free,
1138+
struct kvm_memory_slot *dont)
1139+
{
1140+
}
1141+
1142+
int kvm_arch_create_memslot(struct kvm *kvm, struct kvm_memory_slot *slot,
1143+
unsigned long npages)
1144+
{
1145+
return 0;
1146+
}
1147+
1148+
void kvm_arch_memslots_updated(struct kvm *kvm)
1149+
{
1150+
}
1151+
1152+
void kvm_arch_flush_shadow_all(struct kvm *kvm)
1153+
{
1154+
}
1155+
1156+
void kvm_arch_flush_shadow_memslot(struct kvm *kvm,
1157+
struct kvm_memory_slot *slot)
1158+
{
1159+
}

0 commit comments

Comments
 (0)