From: Jan Beulich <jbeulich@suse.com>
To: Luca Fancellu <Luca.Fancellu@arm.com>
Cc: "Stefano Stabellini" <sstabellini@kernel.org>,
"Julien Grall" <julien@xen.org>,
"Bertrand Marquis" <Bertrand.Marquis@arm.com>,
"Michal Orzel" <michal.orzel@amd.com>,
"Volodymyr Babchuk" <Volodymyr_Babchuk@epam.com>,
"Roger Pau Monné" <roger.pau@citrix.com>,
"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Subject: Re: [PATCH v2 1/2] xen/passthrough: Provide stub functions when !HAS_PASSTHROUGH
Date: Mon, 17 Feb 2025 17:27:01 +0100 [thread overview]
Message-ID: <6bf1d945-e9c1-4e90-aced-cb52ab8e93e3@suse.com> (raw)
In-Reply-To: <6B58EB7A-1A39-40FC-94CF-C871AA3AE06C@arm.com>
On 17.02.2025 17:14, Luca Fancellu wrote:
>>
>>>>> --- a/xen/include/xen/iommu.h
>>>>> +++ b/xen/include/xen/iommu.h
>>>>> @@ -110,6 +110,8 @@ extern int8_t iommu_hwdom_reserved;
>>>>>
>>>>> extern unsigned int iommu_dev_iotlb_timeout;
>>>>>
>>>>> +#ifdef CONFIG_HAS_PASSTHROUGH
>>>>> +
>>>>> int iommu_setup(void);
>>>>> int iommu_hardware_setup(void);
>>>>>
>>>>> @@ -122,6 +124,24 @@ int arch_iommu_domain_init(struct domain *d);
>>>>> void arch_iommu_check_autotranslated_hwdom(struct domain *d);
>>>>> void arch_iommu_hwdom_init(struct domain *d);
>>>>>
>>>>> +#else
>>>>> +
>>>>> +static inline int iommu_setup(void)
>>>>> +{
>>>>> + return -ENODEV;
>>>>> +}
>>>>> +
>>>>> +static inline int iommu_domain_init(struct domain *d, unsigned int opts)
>>>>> +{
>>>>> + return 0;
>>>>
>>>> Shouldn't this fail when is_iommu_enabled(d) is true? (The use of the
>>>> predicate here as well as in the real function is slightly strange, but
>>>> that's the way it is.)
>>>
>>> Right, probably you know better this code than me, I started from the assumption
>>> that when !HAS_PASSTHROUGH, 'iommu_enabled' is false.
>>>
>>> is_iommu_enabled(d) checks if the domain structure ‘options’ field has
>>> XEN_DOMCTL_CDF_iommu, this flag is set on domain creation when ‘iommu_enabled'
>>> is true on arm and x86.
>>>
>>> So when !HAS_PASSTHROUGH can we assume is_iommu_enabled(d) give false?
>>> Or shall we return for example the value of is_iommu_enabled(d)?
>>
>> Since HAS_PASSTHROUGH being selected conditionally a (pretty) new, I
>> fear that assumptions shouldn't be made. It's possible the stub could
>> remain as is, yet even then - if only for documentation purposes - I'd
>> suggest to have some ASSERT() there. In the end it all depends on how
>> XEN_DOMCTL_CDF_iommu is handled when !HAS_PASSTHROUGH.
>
> I’ve tried to add an ASSERT(!is_iommu_enabled(d)); but it’s not building, I’m starting to think there
> is some reason why I can’t do that but I didn’t figure out why, I’ve added the inclusion for xen/sched.h,
> but it still says implicit declaration of function ‘is_iommu_enabled’…
Well, xen/sched.h includes xen/iommu.h. Hence when you make the latter
include xen/sched.h, that'll have a meaningful effect on use sites
of xen/iommu.h; wherever xen/sched.h is used the nested #include will
do nothing due to the include guard.
> But I could assert for !iommu_enabled: I checked into common/domain.c, sanitise_domain_config,
> if a domain is called with XEN_DOMCTL_CDF_iommu set, the function would fail if !iommu_enabled,
> so I would say that the stub returns the expected value (0) since for sure iommu_enabled is false and
> there cannot be a domain with that flag set that has the iommu_enabled=true under !HAS_PASSTHROUGH.
>
> But would it be ok to add this assert (ASSERT(!iommu_enabled);) even if we know that iommu_enabled
> is false, since !HAS_PASSTHROUGH ?
Such an assertion then isn't very useful, imo. Since, as you say,
sanitise_domain_config() properly covers the !HAS_PASSTHROUGH case even
for cases like the MPU one, I think the code is fine then. A brief
comment might be nice ...
Jan
next prev parent reply other threads:[~2025-02-17 16:27 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-17 10:27 [PATCH v2 0/2] Prerequisite patches for Arm64 MPU build Luca Fancellu
2025-02-17 10:27 ` [PATCH v2 1/2] xen/passthrough: Provide stub functions when !HAS_PASSTHROUGH Luca Fancellu
2025-02-17 10:50 ` Jan Beulich
2025-02-17 11:55 ` Luca Fancellu
2025-02-17 11:58 ` Luca Fancellu
2025-02-17 12:10 ` Jan Beulich
2025-02-17 16:14 ` Luca Fancellu
2025-02-17 16:27 ` Jan Beulich [this message]
2025-02-17 10:27 ` [PATCH v2 2/2] xen/arm: Restrict Kconfig configuration for LLC coloring Luca Fancellu
2025-02-17 12:55 ` Orzel, Michal
2025-02-17 13:15 ` Luca Fancellu
2025-02-17 13:21 ` Orzel, Michal
2025-02-17 14:19 ` Luca Fancellu
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=6bf1d945-e9c1-4e90-aced-cb52ab8e93e3@suse.com \
--to=jbeulich@suse.com \
--cc=Bertrand.Marquis@arm.com \
--cc=Luca.Fancellu@arm.com \
--cc=Volodymyr_Babchuk@epam.com \
--cc=julien@xen.org \
--cc=michal.orzel@amd.com \
--cc=roger.pau@citrix.com \
--cc=sstabellini@kernel.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.