diff options
author | David Woodhouse <dwmw@amazon.co.uk> | 2022-11-19 10:25:39 +0100 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2022-11-24 00:58:46 +0100 |
commit | 8332f0ed4f187c7b700831bd7cc83ce180a944b9 (patch) | |
tree | aadcb802494a9cdb91a60327ab4ea8a680284bfd /virt | |
parent | KVM: x86/xen: Only do in-kernel acceleration of hypercalls for guest CPL0 (diff) | |
download | linux-8332f0ed4f187c7b700831bd7cc83ce180a944b9.tar.xz linux-8332f0ed4f187c7b700831bd7cc83ce180a944b9.zip |
KVM: Update gfn_to_pfn_cache khva when it moves within the same page
In the case where a GPC is refreshed to a different location within the
same page, we didn't bother to update it. Mostly we don't need to, but
since the ->khva field also includes the offset within the page, that
does have to be updated.
Fixes: 3ba2c95ea180 ("KVM: Do not incorporate page offset into gfn=>pfn cache user address")
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Reviewed-by: Paul Durrant <paul@xen.org>
Reviewed-by: Sean Christopherson <seanjc@google.com>
Cc: stable@kernel.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'virt')
-rw-r--r-- | virt/kvm/pfncache.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/virt/kvm/pfncache.c b/virt/kvm/pfncache.c index 346e47f15572..7c248193ca26 100644 --- a/virt/kvm/pfncache.c +++ b/virt/kvm/pfncache.c @@ -297,7 +297,12 @@ int kvm_gfn_to_pfn_cache_refresh(struct kvm *kvm, struct gfn_to_pfn_cache *gpc, if (!gpc->valid || old_uhva != gpc->uhva) { ret = hva_to_pfn_retry(kvm, gpc); } else { - /* If the HVA→PFN mapping was already valid, don't unmap it. */ + /* + * If the HVA→PFN mapping was already valid, don't unmap it. + * But do update gpc->khva because the offset within the page + * may have changed. + */ + gpc->khva = old_khva + page_offset; old_pfn = KVM_PFN_ERR_FAULT; old_khva = NULL; ret = 0; |