Skip to contentSkip to conversation

Prerequisite patches for Arm64 MPU build

PATCH Superseded Luca Fancellu 4 participants 17 messages Feb 18, 2025 – Mar 5, 2025

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v3 cover Prerequisite patches for Arm64 MPU build

Hi all,

in order to build Xen for Arm64 with MPU support, there are few changes to support the compilation of Arm code without HAS_PASSTHROUGH and some Kconfig changes.

Luca Fancellu (2):
xen/passthrough: Provide stub functions when !HAS_PASSTHROUGH xen/arm: Restrict Kconfig configuration for LLC coloring

 xen/arch/arm/Kconfig                   |  2 +-
 xen/arch/arm/include/asm/grant_table.h |  5 +--
 xen/include/xen/iommu.h                | 48 +++++++++++++++++++++++++-
 3 files changed, 51 insertions(+), 4 deletions(-)
Signature · 1 line
2.34.1
#1 lore raw

PATCH v3 1/2 xen/passthrough: Provide stub functions when !HAS_PASSTHROUGH

When Xen is built without HAS_PASSTHROUGH, there are some parts in arm where iommu_* functions are called in the codebase, but their implementation is under xen/drivers/passthrough that is not built.

So provide some stub for these functions in order to build Xen when !HAS_PASSTHROUGH, which is the case for example on systems with MPU support.

For gnttab_need_iommu_mapping() in the Arm part, modify the macro to use IS_ENABLED for the HAS_PASSTHROUGH Kconfig.

Fixes 0388a5979b21 ("xen/arm: mpu: Introduce choice between MMU and MPU")

---
v3 Changes:
- removed stub for iommu_use_hap_pt, another solution will be done for the instance in common arm code.
- Moved a comment close to the macro it was referred to
- add comment to iommu_domain_init() stub
- modified commit message
- Add fixes tag

v2 Changes:
- modify gnttab_need_iommu_mapping to use IS_ENABLED
- removed macro that didn't allow some of the parameter to be evaluated
- Changed commit message
---

---
 xen/arch/arm/include/asm/grant_table.h |  5 +--
 xen/include/xen/iommu.h                | 48 +++++++++++++++++++++++++-
 2 files changed, 50 insertions(+), 3 deletions(-)
xen/arch/arm/include/asm/grant_table.h +3 -2
index d3c518a926b9..c5d87b60c4df 100644
@@ -73,8 +73,9 @@ int replace_grant_host_mapping(uint64_t gpaddr, mfn_t frame,
 #define gnttab_status_gfn(d, t, i)                                       \
     page_get_xenheap_gfn(gnttab_status_page(t, i))
 
-#define gnttab_need_iommu_mapping(d)                    \
-    (is_domain_direct_mapped(d) && is_iommu_enabled(d))
+#define gnttab_need_iommu_mapping(d)                                     \
+    (IS_ENABLED(CONFIG_HAS_PASSTHROUGH) && is_domain_direct_mapped(d) && \
+     is_iommu_enabled(d))
 
 #endif /* __ASM_GRANT_TABLE_H__ */
 /*
xen/include/xen/iommu.h +47 -1

83 lines not on this page · raw message

Signature · 1 line
2.34.1
#2 lore raw

Re: [PATCH v3 1/2] xen/passthrough: Provide stub functions when !HAS_PASSTHROUGH

Quoted 20 lines · Luca Fancellu
xen/include/xen/iommu.h +7 -0
@@ -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,28 @@ 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;

xen/include/xen/iommu.h int arch_iommu_domain_init(struct domain *d); · line 141

Quoted 10 lines
xen/include/xen/iommu.h +10 -0
+}
+
+static inline int iommu_domain_init(struct domain *d, unsigned int opts)
+{
+    /*
+     * When !HAS_PASSTHROUGH, iommu_enabled is set to false and the expected
+     * behaviour of this function is to return success in that case.
+     */
+    return 0;
+}

