mirror of https://github.com/xqemu/xqemu.git
kvm: x86: Prepare VCPU loop for in-kernel irqchip
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 <jan.kiszka@siemens.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
This commit is contained in:
parent
6792a57bf1
commit
db1669bcca
|
@ -1442,11 +1442,6 @@ int kvm_arch_get_registers(CPUState *env)
|
||||||
|
|
||||||
int kvm_arch_pre_run(CPUState *env, struct kvm_run *run)
|
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 */
|
/* Inject NMI */
|
||||||
if (env->interrupt_request & CPU_INTERRUPT_NMI) {
|
if (env->interrupt_request & CPU_INTERRUPT_NMI) {
|
||||||
env->interrupt_request &= ~CPU_INTERRUPT_NMI;
|
env->interrupt_request &= ~CPU_INTERRUPT_NMI;
|
||||||
|
@ -1454,6 +1449,12 @@ int kvm_arch_pre_run(CPUState *env, struct kvm_run *run)
|
||||||
kvm_vcpu_ioctl(env, KVM_NMI);
|
kvm_vcpu_ioctl(env, KVM_NMI);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
/* Try to inject an interrupt if the guest can accept it */
|
/* Try to inject an interrupt if the guest can accept it */
|
||||||
if (run->ready_for_interrupt_injection &&
|
if (run->ready_for_interrupt_injection &&
|
||||||
(env->interrupt_request & CPU_INTERRUPT_HARD) &&
|
(env->interrupt_request & CPU_INTERRUPT_HARD) &&
|
||||||
|
@ -1464,6 +1465,7 @@ int kvm_arch_pre_run(CPUState *env, struct kvm_run *run)
|
||||||
irq = cpu_get_pic_interrupt(env);
|
irq = cpu_get_pic_interrupt(env);
|
||||||
if (irq >= 0) {
|
if (irq >= 0) {
|
||||||
struct kvm_interrupt intr;
|
struct kvm_interrupt intr;
|
||||||
|
|
||||||
intr.irq = irq;
|
intr.irq = irq;
|
||||||
/* FIXME: errors */
|
/* FIXME: errors */
|
||||||
DPRINTF("injected interrupt %d\n", irq);
|
DPRINTF("injected interrupt %d\n", irq);
|
||||||
|
@ -1483,6 +1485,7 @@ int kvm_arch_pre_run(CPUState *env, struct kvm_run *run)
|
||||||
|
|
||||||
DPRINTF("setting tpr\n");
|
DPRINTF("setting tpr\n");
|
||||||
run->cr8 = cpu_get_apic_tpr(env->apic_state);
|
run->cr8 = cpu_get_apic_tpr(env->apic_state);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
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)
|
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)) {
|
if (env->interrupt_request & (CPU_INTERRUPT_HARD | CPU_INTERRUPT_NMI)) {
|
||||||
env->halted = 0;
|
env->halted = 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue