target/riscv: Support setting external interrupt by KVM
When KVM is enabled, set the S-mode external interrupt through kvm_riscv_set_irq function. Signed-off-by: Yifei Jiang <jiangyifei@huawei.com> Signed-off-by: Mingwang Li <limingwang@huawei.com> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Reviewed-by: Anup Patel <anup.patel@wdc.com> Message-id: 20220112081329.1835-8-jiangyifei@huawei.com Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
This commit is contained in:
parent
ad40be2708
commit
2b650fbbcc
@ -630,7 +630,11 @@ static void riscv_cpu_set_irq(void *opaque, int irq, int level)
|
||||
case IRQ_S_EXT:
|
||||
case IRQ_VS_EXT:
|
||||
case IRQ_M_EXT:
|
||||
riscv_cpu_update_mip(cpu, 1 << irq, BOOL_TO_MASK(level));
|
||||
if (kvm_enabled()) {
|
||||
kvm_riscv_set_irq(cpu, irq, level);
|
||||
} else {
|
||||
riscv_cpu_update_mip(cpu, 1 << irq, BOOL_TO_MASK(level));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
|
@ -23,3 +23,8 @@ void kvm_riscv_reset_vcpu(RISCVCPU *cpu)
|
||||
{
|
||||
abort();
|
||||
}
|
||||
|
||||
void kvm_riscv_set_irq(RISCVCPU *cpu, int irq, int level)
|
||||
{
|
||||
abort();
|
||||
}
|
||||
|
@ -385,6 +385,23 @@ void kvm_riscv_reset_vcpu(RISCVCPU *cpu)
|
||||
env->satp = 0;
|
||||
}
|
||||
|
||||
void kvm_riscv_set_irq(RISCVCPU *cpu, int irq, int level)
|
||||
{
|
||||
int ret;
|
||||
unsigned virq = level ? KVM_INTERRUPT_SET : KVM_INTERRUPT_UNSET;
|
||||
|
||||
if (irq != IRQ_S_EXT) {
|
||||
perror("kvm riscv set irq != IRQ_S_EXT\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
ret = kvm_vcpu_ioctl(CPU(cpu), KVM_INTERRUPT, &virq);
|
||||
if (ret < 0) {
|
||||
perror("Set irq failed");
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
bool kvm_arch_cpu_check_are_resettable(void)
|
||||
{
|
||||
return true;
|
||||
|
@ -20,5 +20,6 @@
|
||||
#define QEMU_KVM_RISCV_H
|
||||
|
||||
void kvm_riscv_reset_vcpu(RISCVCPU *cpu);
|
||||
void kvm_riscv_set_irq(RISCVCPU *cpu, int irq, int level);
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user