]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
KVM: s390: Fix guest / virtual address confusion in _essa_clear_cbrl()
authorClaudio Imbrenda <imbrenda@linux.ibm.com>
Tue, 2 Jun 2026 14:23:50 +0000 (16:23 +0200)
committerClaudio Imbrenda <imbrenda@linux.ibm.com>
Tue, 2 Jun 2026 14:46:41 +0000 (16:46 +0200)
Until now, gmap_helper_zap_one_page() was being called with the guest
absolute address, but it expects a userspace virtual address.

This meant that in the best case the requested pages were not being
discarded, and in the worst case that the wrong pages were being
discarded.

Fix this by converting the guest absolute address to host virtual
before passing it to gmap_helper_zap_one_page().

Fixes: e38c884df921 ("KVM: s390: Switch to new gmap")
Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Message-ID: <20260602142356.169458-5-imbrenda@linux.ibm.com>

arch/s390/kvm/priv.c

index cc0553da14cbbb8a9d0df17d994f441e10df5cf1..447ec7ed423dc45dd29ff437cbb9c167ce806dd3 100644 (file)
@@ -1188,6 +1188,7 @@ static void _essa_clear_cbrl(struct kvm_vcpu *vcpu, unsigned long *cbrl, int len
        union crste *crstep;
        union pgste pgste;
        union pte *ptep;
+       hva_t hva;
        int i;
 
        lockdep_assert_held(&vcpu->kvm->mmu_lock);
@@ -1199,8 +1200,11 @@ static void _essa_clear_cbrl(struct kvm_vcpu *vcpu, unsigned long *cbrl, int len
                if (!ptep || ptep->s.pr)
                        continue;
                pgste = pgste_get_lock(ptep);
-               if (pgste.usage == PGSTE_GPS_USAGE_UNUSED || pgste.zero)
-                       gmap_helper_zap_one_page(vcpu->kvm->mm, cbrl[i]);
+               if (pgste.usage == PGSTE_GPS_USAGE_UNUSED || pgste.zero) {
+                       hva = gpa_to_hva(vcpu->kvm, cbrl[i]);
+                       if (!kvm_is_error_hva(hva))
+                               gmap_helper_zap_one_page(vcpu->kvm->mm, hva);
+               }
                pgste_set_unlock(ptep, pgste);
        }
 }