Hmm. Would the function be anywhere near likely to do anything else than what it's expected to do? My original concern here was with "opts" perhaps asking for something that cannot be supported. But that was wrong thinking on my part. Here what you do is effectively open-code what the real iommu_domain_init() would do: Return success when !is_iommu_enabled(). Which in turn follows from !iommu_enabled when !HAS_PASSTHROUGH.

On that basis I'd be okay if the comment was dropped again. Else it imo wants re-wording to get closer to the explanation above.

Quoted 4 lines
xen/include/xen/iommu.h +0 -0
@@ -383,12 +429,12 @@ struct domain_iommu {
 #define iommu_set_feature(d, f)   set_bit(f, dom_iommu(d)->features)
 #define iommu_clear_feature(d, f) clear_bit(f, dom_iommu(d)->features)
 

xen/include/xen/iommu.h struct domain_iommu { · line 440

Quoted 10 lines
xen/include/xen/iommu.h +1 -1
+#ifdef CONFIG_HAS_PASSTHROUGH
 /* Are we using the domain P2M table as its IOMMU pagetable? */
 #define iommu_use_hap_pt(d)       (IS_ENABLED(CONFIG_HVM) && \
                                    dom_iommu(d)->hap_pt_share)
 
 /* Does the IOMMU pagetable need to be kept synchronized with the P2M */
-#ifdef CONFIG_HAS_PASSTHROUGH
 #define need_iommu_pt_sync(d)     (dom_iommu(d)->need_sync)
 
 int iommu_do_domctl(struct xen_domctl *domctl, struct domain *d,

Coming back to my v2 comment: Why exactly is this change needed here? If things build fine without the macro being defined when !HAS_PASSTHROUGH, surely they will also build fine with it being defined? As per the respective revlog entry, this change looks to belong into whatever is going to be done to deal with the one Arm use of the macro. Or maybe it's unneeded altogether.

Jan

#3 lore raw

Re: [PATCH v3 1/2] xen/passthrough: Provide stub functions when !HAS_PASSTHROUGH

Quoted 43 lines · Jan Beulich
Quoted 20 lines · Luca Fancellu
xen/include/xen/iommu.h +7 -0
@@ -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,28 @@ 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;

xen/include/xen/iommu.h int arch_iommu_domain_init(struct domain *d); · line 141

Quoted 10 lines
xen/include/xen/iommu.h +10 -0
+}
+
+static inline int iommu_domain_init(struct domain *d, unsigned int opts)
+{
+    /*
+     * When !HAS_PASSTHROUGH, iommu_enabled is set to false and the expected
+     * behaviour of this function is to return success in that case.
+     */
+    return 0;
+}

Hmm. Would the function be anywhere near likely to do anything else than what it's expected to do? My original concern here was with "opts" perhaps asking for something that cannot be supported. But that was wrong thinking on my part. Here what you do is effectively open-code what the real iommu_domain_init() would do: Return success when !is_iommu_enabled(). Which in turn follows from !iommu_enabled when !HAS_PASSTHROUGH.

Quoted 2 lines

On that basis I'd be okay if the comment was dropped again. Else it imo wants re-wording to get closer to the explanation above.

Would it be ok for you a comment saying:
“This stub returns the same as the real iommu_domain_init()
function: success when !is_iommu_enabled(), which value is based on iommu_enabled
that is false when !HAS_PASSTHROUGH"

Quoted 14 lines
Quoted 14 lines
xen/include/xen/iommu.h +1 -1
@@ -383,12 +429,12 @@ struct domain_iommu {
 #define iommu_set_feature(d, f)   set_bit(f, dom_iommu(d)->features)
 #define iommu_clear_feature(d, f) clear_bit(f, dom_iommu(d)->features)
 
+#ifdef CONFIG_HAS_PASSTHROUGH
 /* Are we using the domain P2M table as its IOMMU pagetable? */
 #define iommu_use_hap_pt(d)       (IS_ENABLED(CONFIG_HVM) && \
                                   dom_iommu(d)->hap_pt_share)
 
 /* Does the IOMMU pagetable need to be kept synchronized with the P2M */
-#ifdef CONFIG_HAS_PASSTHROUGH
 #define need_iommu_pt_sync(d)     (dom_iommu(d)->need_sync)
 
Quoted 5 lines

xen/include/xen/iommu.h struct domain_iommu { · line 440

Quoted 1 line
xen/include/xen/iommu.h +0 -0
 int iommu_do_domctl(struct xen_domctl *domctl, struct domain *d,

Coming back to my v2 comment: Why exactly is this change needed here? If things build fine without the macro being defined when !HAS_PASSTHROUGH, surely they will also build fine with it being defined?

I’ve defined an empty stub on an header included only on MPU systems for the p2m module, this is why it is building

I didn’t modify p2m_set_way_flush() which lives in arm common code, because it will be used also on MPU systems (R82 has MPU at EL2 but MMU/MPU at EL1) and I would like to stay the same and be used by MMU/MPU subsystems.

Quoted 4 lines

As per the
respective revlog entry, this change looks to belong into whatever is going to be done to deal with the one Arm use of the macro. Or maybe it's unneeded altogether.

I didn’t understand that you were opposing to protecting iommu_use_hap_pt() when !HAS_PASSTHROUGH, I thought you were referring only to the stub in the #else branch.
Can I ask why? in any case when !HAS_PASSTHROUGH, this macro is not usable since dom_iommu() is resolved to a membed that doesn’t exist in the configuration, am I missing something?

Cheers,
Luca

#4 lore raw

Re: [PATCH v3 1/2] xen/passthrough: Provide stub functions when !HAS_PASSTHROUGH

Quoted 40 lines · Luca Fancellu
Quoted 40 lines · Jan Beulich
Quoted 20 lines · Luca Fancellu
xen/include/xen/iommu.h +7 -0
@@ -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,28 @@ 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;

xen/include/xen/iommu.h int arch_iommu_domain_init(struct domain *d); · line 141

Quoted 10 lines
xen/include/xen/iommu.h +10 -0
+}
+
+static inline int iommu_domain_init(struct domain *d, unsigned int opts)
+{
+    /*
+     * When !HAS_PASSTHROUGH, iommu_enabled is set to false and the expected
+     * behaviour of this function is to return success in that case.
+     */
+    return 0;
+}

Hmm. Would the function be anywhere near likely to do anything else than what it's expected to do? My original concern here was with "opts" perhaps asking for something that cannot be supported. But that was wrong thinking on my part. Here what you do is effectively open-code what the real iommu_domain_init() would do: Return success when !is_iommu_enabled(). Which in turn follows from !iommu_enabled when !HAS_PASSTHROUGH.

Quoted 7 lines
Quoted 2 lines

On that basis I'd be okay if the comment was dropped again. Else it imo wants re-wording to get closer to the explanation above.

Would it be ok for you a comment saying:
“This stub returns the same as the real iommu_domain_init()
function: success when !is_iommu_enabled(), which value is based on iommu_enabled
that is false when !HAS_PASSTHROUGH"

I'm sorry, but this is too verbose for my taste. What's wrong with the more terse

"Return as the real iommu_domain_init() would: Success when
!is_iommu_enabled(), following from !iommu_enabled when !HAS_PASSTHROUGH"

?

Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
xen/include/xen/iommu.h +1 -1
@@ -383,12 +429,12 @@ struct domain_iommu {
 #define iommu_set_feature(d, f)   set_bit(f, dom_iommu(d)->features)
 #define iommu_clear_feature(d, f) clear_bit(f, dom_iommu(d)->features)
 
+#ifdef CONFIG_HAS_PASSTHROUGH
 /* Are we using the domain P2M table as its IOMMU pagetable? */
 #define iommu_use_hap_pt(d)       (IS_ENABLED(CONFIG_HVM) && \
                                   dom_iommu(d)->hap_pt_share)
 
 /* Does the IOMMU pagetable need to be kept synchronized with the P2M */
-#ifdef CONFIG_HAS_PASSTHROUGH
 #define need_iommu_pt_sync(d)     (dom_iommu(d)->need_sync)
 
Quoted 8 lines
Quoted 5 lines

xen/include/xen/iommu.h struct domain_iommu { · line 440

Quoted 1 line
xen/include/xen/iommu.h +0 -0
 int iommu_do_domctl(struct xen_domctl *domctl, struct domain *d,

Coming back to my v2 comment: Why exactly is this change needed here? If things build fine without the macro being defined when !HAS_PASSTHROUGH, surely they will also build fine with it being defined?

I’ve defined an empty stub on an header included only on MPU systems for the p2m module, this is why it is building

But that wasn't part of the patch, was it? I.e. with this series alone applied, things still don't build?

Quoted 9 lines

I didn’t modify p2m_set_way_flush() which lives in arm common code, because it will be used also on MPU systems (R82 has MPU at EL2 but MMU/MPU at EL1) and I would like to stay the same and be used by MMU/MPU subsystems.

Quoted 4 lines

As per the
respective revlog entry, this change looks to belong into whatever is going to be done to deal with the one Arm use of the macro. Or maybe it's unneeded altogether.

Quoted 4 lines

I didn’t understand that you were opposing to protecting iommu_use_hap_pt() when !HAS_PASSTHROUGH, I thought you were referring only to the stub in the #else branch.
Can I ask why?

Sure. And no, I'm not against the extra protection. I'm against unnecessary code churn. That is, any such a re-arrangement wants to have some kind of justification.

Quoted 3 lines

in any case when !HAS_PASSTHROUGH, this macro is not usable
since dom_iommu() is resolved to a membed that doesn’t exist in the configuration, am I missing something?

You very likely aren't, yet the macro's presence also does no harm. We have lots of macros and declarations which are usable only in certain configurations. Sometimes this just happens to be that way, sometimes it's actually deliberate (e.g. to facilitate DCE).

Jan

#5 lore raw

Re: [PATCH v3 1/2] xen/passthrough: Provide stub functions when !HAS_PASSTHROUGH

Quoted 53 lines · Jan Beulich
Quoted 40 lines · Luca Fancellu
Quoted 40 lines · Jan Beulich
Quoted 20 lines · Luca Fancellu
xen/include/xen/iommu.h +7 -0
@@ -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,28 @@ 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;

xen/include/xen/iommu.h int arch_iommu_domain_init(struct domain *d); · line 141

Quoted 10 lines
xen/include/xen/iommu.h +10 -0
+}
+
+static inline int iommu_domain_init(struct domain *d, unsigned int opts)
+{
+    /*
+     * When !HAS_PASSTHROUGH, iommu_enabled is set to false and the expected
+     * behaviour of this function is to return success in that case.
+     */
+    return 0;
+}

Hmm. Would the function be anywhere near likely to do anything else than what it's expected to do? My original concern here was with "opts" perhaps asking for something that cannot be supported. But that was wrong thinking on my part. Here what you do is effectively open-code what the real iommu_domain_init() would do: Return success when !is_iommu_enabled(). Which in turn follows from !iommu_enabled when !HAS_PASSTHROUGH.

Quoted 7 lines
Quoted 2 lines

On that basis I'd be okay if the comment was dropped again. Else it imo wants re-wording to get closer to the explanation above.

Would it be ok for you a comment saying:
“This stub returns the same as the real iommu_domain_init()
function: success when !is_iommu_enabled(), which value is based on iommu_enabled that is false when !HAS_PASSTHROUGH"

Quoted 7 lines

I'm sorry, but this is too verbose for my taste. What's wrong with the more terse

"Return as the real iommu_domain_init() would: Success when !is_iommu_enabled(), following from !iommu_enabled when !HAS_PASSTHROUGH"

?

nothing wrong, I’ll use that, thanks for confirming.

Quoted 20 lines
Quoted 20 lines
Quoted 19 lines
Quoted 5 lines
xen/include/xen/iommu.h +0 -0
@@ -383,12 +429,12 @@ struct domain_iommu {
 #define iommu_set_feature(d, f)   set_bit(f, dom_iommu(d)->features)
 #define iommu_clear_feature(d, f) clear_bit(f, dom_iommu(d)->features)
 

xen/include/xen/iommu.h struct domain_iommu { · line 440

Quoted 10 lines
xen/include/xen/iommu.h +1 -1
+#ifdef CONFIG_HAS_PASSTHROUGH
 /* Are we using the domain P2M table as its IOMMU pagetable? */
 #define iommu_use_hap_pt(d)       (IS_ENABLED(CONFIG_HVM) && \
                                  dom_iommu(d)->hap_pt_share)
 
 /* Does the IOMMU pagetable need to be kept synchronized with the P2M */
-#ifdef CONFIG_HAS_PASSTHROUGH
 #define need_iommu_pt_sync(d)     (dom_iommu(d)->need_sync)
 
 int iommu_do_domctl(struct xen_domctl *domctl, struct domain *d,

Coming back to my v2 comment: Why exactly is this change needed here? If things build fine without the macro being defined when !HAS_PASSTHROUGH, surely they will also build fine with it being defined?

Quoted 5 lines
Quoted 2 lines

I’ve defined an empty stub on an header included only on MPU systems for the p2m module, this is why it is building

But that wasn't part of the patch, was it? I.e. with this series alone applied, things still don't build?

yes, before building there are other bits needed, this is only a small step towards that.

Quoted 10 lines
Quoted 10 lines

I didn’t modify p2m_set_way_flush() which lives in arm common code, because it will be used also on MPU systems (R82 has MPU at EL2 but MMU/MPU at EL1) and I would like to stay the same and be used by MMU/MPU subsystems.

Quoted 4 lines

As per the
respective revlog entry, this change looks to belong into whatever is going to be done to deal with the one Arm use of the macro. Or maybe it's unneeded altogether.

Quoted 8 lines
Quoted 4 lines

I didn’t understand that you were opposing to protecting iommu_use_hap_pt() when !HAS_PASSTHROUGH, I thought you were referring only to the stub in the #else branch.
Can I ask why?

Sure. And no, I'm not against the extra protection. I'm against unnecessary code churn. That is, any such a re-arrangement wants to have some kind of justification.

ok, yes the justification is that MPU system will be built with !HAS_PASSTHROUGH, but there is a common function (p2m_set_way_flush) to MMU/MPU subsystem that I would like to keep common, to do so I have to hide the macro in this particular configuration and afterwards I have two choices:

1) provide a stub implementation on the Arm side
2) provide a stub implementation in iommu.h

number 2 felt better because it could be applied on any Xen configuration without HAS_PASSTHROUGH, even if at the moment there is only MPU.

Number 1 let the possibility for the specific configuration to choose what to do in absence of HAS_PASSTHROUGH.

Now I would like your view on what would be acceptable here.

Quoted 9 lines
Quoted 4 lines

in any case when !HAS_PASSTHROUGH, this macro is not usable
since dom_iommu() is resolved to a membed that doesn’t exist in the configuration, am I missing something?

You very likely aren't, yet the macro's presence also does no harm. We have lots of macros and declarations which are usable only in certain configurations. Sometimes this just happens to be that way, sometimes it's actually deliberate (e.g. to facilitate DCE).

Ok, in this particular case, as I explained above, this macro is one of the thing preventing Arm MPU side to build, otherwise I wouldn’t have touched it.

Cheers,
Luca

#6 lore raw

Re: [PATCH v3 1/2] xen/passthrough: Provide stub functions when !HAS_PASSTHROUGH

Quoted 25 lines · Luca Fancellu
Quoted 8 lines · Jan Beulich
Quoted 6 lines · Luca Fancellu
Quoted 5 lines · Jan Beulich

As per the
respective revlog entry, this change looks to belong into whatever is going to be done to deal with the one Arm use of the macro. Or maybe it's unneeded altogether.

Quoted 8 lines
Quoted 4 lines

I didn’t understand that you were opposing to protecting iommu_use_hap_pt() when !HAS_PASSTHROUGH, I thought you were referring only to the stub in the #else branch.
Can I ask why?

Sure. And no, I'm not against the extra protection. I'm against unnecessary code churn. That is, any such a re-arrangement wants to have some kind of justification.

ok, yes the justification is that MPU system will be built with !HAS_PASSTHROUGH, but there is a common function (p2m_set_way_flush) to MMU/MPU subsystem that I would like to keep common, to do so I have to hide the macro in this particular configuration and afterwards I have two choices:

1) provide a stub implementation on the Arm side
2) provide a stub implementation in iommu.h

Quoted 7 lines

number 2 felt better because it could be applied on any Xen configuration without HAS_PASSTHROUGH, even if at the moment there is only MPU.

Number 1 let the possibility for the specific configuration to choose what to do in absence of HAS_PASSTHROUGH.

Now I would like your view on what would be acceptable here.

I think I indicated earlier that I'd like the Arm maintainers to voice their preference. Doing it in iommu.h may be okay, but also may not be. Yet to decide that very Arm use of the macro needs taking into account, and I lack context there.

Quoted 11 lines
Quoted 8 lines
Quoted 3 lines

in any case when !HAS_PASSTHROUGH, this macro is not usable
since dom_iommu() is resolved to a membed that doesn’t exist in the configuration, am I missing something?

You very likely aren't, yet the macro's presence also does no harm. We have lots of macros and declarations which are usable only in certain configurations. Sometimes this just happens to be that way, sometimes it's actually deliberate (e.g. to facilitate DCE).

Ok, in this particular case, as I explained above, this macro is one of the thing preventing Arm MPU side to build, otherwise I wouldn’t have touched it.

Yes, except that this wasn't said anywhere. Also if you mean to take care of this macro here, then in full please. I.e. either don't touch that area of the header at all, or provide (wherever suitable) a stub alongside moving the #ifdef.

Jan

#7 lore raw

Re: [PATCH v3 1/2] xen/passthrough: Provide stub functions when !HAS_PASSTHROUGH

Quoted 32 lines · Jan Beulich
Quoted 31 lines · Luca Fancellu
Quoted 8 lines · Jan Beulich
Quoted 6 lines · Luca Fancellu
Quoted 5 lines · Jan Beulich

As per the
respective revlog entry, this change looks to belong into whatever is going to be done to deal with the one Arm use of the macro. Or maybe it's unneeded altogether.

Quoted 8 lines
Quoted 4 lines

I didn’t understand that you were opposing to protecting iommu_use_hap_pt() when !HAS_PASSTHROUGH, I thought you were referring only to the stub in the #else branch.
Can I ask why?

Sure. And no, I'm not against the extra protection. I'm against unnecessary code churn. That is, any such a re-arrangement wants to have some kind of justification.

ok, yes the justification is that MPU system will be built with !HAS_PASSTHROUGH, but there is a common function (p2m_set_way_flush) to MMU/MPU subsystem that I would like to keep common, to do so I have to hide the macro in this particular configuration and afterwards I have two choices:

1) provide a stub implementation on the Arm side
2) provide a stub implementation in iommu.h

