Revision db1669bc
b/target-i386/kvm.c | ||
---|---|---|
1442 | 1442 |
|
1443 | 1443 |
int kvm_arch_pre_run(CPUState *env, struct kvm_run *run) |
1444 | 1444 |
{ |
1445 |
/* Force the VCPU out of its inner loop to process the INIT request */ |
|
1446 |
if (env->interrupt_request & CPU_INTERRUPT_INIT) { |
|
1447 |
env->exit_request = 1; |
|
1448 |
} |
|
1449 |
|
|
1450 | 1445 |
/* Inject NMI */ |
1451 | 1446 |
if (env->interrupt_request & CPU_INTERRUPT_NMI) { |
1452 | 1447 |
env->interrupt_request &= ~CPU_INTERRUPT_NMI; |
... | ... | |
1454 | 1449 |
kvm_vcpu_ioctl(env, KVM_NMI); |
1455 | 1450 |
} |
1456 | 1451 |
|
1457 |
/* Try to inject an interrupt if the guest can accept it */ |
|
1458 |
if (run->ready_for_interrupt_injection && |
|
1459 |
(env->interrupt_request & CPU_INTERRUPT_HARD) && |
|
1460 |
(env->eflags & IF_MASK)) { |
|
1461 |
int irq; |
|
1462 |
|
|
1463 |
env->interrupt_request &= ~CPU_INTERRUPT_HARD; |
|
1464 |
irq = cpu_get_pic_interrupt(env); |
|
1465 |
if (irq >= 0) { |
|
1466 |
struct kvm_interrupt intr; |
|
1467 |
intr.irq = irq; |
|
1468 |
/* FIXME: errors */ |
|
1469 |
DPRINTF("injected interrupt %d\n", irq); |
|
1470 |
kvm_vcpu_ioctl(env, KVM_INTERRUPT, &intr); |
|
1452 |
if (!kvm_irqchip_in_kernel()) { |
|
1453 |
/* Force the VCPU out of its inner loop to process the INIT request */ |
|
1454 |
if (env->interrupt_request & CPU_INTERRUPT_INIT) { |
|
1455 |
env->exit_request = 1; |
|
1471 | 1456 |
} |
1472 |
} |
|
1473 | 1457 |
|
1474 |
/* If we have an interrupt but the guest is not ready to receive an |
|
1475 |
* interrupt, request an interrupt window exit. This will |
|
1476 |
* cause a return to userspace as soon as the guest is ready to |
|
1477 |
* receive interrupts. */ |
|
1478 |
if ((env->interrupt_request & CPU_INTERRUPT_HARD)) { |
|
1479 |
run->request_interrupt_window = 1; |
|
1480 |
} else { |
|
1481 |
run->request_interrupt_window = 0; |
|
1482 |
} |
|
1458 |
/* Try to inject an interrupt if the guest can accept it */ |
|
1459 |
if (run->ready_for_interrupt_injection && |
|
1460 |
(env->interrupt_request & CPU_INTERRUPT_HARD) && |
|
1461 |
(env->eflags & IF_MASK)) { |
|
1462 |
int irq; |
|
1463 |
|
|
1464 |
env->interrupt_request &= ~CPU_INTERRUPT_HARD; |
|
1465 |
irq = cpu_get_pic_interrupt(env); |
|
1466 |
if (irq >= 0) { |
|
1467 |
struct kvm_interrupt intr; |
|
1468 |
|
|
1469 |
intr.irq = irq; |
|
1470 |
/* FIXME: errors */ |
|
1471 |
DPRINTF("injected interrupt %d\n", irq); |
|
1472 |
kvm_vcpu_ioctl(env, KVM_INTERRUPT, &intr); |
|
1473 |
} |
|
1474 |
} |
|
1483 | 1475 |
|
1484 |
DPRINTF("setting tpr\n"); |
|
1485 |
run->cr8 = cpu_get_apic_tpr(env->apic_state); |
|
1476 |
/* If we have an interrupt but the guest is not ready to receive an |
|
1477 |
* interrupt, request an interrupt window exit. This will |
|
1478 |
* cause a return to userspace as soon as the guest is ready to |
|
1479 |
* receive interrupts. */ |
|
1480 |
if ((env->interrupt_request & CPU_INTERRUPT_HARD)) { |
|
1481 |
run->request_interrupt_window = 1; |
|
1482 |
} else { |
|
1483 |
run->request_interrupt_window = 0; |
|
1484 |
} |
|
1485 |
|
|
1486 |
DPRINTF("setting tpr\n"); |
|
1487 |
run->cr8 = cpu_get_apic_tpr(env->apic_state); |
|
1488 |
} |
|
1486 | 1489 |
|
1487 | 1490 |
return 0; |
1488 | 1491 |
} |
... | ... | |
1502 | 1505 |
|
1503 | 1506 |
int kvm_arch_process_irqchip_events(CPUState *env) |
1504 | 1507 |
{ |
1508 |
if (kvm_irqchip_in_kernel()) { |
|
1509 |
return 0; |
|
1510 |
} |
|
1511 |
|
|
1505 | 1512 |
if (env->interrupt_request & (CPU_INTERRUPT_HARD | CPU_INTERRUPT_NMI)) { |
1506 | 1513 |
env->halted = 0; |
1507 | 1514 |
} |
Also available in: Unified diff