public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 1/1] KVM: s390: VSIE: fix virtual/physical address in unpin_scb()
@ 2024-12-10  8:39 Claudio Imbrenda
  2024-12-10 11:39 ` Janosch Frank
  2024-12-10 12:38 ` Nico Boehr
  0 siblings, 2 replies; 3+ messages in thread
From: Claudio Imbrenda @ 2024-12-10  8:39 UTC (permalink / raw)
  To: kvm; +Cc: linux-s390, linux-kernel, frankja, borntraeger, nrb

In commit 77b533411595 ("KVM: s390: VSIE: sort out virtual/physical
address in pin_guest_page"), only pin_scb() has been updated. This
means that in unpin_scb() a virtual address was still used directly as
physical address without conversion. The resulting physical address is
obviously wrong and most of the time also invalid.

Since commit d0ef8d9fbebe ("KVM: s390: Use kvm_release_page_dirty() to
unpin "struct page" memory"), unpin_guest_page() will directly use
kvm_release_page_dirty(), instead of kvm_release_pfn_dirty(), which has
since been removed.

One of the checks that were performed by kvm_release_pfn_dirty() was to
verify whether the page was valid at all, and silently return
successfully without doing anything if the page was invalid.

When kvm_release_pfn_dirty() was still used, the invalid page was thus
silently ignored. Now the check is gone and the result is an Oops.
This also means that when running with a V!=R kernel, the page was not
released, causing a leak.

The solution is simply to add the missing virt_to_phys().

Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Fixes: 77b533411595 ("KVM: s390: VSIE: sort out virtual/physical address in pin_guest_page")
---
 arch/s390/kvm/vsie.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/s390/kvm/vsie.c b/arch/s390/kvm/vsie.c
index 150b9387860a..a687695d8f68 100644
--- a/arch/s390/kvm/vsie.c
+++ b/arch/s390/kvm/vsie.c
@@ -854,7 +854,7 @@ static int pin_blocks(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
 static void unpin_scb(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page,
 		      gpa_t gpa)
 {
-	hpa_t hpa = (hpa_t) vsie_page->scb_o;
+	hpa_t hpa = virt_to_phys(vsie_page->scb_o);
 
 	if (hpa)
 		unpin_guest_page(vcpu->kvm, gpa, hpa);
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-12-10 12:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-10  8:39 [PATCH v1 1/1] KVM: s390: VSIE: fix virtual/physical address in unpin_scb() Claudio Imbrenda
2024-12-10 11:39 ` Janosch Frank
2024-12-10 12:38 ` Nico Boehr

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox