Skip to contentSkip to conversation

SVM: acknowledge interrupt only after it is taken

PATCH Applied Alexander Graf 2 participants 3 messages Dec 12, 2008 – Dec 13, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 SVM: acknowledge interrupt only after it is taken

SVM specifies that the V_IRQ mask is only to be removed, if the interrupt that is to be delivered actually is delivered.

As of the SVM rewrite, this mask is always unmasked when the main cpu loop is processed, leaving a corner case where calling the interrupt handler causes a #PF. In that case (booting Linux / starting gfxboot) the current implementation tells the VMM the interrupt is taken, even though it is not.

This patch modifies the VIRQ unmasking to occur after do_interrupt, making gfxboot work again.

---
 cpu-exec.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
cpu-exec.c +1 -1
index 9a35a59..981ba86 100644
@@ -401,11 +401,11 @@ int cpu_exec(CPUState *env1)
                             int intno;
                             /* FIXME: this should respect TPR */
                             svm_check_intercept(SVM_EXIT_VINTR);
-                            env->interrupt_request &= ~CPU_INTERRUPT_VIRQ;
                             intno = ldl_phys(env->vm_vmcb + offsetof(struct vmcb, control.int_vector));
                             if (loglevel & CPU_LOG_TB_IN_ASM)
                                 fprintf(logfile, "Servicing virtual hardware INT=0x%02x\n", intno);
                             do_interrupt(intno, 0, 0, 0, 1);
+                            env->interrupt_request &= ~CPU_INTERRUPT_VIRQ;
                             next_tb = 0;
 #endif
                         }
Signature · 1 line
1.5.6
#1 lore raw
Quoted 12 lines · Alexander Graf

SVM specifies that the V_IRQ mask is only to be removed, if the interrupt that is to be delivered actually is delivered.

As of the SVM rewrite, this mask is always unmasked when the main cpu loop is processed, leaving a corner case where calling the interrupt handler causes a #PF. In that case (booting Linux / starting gfxboot) the current implementation tells the VMM the interrupt is taken, even though it is not.

This patch modifies the VIRQ unmasking to occur after do_interrupt, making gfxboot work again.

(wow, I actually forgot that line even though working with git - phew)

Quoted 22 lines
---
 cpu-exec.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
cpu-exec.c +1 -1
index 9a35a59..981ba86 100644
@@ -401,11 +401,11 @@ int cpu_exec(CPUState *env1)
                             int intno;
                             /* FIXME: this should respect TPR */
                             svm_check_intercept(SVM_EXIT_VINTR);
-                            env->interrupt_request &= ~CPU_INTERRUPT_VIRQ;
                             intno = ldl_phys(env->vm_vmcb + offsetof(struct vmcb, control.int_vector));
                             if (loglevel & CPU_LOG_TB_IN_ASM)
                                 fprintf(logfile, "Servicing virtual hardware INT=0x%02x\n", intno);
                             do_interrupt(intno, 0, 0, 0, 1);
+                            env->interrupt_request &= ~CPU_INTERRUPT_VIRQ;
                             next_tb = 0;
 #endif
                         }
#2 lore raw
In reply to Alexander Graf
Quoted 11 lines · Alexander Graf

SVM specifies that the V_IRQ mask is only to be removed, if the interrupt that is to be delivered actually is delivered.

As of the SVM rewrite, this mask is always unmasked when the main cpu loop is processed, leaving a corner case where calling the interrupt handler causes a #PF. In that case (booting Linux / starting gfxboot) the current implementation tells the VMM the interrupt is taken, even though it is not.

This patch modifies the VIRQ unmasking to occur after do_interrupt, making gfxboot work again.

Thanks, applied.

Quoted 27 lines
---
 cpu-exec.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
cpu-exec.c +1 -1
index 9a35a59..981ba86 100644
@@ -401,11 +401,11 @@ int cpu_exec(CPUState *env1)
                             int intno;
                             /* FIXME: this should respect TPR */
                             svm_check_intercept(SVM_EXIT_VINTR);
-                            env->interrupt_request &= ~CPU_INTERRUPT_VIRQ;
                             intno = ldl_phys(env->vm_vmcb + offsetof(struct vmcb, control.int_vector));
                             if (loglevel & CPU_LOG_TB_IN_ASM)
                                 fprintf(logfile, "Servicing virtual hardware INT=0x%02x\n", intno);
                             do_interrupt(intno, 0, 0, 0, 1);
+                            env->interrupt_request &= ~CPU_INTERRUPT_VIRQ;
                             next_tb = 0;
 #endif
                         }
Signature · 1 line
1.5.6
Signature · 4 lines
  .''`.  Aurelien Jarno	            | GPG: 1024D/F1BCDB73
 : :' :  Debian developer           | Electrical Engineer
 `. `'   [email protected]         | [email protected]
   `-    people.debian.org/~aurel32 | www.aurel32.net