number 2 felt better because it could be applied on any Xen configuration without HAS_PASSTHROUGH, even if at the moment there is only MPU.

Number 1 let the possibility for the specific configuration to choose what to do in absence of HAS_PASSTHROUGH.

Quoted 6 lines
Quoted 1 line

Now I would like your view on what would be acceptable here.

I think I indicated earlier that I'd like the Arm maintainers to voice their preference. Doing it in iommu.h may be okay, but also may not be. Yet to decide that very Arm use of the macro needs taking into account, and I lack context there.

I think that doing it in iommu.h is fine

#8 lore raw

Re: [PATCH v3 1/2] xen/passthrough: Provide stub functions when !HAS_PASSTHROUGH

Hi Stefano,

Quoted 35 lines · Stefano Stabellini
Quoted 32 lines · Jan Beulich
Quoted 31 lines · Luca Fancellu
Quoted 8 lines · Jan Beulich
Quoted 6 lines · Luca Fancellu
Quoted 5 lines · Jan Beulich

As per the
respective revlog entry, this change looks to belong into whatever is going to be done to deal with the one Arm use of the macro. Or maybe it's unneeded altogether.

Quoted 8 lines
Quoted 4 lines

I didn’t understand that you were opposing to protecting iommu_use_hap_pt() when !HAS_PASSTHROUGH, I thought you were referring only to the stub in the #else branch.
Can I ask why?

Sure. And no, I'm not against the extra protection. I'm against unnecessary code churn. That is, any such a re-arrangement wants to have some kind of justification.

ok, yes the justification is that MPU system will be built with !HAS_PASSTHROUGH, but there is a common function (p2m_set_way_flush) to MMU/MPU subsystem that I would like to keep common, to do so I have to hide the macro in this particular configuration and afterwards I have two choices:

1) provide a stub implementation on the Arm side
2) provide a stub implementation in iommu.h

number 2 felt better because it could be applied on any Xen configuration without HAS_PASSTHROUGH, even if at the moment there is only MPU.

Number 1 let the possibility for the specific configuration to choose what to do in absence of HAS_PASSTHROUGH.

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

Now I would like your view on what would be acceptable here.

I think I indicated earlier that I'd like the Arm maintainers to voice their preference. Doing it in iommu.h may be okay, but also may not be. Yet to decide that very Arm use of the macro needs taking into account, and I lack context there.

I think that doing it in iommu.h is fine

Thanks for sharing your view, Jan if you are ok with that, I’ll respin this patch with the stub implementation in iommu.h.

Cheers,
Luca

#9 lore raw

PATCH v3 2/2 xen/arm: Restrict Kconfig configuration for LLC coloring

In reply to Luca Fancellu

LLC coloring can be used only on MMU system, move the code that selects it from ARM_64 to MMU and add the ARM_64 dependency.

---
v3 changes:
- Dropped comment on top of boot_fdt_info()

v2 changes:
- dropped part of the v1 code, now this one is simpler, I will discuss better how to design a common boot flow for MPU and implement on another patch.

---

---
 xen/arch/arm/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/arm/Kconfig +1 -1
index a26d3e11827c..ffdff1f0a36c 100644
@@ -8,7 +8,6 @@ config ARM_64
 	depends on !ARM_32
 	select 64BIT
 	select HAS_FAST_MULTIPLY
-	select HAS_LLC_COLORING if !NUMA
 
 config ARM
 	def_bool y
@@ -76,6 +75,7 @@ choice
 
 config MMU
 	bool "MMU"
+	select HAS_LLC_COLORING if !NUMA && ARM_64
 	select HAS_PMAP
 	select HAS_VMAP
 	select HAS_PASSTHROUGH
Signature · 1 line
2.34.1
#11 lore raw

Re: [PATCH v3 2/2] xen/arm: Restrict Kconfig configuration for LLC coloring

In reply to Luca Fancellu
Quoted 1 line · Luca Fancellu

LLC coloring can be used only on MMU system,

Just for my own education: Why is this?

