Commit ec81ed2f authored by KarimAllah Ahmed's avatar KarimAllah Ahmed Committed by Greg Kroah-Hartman

KVM: Properly check if "page" is valid in kvm_vcpu_unmap

commit b614c602 upstream.

The field "page" is initialized to KVM_UNMAPPED_PAGE when it is not used
(i.e. when the memory lives outside kernel control). So this check will
always end up using kunmap even for memremap regions.

Fixes: e45adf66 ("KVM: Introduce a new guest mapping API")
Signed-off-by: default avatarKarimAllah Ahmed <karahmed@amazon.de>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
Signed-off-by: default avatarBen Hutchings <ben.hutchings@codethink.co.uk>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent e2544127
...@@ -1754,7 +1754,7 @@ void kvm_vcpu_unmap(struct kvm_vcpu *vcpu, struct kvm_host_map *map, ...@@ -1754,7 +1754,7 @@ void kvm_vcpu_unmap(struct kvm_vcpu *vcpu, struct kvm_host_map *map,
if (!map->hva) if (!map->hva)
return; return;
if (map->page) if (map->page != KVM_UNMAPPED_PAGE)
kunmap(map->page); kunmap(map->page);
#ifdef CONFIG_HAS_IOMEM #ifdef CONFIG_HAS_IOMEM
else else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment