Skip to content

Commit 857b8de

Browse files
heicarstborntraeger
authored andcommitted
KVM: s390: sthyi: fix specification exception detection
sthyi should only generate a specification exception if the function code is zero and the response buffer is not on a 4k boundary. The current code would also test for unknown function codes if the response buffer, that is currently only defined for function code 0, is not on a 4k boundary and incorrectly inject a specification exception instead of returning with condition code 3 and return code 4 (unsupported function code). Fix this by moving the boundary check. Fixes: 95ca2cb ("KVM: s390: Add sthyi emulation") Cc: <[email protected]> # 4.8+ Reviewed-by: Janosch Frank <[email protected]> Signed-off-by: Heiko Carstens <[email protected]> Reviewed-by: David Hildenbrand <[email protected]> Reviewed-by: Cornelia Huck <[email protected]> Signed-off-by: Christian Borntraeger <[email protected]>
1 parent 4a4eefc commit 857b8de

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

arch/s390/kvm/sthyi.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,14 +425,17 @@ int handle_sthyi(struct kvm_vcpu *vcpu)
425425
VCPU_EVENT(vcpu, 3, "STHYI: fc: %llu addr: 0x%016llx", code, addr);
426426
trace_kvm_s390_handle_sthyi(vcpu, code, addr);
427427

428-
if (reg1 == reg2 || reg1 & 1 || reg2 & 1 || addr & ~PAGE_MASK)
428+
if (reg1 == reg2 || reg1 & 1 || reg2 & 1)
429429
return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION);
430430

431431
if (code & 0xffff) {
432432
cc = 3;
433433
goto out;
434434
}
435435

436+
if (addr & ~PAGE_MASK)
437+
return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION);
438+
436439
/*
437440
* If the page has not yet been faulted in, we want to do that
438441
* now and not after all the expensive calculations.

0 commit comments

Comments
 (0)