Skip to contentSkip to conversation

KVM: s390: pqap: fix AP status written to wrong half of GR1

PATCH In review Gautam Gala 3 participants 3 messages Oct 20

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

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.

Fixes e5282de93105 ("s390: ap: kvm: add PQAP interception for AQIC")
---
 arch/s390/kvm/s390/priv.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
arch/s390/kvm/s390/priv.c +3 -3
index b3cb2c2c3aa7..ccb2a7830265 100644
@@ -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
#1 lore raw
Sashiko 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 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.

Quoted 7 lines

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.

Fixes e5282de93105 ("s390: ap: kvm: add PQAP interception for AQIC")

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to Gautam Gala

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 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.

Quoted 7 lines

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.

Fixes e5282de93105 ("s390: ap: kvm: add PQAP interception for AQIC")

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
index b3cb2c2c3aa7..ccb2a7830265 100644
@@ -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;
  }