KVM: s390: pqap: fix AP status written to wrong half of GR1
PATCH 1/1 KVM: s390: pqap: fix AP status written to wrong half of GR1
The AP Queue Status Word (APQSW) occupies bit positions 32-63 of GR1, i.e. the low 32 bits of the 64-bit register, while the upper 32 bits are reserved.
The no-hook fallback path in handle_pqap() synthesizes an APQSW and copies struct ap_queue_status directly into GPR1 using memcpy(). On big-endian s390 this places the APQSW in the upper 32 bits of the register rather than in the architecturally defined APQSW field.
Use union ap_queue_status_reg and assign its value directly to GPR1. This places APQSW in the correct half of the register and aligns the fallback path with the register layout used by the AP infrastructure.
--- arch/s390/kvm/s390/priv.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/s390/kvm/s390/priv.c +3 -3
@@ -592,7 +592,7 @@ EXPORT_SYMBOL_FOR_MODULES(kvm_s390_is_gpa_in_memslot, "vfio_ap");*/ static int handle_pqap (struct kvm_vcpu *vcpu) { -struct ap_queue_status status = {}; +union ap_queue_status_reg status = {};crypto_hook pqap_hook;unsigned long reg0;int ret;
@@ -661,8 +661,8 @@ static int handle_pqap(struct kvm_vcpu *vcpu)* No hook means no driver to enable the SIE CRYCB and no queues. * We send this response to the guest. */ - status.response_code =0x01 ; -memcpy (&vcpu->run->s.regs.gprs[1 ], &status,sizeof (status)); + status.status.response_code =0x01 ; + vcpu->run->s.regs.gprs[1 ] = status.value;kvm_s390_set_psw_cc (vcpu,3 );return 0 ; }
Signature · 1 line
2.56.0
[email protected]
AI reviewSashiko has reviewed this patch and found no issues.
Quoted 9 lines
The AP Queue Status Word (APQSW) occupies bit positions 32-63 of GR1, i.e. the low 32 bits of the 64-bit register, while the upper 32 bits are reserved.
The no-hook fallback path in
handle_pqap()synthesizes an APQSW and copies structap_queue_statusdirectly into GPR1 usingmemcpy(). On big-endian s390 this places the APQSW in the upper 32 bits of the register rather than in the architecturally defined APQSW field.
Quoted 7 lines
Use union
ap_queue_status_regand assign its value directly to GPR1. This places APQSW in the correct half of the register and aligns the fallback path with the register layout used by the AP infrastructure.Fixes e5282de93105 ("s390: ap: kvm: add PQAP interception for AQIC")Reported-by Christian Borntraeger <[email protected]>Signed-off-by Gautam Gala <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Am 20.10.26 um 10:25 schrieb Gautam Gala:
Quoted 9 lines
The AP Queue Status Word (APQSW) occupies bit positions 32-63 of GR1, i.e. the low 32 bits of the 64-bit register, while the upper 32 bits are reserved.
The no-hook fallback path in
handle_pqap()synthesizes an APQSW and copies structap_queue_statusdirectly into GPR1 usingmemcpy(). On big-endian s390 this places the APQSW in the upper 32 bits of the register rather than in the architecturally defined APQSW field.
Quoted 7 lines
Use union
ap_queue_status_regand assign its value directly to GPR1. This places APQSW in the correct half of the register and aligns the fallback path with the register layout used by the AP infrastructure.Fixes e5282de93105 ("s390: ap: kvm: add PQAP interception for AQIC")Reported-by Christian Borntraeger <[email protected]>Signed-off-by Gautam Gala <[email protected]>
Thanks. applied.
Quoted 28 lines
--- arch/s390/kvm/s390/priv.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)arch/s390/kvm/s390/priv.c +3
-3@@ -592,7 +592,7 @@ EXPORT_SYMBOL_FOR_MODULES(kvm_s390_is_gpa_in_memslot, "vfio_ap");*/ static int handle_pqap (struct kvm_vcpu *vcpu) { -struct ap_queue_status status = {}; +union ap_queue_status_reg status = {};crypto_hook pqap_hook;unsigned long reg0;int ret;@@ -661,8 +661,8 @@ static int handle_pqap(struct kvm_vcpu *vcpu)* No hook means no driver to enable the SIE CRYCB and no queues. * We send this response to the guest. */ - status.response_code =0x01 ; -memcpy (&vcpu->run->s.regs.gprs[1 ], &status,sizeof (status)); + status.status.response_code =0x01 ; + vcpu->run->s.regs.gprs[1 ] = status.value;kvm_s390_set_psw_cc (vcpu,3 );return 0 ; }