Jan

#12 lore raw

Re: [PATCH v3 2/2] xen/arm: Restrict Kconfig configuration for LLC coloring

Quoted 6 lines · Jan Beulich
Quoted 1 line · Luca Fancellu

LLC coloring can be used only on MMU system,

Just for my own education: Why is this?

I read this as it refers to the feature we have in Xen, not the generic concept. You could in theory achieve cache coloring without MMU using static allocation or some custom allocator but in general we benefit from being able to map VA to PA aligning with cache coloring scheme.

P.S. Personally, I've never seen a solution without MMU.

~Michal

#13 lore raw

Re: [PATCH v3 2/2] xen/arm: Restrict Kconfig configuration for LLC coloring

Quoted 9 lines · Michal
Quoted 4 lines · Jan Beulich
Quoted 1 line · Luca Fancellu

LLC coloring can be used only on MMU system,

Just for my own education: Why is this?

I read this as it refers to the feature we have in Xen, not the generic concept. You could in theory achieve cache coloring without MMU using static allocation or some custom allocator but in general we benefit from being able to map VA to PA aligning with cache coloring scheme.

Oh, okay. Then maybe the sentence would better be worded to express that it's our present choice, rather than an inherent limitation?

Jan

#14 lore raw

Re: [PATCH v3 2/2] xen/arm: Restrict Kconfig configuration for LLC coloring

