mirror of
https://github.com/clearlinux/kvmtool.git
synced 2026-08-26 16:28:12 +00:00
kvm tools, x86: Fix munmap() size in kvm__arch_delete_ram()
Sasha noticed during code review that commit e106906 ("kvm tool: Change
kvm->ram_size to real mapped size.") changed kvm->ram_size accounting to
include 32-bit memory hole but forgot to update munmap in
kvm__arch_delete_ram().
Reported-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
This commit is contained in:
committed by
Will Deacon
parent
c4b716ec6b
commit
cad59b93e8
@@ -156,11 +156,11 @@ void kvm__arch_init(struct kvm *kvm, const char *hugetlbfs_path, u64 ram_size)
|
||||
die_perror("KVM_CREATE_PIT2 ioctl");
|
||||
|
||||
if (ram_size < KVM_32BIT_GAP_START) {
|
||||
kvm->ram_size = ram_size;
|
||||
kvm->ram_size = ram_size;
|
||||
kvm->ram_start = mmap_anon_or_hugetlbfs(hugetlbfs_path, ram_size);
|
||||
} else {
|
||||
kvm->ram_start = mmap_anon_or_hugetlbfs(hugetlbfs_path, ram_size + KVM_32BIT_GAP_SIZE);
|
||||
kvm->ram_size = ram_size + KVM_32BIT_GAP_SIZE;
|
||||
kvm->ram_size = ram_size + KVM_32BIT_GAP_SIZE;
|
||||
if (kvm->ram_start != MAP_FAILED)
|
||||
/*
|
||||
* We mprotect the gap (see kvm__init_ram() for details) PROT_NONE so that
|
||||
@@ -180,10 +180,7 @@ void kvm__arch_init(struct kvm *kvm, const char *hugetlbfs_path, u64 ram_size)
|
||||
|
||||
void kvm__arch_delete_ram(struct kvm *kvm)
|
||||
{
|
||||
if (kvm->ram_size < KVM_32BIT_GAP_START)
|
||||
munmap(kvm->ram_start, kvm->ram_size);
|
||||
else
|
||||
munmap(kvm->ram_start, kvm->ram_size + KVM_32BIT_GAP_SIZE);
|
||||
munmap(kvm->ram_start, kvm->ram_size);
|
||||
}
|
||||
|
||||
void kvm__irq_line(struct kvm *kvm, int irq, int level)
|
||||
|
||||
Reference in New Issue
Block a user