Skip to content

Commit 7760bb0

Browse files
Lara Lazierbonzini
authored andcommitted
target/i386: Added changed priority check for VIRQ
Writes to cr8 affect v_tpr. This could set or unset an interrupt request as the priority might have changed. Signed-off-by: Lara Lazier <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 66a0201 commit 7760bb0

File tree

3 files changed

+22
-15
lines changed

3 files changed

+22
-15
lines changed

target/i386/cpu.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2246,6 +2246,21 @@ static inline uint64_t cr4_reserved_bits(CPUX86State *env)
22462246
return reserved_bits;
22472247
}
22482248

2249+
static inline bool ctl_has_irq(CPUX86State *env)
2250+
{
2251+
uint32_t int_prio;
2252+
uint32_t tpr;
2253+
2254+
int_prio = (env->int_ctl & V_INTR_PRIO_MASK) >> V_INTR_PRIO_SHIFT;
2255+
tpr = env->int_ctl & V_TPR_MASK;
2256+
2257+
if (env->int_ctl & V_IGN_TPR_MASK) {
2258+
return (env->int_ctl & V_IRQ_MASK);
2259+
}
2260+
2261+
return (env->int_ctl & V_IRQ_MASK) && (int_prio >= tpr);
2262+
}
2263+
22492264
#if defined(TARGET_X86_64) && \
22502265
defined(CONFIG_USER_ONLY) && \
22512266
defined(CONFIG_LINUX)

target/i386/tcg/sysemu/misc_helper.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,13 @@ void helper_write_crN(CPUX86State *env, int reg, target_ulong t0)
122122
qemu_mutex_unlock_iothread();
123123
}
124124
env->int_ctl = (env->int_ctl & ~V_TPR_MASK) | (t0 & V_TPR_MASK);
125+
126+
CPUState *cs = env_cpu(env);
127+
if (ctl_has_irq(env)) {
128+
cpu_interrupt(cs, CPU_INTERRUPT_VIRQ);
129+
} else {
130+
cpu_reset_interrupt(cs, CPU_INTERRUPT_VIRQ);
131+
}
125132
break;
126133
default:
127134
env->cr[reg] = t0;

target/i386/tcg/sysemu/svm_helper.c

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -76,21 +76,6 @@ static inline void svm_load_seg_cache(CPUX86State *env, hwaddr addr,
7676
sc->base, sc->limit, sc->flags);
7777
}
7878

79-
static inline bool ctl_has_irq(CPUX86State *env)
80-
{
81-
uint32_t int_prio;
82-
uint32_t tpr;
83-
84-
int_prio = (env->int_ctl & V_INTR_PRIO_MASK) >> V_INTR_PRIO_SHIFT;
85-
tpr = env->int_ctl & V_TPR_MASK;
86-
87-
if (env->int_ctl & V_IGN_TPR_MASK) {
88-
return env->int_ctl & V_IRQ_MASK;
89-
}
90-
91-
return (env->int_ctl & V_IRQ_MASK) && (int_prio >= tpr);
92-
}
93-
9479
static inline bool is_efer_invalid_state (CPUX86State *env)
9580
{
9681
if (!(env->efer & MSR_EFER_SVME)) {

0 commit comments

Comments
 (0)