On Fri, 29 Nov 2019 04:48:02 -0500 Janosch Frank <fran...@linux.ibm.com> wrote:
> Secure guests no longer intercept with code 4 for an instruction > interception. Instead they have codes 104 and 108 for secure > instruction interception and secure instruction notification > respectively. > > The 104 mirrors the 4 interception. > > The 108 is a notification interception to let KVM and QEMU know that > something changed and we need to update tracking information or > perform specific tasks. It's currently taken for the following > instructions: > > * stpx (To inform about the changed prefix location) > * sclp (On incorrect SCCB values, so we can inject a IRQ) > * sigp (All but "stop and store status") > * diag308 (Subcodes 0/1) > > Signed-off-by: Janosch Frank <fran...@linux.ibm.com> > --- > target/s390x/kvm.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c > index ad6e38c876..3d9c44ba9d 100644 > --- a/target/s390x/kvm.c > +++ b/target/s390x/kvm.c > @@ -115,6 +115,8 @@ > #define ICPT_CPU_STOP 0x28 > #define ICPT_OPEREXC 0x2c > #define ICPT_IO 0x40 > +#define ICPT_PV_INSTR 0x68 > +#define ICPT_PV_INSTR_NOTIFICATION 0x6c > > #define NR_LOCAL_IRQS 32 > /* > @@ -151,6 +153,7 @@ static int cap_s390_irq; > static int cap_ri; > static int cap_gs; > static int cap_hpage_1m; > +static int cap_protvirt; > > static int active_cmma; > > @@ -342,6 +345,7 @@ int kvm_arch_init(MachineState *ms, KVMState *s) > cap_async_pf = kvm_check_extension(s, KVM_CAP_ASYNC_PF); > cap_mem_op = kvm_check_extension(s, KVM_CAP_S390_MEM_OP); > cap_s390_irq = kvm_check_extension(s, KVM_CAP_S390_INJECT_IRQ); > + cap_protvirt = kvm_check_extension(s, KVM_CAP_S390_PROTECTED); > > if (!kvm_check_extension(s, KVM_CAP_S390_GMAP) > || !kvm_check_extension(s, KVM_CAP_S390_COW)) { > @@ -1664,6 +1668,8 @@ static int handle_intercept(S390CPU *cpu) > (long)cs->kvm_run->psw_addr); > switch (icpt_code) { > case ICPT_INSTRUCTION: > + case ICPT_PV_INSTR: > + case ICPT_PV_INSTR_NOTIFICATION: > r = handle_instruction(cpu, run); I'm still a bit uneasy about going through the same path for both 104 and 108. How does the handler figure out whether it should emulate an instruction, or just process a notification? Is it guaranteed that a given instruction is always showing up as either a 104 or a 108, so that the handler can check the pv state? [Even if that works, it still feels a bit unclean to me.] > break; > case ICPT_PROGRAM: