From: "Roger Pau Monné" <roger.pau@citrix.com>
To: "Chen, Jiqian" <Jiqian.Chen@amd.com>
Cc: Jan Beulich <jbeulich@suse.com>,
"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>,
Andrew Cooper <andrew.cooper3@citrix.com>, Wei Liu <wl@xen.org>,
George Dunlap <george.dunlap@citrix.com>,
Julien Grall <julien@xen.org>,
Anthony PERARD <anthony.perard@citrix.com>,
Juergen Gross <jgross@suse.com>,
"Hildebrand, Stewart" <Stewart.Hildebrand@amd.com>,
"Huang, Ray" <Ray.Huang@amd.com>,
Stefano Stabellini <sstabellini@kernel.org>
Subject: Re: [RFC XEN PATCH v4 4/5] domctl: Use gsi to grant/revoke irq permission
Date: Tue, 9 Jan 2024 11:40:36 +0100 [thread overview]
Message-ID: <ZZ0ipBYirbJnLreJ@macbook> (raw)
In-Reply-To: <BL1PR12MB58490E62825A5B1ACCE605EAE76A2@BL1PR12MB5849.namprd12.prod.outlook.com>
On Tue, Jan 09, 2024 at 10:16:26AM +0000, Chen, Jiqian wrote:
> On 2024/1/9 17:38, Jan Beulich wrote:
> > On 09.01.2024 09:18, Chen, Jiqian wrote:
> >> On 2024/1/8 23:05, Roger Pau Monné wrote:
> >>> On Mon, Jan 08, 2024 at 09:55:26AM +0100, Jan Beulich wrote:
> >>>> On 06.01.2024 02:08, Stefano Stabellini wrote:
> >>>>> On Fri, 5 Jan 2024, Jiqian Chen wrote:
> >>>>>> --- a/tools/libs/light/libxl_pci.c
> >>>>>> +++ b/tools/libs/light/libxl_pci.c
> >>>>>> @@ -1418,6 +1418,7 @@ static void pci_add_dm_done(libxl__egc *egc,
> >>>>>> unsigned long long start, end, flags, size;
> >>>>>> int irq, i;
> >>>>>> int r;
> >>>>>> + int gsi;
> >>>>>> uint32_t flag = XEN_DOMCTL_DEV_RDM_RELAXED;
> >>>>>> uint32_t domainid = domid;
> >>>>>> bool isstubdom = libxl_is_stubdom(ctx, domid, &domainid);
> >>>>>> @@ -1486,6 +1487,7 @@ static void pci_add_dm_done(libxl__egc *egc,
> >>>>>> goto out_no_irq;
> >>>>>> }
> >>>>>> if ((fscanf(f, "%u", &irq) == 1) && irq) {
> >>>>>> + gsi = irq;
> >>>>>
> >>>>> A question for Roger and Jan: are we always guaranteed that gsi == irq
> >>>>> (also in the PV case)?
> >>>>
> >>>> Iirc for IO-APIC based IRQs that's always the case;
> >>>
> >>> I think that's always the case on Linux, because it calls
> >>> PHYSDEVOP_map_pirq with index == pirq (see Linux
> >>> pci_xen_initial_domain()). But other OSes could possibly make the
> >>> call with pirq == -1 and get a randomly allocated pirq for GSIs.
> >> I don't think it's important whether pirq is randomly generated. What's important is whether irq always equals gsi in xen.
My 'randomly generated' comment was in that direction, not so much as
the pirq being truly random, but no longer matching the gsi.
> >> If so, we can directly pass in and grant gsi. However, according to Jan's previous email reply, in the case of Msi, irq may not be equal to gsi, so my patch cannot meet this situation.
> >> I am confusing if the current domain doesn't have PIRQ flag, then regarding to XEN_DOMCTL_irq_permission, which kind of irq we should grant to caller domain? The gsi or other irq?
> >> Or can we add a check in XEN_DOMCTL_irq_permission, if the current domain has PRIQ, we can get irq from pirq(like the original implementation), if not we can assign gsi to irq, and then grant irq. Of course, that needs to require the caller to pass in both the pirq and gsi.
> >
> > I expect MSI will need handling differently from GSIs. When MSI is
> > set up for a device (and hence for a domain in possession of that
> > device), access ought to be granted right away.
> >
> >>> IOW: I don't think the pirq field in xen_domctl_irq_permission can be
> >>> altered like proposed here to switch from passing a pirq to a GSI. A
> >>> new hypercall should be introduced that either is GSI specific, or
> >>> contains a type field in order to specify the namespace the field
> >>> targets.
> >> A new hypercall using for granting gsi? If so, how does the caller know to call which hypercall to grant permission, XEN_DOMCTL_irq_permission or that new hypercall?
> >
> > Either we add a feature indicator, or the caller simply tries the
> > new GSI interface first.
> I am still not sure how to use and implement it.
> Taking pci_add_dm_done as an example, for now its implementation is:
> pci_add_dm_done
> xc_physdev_map_pirq
> xc_domain_irq_permission(,,pirq,)
> XEN_DOMCTL_irq_permission
>
> And assume the new hypercall is XEN_DOMCTL_gsi_permission, do you mean:
> pci_add_dm_done
> xc_physdev_map_pirq
> ret = xc_domain_gsi_permission(,,gsi,)
> XEN_DOMCTL_gsi_permission
Making this first call would also depend on whether the 'gsi' can be
fetched from sysfs, otherwise the call should be avoided.
> if ( ret != 0 )
> xc_domain_irq_permission(,,pirq,)
> XEN_DOMCTL_irq_permission
You can only fallback when you have the pirq (ie: when in a PV dom0),
on a PVH dom0 there's no pirq, so no fallback.
The code in pci_add_dm_done() must be aware of this, and only fallback
when in PV dom0.
> But if so, I have a question that in XEN_DOMCTL_gsi_permission, when to fail and when to success?
>
> Or do you mean:
> pci_add_dm_done
> xc_physdev_map_pirq
> ret = xc_domain_irq_permission(,,pirq,)
> XEN_DOMCTL_irq_permission
> if ( ret != 0 )
> xc_domain_gsi_permission(,,gsi,)
> XEN_DOMCTL_gsi_permission
> And in XEN_DOMCTL_gsi_permission, as long as the current domain has the access of gsi, then granting gsi to caller should be successful. Right?
No, I think that would be backwards, the logic above looks correct
regarding the ordering of the hypercalls.
Thanks, Roger.
next prev parent reply other threads:[~2024-01-09 10:40 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-05 7:09 [RFC XEN PATCH v4 0/5] Support device passthrough when dom0 is PVH on Xen Jiqian Chen
2024-01-05 7:09 ` [RFC XEN PATCH v4 1/5] xen/vpci: Clear all vpci status of device Jiqian Chen
2024-01-09 15:24 ` Stewart Hildebrand
2024-01-10 6:24 ` Chen, Jiqian
2024-01-10 14:09 ` Stewart Hildebrand
2024-01-11 2:36 ` Chen, Jiqian
2024-01-05 7:09 ` [RFC XEN PATCH v4 2/5] x86/pvh: Allow (un)map_pirq when caller isn't DOMID_SELF Jiqian Chen
2024-01-06 0:46 ` Stefano Stabellini
2024-01-08 8:47 ` Jan Beulich
2024-01-08 9:15 ` Chen, Jiqian
2024-01-08 9:25 ` Jan Beulich
2024-01-09 7:58 ` Chen, Jiqian
2024-01-05 7:09 ` [RFC XEN PATCH v4 3/5] x86/pvh: Add PHYSDEVOP_setup_gsi for PVH dom0 Jiqian Chen
2024-01-06 0:54 ` Stefano Stabellini
2024-01-08 8:50 ` Jan Beulich
2024-01-09 8:01 ` Chen, Jiqian
2024-01-05 7:09 ` [RFC XEN PATCH v4 4/5] domctl: Use gsi to grant/revoke irq permission Jiqian Chen
2024-01-06 1:08 ` Stefano Stabellini
2024-01-06 1:12 ` Stefano Stabellini
2024-01-08 3:43 ` Chen, Jiqian
2024-01-08 8:55 ` Jan Beulich
2024-01-08 15:05 ` Roger Pau Monné
2024-01-09 8:18 ` Chen, Jiqian
2024-01-09 9:38 ` Jan Beulich
2024-01-09 10:16 ` Chen, Jiqian
2024-01-09 10:40 ` Roger Pau Monné [this message]
2024-01-09 10:46 ` Jan Beulich
2024-01-10 8:49 ` Chen, Jiqian
2024-01-10 20:09 ` Stewart Hildebrand
2024-01-11 2:39 ` Chen, Jiqian
2024-01-05 7:09 ` [RFC XEN PATCH v4 5/5] libxl: Use gsi instead of irq for mapping pirq Jiqian Chen
2024-01-05 7:36 ` Jan Beulich
2024-01-05 7:59 ` Chen, Jiqian
2024-01-06 1:11 ` Stefano Stabellini
2024-01-08 6:02 ` Chen, Jiqian
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZZ0ipBYirbJnLreJ@macbook \
--to=roger.pau@citrix.com \
--cc=Jiqian.Chen@amd.com \
--cc=Ray.Huang@amd.com \
--cc=Stewart.Hildebrand@amd.com \
--cc=andrew.cooper3@citrix.com \
--cc=anthony.perard@citrix.com \
--cc=george.dunlap@citrix.com \
--cc=jbeulich@suse.com \
--cc=jgross@suse.com \
--cc=julien@xen.org \
--cc=sstabellini@kernel.org \
--cc=wl@xen.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.