[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 30/37] kvm: x86: Prepare VCPU loop for in-kernel irq
From: |
Marcelo Tosatti |
Subject: |
[Qemu-devel] [PATCH 30/37] kvm: x86: Prepare VCPU loop for in-kernel irqchip |
Date: |
Mon, 14 Feb 2011 13:22:59 -0200 |
From: Jan Kiszka <address@hidden>
Effectively no functional change yet as kvm_irqchip_in_kernel still only
returns 0, but this patch will allow qemu-kvm to adopt the VCPU loop of
upsteam KVM.
Signed-off-by: Jan Kiszka <address@hidden>
Signed-off-by: Marcelo Tosatti <address@hidden>
---
target-i386/kvm.c | 69 +++++++++++++++++++++++++++++-----------------------
1 files changed, 38 insertions(+), 31 deletions(-)
diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index 377a0a3..f02f478 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -1442,11 +1442,6 @@ int kvm_arch_get_registers(CPUState *env)
int kvm_arch_pre_run(CPUState *env, struct kvm_run *run)
{
- /* Force the VCPU out of its inner loop to process the INIT request */
- if (env->interrupt_request & CPU_INTERRUPT_INIT) {
- env->exit_request = 1;
- }
-
/* Inject NMI */
if (env->interrupt_request & CPU_INTERRUPT_NMI) {
env->interrupt_request &= ~CPU_INTERRUPT_NMI;
@@ -1454,35 +1449,43 @@ int kvm_arch_pre_run(CPUState *env, struct kvm_run *run)
kvm_vcpu_ioctl(env, KVM_NMI);
}
- /* Try to inject an interrupt if the guest can accept it */
- if (run->ready_for_interrupt_injection &&
- (env->interrupt_request & CPU_INTERRUPT_HARD) &&
- (env->eflags & IF_MASK)) {
- int irq;
-
- env->interrupt_request &= ~CPU_INTERRUPT_HARD;
- irq = cpu_get_pic_interrupt(env);
- if (irq >= 0) {
- struct kvm_interrupt intr;
- intr.irq = irq;
- /* FIXME: errors */
- DPRINTF("injected interrupt %d\n", irq);
- kvm_vcpu_ioctl(env, KVM_INTERRUPT, &intr);
+ if (!kvm_irqchip_in_kernel()) {
+ /* Force the VCPU out of its inner loop to process the INIT request */
+ if (env->interrupt_request & CPU_INTERRUPT_INIT) {
+ env->exit_request = 1;
}
- }
- /* If we have an interrupt but the guest is not ready to receive an
- * interrupt, request an interrupt window exit. This will
- * cause a return to userspace as soon as the guest is ready to
- * receive interrupts. */
- if ((env->interrupt_request & CPU_INTERRUPT_HARD)) {
- run->request_interrupt_window = 1;
- } else {
- run->request_interrupt_window = 0;
- }
+ /* Try to inject an interrupt if the guest can accept it */
+ if (run->ready_for_interrupt_injection &&
+ (env->interrupt_request & CPU_INTERRUPT_HARD) &&
+ (env->eflags & IF_MASK)) {
+ int irq;
+
+ env->interrupt_request &= ~CPU_INTERRUPT_HARD;
+ irq = cpu_get_pic_interrupt(env);
+ if (irq >= 0) {
+ struct kvm_interrupt intr;
+
+ intr.irq = irq;
+ /* FIXME: errors */
+ DPRINTF("injected interrupt %d\n", irq);
+ kvm_vcpu_ioctl(env, KVM_INTERRUPT, &intr);
+ }
+ }
- DPRINTF("setting tpr\n");
- run->cr8 = cpu_get_apic_tpr(env->apic_state);
+ /* If we have an interrupt but the guest is not ready to receive an
+ * interrupt, request an interrupt window exit. This will
+ * cause a return to userspace as soon as the guest is ready to
+ * receive interrupts. */
+ if ((env->interrupt_request & CPU_INTERRUPT_HARD)) {
+ run->request_interrupt_window = 1;
+ } else {
+ run->request_interrupt_window = 0;
+ }
+
+ DPRINTF("setting tpr\n");
+ run->cr8 = cpu_get_apic_tpr(env->apic_state);
+ }
return 0;
}
@@ -1502,6 +1505,10 @@ int kvm_arch_post_run(CPUState *env, struct kvm_run *run)
int kvm_arch_process_irqchip_events(CPUState *env)
{
+ if (kvm_irqchip_in_kernel()) {
+ return 0;
+ }
+
if (env->interrupt_request & (CPU_INTERRUPT_HARD | CPU_INTERRUPT_NMI)) {
env->halted = 0;
}
--
1.7.4
- [Qemu-devel] [PATCH 23/37] Refactor kvm&tcg function names in cpus.c, (continued)
- [Qemu-devel] [PATCH 23/37] Refactor kvm&tcg function names in cpus.c, Marcelo Tosatti, 2011/02/14
- [Qemu-devel] [PATCH 14/37] kvm: Call qemu_kvm_eat_signals also under !CONFIG_IOTHREAD, Marcelo Tosatti, 2011/02/14
- [Qemu-devel] [PATCH 15/37] Set up signalfd under !CONFIG_IOTHREAD, Marcelo Tosatti, 2011/02/14
- [Qemu-devel] [PATCH 02/37] Stop current VCPU on synchronous reset requests, Marcelo Tosatti, 2011/02/14
- [Qemu-devel] [PATCH 22/37] kvm: make tsc stable over migration and machine start, Marcelo Tosatti, 2011/02/14
- [Qemu-devel] [PATCH 04/37] Trigger exit from cpu_exec_all on pending IO events, Marcelo Tosatti, 2011/02/14
- [Qemu-devel] [PATCH 34/37] Introduce log_start/log_stop in CPUPhysMemoryClient, Marcelo Tosatti, 2011/02/14
- [Qemu-devel] [PATCH 16/37] kvm: Fix race between timer signals and vcpu entry under !IOTHREAD, Marcelo Tosatti, 2011/02/14
- [Qemu-devel] [PATCH 17/37] kvm: Add MCE signal support for !CONFIG_IOTHREAD, Marcelo Tosatti, 2011/02/14
- [Qemu-devel] [PATCH 37/37] kvm: x86: Introduce kvmclock device to save/restore its state, Marcelo Tosatti, 2011/02/14
- [Qemu-devel] [PATCH 30/37] kvm: x86: Prepare VCPU loop for in-kernel irqchip,
Marcelo Tosatti <=
- [Qemu-devel] [PATCH 31/37] kvm: Drop return values from kvm_arch_pre/post_run, Marcelo Tosatti, 2011/02/14
- Re: [Qemu-devel] [PATCH 00/37] [PULL] qemu-kvm.git uq/master queue, Anthony Liguori, 2011/02/14