s390x/kvm: detect some program check loops
commit409422cd83f36450a3c0bdd49163786cbff3a7ea
authorChristian Borntraeger <borntraeger@de.ibm.com>
Thu, 26 Jan 2017 19:23:30 +0000 (26 20:23 +0100)
committerCornelia Huck <cornelia.huck@de.ibm.com>
Fri, 24 Feb 2017 09:15:18 +0000 (24 10:15 +0100)
tree8ace7d46929dc1274060aba84b4b57131a317dd6
parent94b5024b1f466b4b8f03e7b2219f77e9a3a24d51
s390x/kvm: detect some program check loops

Sometimes (e.g. early boot) a guest is broken in such ways that it loops
100% delivering operation exceptions (illegal operation) but the pgm new
PSW is not set properly. This will result in code being read from
address zero, which usually contains another illegal op. Let's detect
this case and put the guest in crashed state. Instead of only detecting
this for address zero apply a heuristic that will work for any program
check new psw so that it will also reach the crashed state if you
provide some random elf file to the -kernel option.
We do not want guest problem state to be able to trigger a guest panic,
e.g. by faulting on an address that is the same as the program check
new PSW, so we check for the problem state bit being off.

With this we
a: get rid of CPU consumption of such broken guests
b: keep the program old PSW. This allows to find out the original illegal
   operation - making debugging such early boot issues much easier than
   with single stepping

This relies on the kernel using a similar heuristic and passing such
operation exceptions to user space.

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
target/s390x/kvm.c