KVM: s390: VSIE: sort out virtual/physical address in pin_guest_page
v2 cover KVM: s390: VSIE: sort out virtual/physical address in pin_guest_page
v1->v2:
---
* remove useless cast (thanks Christian)
Nico Boehr (1):
KVM: s390: VSIE: sort out virtual/physical address in pin_guest_page
arch/s390/kvm/vsie.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Signature · 1 line
2.37.3
PATCH v2 1/1 KVM: s390: VSIE: sort out virtual/physical address in pin_guest_page
pin_guest_page() used page_to_virt() to calculate the hpa of the pinned page. This currently works, because virtual and physical addresses are the same. Use page_to_phys() instead to resolve the virtual-real address confusion.
One caller of pin_guest_page() actually expected the hpa to be a hva, so add the missing phys_to_virt() conversion here.
--- arch/s390/kvm/vsie.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/s390/kvm/vsie.c +2 -2
@@ -654,7 +654,7 @@ static int pin_guest_page(struct kvm *kvm, gpa_t gpa, hpa_t *hpa) page =gfn_to_page (kvm,gpa_to_gfn (gpa));if (is_error_page (page))return -EINVAL ; - *hpa = (hpa_t )page_to_virt (page) + (gpa & ~PAGE_MASK ); + *hpa = (hpa_t )page_to_phys (page) + (gpa & ~PAGE_MASK );return 0 ; }
@@ -869,7 +869,7 @@ static int pin_scb(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page,WARN_ON_ONCE (rc);return 1 ; } - vsie_page->scb_o = (struct kvm_s390_sie_block *) hpa; + vsie_page->scb_o =phys_to_virt (hpa);return 0 ; }
Signature · 1 line
2.37.3
Am 25.10.22 um 10:20 schrieb Nico Boehr:
Quoted 9 lines
pin_guest_page()usedpage_to_virt()to calculate the hpa of the pinned page. This currently works, because virtual and physical addresses are the same. Usepage_to_phys()instead to resolve the virtual-real address confusion.One caller of
pin_guest_page()actually expected the hpa to be a hva, so add the missingphys_to_virt()conversion here.Signed-off-by Nico Boehr <[email protected]>
Looks good.
Adding David CC.
Quoted 26 lines
--- arch/s390/kvm/vsie.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/s390/kvm/vsie.c +2
-2@@ -654,7 +654,7 @@ static int pin_guest_page(struct kvm *kvm, gpa_t gpa, hpa_t *hpa) page =gfn_to_page (kvm,gpa_to_gfn (gpa));if (is_error_page (page))return -EINVAL ; - *hpa = (hpa_t )page_to_virt (page) + (gpa & ~PAGE_MASK ); + *hpa = (hpa_t )page_to_phys (page) + (gpa & ~PAGE_MASK );return 0 ; }@@ -869,7 +869,7 @@ static int pin_scb(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page,WARN_ON_ONCE (rc);return 1 ; } - vsie_page->scb_o = (struct kvm_s390_sie_block *) hpa; + vsie_page->scb_o =phys_to_virt (hpa);return 0 ; }
David Hildenbrand
Acked-byQuoted 36 lines · Christian Borntraeger
Am 25.10.22 um 10:20 schrieb Nico Boehr:
Quoted 9 lines
pin_guest_page()usedpage_to_virt()to calculate the hpa of the pinned page. This currently works, because virtual and physical addresses are the same. Usepage_to_phys()instead to resolve the virtual-real address confusion.One caller of
pin_guest_page()actually expected the hpa to be a hva, so add the missingphys_to_virt()conversion here.Signed-off-by Nico Boehr <[email protected]>Looks good.
Reviewed-by Christian Borntraeger <[email protected]>Adding David CC.
Quoted 17 lines
--- arch/s390/kvm/vsie.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/s390/kvm/vsie.c +1
-1@@ -654,7 +654,7 @@ static int pin_guest_page(struct kvm *kvm, gpa_t gpa, hpa_t *hpa) page =gfn_to_page (kvm,gpa_to_gfn (gpa));if (is_error_page (page))return -EINVAL ; - *hpa = (hpa_t )page_to_virt (page) + (gpa & ~PAGE_MASK ); + *hpa = (hpa_t )page_to_phys (page) + (gpa & ~PAGE_MASK );return 0 ; }
Quoted 7 lines
arch/s390/kvm/vsie.c static int pin_scb(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page, · line 873
Quoted 7 lines
arch/s390/kvm/vsie.c +1
-1@@ -869,7 +869,7 @@ static int pin_scb(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page,WARN_ON_ONCE (rc);return 1 ; } - vsie_page->scb_o = (struct kvm_s390_sie_block *) hpa; + vsie_page->scb_o =phys_to_virt (hpa);return 0 ;
Right, we don't provide the scb to the SIE, but only read/write manually from it.
Signature · 3 lines
Thanks, David / dhildenb
Quoted 9 lines · On Tue, 25 Oct 2022 10:20:39 +0200 Nico Boehr <[email protected]> wrote:
pin_guest_page()usedpage_to_virt()to calculate the hpa of the pinned page. This currently works, because virtual and physical addresses are the same. Usepage_to_phys()instead to resolve the virtual-real address confusion.One caller of
pin_guest_page()actually expected the hpa to be a hva, so add the missingphys_to_virt()conversion here.Signed-off-by Nico Boehr <[email protected]>
Quoted 26 lines
--- arch/s390/kvm/vsie.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/s390/kvm/vsie.c +2
-2@@ -654,7 +654,7 @@ static int pin_guest_page(struct kvm *kvm, gpa_t gpa, hpa_t *hpa) page =gfn_to_page (kvm,gpa_to_gfn (gpa));if (is_error_page (page))return -EINVAL ; - *hpa = (hpa_t )page_to_virt (page) + (gpa & ~PAGE_MASK ); + *hpa = (hpa_t )page_to_phys (page) + (gpa & ~PAGE_MASK );return 0 ; }@@ -869,7 +869,7 @@ static int pin_scb(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page,WARN_ON_ONCE (rc);return 1 ; } - vsie_page->scb_o = (struct kvm_s390_sie_block *) hpa; + vsie_page->scb_o =phys_to_virt (hpa);return 0 ; }
Janosch Frank
maintainerQuoted 10 lines · Nico Boehr
v1->v2:
---
* remove useless cast (thanks Christian)Nico Boehr (1):
KVM: s390: VSIE: sort out virtual/physical address inpin_guest_pagearch/s390/kvm/vsie.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
I'll put this on devel since the initial patch set is already there to get as much CI coverage as possible.