KVM: PPC: Fix contents of SRR1 when injecting a program exception in kvm-pr
Subsystems (3)
PATCH v2 1/1 KVM: PPC: Fix contents of SRR1 when injecting a program exception in kvm-pr
vcpu->arch.shadow_srr1 only contains usable values for injecting a program exception into the guest if we entered the function kvmppc_handle_exit_pr() with exit_nr = BOOK3S_INTERRUPT_PROGRAM. In other cases, the shadow_srr1 bits are zero. Since we want to pass an illegal-instruction program check to the guest, set "flags" to SRR1_PROGILL for these other cases.
---
v2: Added a comment, as suggested by Alexander Graf
arch/powerpc/kvm/book3s_pr.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
arch/powerpc/kvm/book3s_pr.c +11 -1
@@ -1031,7 +1031,17 @@ int kvmppc_handle_exit_pr(struct kvm_run *run, struct kvm_vcpu *vcpu,int emul; program_interrupt: - flags = vcpu->arch.shadow_srr1 &0x1f0000ull ; +/* +* shadow_srr1 only contains valid flags if we came here via +* a program exception. The other exceptions (emulation assist, +* FP unavailable, etc.) do not provide flags in SRR1, so use +* an illegal-instruction exception when injecting a program +* interrupt into the guest. +*/ +if (exit_nr =BOOK3S_INTERRUPT_PROGRAM ) + flags = vcpu->arch.shadow_srr1 &0x1f0000ull ; +else + flags =SRR1_PROGILL ; emul =kvmppc_get_last_inst (vcpu,INST_GENERIC , &last_inst);if (emul !=EMULATE_DONE ) {
Signature · 1 line
1.8.3.1
Quoted 28 lines · Thomas Huth
vcpu->arch.shadow_srr1only contains usable values for injecting a program exception into the guest if we entered the functionkvmppc_handle_exit_pr()withexit_nr=BOOK3S_INTERRUPT_PROGRAM. In other cases, theshadow_srr1bits are zero. Since we want to pass an illegal-instruction program check to the guest, set "flags" toSRR1_PROGILLfor these other cases.Signed-off-by Thomas Huth <[email protected]>---
v2: Added a comment, as suggested by Alexander Grafarch/powerpc/kvm/book3s_pr.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)arch/powerpc/kvm/book3s_pr.c +4
-1@@ -1031,7 +1031,17 @@ int kvmppc_handle_exit_pr(struct kvm_run *run, struct kvm_vcpu *vcpu,int emul; program_interrupt: - flags = vcpu->arch.shadow_srr1 &0x1f0000ull ; +/* +* shadow_srr1 only contains valid flags if we came here via +* a program exception. The other exceptions (emulation assist, +* FP unavailable, etc.) do not provide flags in SRR1, so use
arch/powerpc/kvm/book3s_pr.c int kvmppc_handle_exit_pr(struct kvm_run *run, struct kvm_vcpu *vcpu, · line 1047
Quoted 10 lines
arch/powerpc/kvm/book3s_pr.c +7
-0+* an illegal-instruction exception when injecting a program +* interrupt into the guest. +*/ +if (exit_nr =BOOK3S_INTERRUPT_PROGRAM ) + flags = vcpu->arch.shadow_srr1 &0x1f0000ull ; +else + flags =SRR1_PROGILL ; emul =kvmppc_get_last_inst (vcpu,INST_GENERIC , &last_inst);if (emul !=EMULATE_DONE ) {
*ping*
Thomas
Paul Mackerras
AppliedQuoted 8 lines · Thomas Huth
vcpu->arch.shadow_srr1only contains usable values for injecting a program exception into the guest if we entered the functionkvmppc_handle_exit_pr()withexit_nr=BOOK3S_INTERRUPT_PROGRAM. In other cases, theshadow_srr1bits are zero. Since we want to pass an illegal-instruction program check to the guest, set "flags" toSRR1_PROGILLfor these other cases.Signed-off-by Thomas Huth <[email protected]>
Thanks, applied to my kvm-ppc-next branch.
Paul.