[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2 8/8] vpci/msix: Add function to clean MSIX resources


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: "Chen, Jiqian" <Jiqian.Chen@xxxxxxx>
  • Date: Thu, 17 Apr 2025 07:38:27 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=dJ+74WHcwWC8t3dpXGqTz5XsO7XbITod2Hr1Nz9kifI=; b=pYt5St4r0NefohrY6f1RIkHO2t08dBT8cLi1neu0uO0Dce0TapDdiRTNVFyzmtoxEoZlObQfKcRF4/kaqWT6gdmpGT2gKhqr3zjk3awkaP4X5ay9SNhIxAqYX4RTLxKK3Gpi5JM0Lu8YZqZutgk+u790ivnlwwdFDFO5XQoFFJ5pXiJnBixVmyPe+N6+SZK9SrMOMXd7F8QcNkXXkE91RNcOVriKrvTUH1xoNNI5nRJKiEwnRhuVLm6GzX7cYEe0+RZH6x6y3AxAH5vbpn7v9kDv2jOL0NgLQ+6vx9L4GPZBT8O5oDa3815WIBsuj9kFfMl1I026PU3H4N6kyFYw8A==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=F97JF2PE9W34CL8HsQUelMLc6avjoig+THbrg/pHL8roxChxOmdd+GUftTZmFoOkKh/gABQbnhAsxjaiRU9Vn+6txoTfyd1na6xgPstLOnCxUmwLPsqXWrI7je5lTCQbQNjqTQDG08mJzcgwf+P93zGnqtoEHcEC7N82m8tlNf6LS+rCt2fwbM3YalwcF0wReqXLqYs8MCC+XfB6I+jorWD9CQo7KUe9r+vhFdOMmuvo407MVmXcLB72F4LF9sRlSt5cMQDcflmyO0QWOap4GqVhw+Q80DftBK0khEHizMWI+FgmcsCupFTWGxzvpiFWbxMFNzhl5qS3X3WGDprFrw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com;
  • Cc: "Huang, Ray" <Ray.Huang@xxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, "Chen, Jiqian" <Jiqian.Chen@xxxxxxx>
  • Delivery-date: Thu, 17 Apr 2025 07:38:38 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHbqRsh+jmpxStIakeU85xhe5CvZrOng/cAgACHCoA=
  • Thread-topic: [PATCH v2 8/8] vpci/msix: Add function to clean MSIX resources

On 2025/4/17 15:34, Jan Beulich wrote:
> On 09.04.2025 08:45, Jiqian Chen wrote:
>> --- a/xen/arch/x86/hvm/intercept.c
>> +++ b/xen/arch/x86/hvm/intercept.c
>> @@ -276,6 +276,50 @@ void register_mmio_handler(struct domain *d,
>>      handler->mmio.ops = ops;
>>  }
>>  
>> +void unregister_mmio_handler(struct domain *d,
>> +                             const struct hvm_mmio_ops *ops)
>> +{
>> +    unsigned int i, count = d->arch.hvm.io_handler_count;
>> +
>> +    ASSERT(d->arch.hvm.io_handler);
>> +
>> +    if ( !count )
>> +        return;
>> +
>> +    for ( i = 0; i < count; i++ )
>> +        if ( d->arch.hvm.io_handler[i].type == IOREQ_TYPE_COPY &&
>> +             d->arch.hvm.io_handler[i].mmio.ops == ops )
>> +            break;
>> +
>> +    if ( i == count )
>> +        return;
>> +
>> +    for ( ; i < count - 1; i++ )
>> +    {
>> +        struct hvm_io_handler *curr = &d->arch.hvm.io_handler[i];
>> +        struct hvm_io_handler *next = &d->arch.hvm.io_handler[i + 1];
>> +
>> +        curr->type = next->type;
>> +        curr->ops = next->ops;
>> +        if ( next->type == IOREQ_TYPE_COPY )
>> +        {
>> +            curr->portio.port = 0;
>> +            curr->portio.size = 0;
>> +            curr->portio.action = 0;
>> +            curr->mmio.ops = next->mmio.ops;
>> +        }
>> +        else
>> +        {
>> +            curr->mmio.ops = 0;
>> +            curr->portio.port = next->portio.port;
>> +            curr->portio.size = next->portio.size;
>> +            curr->portio.action = next->portio.action;
>> +        }
>> +    }
>> +
>> +    d->arch.hvm.io_handler_count--;
>> +}
> 
> To add on what Roger said: This is inherently non-atomic, so the domain
> would need pausing to do such removal in a race-free way. Hence why we
> deliberately didn't have such a function so far, aiui. (The removal may
> be safe in the specific case you use it helow, but there's nothing here
> preventing it from being used elsewhere, without paying attention to
> the raciness.)
Make sense, thanks for your detailed inputs.
I will delete this part in next version.

> 
> Jan

-- 
Best regards,
Jiqian Chen.

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.