On 2013-03-12 13:06, Paolo Bonzini wrote:
>> diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
>> index 02b51dd..4a21a6b 100644
>> --- a/arch/x86/kvm/lapic.c
>> +++ b/arch/x86/kvm/lapic.c
>> @@ -731,7 +731,7 @@ static int __apic_accept_irq(struct kvm_lapic *apic, int 
>> delivery_mode,
>>      case APIC_DM_INIT:
>>              if (!trig_mode || level) {
>>                      result = 1;
>> -                    vcpu->arch.mp_state = KVM_MP_STATE_INIT_RECEIVED;
>> +                    set_bit(KVM_APIC_INIT, &apic->pending_events);
> 
> I think this should clear pending SIPIs, unless KVM_APIC_INIT was
> already set in which case it should be a no-op.  Something like:
> 
>       e = apic->pending_events;
>       while (!(e & KVM_APIC_INIT))
>               e = cmpxchg(&apic->pending_events, e,
>                           (e | KVM_APIC_INIT) & ~KVM_APIC_SIPI);
> 
> If you do this, better make pending_events an atomic_t.

Quick question: Why atomic_t? It becomes a bit ugly to poke into the
atomic counter for bitops, and cmpxchg is mapped on an interlocked version.

Jan


Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to