diff mbox series

[v1,2/2] KVM: s390: Change virtual to physical address access in diag 0x258 handler

Message ID 20240917151904.74314-3-nrb@linux.ibm.com (mailing list archive)
State New, archived
Headers show
Series KVM: s390: fix diag258 virtual-physical confusion | expand

Commit Message

Nico Boehr Sept. 17, 2024, 3:18 p.m. UTC
From: Michael Mueller <mimu@linux.ibm.com>

The parameters for the diag 0x258 are real addresses, not virtual, but
KVM was using them as virtual addresses. This only happened to work, since
the Linux kernel as a guest used to have a 1:1 mapping for physical vs
virtual addresses.

Fix KVM so that it correctly uses the addresses as real addresses.

Cc: stable@vger.kernel.org
Fixes: 8ae04b8f500b ("KVM: s390: Guest's memory access functions get access registers")
Suggested-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Michael Mueller <mimu@linux.ibm.com>
[ nrb: drop tested-by tags ]
Signed-off-by: Nico Boehr <nrb@linux.ibm.com>
---
 arch/s390/kvm/diag.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Christian Borntraeger Sept. 18, 2024, 10:46 a.m. UTC | #1
Am 17.09.24 um 17:18 schrieb Nico Boehr:
> From: Michael Mueller <mimu@linux.ibm.com>
> 
> The parameters for the diag 0x258 are real addresses, not virtual, but
> KVM was using them as virtual addresses. This only happened to work, since
> the Linux kernel as a guest used to have a 1:1 mapping for physical vs
> virtual addresses.
> 
> Fix KVM so that it correctly uses the addresses as real addresses.
> 
> Cc: stable@vger.kernel.org
> Fixes: 8ae04b8f500b ("KVM: s390: Guest's memory access functions get access registers")
> Suggested-by: Vasily Gorbik <gor@linux.ibm.com>
> Signed-off-by: Michael Mueller <mimu@linux.ibm.com>
> [ nrb: drop tested-by tags ]
> Signed-off-by: Nico Boehr <nrb@linux.ibm.com>
Reviewed-by: Christian Borntraeger <borntraeger@linux.ibm.com>

> ---
>   arch/s390/kvm/diag.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/s390/kvm/diag.c b/arch/s390/kvm/diag.c
> index 2a32438e09ce..74f73141f9b9 100644
> --- a/arch/s390/kvm/diag.c
> +++ b/arch/s390/kvm/diag.c
> @@ -77,7 +77,7 @@ static int __diag_page_ref_service(struct kvm_vcpu *vcpu)
>   	vcpu->stat.instruction_diagnose_258++;
>   	if (vcpu->run->s.regs.gprs[rx] & 7)
>   		return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION);
> -	rc = read_guest(vcpu, vcpu->run->s.regs.gprs[rx], rx, &parm, sizeof(parm));
> +	rc = read_guest_real(vcpu, vcpu->run->s.regs.gprs[rx], &parm, sizeof(parm));
>   	if (rc)
>   		return kvm_s390_inject_prog_cond(vcpu, rc);
>   	if (parm.parm_version != 2 || parm.parm_len < 5 || parm.code != 0x258)
Heiko Carstens Sept. 18, 2024, 10:58 a.m. UTC | #2
On Tue, Sep 17, 2024 at 05:18:34PM +0200, Nico Boehr wrote:
> From: Michael Mueller <mimu@linux.ibm.com>
> 
> The parameters for the diag 0x258 are real addresses, not virtual, but
> KVM was using them as virtual addresses. This only happened to work, since
> the Linux kernel as a guest used to have a 1:1 mapping for physical vs
> virtual addresses.
> 
> Fix KVM so that it correctly uses the addresses as real addresses.
> 
> Cc: stable@vger.kernel.org
> Fixes: 8ae04b8f500b ("KVM: s390: Guest's memory access functions get access registers")
> Suggested-by: Vasily Gorbik <gor@linux.ibm.com>
> Signed-off-by: Michael Mueller <mimu@linux.ibm.com>
> [ nrb: drop tested-by tags ]
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

This shouldn't be part of the commit message.

> Signed-off-by: Nico Boehr <nrb@linux.ibm.com>
> ---
>  arch/s390/kvm/diag.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Heiko Carstens <hca@linux.ibm.com>
diff mbox series

Patch

diff --git a/arch/s390/kvm/diag.c b/arch/s390/kvm/diag.c
index 2a32438e09ce..74f73141f9b9 100644
--- a/arch/s390/kvm/diag.c
+++ b/arch/s390/kvm/diag.c
@@ -77,7 +77,7 @@  static int __diag_page_ref_service(struct kvm_vcpu *vcpu)
 	vcpu->stat.instruction_diagnose_258++;
 	if (vcpu->run->s.regs.gprs[rx] & 7)
 		return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION);
-	rc = read_guest(vcpu, vcpu->run->s.regs.gprs[rx], rx, &parm, sizeof(parm));
+	rc = read_guest_real(vcpu, vcpu->run->s.regs.gprs[rx], &parm, sizeof(parm));
 	if (rc)
 		return kvm_s390_inject_prog_cond(vcpu, rc);
 	if (parm.parm_version != 2 || parm.parm_len < 5 || parm.code != 0x258)