mirror of https://github.com/xemu-project/xemu.git
target/riscv: Split interrupt logic from riscv_cpu_update_mip.
This is to allow virtual interrupts to be inserted into S and VS modes. Given virtual interrupts will be maintained in separate mvip and hvip CSRs, riscv_cpu_update_mip will no longer be in the path and interrupts need to be triggered for these cases from rmw_hvip64 and rmw_mvip64 functions. Signed-off-by: Rajnesh Kanwal <rkanwal@rivosinc.com> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Message-ID: <20231016111736.28721-5-rkanwal@rivosinc.com> Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
This commit is contained in:
parent
b901c7eb70
commit
1ebad505f3
|
@ -463,6 +463,7 @@ void riscv_cpu_swap_hypervisor_regs(CPURISCVState *env);
|
|||
int riscv_cpu_claim_interrupts(RISCVCPU *cpu, uint64_t interrupts);
|
||||
uint64_t riscv_cpu_update_mip(CPURISCVState *env, uint64_t mask,
|
||||
uint64_t value);
|
||||
void riscv_cpu_interrupt(CPURISCVState *env);
|
||||
#define BOOL_TO_MASK(x) (-!!(x)) /* helper for riscv_cpu_update_mip value */
|
||||
void riscv_cpu_set_rdtime_fn(CPURISCVState *env, uint64_t (*fn)(void *),
|
||||
void *arg);
|
||||
|
|
|
@ -620,11 +620,12 @@ int riscv_cpu_claim_interrupts(RISCVCPU *cpu, uint64_t interrupts)
|
|||
}
|
||||
}
|
||||
|
||||
uint64_t riscv_cpu_update_mip(CPURISCVState *env, uint64_t mask,
|
||||
uint64_t value)
|
||||
void riscv_cpu_interrupt(CPURISCVState *env)
|
||||
{
|
||||
uint64_t gein, vsgein = 0, vstip = 0;
|
||||
CPUState *cs = env_cpu(env);
|
||||
uint64_t gein, vsgein = 0, vstip = 0, old = env->mip;
|
||||
|
||||
QEMU_IOTHREAD_LOCK_GUARD();
|
||||
|
||||
if (env->virt_enabled) {
|
||||
gein = get_field(env->hstatus, HSTATUS_VGEIN);
|
||||
|
@ -633,15 +634,25 @@ uint64_t riscv_cpu_update_mip(CPURISCVState *env, uint64_t mask,
|
|||
|
||||
vstip = env->vstime_irq ? MIP_VSTIP : 0;
|
||||
|
||||
QEMU_IOTHREAD_LOCK_GUARD();
|
||||
|
||||
env->mip = (env->mip & ~mask) | (value & mask);
|
||||
|
||||
if (env->mip | vsgein | vstip) {
|
||||
cpu_interrupt(cs, CPU_INTERRUPT_HARD);
|
||||
} else {
|
||||
cpu_reset_interrupt(cs, CPU_INTERRUPT_HARD);
|
||||
}
|
||||
}
|
||||
|
||||
uint64_t riscv_cpu_update_mip(CPURISCVState *env, uint64_t mask, uint64_t value)
|
||||
{
|
||||
uint64_t old = env->mip;
|
||||
|
||||
/* No need to update mip for VSTIP */
|
||||
mask = ((mask == MIP_VSTIP) && env->vstime_irq) ? 0 : mask;
|
||||
|
||||
QEMU_IOTHREAD_LOCK_GUARD();
|
||||
|
||||
env->mip = (env->mip & ~mask) | (value & mask);
|
||||
|
||||
riscv_cpu_interrupt(env);
|
||||
|
||||
return old;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue