This patch adds interface to inject interrupt to guest.
Currently a void program check exception function added.
Follow up patch will use this interface to inject program
check exception to guest
Signed-off-by: Bharat Bhushan <address@hidden>
---
v5->v6
- replace debug with program interrupt
target-ppc/cpu.h | 1 +
target-ppc/kvm.c | 23 +++++++++++++++++++++++
2 files changed, 24 insertions(+)
diff --git a/target-ppc/cpu.h b/target-ppc/cpu.h
index b64c652..e60fc40 100644
--- a/target-ppc/cpu.h
+++ b/target-ppc/cpu.h
@@ -2144,6 +2144,7 @@ enum {
PPC_INTERRUPT_CDOORBELL, /* Critical doorbell interrupt */
PPC_INTERRUPT_DOORBELL, /* Doorbell interrupt */
PPC_INTERRUPT_PERFM, /* Performance monitor interrupt */
+ PPC_INTERRUPT_PROGRAM, /* Program check exception */
};
/* Processor Compatibility mask (PCR) */
diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c
index 4df23dd..673c369 100644
--- a/target-ppc/kvm.c
+++ b/target-ppc/kvm.c
@@ -761,6 +761,25 @@ static int kvm_put_vpa(CPUState *cs)
}
#endif /* TARGET_PPC64 */
+static int kvmppc_inject_program_exception(CPUState *cs)
+{
+ return 0;
+}
+
+static void kvmppc_inject_exception(CPUState *cs)
+{
+ PowerPCCPU *cpu = POWERPC_CPU(cs);
+ CPUPPCState *env = &cpu->env;
+
+ if (env->pending_interrupts & (1 << PPC_INTERRUPT_PROGRAM)) {
+ if (kvmppc_inject_program_exception(cs)) {
+ fprintf(stderr, "%s: PROGRAM exception injection failed\n",
__func__);
+ return;
+ }
+ env->pending_interrupts &= ~(1 << PPC_INTERRUPT_PROGRAM);
+ }
+}
+
int kvm_arch_put_registers(CPUState *cs, int level)
{
PowerPCCPU *cpu = POWERPC_CPU(cs);
@@ -774,6 +793,10 @@ int kvm_arch_put_registers(CPUState *cs, int level)
return ret;
}
+ if (env->pending_interrupts) {
+ kvmppc_inject_exception(cs);
+ }
+
regs.ctr = env->ctr;
regs.lr = env->lr;
regs.xer = cpu_read_xer(env);