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

Re: [RFC XEN PATCH v5 5/5] domctl: Add XEN_DOMCTL_gsi_permission to grant gsi


  • To: Anthony PERARD <anthony.perard@xxxxxxxxx>
  • From: "Chen, Jiqian" <Jiqian.Chen@xxxxxxx>
  • Date: Mon, 26 Feb 2024 07:27:17 +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=arcselector9901; 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=xu0pfrPxmlGqZrRP6Gxt1NJJQ0n8AY6GEFqapd9lgrI=; b=SO0pTEle0s+8H9AbeeM/cvjdT+AC+3bS4iUCfoIZ7CsW4hX3MBFMoselNrvUxJBsblVSvvc7YJGJYJXn0Jx2l6MUKeui2IXg1Tmw+dZ1D064laKoYkG3luuaD90ReGMBKRTSWCJ6tE2izbOf4UuIyTwBRre4Fg5WltElvnz3LK94H3H81wy++EdWa8MSSfinH+RMbUJ2pDmBduMcBdenEfrA3aIUx6hMEvM/Bdywovv/zQm7uOAjTmIw21J56iZOij+8nLpgcr1nkvd/fa80RIUDtovO9EtuaRjSzq/Z0aHQ9wCRQCUr8PYdvZcwikAYnAVfMR91JHgQtLs6qfQJ6g==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LRCl4H2JMgM3UwNg41p55Hqnss5614X0HizPQQT8b5bb1eYsOfG2AbeZLpOS9zmF/Q2oYYsX+jY6gmNrNhaKQBNSg1CItLm0swSNGqqyp1X2Ai9KEUHKMX1NmbSQQL0F2ZFjG4EgLbuIsM2DDsl+cEyRRAhlzqSgoQ7MWud47SYZsG/fkc9f8hf47lyQIFFVmi0Llo0bWI1JxyK86QufbqYt28B5ziL+UXw+ZaAlkRBNZHOUrQv1fGNQcnMEx/cb/zTdV82x7GrQ7ofFDyonwRAcohr+C4hIaUJrxFy03Px6B97A34+vBz1Cdp9lhs9Cn88bqM0Z/3e+R7fG9xLbsQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com;
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>, "Daniel P . Smith" <dpsmith@xxxxxxxxxxxxxxxxxxxx>, "Hildebrand, Stewart" <Stewart.Hildebrand@xxxxxxx>, "Huang, Ray" <Ray.Huang@xxxxxxx>, "Chen, Jiqian" <Jiqian.Chen@xxxxxxx>
  • Delivery-date: Mon, 26 Feb 2024 07:27:25 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHaRR65Xby346gk7ESzHNZtxrKssbEVI+YAgAGO+4CAAaWUAIAEltsA
  • Thread-topic: [RFC XEN PATCH v5 5/5] domctl: Add XEN_DOMCTL_gsi_permission to grant gsi

On 2024/2/23 23:59, Anthony PERARD wrote:
> On Thu, Feb 22, 2024 at 07:22:45AM +0000, Chen, Jiqian wrote:
>> On 2024/2/21 23:03, Anthony PERARD wrote:
>>> On Fri, Jan 12, 2024 at 02:13:17PM +0800, Jiqian Chen wrote:
>>>> diff --git a/tools/libs/light/libxl_pci.c b/tools/libs/light/libxl_pci.c
>>>> index a1c6e82631e9..4136a860a048 100644
>>>> --- a/tools/libs/light/libxl_pci.c
>>>> +++ b/tools/libs/light/libxl_pci.c
>>>> @@ -1421,6 +1421,8 @@ static void pci_add_dm_done(libxl__egc *egc,
>>>>      uint32_t flag = XEN_DOMCTL_DEV_RDM_RELAXED;
>>>>      uint32_t domainid = domid;
>>>>      bool isstubdom = libxl_is_stubdom(ctx, domid, &domainid);
>>>> +    int gsi;
>>>> +    bool has_gsi = true;
>>>
>>> Why is this function has "gsi" variable, and "gsi = irq" but the next
>>> function pci_remove_detached() does only have "irq" variable?
>> Because in pci_add_dm_done, it calls " r = xc_physdev_map_pirq(ctx->xch, 
>> domid, irq, &irq); ", it passes the pointer of irq in, and then irq will be 
>> changed, so I need to use gsi to save the origin value.
> 
> I'm sorry but unconditional "gsi = irq" looks very wrong, that line
Make sense, I should add a condition and some comments here. Maybe:
        /* if has gsi sysfs node, then fscanf() read from the gsi sysfs and 
store it in irq variable, we need to save the original gsi value, because irq 
will be changed in xc_physdev_map_pirq */
        if (has_gsi)
                gsi = irq;

> needs to be removed or changed, otherwise we have two functions doing the
> same thing just after that (xc_domain_irq_permission and
> xc_domain_gsi_permission). Instead, my guess is that the
> arguments of xc_physdev_map_pirq() needs to be changes. What does
> contain `irq` after the map_pirq() call? A "pirq" of some kind? Maybe
Yes, pirq.

> xc_physdev_map_pirq(ctx->xch, domid, irq, &pirq) would make things more
> clear about what's going on.
> 
> 
> And BTW, maybe renaming the variable "has_gsi" to "is_gsi" might make
> things a bit clearer as well, as in: "the variable 'irq' $is_gsi",
> instead of a variable that have a meaning of "the system $has_gsi"
> without necessarily meaning that the code is using it.
Gsi is a new sysfs node added by my kernel patch, and it is still in discussion 
with PCI Maintainer.
And for compatible with old version of kernel that didn't has gsi sysfs node, 
we still need to use irq here.
So, I named this variable to has_gsi. Is it clearer that changing it to 
has_gsi_sysfs_node?
Maybe I need to add some comments in code to make the usage of gsi clear.

> 
> Maybe using (abusing?) the variable name "irq" might be a bit wrong now?
> What does "GSI" stand for anyway? And about "PIRQ"? This is just some
GSI is x86 specific concept, it is related to IOAPIC-PIN. PIRQ is used to route 
interrupts in Xen.

> question to figure out if there's potentially a better name for the
> variables names.
> 
> Thanks,
> 

-- 
Best regards,
Jiqian Chen.

 


Rackspace

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