lkml.org 
[lkml]   [2024]   [Feb]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH 07/17] vfio/pci: Preserve per-interrupt contexts
From
Hi Alex,

On 2/6/2024 2:03 PM, Alex Williamson wrote:
> On Tue, 6 Feb 2024 13:45:22 -0800
> Reinette Chatre <reinette.chatre@intel.com> wrote:
>> On 2/5/2024 2:35 PM, Alex Williamson wrote:
>>> On Thu, 1 Feb 2024 20:57:01 -0800
>>> Reinette Chatre <reinette.chatre@intel.com> wrote:
>>
>> ..
>>
>>>> diff --git a/drivers/vfio/pci/vfio_pci_intrs.c b/drivers/vfio/pci/vfio_pci_intrs.c
>>>> index 31f73c70fcd2..7ca2b983b66e 100644
>>>> --- a/drivers/vfio/pci/vfio_pci_intrs.c
>>>> +++ b/drivers/vfio/pci/vfio_pci_intrs.c
>>>> @@ -427,7 +427,7 @@ static int vfio_msi_set_vector_signal(struct vfio_pci_core_device *vdev,
>>>>
>>>> ctx = vfio_irq_ctx_get(vdev, vector);
>>>>
>>>> - if (ctx) {
>>>> + if (ctx && ctx->trigger) {
>>>> irq_bypass_unregister_producer(&ctx->producer);
>>>> irq = pci_irq_vector(pdev, vector);
>>>> cmd = vfio_pci_memory_lock_and_enable(vdev);
>>>> @@ -435,8 +435,9 @@ static int vfio_msi_set_vector_signal(struct vfio_pci_core_device *vdev,
>>>> vfio_pci_memory_unlock_and_restore(vdev, cmd);
>>>> /* Interrupt stays allocated, will be freed at MSI-X disable. */
>>>> kfree(ctx->name);
>>>> + ctx->name = NULL;
>>>
>>> Setting ctx->name = NULL is not strictly necessary and does not match
>>> the INTx code that we're claiming to try to emulate. ctx->name is only
>>> tested immediately after allocation below, otherwise it can be inferred
>>> from ctx->trigger. Thanks,
>>
>> This all matches my understanding. I added ctx->name = NULL after every kfree(ctx->name)
>> (see below for confirmation of other instance). You are correct that the flow
>> infers validity of ctx->name from ctx->trigger. My motivation for
>> adding ctx->name = NULL is that, since the interrupt context persists, this
>> change ensures that there will be no pointer that points to freed memory. I
>> am not comfortable leaving pointers to freed memory around.
>
> Fair enough. Maybe note the change in the commit log. Thanks,
>

Will do. Thank you.

Reinette


\
 
 \ /
  Last update: 2024-05-27 14:51    [W:0.157 / U:0.352 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site