Skip to contentSkip to conversation

KVM: PPC: Fix contents of SRR1 when injecting a program exception in kvm-pr

PATCH Superseded Thomas Huth 2 participants 2 messages May 19, 2016

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 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.

---
 arch/powerpc/kvm/book3s_pr.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
arch/powerpc/kvm/book3s_pr.c +4 -1
index 95bceca..b12e80a 100644
@@ -1031,7 +1031,10 @@ int kvmppc_handle_exit_pr(struct kvm_run *run, struct kvm_vcpu *vcpu,
 		int emul;
 
 program_interrupt:
-		flags = vcpu->arch.shadow_srr1 & 0x1f0000ull;
+		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
#1 lore raw
Quoted 8 lines · Thomas Huth

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.

Looks good, but please add a comment that H_EMUL_ASSIST doesn't provide the flags inside the code ;)

Alex

Quoted 20 lines
---
  arch/powerpc/kvm/book3s_pr.c | 5 ++++-
  1 file changed, 4 insertions(+), 1 deletion(-)
arch/powerpc/kvm/book3s_pr.c +4 -1
index 95bceca..b12e80a 100644
@@ -1031,7 +1031,10 @@ int kvmppc_handle_exit_pr(struct kvm_run *run, struct kvm_vcpu *vcpu,
  		int emul;
 
  program_interrupt:
-		flags = vcpu->arch.shadow_srr1 & 0x1f0000ull;
+		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) {