Hi,

Quoted 7 lines · Jan Beulich
Quoted 4 lines · Michal
Quoted 3 lines · Jan Beulich
Quoted 1 line · Luca Fancellu

LLC coloring can be used only on MMU system,

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

Just for my own education: Why is this?

I read this as it refers to the feature we have in Xen, not the generic concept. You could in theory achieve cache coloring without MMU using static allocation or some custom allocator but in general we benefit from being able to map VA to PA aligning with cache coloring scheme.

Oh, okay. Then maybe the sentence would better be worded to express that it's our present choice, rather than an inherent limitation?

Is this better? Can be addressed on commit?

Xen LLC coloring feature can be used only on MMU system, move the code that selects it from ARM_64 to MMU and add the ARM_64 dependency.

Quoted 3 lines

Jan

#15 lore raw

Re: [PATCH v3 2/2] xen/arm: Restrict Kconfig configuration for LLC coloring

Quoted 15 lines · Luca Fancellu

Hi,

Quoted 13 lines · Jan Beulich
Quoted 9 lines · Michal
Quoted 4 lines · Jan Beulich
Quoted 1 line · Luca Fancellu

LLC coloring can be used only on MMU system,

Just for my own education: Why is this?

I read this as it refers to the feature we have in Xen, not the generic concept. You could in theory achieve cache coloring without MMU using static allocation or some custom allocator but in general we benefit from being able to map VA to PA aligning with cache coloring scheme.

