From: Julien Grall <julien@xen.org>
To: Jan Beulich <jbeulich@suse.com>, Connor Davis <connojdavis@gmail.com>
Cc: Bobby Eshleman <bobbyeshleman@gmail.com>,
Alistair Francis <alistair23@gmail.com>,
Andrew Cooper <andrew.cooper3@citrix.com>,
George Dunlap <george.dunlap@citrix.com>,
Ian Jackson <iwj@xenproject.org>,
Stefano Stabellini <sstabellini@kernel.org>, Wei Liu <wl@xen.org>,
Paul Durrant <paul@xen.org>,
xen-devel@lists.xenproject.org
Subject: Re: [PATCH v3 2/5] xen/common: Guard iommu symbols with CONFIG_HAS_PASSTHROUGH
Date: Tue, 18 May 2021 16:17:03 +0100 [thread overview]
Message-ID: <d486c0f9-b615-0706-e1f2-3fd15bd7ec6a@xen.org> (raw)
In-Reply-To: <922c6304-9299-a697-2405-1b7f6d069842@suse.com>
Hi Jan,
On 18/05/2021 16:13, Jan Beulich wrote:
> On 18.05.2021 16:06, Julien Grall wrote:
>>
>>
>> On 18/05/2021 07:27, Jan Beulich wrote:
>>> On 18.05.2021 06:11, Connor Davis wrote:
>>>>
>>>> On 5/17/21 9:42 AM, Julien Grall wrote:
>>>>> Hi Jan,
>>>>>
>>>>> On 17/05/2021 12:16, Jan Beulich wrote:
>>>>>> On 14.05.2021 20:53, Connor Davis wrote:
>>>>>>> --- a/xen/common/memory.c
>>>>>>> +++ b/xen/common/memory.c
>>>>>>> @@ -294,7 +294,9 @@ int guest_remove_page(struct domain *d, unsigned
>>>>>>> long gmfn)
>>>>>>> p2m_type_t p2mt;
>>>>>>> #endif
>>>>>>> mfn_t mfn;
>>>>>>> +#ifdef CONFIG_HAS_PASSTHROUGH
>>>>>>> bool *dont_flush_p, dont_flush;
>>>>>>> +#endif
>>>>>>> int rc;
>>>>>>> #ifdef CONFIG_X86
>>>>>>> @@ -385,13 +387,17 @@ int guest_remove_page(struct domain *d,
>>>>>>> unsigned long gmfn)
>>>>>>> * Since we're likely to free the page below, we need to suspend
>>>>>>> * xenmem_add_to_physmap()'s suppressing of IOMMU TLB flushes.
>>>>>>> */
>>>>>>> +#ifdef CONFIG_HAS_PASSTHROUGH
>>>>>>> dont_flush_p = &this_cpu(iommu_dont_flush_iotlb);
>>>>>>> dont_flush = *dont_flush_p;
>>>>>>> *dont_flush_p = false;
>>>>>>> +#endif
>>>>>>> rc = guest_physmap_remove_page(d, _gfn(gmfn), mfn, 0);
>>>>>>> +#ifdef CONFIG_HAS_PASSTHROUGH
>>>>>>> *dont_flush_p = dont_flush;
>>>>>>> +#endif
>>>>>>> /*
>>>>>>> * With the lack of an IOMMU on some platforms, domains with
>>>>>>> DMA-capable
>>>>>>> @@ -839,11 +845,13 @@ int xenmem_add_to_physmap(struct domain *d,
>>>>>>> struct xen_add_to_physmap *xatp,
>>>>>>> xatp->gpfn += start;
>>>>>>> xatp->size -= start;
>>>>>>> +#ifdef CONFIG_HAS_PASSTHROUGH
>>>>>>> if ( is_iommu_enabled(d) )
>>>>>>> {
>>>>>>> this_cpu(iommu_dont_flush_iotlb) = 1;
>>>>>>> extra.ppage = &pages[0];
>>>>>>> }
>>>>>>> +#endif
>>>>>>> while ( xatp->size > done )
>>>>>>> {
>>>>>>> @@ -868,6 +876,7 @@ int xenmem_add_to_physmap(struct domain *d,
>>>>>>> struct xen_add_to_physmap *xatp,
>>>>>>> }
>>>>>>> }
>>>>>>> +#ifdef CONFIG_HAS_PASSTHROUGH
>>>>>>> if ( is_iommu_enabled(d) )
>>>>>>> {
>>>>>>> int ret;
>>>>>>> @@ -894,6 +903,7 @@ int xenmem_add_to_physmap(struct domain *d,
>>>>>>> struct xen_add_to_physmap *xatp,
>>>>>>> if ( unlikely(ret) && rc >= 0 )
>>>>>>> rc = ret;
>>>>>>> }
>>>>>>> +#endif
>>>>>>> return rc;
>>>>>>> }
>>>>>>
>>>>>> I wonder whether all of these wouldn't better become CONFIG_X86:
>>>>>> ISTR Julien indicating that he doesn't see the override getting used
>>>>>> on Arm. (Julien, please correct me if I'm misremembering.)
>>>>>
>>>>> Right, so far, I haven't been in favor to introduce it because:
>>>>> 1) The P2M code may free some memory. So you can't always ignore
>>>>> the flush (I think this is wrong for the upper layer to know when this
>>>>> can happen).
>>>>> 2) It is unclear what happen if the IOMMU TLBs and the PT contains
>>>>> different mappings (I received conflicted advice).
>>>>>
>>>>> So it is better to always flush and as early as possible.
>>>>
>>>> So keep it as is or switch to CONFIG_X86?
>>>
>>> Please switch, unless anyone else voices a strong opinion towards
>>> keeping as is.
>>
>> I would like to avoid adding more #ifdef CONFIG_X86 in the common code.
>> Can we instead provide a wrapper for them?
>
> Doable, sure, but I don't know whether Connor is up to going this
> more extensive route.
That's a fair point. If that the case, then I prefer the #ifdef
CONFIG_HAS_PASSTHROUGH version.
I can add an item in my todo list to introduce some helpers.
Cheers,
--
Julien Grall
next prev parent reply other threads:[~2021-05-18 15:17 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-14 18:53 [PATCH v3 0/5] Minimal build for RISCV Connor Davis
2021-05-14 18:53 ` [PATCH v3 1/5] xen/char: Default HAS_NS16550 to y only for X86 and ARM Connor Davis
2021-05-16 22:48 ` Alistair Francis
2021-05-17 11:56 ` Jan Beulich
2021-05-17 23:43 ` Connor Davis
2021-05-14 18:53 ` [PATCH v3 2/5] xen/common: Guard iommu symbols with CONFIG_HAS_PASSTHROUGH Connor Davis
2021-05-17 11:16 ` Jan Beulich
2021-05-17 13:52 ` Connor Davis
2021-05-17 15:42 ` Julien Grall
2021-05-18 4:11 ` Connor Davis
2021-05-18 6:27 ` Jan Beulich
2021-05-18 14:06 ` Julien Grall
2021-05-18 15:13 ` Jan Beulich
2021-05-18 15:17 ` Julien Grall [this message]
2021-05-14 18:53 ` [PATCH v3 3/5] xen: Fix build when !CONFIG_GRANT_TABLE Connor Davis
2021-05-17 11:22 ` Jan Beulich
2021-05-17 23:46 ` Connor Davis
2021-05-18 3:58 ` Connor Davis
2021-05-18 6:31 ` Jan Beulich
2021-05-14 18:53 ` [PATCH v3 4/5] xen: Add files needed for minimal riscv build Connor Davis
2021-05-14 21:53 ` Bob Eshleman
2021-05-14 23:47 ` Connor Davis
2021-05-18 1:43 ` Bob Eshleman
2021-05-18 4:05 ` Connor Davis
2021-05-17 11:51 ` Jan Beulich
2021-05-18 4:58 ` Connor Davis
2021-05-18 6:33 ` Jan Beulich
2021-05-14 18:53 ` [PATCH v3 5/5] automation: Add container for riscv64 builds Connor Davis
2021-05-14 21:01 ` Bob Eshleman
2021-05-14 23:54 ` Connor Davis
2021-05-17 23:20 ` [PATCH v3 0/5] Minimal build for RISCV Roman Shaposhnik
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=d486c0f9-b615-0706-e1f2-3fd15bd7ec6a@xen.org \
--to=julien@xen.org \
--cc=alistair23@gmail.com \
--cc=andrew.cooper3@citrix.com \
--cc=bobbyeshleman@gmail.com \
--cc=connojdavis@gmail.com \
--cc=george.dunlap@citrix.com \
--cc=iwj@xenproject.org \
--cc=jbeulich@suse.com \
--cc=paul@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).