Skip to content

Commit 5f2093b

Browse files
sean-jcgregkh
authored andcommitted
KVM: Use kvm_pfn_t for local PFN variable in hva_to_pfn_remapped()
commit a954577 upstream. Use kvm_pfn_t, a.k.a. u64, for the local 'pfn' variable when retrieving a so called "remapped" hva/pfn pair. In theory, the hva could resolve to a pfn in high memory on a 32-bit kernel. This bug was inadvertantly exposed by commit bd2fae8 ("KVM: do not assume PTE is writable after follow_pfn"), which added an error PFN value to the mix, causing gcc to comlain about overflowing the unsigned long. arch/x86/kvm/../../../virt/kvm/kvm_main.c: In function ‘hva_to_pfn_remapped’: include/linux/kvm_host.h:89:30: error: conversion from ‘long long unsigned int’ to ‘long unsigned int’ changes value from ‘9218868437227405314’ to ‘2’ [-Werror=overflow] 89 | #define KVM_PFN_ERR_RO_FAULT (KVM_PFN_ERR_MASK + 2) | ^ virt/kvm/kvm_main.c:1935:9: note: in expansion of macro ‘KVM_PFN_ERR_RO_FAULT’ Cc: stable@vger.kernel.org Fixes: add6a0c ("KVM: MMU: try to fix up page faults before giving up") Signed-off-by: Sean Christopherson <seanjc@google.com> Message-Id: <20210208201940.1258328-1-seanjc@google.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 3f9fbe7 commit 5f2093b

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

virt/kvm/kvm_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1598,7 +1598,7 @@ static int hva_to_pfn_remapped(struct vm_area_struct *vma,
15981598
bool write_fault, bool *writable,
15991599
kvm_pfn_t *p_pfn)
16001600
{
1601-
unsigned long pfn;
1601+
kvm_pfn_t pfn;
16021602
pte_t *ptep;
16031603
spinlock_t *ptl;
16041604
int r;

0 commit comments

Comments
 (0)