[PATCH 3/3] kvm: s390: Fix lpsw/e spec exception ilc reporting

Janosch Frank
2026-04-23T12:39:31Z

On early PSW specification exception the ILC has to be 0 according to
architecture.

Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
Fixes: 48a3e950f4cee ("KVM: s390: Add support for machine checks.")
---
arch/s390/kvm/priv.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/arch/s390/kvm/priv.c b/arch/s390/kvm/priv.c
index 56e63679f9d1..9fd7d3f1d1e8 100644
--- a/arch/s390/kvm/priv.c
+++ b/arch/s390/kvm/priv.c
@@ -713,6 +713,7 @@ int is_valid_psw(psw_t *psw)
int kvm_s390_handle_lpsw(struct kvm_vcpu *vcpu)
{
psw_t *gpsw = &vcpu->arch.sie_block->gpsw;
+ struct kvm_s390_pgm_info info = {};
psw32_t new_psw;
u64 addr, iaddr;
int rc;
@@ -738,14 +739,18 @@ int kvm_s390_handle_lpsw(struct kvm_vcpu *vcpu)
gpsw->addr = new_psw.addr & ~PSW32_ADDR_AMODE;
vcpu->arch.sie_block->gbea = iaddr;

- if (!is_valid_psw(gpsw))
- return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION);
+ if (!is_valid_psw(gpsw)) {
+ info.code = PGM_SPECIFICATION;
+ info.flags = KVM_S390_PGM_FLAGS_ILC_VALID;
+ return kvm_s390_inject_prog_irq(vcpu, &info);
+ }

return 0;
}

static int handle_lpswe(struct kvm_vcpu *vcpu)
{
+ struct kvm_s390_pgm_info info = {};
psw_t new_psw;
u64 addr, iaddr;
int rc;
@@ -766,8 +771,11 @@ static int handle_lpswe(struct kvm_vcpu *vcpu)
vcpu->arch.sie_block->gpsw = new_psw;
vcpu->arch.sie_block->gbea = iaddr;

- if (!is_valid_psw(&vcpu->arch.sie_block->gpsw))
- return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION);
+ if (!is_valid_psw(&vcpu->arch.sie_block->gpsw)) {
+ info.code = PGM_SPECIFICATION;
+ info.flags = KVM_S390_PGM_FLAGS_ILC_VALID;
+ return kvm_s390_inject_prog_irq(vcpu, &info);
+ }

return 0;
}
--
2.51.0