x86/kvm: Cache gfn to pfn translation
authorBoris Ostrovsky <boris.ostrovsky@oracle.com>
Thu, 5 Dec 2019 01:30:51 +0000 (01:30 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 29 Apr 2020 14:31:19 +0000 (16:31 +0200)
commitccfc73e56da7c8e68ab6a543c5b8cd0b83c9e9bb
tree5de4d00496ea683cef6960cb7ef8fd0c7ed451c3
parente36d68ec5090599058650152547d4a58ef3d79a0
x86/kvm: Cache gfn to pfn translation

commit 917248144db5d7320655dbb41d3af0b8a0f3d589 upstream.

__kvm_map_gfn()'s call to gfn_to_pfn_memslot() is
* relatively expensive
* in certain cases (such as when done from atomic context) cannot be called

Stashing gfn-to-pfn mapping should help with both cases.

This is part of CVE-2019-3016.

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Reviewed-by: Joao Martins <joao.m.martins@oracle.com>
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>
arch/x86/include/asm/kvm_host.h
arch/x86/kvm/x86.c
include/linux/kvm_host.h
include/linux/kvm_types.h
virt/kvm/kvm_main.c