Commit b14c876b994f208b6b95c222056e1deb0a45de0e

Authored by Radim Krcmar
Committed by Paolo Bonzini
1 parent a738b5e75b

kvm: x86: skip populating logical dest map if apic is not sw enabled

recalculate_apic_map does not santize ldr and it's possible that
multiple bits are set. In that case, a previous valid entry
can potentially be overwritten by an invalid one.

This condition is hit when booting a 32 bit, >8 CPU, RHEL6 guest and then
triggering a crash to boot a kdump kernel. This is the sequence of
events:
1. Linux boots in bigsmp mode and enables PhysFlat, however, it still
writes to the LDR which probably will never be used.
2. However, when booting into kdump, the stale LDR values remain as
they are not cleared by the guest and there isn't a apic reset.
3. kdump boots with 1 cpu, and uses Logical Destination Mode but the
logical map has been overwritten and points to an inactive vcpu.

Signed-off-by: Radim Krcmar <rkrcmar@redhat.com>
Signed-off-by: Bandan Das <bsd@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

Showing 1 changed file with 5 additions and 0 deletions Side-by-side Diff

arch/x86/kvm/lapic.c
... ... @@ -216,6 +216,9 @@
216 216 if (!apic_x2apic_mode(apic) && !new->phys_map[xapic_id])
217 217 new->phys_map[xapic_id] = apic;
218 218  
  219 + if (!kvm_apic_sw_enabled(apic))
  220 + continue;
  221 +
219 222 ldr = kvm_lapic_get_reg(apic, APIC_LDR);
220 223  
221 224 if (apic_x2apic_mode(apic)) {
... ... @@ -258,6 +261,8 @@
258 261 static_key_slow_dec_deferred(&apic_sw_disabled);
259 262 else
260 263 static_key_slow_inc(&apic_sw_disabled.key);
  264 +
  265 + recalculate_apic_map(apic->vcpu->kvm);
261 266 }
262 267 }
263 268