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

Re: [PATCH v4 09/10] vpci/msi: Free MSI resources when init_msi() fails


  • To: Roger Pau Monné <roger.pau@xxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>
  • From: "Chen, Jiqian" <Jiqian.Chen@xxxxxxx>
  • Date: Wed, 21 May 2025 07:00:37 +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=KR6TXHco41bm2waWPB9DKT3Iq4ZAIK+Gekujl7B24A4=; b=J4zsAqe9mg8iZzSkDMeAz3g+ogwuV/YnVe1wvUxCluFH8hy/SyG6+ofPxLzja5z8Cx1txbEHWyz54JBp7XPZjBNGo0r8ZdUscyEU812iaWTzl2YU/efSQCbf88apSCQWMnH24itS75hVdype4o3BhY81OG1s+Yo9MT6LziXev/F/btEFofNIamVx1vdV8pvTV200nW1RGY1/+607szDkhBfOxTjvwkDh15mTR7TK/OusPc064jArXMFmOLGd/NWQCg7xhlNJ6V+AM45gQ07UGyhh5QJONc4Jm6gIqsUa9AZIokgYejURUj6TOKErsKq7fZYnJVkXbtJ2kYpkWVMTjA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=bYfYMuENC0S4qeyVIijcDq99KQWOEMMZmbby+mMFFWzvoV5n1Hb2NLkDvUVZCpE6O9qLc8CTsuN0/3bybnDiJfuum2QwO+NHatJoVc+KizKTEX5gHiA0/CUYrNhfLX+f5j9vi5B7WoHs4a+QPhyPw/zrJPQ550sOUmu4qiAGBrRpc4SMjKOvDNBvghvxOMcsplNvp/eoMnx8fVvIJKtnpxEoBXEie0cqX0DYejPwm68JhGIVFqxaoCrXESxJmXerQIV4XEIjDOFXKWK22yhYtkgd1ForLqWaq/CBx+5xhRFT78dTXk4b1gzRaNOSAZ0G8p5KehSyV64coABxvr2+IQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com;
  • Cc: "Chen, Jiqian" <Jiqian.Chen@xxxxxxx>, "Huang, Ray" <Ray.Huang@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Wed, 21 May 2025 07:00:54 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHbwMGh3xGCtPOZ6EmRbIkDtAY42rPbIqIAgAApmYCAAAFtgIAACDMAgAHezgA=
  • Thread-topic: [PATCH v4 09/10] vpci/msi: Free MSI resources when init_msi() fails

On 2025/5/20 17:43, Roger Pau Monné wrote:
> On Tue, May 20, 2025 at 11:14:27AM +0200, Jan Beulich wrote:
>> On 20.05.2025 11:09, Roger Pau Monné wrote:
>>> On Tue, May 20, 2025 at 08:40:28AM +0200, Jan Beulich wrote:
>>>> On 09.05.2025 11:05, Jiqian Chen wrote:
>>>>> When init_msi() fails, the previous new changes will hide MSI
>>>>> capability, it can't rely on vpci_deassign_device() to remove
>>>>> all MSI related resources anymore, those resources must be
>>>>> removed in cleanup function of MSI.
>>>>
>>>> That's because vpci_deassign_device() simply isn't called anymore?
>>>> Could do with wording along these lines then. But (also applicable
>>>> to the previous patch) - doesn't this need to come earlier? And is
>>>> it sufficient to simply remove the register intercepts? Don't you
>>>> need to put in place ones dropping all writes and making all reads
>>>> return either 0 or ~0 (covering in particular Dom0, while for DomU-s
>>>> this may already be the case by default behavior)?
>>>
>>> For domUs this is already the default behavior.
>>>
>>> For dom0 I think it should be enough to hide the capability from the
>>> linked list, but not hide all the capability related
>>> registers.  IMO a well behaved dom0 won't try to access capabilities
>>> disconnected from the linked list,
>>
>> Just that I've seen drivers knowing where their device has certain
>> capabilities, thus not bothering to look up the respective
>> capability.
> 
> OK, so let's make the control register read-only in case of failure.
> 
> If MSI(-X) is already enabled we should also make the entries
> read-only, and while that's not very complicated for MSI, it does get
> more convoluted for MSI-X.  I'm fine with just making the control
> register read-only for the time being.
If I understand correctly, I need to avoid control register being removed and 
set the write hook of control register to be vpci_ignored_write and avoid 
freeing vpci->msi?

"
     if ( !msi_pos || !vpci->msi )
         return;

+    spin_lock(&vpci->lock);
+    control = vpci_get_register(vpci, msi_control_reg(msi_pos), 2);
+    if ( control )
+        control->write = vpci_ignored_write;
+    spin_unlock(&vpci->lock);
+
     if ( vpci->msi->masking )
         end = msi_pending_bits_reg(msi_pos, vpci->msi->address64);
     else
         end = msi_mask_bits_reg(msi_pos, vpci->msi->address64) - 2;

-    size = end - msi_control_reg(msi_pos);
+    start = msi_control_reg(msi_pos) + 2;
+    size = end - start;

-    vpci_remove_registers(vpci, msi_control_reg(msi_pos), size);
-    XFREE(vpci->msi);
+    vpci_remove_registers(vpci, start, size);
"

> 
> Thanks, Roger.

-- 
Best regards,
Jiqian Chen.



 


Rackspace

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