Skip to contentSkip to conversation

target/i386: Added V_INTR_PRIO check to virtual interrupts

PATCH Applied Lara Lazier 2 participants 2 messages Jul 28, 2021 – Jul 29, 2021

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 target/i386: Added V_INTR_PRIO check to virtual interrupts

v1->v2: Fixed Mask

The APM2 states that The processor takes a virtual INTR interrupt if V_IRQ and V_INTR_PRIO indicate that there is a virtual interrupt pending whose priority is greater than the value in V_TPR.

---
 target/i386/tcg/sysemu/svm_helper.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
target/i386/tcg/sysemu/svm_helper.c +10 -1
index 72ea7c9a08..a3138e9f86 100644
@@ -65,6 +65,16 @@ static inline void svm_load_seg_cache(CPUX86State *env, hwaddr addr,
                            sc->base, sc->limit, sc->flags);
 }
 
+static inline bool ctl_has_irq(uint32_t int_ctl)
+{
+    uint32_t int_prio;
+    uint32_t tpr;
+
+    int_prio = (int_ctl & V_INTR_PRIO_MASK) >> V_INTR_PRIO_SHIFT;
+    tpr = int_ctl & V_TPR_MASK;
+    return (int_ctl & V_IRQ_MASK) && (int_prio >= tpr);
+}
+
 static inline bool is_efer_invalid_state (CPUX86State *env)
 {
     if (!(env->efer & MSR_EFER_SVME)) {
@@ -365,7 +375,6 @@ void helper_vmrun(CPUX86State *env, int aflag, int next_eip_addend)
 
     if (ctl_has_irq(int_ctl)) {
         CPUState *cs = env_cpu(env);
-
         cs->interrupt_request |= CPU_INTERRUPT_VIRQ;
     }
 
Signature · 1 line
2.25.1
#1 lore raw
Quoted 34 lines · Lara Lazier

v1->v2: Fixed Mask

The APM2 states that The processor takes a virtual INTR interrupt if V_IRQ and V_INTR_PRIO indicate that there is a virtual interrupt pending whose priority is greater than the value in V_TPR.

---
  target/i386/tcg/sysemu/svm_helper.c | 11 ++++++++++-
  1 file changed, 10 insertions(+), 1 deletion(-)
target/i386/tcg/sysemu/svm_helper.c +10 -0
index 72ea7c9a08..a3138e9f86 100644
@@ -65,6 +65,16 @@ static inline void svm_load_seg_cache(CPUX86State *env, hwaddr addr,
                             sc->base, sc->limit, sc->flags);
  }
 
+static inline bool ctl_has_irq(uint32_t int_ctl)
+{
+    uint32_t int_prio;
+    uint32_t tpr;
+
+    int_prio = (int_ctl & V_INTR_PRIO_MASK) >> V_INTR_PRIO_SHIFT;
+    tpr = int_ctl & V_TPR_MASK;
+    return (int_ctl & V_IRQ_MASK) && (int_prio >= tpr);
+}
+
  static inline bool is_efer_invalid_state (CPUX86State *env)
  {
      if (!(env->efer & MSR_EFER_SVME)) {

target/i386/tcg/sysemu/svm_helper.c void helper_vmrun(CPUX86State *env, int aflag, int next_eip_addend) · line 380

Quoted 7 lines
target/i386/tcg/sysemu/svm_helper.c +0 -1
@@ -365,7 +375,6 @@ void helper_vmrun(CPUX86State *env, int aflag, int next_eip_addend)
 
      if (ctl_has_irq(int_ctl)) {
          CPUState *cs = env_cpu(env);
-
          cs->interrupt_request |= CPU_INTERRUPT_VIRQ;
      }
 

Merged, thanks.

Paolo