@@ -10,6 +10,7 @@ void apic_deliver_nmi(DeviceState *d);
int apic_get_interrupt(DeviceState *s);
int cpu_set_apic_base(DeviceState *s, uint64_t val);
uint64_t cpu_get_apic_base(DeviceState *s);
+bool cpu_is_apic_enabled(DeviceState *s);
void cpu_set_apic_tpr(DeviceState *s, uint8_t val);
uint8_t cpu_get_apic_tpr(DeviceState *s);
void apic_init_reset(DeviceState *s);
@@ -520,7 +520,7 @@ static void x86_nmi(NMIState *n, int cpu_index, Error **errp)
CPU_FOREACH(cs) {
X86CPU *cpu = X86_CPU(cs);
- if (cpu->apic_state) {
+ if (cpu_is_apic_enabled(cpu->apic_state)) {
apic_deliver_nmi(cpu->apic_state);
} else {
cpu_interrupt(cs, CPU_INTERRUPT_NMI);
@@ -555,7 +555,7 @@ static void pic_irq_request(void *opaque, int irq, int level)
X86CPU *cpu = X86_CPU(cs);
trace_x86_pic_interrupt(irq, level);
- if (cpu->apic_state && !kvm_irqchip_in_kernel() &&
+ if (cpu_is_apic_enabled(cpu->apic_state) && !kvm_irqchip_in_kernel() &&
!whpx_apic_in_platform()) {
CPU_FOREACH(cs) {
cpu = X86_CPU(cs);
@@ -62,6 +62,19 @@ uint64_t cpu_get_apic_base(DeviceState *dev)
}
}
+bool cpu_is_apic_enabled(DeviceState *dev)
+{
+ APICCommonState *s;
+
+ if (!dev) {
+ return false;
+ }
+
+ s = APIC_COMMON(dev);
+
+ return s->apicbase & MSR_IA32_APICBASE_ENABLE;
+}
+
void cpu_set_apic_tpr(DeviceState *dev, uint8_t val)
{
APICCommonState *s;