Re: [PATCH 5/5] KVM: Allow host IRQ sharing for passed-through PCI2.3 devices

From: Jan Kiszka
Date: Mon Dec 06 2010 - 12:12:23 EST


Am 06.12.2010 18:01, Avi Kivity wrote:
> On 12/06/2010 06:46 PM, Jan Kiszka wrote:
>> Am 06.12.2010 17:40, Avi Kivity wrote:
>>> On 12/06/2010 06:34 PM, Jan Kiszka wrote:
>>>>>
>>>>> What's the protocol for doing this? I suppose userspace has to disable
>>>>> interrupts, ioctl(SET_INTX_MASK, masked), ..., ioctl(SET_INTX_MASK,
>>>>> unmasked), enable interrupts?
>>>>
>>>> Userspace just has to synchronize against itself - what it already does:
>>>> qemu_mutex, and masking/unmasking is synchronous /wrt the the executing
>>>> VCPU. Otherwise, masking/unmasking is naturally racy, also in Real Life.
>>>> The guest resolves the remaining races.
>>>
>>> I meant when qemu sets INTX_MASK and the kernel clears it immediately
>>> afterwards because the two are not synchronized. I guess that won't
>>> happen in practice because playing with INTX_MASK is very rare.
>>
>> Ah, there is indeed a race, and the qemu-kvm patches I did not post yet
>> (to wait for the kernel interface to settle) actually suffer from it:
>> userspace needs to set the kernel mask before writing the config space
>> (it's the other way around ATM). This avoids that the kernel overwrites
>> what userspace just wrote out. We always suffer from the race the other
>> way around, see below.
>
> Please document the protocol.

Yes, will do.

> Is this always the right order?
> Shouldn't it be reversed when unmasking? I admit I'm confused about this.

The kernel only notes down userspace's view on the mask, it doesn't
modify the hardware (unless it is in line-disabling mode, but then there
is no conflict anyway). Therefore, if userspace first unmasks and an
interrupts arrives before this was reported to the kernel, the device
interrupt will remain masked and no event is delivered to userspace.

Jan

--
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/