Quoted 7 lines
Quoted 2 lines

Oh, okay. Then maybe the sentence would better be worded to express that it's our present choice, rather than an inherent limitation?

Is this better? Can be addressed on commit?

Xen LLC coloring feature can be used only on MMU system, move the code that selects it from ARM_64 to MMU and add the ARM_64 dependency.

Hi Luca, I think that's OK. Can this patch be committed without the previous patch in the series?

#16 lore raw

Re: [PATCH v3 2/2] xen/arm: Restrict Kconfig configuration for LLC coloring

Hi Stefano,

Quoted 21 lines · Stefano Stabellini
Quoted 18 lines · Luca Fancellu

Hi,

Quoted 15 lines · Jan Beulich
Quoted 9 lines · Michal
Quoted 4 lines · Jan Beulich
Quoted 1 line · Luca Fancellu

LLC coloring can be used only on MMU system,

Just for my own education: Why is this?

I read this as it refers to the feature we have in Xen, not the generic concept. You could in theory achieve cache coloring without MMU using static allocation or some custom allocator but in general we benefit from being able to map VA to PA aligning with cache coloring scheme.

Oh, okay. Then maybe the sentence would better be worded to express that it's our present choice, rather than an inherent limitation?

Quoted 7 lines
Quoted 4 lines

Is this better? Can be addressed on commit?

Xen LLC coloring feature can be used only on MMU system, move the code that selects it from ARM_64 to MMU and add the ARM_64 dependency.

Hi Luca, I think that's OK. Can this patch be committed without the previous patch in the series?

Yes it can, I think we need more time to get an agreement for the first patch, probably Jan would like to see that together with the rest in order to understand if it goes to the right path or not.

Cheers,
Luca