KVM: Properly check if "page" is valid in kvm_vcpu_unmap
commitec81ed2fba221b8bb92b8010e82d92e1de3b39fa
authorKarimAllah Ahmed <karahmed@amazon.de>
Wed, 10 Jul 2019 09:13:13 +0000 (10 11:13 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 29 Apr 2020 14:31:19 +0000 (29 16:31 +0200)
tree17ed07b75e2a9397afe8c6da772a00f19af3b15a
parente25441275142a0d57a51025213c4b6ef17b193e6
KVM: Properly check if "page" is valid in kvm_vcpu_unmap

commit b614c6027896ff9ad6757122e84760d938cab15e 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: e45adf665a53 ("KVM: Introduce a new guest mapping API")
Signed-off-by: KarimAllah Ahmed <karahmed@amazon.de>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Ben Hutchings <ben.hutchings@codethink.co.uk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
virt/kvm/kvm_main.c