Skip to contentSkip to conversation

Move calls to memory_type_changed()

PATCH In review Roger Pau Monne 4 participants 10 messages Sep 28, 2022 – Sep 29, 2022

lore
Share & tools
lore
#0 lore raw

v3 cover Move calls to memory_type_changed()

Hello,

The current calls to memory_type_changed() are wider than strictly necessary. Move them inside the iocap handlers and also limit to only issue them when required.

I would really like to get some feedback on the Arm change, since this is now a prereq for the actual fix.

Thanks, Roger.

Roger Pau Monne (2):
arm/vgic: drop const attribute from gic_iomem_deny_access() x86/ept: limit calls to memory_type_changed()

 xen/arch/arm/gic-v2.c            |  2 +-
 xen/arch/arm/gic-v3.c            |  2 +-
 xen/arch/arm/gic.c               |  2 +-
 xen/arch/arm/include/asm/gic.h   |  4 ++--
 xen/arch/x86/domctl.c            |  4 ----
 xen/arch/x86/include/asm/iocap.h | 33 +++++++++++++++++++++++----
 xen/arch/x86/mm/p2m-ept.c        |  4 ++++
 xen/common/domctl.c              |  4 ----
 xen/include/xen/iocap.h          | 38 ++++++++++++++++++++++++++++----
 9 files changed, 72 insertions(+), 21 deletions(-)
Signature · 1 line
2.37.3
#1 lore raw

PATCH v3 1/2 arm/vgic: drop const attribute from gic_iomem_deny_access()

While correct from a code point of view, the usage of the const attribute for the domain parameter of gic_iomem_deny_access() is at least partially bogus. Contents of the domain structure (the iomem rangeset) is modified by the function. Such modifications succeed because right now the iomem rangeset is allocated separately from struct domain, and hence is not subject to the constness of struct domain.

Amend this by dropping the const attribute from the function parameter.

This is required by further changes that will convert iomem_{permit,deny}_access into a function.

---
 xen/arch/arm/gic-v2.c          | 2 +-
 xen/arch/arm/gic-v3.c          | 2 +-
 xen/arch/arm/gic.c             | 2 +-
 xen/arch/arm/include/asm/gic.h | 4 ++--
 4 files changed, 5 insertions(+), 5 deletions(-)
xen/arch/arm/gic-v2.c +1 -1
index bd773bcc67..ae5bd8e95f 100644
@@ -1083,7 +1083,7 @@ static void __init gicv2_dt_init(void)
     gicv2_extension_dt_init(node);
 }
 
-static int gicv2_iomem_deny_access(const struct domain *d)
+static int gicv2_iomem_deny_access(struct domain *d)
 {
     int rc;
     unsigned long mfn, nr;
xen/arch/arm/gic-v3.c +1 -1
index 64b36cec25..018fa0dfa0 100644
@@ -1424,7 +1424,7 @@ static void __init gicv3_dt_init(void)
                               &vbase, &vsize);
 }
 
-static int gicv3_iomem_deny_access(const struct domain *d)
+static int gicv3_iomem_deny_access(struct domain *d)
 {
     int rc, i;
     unsigned long mfn, nr;
xen/arch/arm/gic.c +1 -1
index 3b0331b538..9b82325442 100644
@@ -462,7 +462,7 @@ unsigned long gic_get_hwdom_madt_size(const struct domain *d)
 }
 #endif
 
-int gic_iomem_deny_access(const struct domain *d)
+int gic_iomem_deny_access(struct domain *d)
 {
     return gic_hw_ops->iomem_deny_access(d);
 }
xen/arch/arm/include/asm/gic.h +2 -2
index 3692fae393..76e3fa5dc4 100644
@@ -392,7 +392,7 @@ struct gic_hw_operations {
     /* Map extra GIC MMIO, irqs and other hw stuffs to the hardware domain. */
     int (*map_hwdom_extra_mappings)(struct domain *d);
     /* Deny access to GIC regions */
-    int (*iomem_deny_access)(const struct domain *d);
+    int (*iomem_deny_access)(struct domain *d);
     /* Handle LPIs, which require special handling */
     void (*do_LPI)(unsigned int lpi);
 };
@@ -449,7 +449,7 @@ unsigned long gic_get_hwdom_madt_size(const struct domain *d);
 #endif
 
 int gic_map_hwdom_extra_mappings(struct domain *d);
-int gic_iomem_deny_access(const struct domain *d);
+int gic_iomem_deny_access(struct domain *d);
 
 #endif /* __ASSEMBLY__ */
 #endif
Signature · 1 line
2.37.3
Reviewed-by on v3 1/2
#2 lore raw

Re: [PATCH v3 1/2] arm/vgic: drop const attribute from gic_iomem_deny_access()

Hi Roger,

Quoted 10 lines · Roger Pau Monne

While correct from a code point of view, the usage of the const attribute for the domain parameter of gic_iomem_deny_access() is at least partially bogus. Contents of the domain structure (the iomem rangeset) is modified by the function. Such modifications succeed because right now the iomem rangeset is allocated separately from struct domain, and hence is not subject to the constness of struct domain.

Quoted 7 lines

Amend this by dropping the const attribute from the function parameter.

This is required by further changes that will convert iomem_{permit,deny}_access into a function.

Cheers
Bertrand

Quoted 71 lines

---

xen/arch/arm/gic-v2.c          | 2 +-
xen/arch/arm/gic-v3.c          | 2 +-
xen/arch/arm/gic.c             | 2 +-
xen/arch/arm/include/asm/gic.h | 4 ++--
4 files changed, 5 insertions(+), 5 deletions(-)
xen/arch/arm/gic-v2.c +1 -1
index bd773bcc67..ae5bd8e95f 100644
@@ -1083,7 +1083,7 @@ static void __init gicv2_dt_init(void)
    gicv2_extension_dt_init(node);
 }
 
-static int gicv2_iomem_deny_access(const struct domain *d)
+static int gicv2_iomem_deny_access(struct domain *d)
 {
    int rc;
    unsigned long mfn, nr;
xen/arch/arm/gic-v3.c +1 -1
index 64b36cec25..018fa0dfa0 100644
@@ -1424,7 +1424,7 @@ static void __init gicv3_dt_init(void)
                              &vbase, &vsize);
 }
 
-static int gicv3_iomem_deny_access(const struct domain *d)
+static int gicv3_iomem_deny_access(struct domain *d)
 {
    int rc, i;
    unsigned long mfn, nr;
xen/arch/arm/gic.c +1 -1
index 3b0331b538..9b82325442 100644
@@ -462,7 +462,7 @@ unsigned long gic_get_hwdom_madt_size(const struct domain *d)
 }
 #endif
 
-int gic_iomem_deny_access(const struct domain *d)
+int gic_iomem_deny_access(struct domain *d)
 {
    return gic_hw_ops->iomem_deny_access(d);
 }
xen/arch/arm/include/asm/gic.h +2 -2
index 3692fae393..76e3fa5dc4 100644
@@ -392,7 +392,7 @@ struct gic_hw_operations {
    /* Map extra GIC MMIO, irqs and other hw stuffs to the hardware domain. */
    int (*map_hwdom_extra_mappings)(struct domain *d);
    /* Deny access to GIC regions */
-    int (*iomem_deny_access)(const struct domain *d);
+    int (*iomem_deny_access)(struct domain *d);
    /* Handle LPIs, which require special handling */
    void (*do_LPI)(unsigned int lpi);
 };
@@ -449,7 +449,7 @@ unsigned long gic_get_hwdom_madt_size(const struct domain *d);
 #endif
 
 int gic_map_hwdom_extra_mappings(struct domain *d);
-int gic_iomem_deny_access(const struct domain *d);
+int gic_iomem_deny_access(struct domain *d);
 
 #endif /* __ASSEMBLY__ */
 #endif
Signature · 1 line
2.37.3
#3 lore raw

PATCH v3 2/2 x86/ept: limit calls to memory_type_changed()

In reply to Roger Pau Monne

memory_type_changed() is currently only implemented for Intel EPT, and results in the invalidation of EMT attributes on all the entries in the EPT page tables. Such invalidation causes EPT_MISCONFIG vmexits when the guest tries to access any gfns for the first time, which results in the recalculation of the EMT for the accessed page. The vmexit and the recalculations are expensive, and as such should be avoided when possible.

Remove the call to memory_type_changed() from
XEN_DOMCTL_memory_mapping: there are no modifications of the iomem_caps ranges anymore that could alter the return of cache_flush_permitted() from that domctl.

Encapsulate calls to memory_type_changed() resulting from changes to the domain iomem_caps or ioport_caps ranges in the helpers themselves (io{ports,mem}_{permit,deny}_access()), and add a note in epte_get_entry_emt() to remind that changes to the logic there likely need to be propagaed to the IO capabilities helpers.

Note changes to the IO ports or memory ranges are not very common during guest runtime, but Citrix Hypervisor has an use case for them related to device passthrough.

---
Changes since v2:
- Split the Arm side changes into a pre-patch.

Changes since v1:
- Place the calls to memory_type_changed() inside the io{ports,mem}_{permit,deny}_access() helpers.

---
 xen/arch/x86/domctl.c            |  4 ----
 xen/arch/x86/include/asm/iocap.h | 33 +++++++++++++++++++++++----
 xen/arch/x86/mm/p2m-ept.c        |  4 ++++
 xen/common/domctl.c              |  4 ----
 xen/include/xen/iocap.h          | 38 ++++++++++++++++++++++++++++----
 5 files changed, 67 insertions(+), 16 deletions(-)
xen/arch/x86/domctl.c +0 -4
index 020df615bd..e9bfbc57a7 100644
@@ -232,8 +232,6 @@ long arch_do_domctl(
             ret = ioports_permit_access(d, fp, fp + np - 1);
         else
             ret = ioports_deny_access(d, fp, fp + np - 1);
-        if ( !ret )
-            memory_type_changed(d);
         break;
     }
 
@@ -666,8 +664,6 @@ long arch_do_domctl(
                        "ioport_map: error %ld denying dom%d access to [%x,%x]\n",
                        ret, d->domain_id, fmp, fmp + np - 1);
         }
-        if ( !ret )
-            memory_type_changed(d);
         break;
     }
 
xen/arch/x86/include/asm/iocap.h +29 -4
index eee47228d4..ce83c3d8a4 100644
@@ -7,10 +7,11 @@
 #ifndef __X86_IOCAP_H__
 #define __X86_IOCAP_H__
 
-#define ioports_permit_access(d, s, e)                  \
-    rangeset_add_range((d)->arch.ioport_caps, s, e)
-#define ioports_deny_access(d, s, e)                    \
-    rangeset_remove_range((d)->arch.ioport_caps, s, e)
+#include <xen/sched.h>
+#include <xen/rangeset.h>
+
+#include <asm/p2m.h>
+
 #define ioports_access_permitted(d, s, e)               \
     rangeset_contains_range((d)->arch.ioport_caps, s, e)
 
@@ -18,4 +19,28 @@
     (!rangeset_is_empty((d)->iomem_caps) ||             \
      !rangeset_is_empty((d)->arch.ioport_caps))
 
+static inline int ioports_permit_access(struct domain *d, unsigned long s,
+                                        unsigned long e)
+{
+    bool flush = cache_flush_permitted(d);
+    int ret = rangeset_add_range(d->arch.ioport_caps, s, e);
+
+    if ( !ret && !is_iommu_enabled(d) && !flush )
+        /* See comment in iomem_permit_access(). */
+        memory_type_changed(d);
+
+    return ret;
+}
+static inline int ioports_deny_access(struct domain *d, unsigned long s,
+                                      unsigned long e)
+{
+    int ret = rangeset_remove_range(d->arch.ioport_caps, s, e);
+
+    if ( !ret && !is_iommu_enabled(d) && !cache_flush_permitted(d) )
+        /* See comment in iomem_deny_access(). */
+        memory_type_changed(d);
+
+    return ret;
+}
+
 #endif /* __X86_IOCAP_H__ */
xen/arch/x86/mm/p2m-ept.c +4 -0
index b4919bad51..d61d66c20e 100644
@@ -518,6 +518,10 @@ int epte_get_entry_emt(struct domain *d, gfn_t gfn, mfn_t mfn,
         return MTRR_TYPE_UNCACHABLE;
     }
 
+    /*
+     * Conditional must be kept in sync with the code in
+     * {iomem,ioports}_{permit,deny}_access().
+     */
     if ( type != p2m_mmio_direct && !is_iommu_enabled(d) &&
          !cache_flush_permitted(d) )
     {
xen/common/domctl.c +0 -4
index 452266710a..69fb9abd34 100644
@@ -716,8 +716,6 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl)
             ret = iomem_permit_access(d, mfn, mfn + nr_mfns - 1);
         else
             ret = iomem_deny_access(d, mfn, mfn + nr_mfns - 1);
-        if ( !ret )
-            memory_type_changed(d);
         break;
     }
 
@@ -778,8 +776,6 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl)
                        "memory_map: error %ld removing dom%d access to [%lx,%lx]\n",
                        ret, d->domain_id, mfn, mfn_end);
         }
-        /* Do this unconditionally to cover errors on above failure paths. */
-        memory_type_changed(d);
         break;
     }
 
xen/include/xen/iocap.h +34 -4
index 1ca3858fc0..0ca4c9745f 100644
@@ -7,13 +7,43 @@
 #ifndef __XEN_IOCAP_H__
 #define __XEN_IOCAP_H__
 
+#include <xen/sched.h>
 #include <xen/rangeset.h>
 #include <asm/iocap.h>
+#include <asm/p2m.h>
+
+static inline int iomem_permit_access(struct domain *d, unsigned long s,
+                                      unsigned long e)
+{
+    bool flush = cache_flush_permitted(d);
+    int ret = rangeset_add_range(d->iomem_caps, s, e);
+
+    if ( !ret && !is_iommu_enabled(d) && !flush )
+        /*
+         * Only flush if the range(s) are empty before this addition and
+         * IOMMU is not enabled for the domain, otherwise it makes no
+         * difference for effective cache attribute calculation purposes.
+         */
+        memory_type_changed(d);
+
+    return ret;
+}
+static inline int iomem_deny_access(struct domain *d, unsigned long s,
+                                    unsigned long e)
+{
+    int ret = rangeset_remove_range(d->iomem_caps, s, e);
+
+    if ( !ret && !is_iommu_enabled(d) && !cache_flush_permitted(d) )
+        /*
+         * Only flush if the range(s) are empty after this removal and
+         * IOMMU is not enabled for the domain, otherwise it makes no
+         * difference for effective cache attribute calculation purposes.
+         */
+        memory_type_changed(d);
+
+    return ret;
+}
 
-#define iomem_permit_access(d, s, e)                    \
-    rangeset_add_range((d)->iomem_caps, s, e)
-#define iomem_deny_access(d, s, e)                      \
-    rangeset_remove_range((d)->iomem_caps, s, e)
 #define iomem_access_permitted(d, s, e)                 \
     rangeset_contains_range((d)->iomem_caps, s, e)
 
Signature · 1 line
2.37.3
Reviewed-by on v3 2/2
#4 lore raw

Re: [PATCH v3 2/2] x86/ept: limit calls to memory_type_changed()

Quoted 19 lines · Roger Pau Monne

memory_type_changed() is currently only implemented for Intel EPT, and results in the invalidation of EMT attributes on all the entries in the EPT page tables. Such invalidation causes EPT_MISCONFIG vmexits when the guest tries to access any gfns for the first time, which results in the recalculation of the EMT for the accessed page. The vmexit and the recalculations are expensive, and as such should be avoided when possible.

Remove the call to memory_type_changed() from
XEN_DOMCTL_memory_mapping: there are no modifications of the iomem_caps ranges anymore that could alter the return of cache_flush_permitted() from that domctl.

Encapsulate calls to memory_type_changed() resulting from changes to the domain iomem_caps or ioport_caps ranges in the helpers themselves (io{ports,mem}_{permit,deny}_access()), and add a note in epte_get_entry_emt() to remind that changes to the logic there likely need to be propagaed to the IO capabilities helpers.

Quoted 5 lines

Note changes to the IO ports or memory ranges are not very common during guest runtime, but Citrix Hypervisor has an use case for them related to device passthrough.

with one minor remark at the end, which can be taken care of while committing.

Quoted 3 lines

---
Changes since v2:
- Split the Arm side changes into a pre-patch.

Despite this I'd prefer to have an Arm maintainer view on this as well. As previously pointed out the resulting code is going to be sub-optimal there.

Quoted 18 lines
xen/include/xen/iocap.h +10 -0
@@ -7,13 +7,43 @@
 #ifndef __XEN_IOCAP_H__
 #define __XEN_IOCAP_H__
 
+#include <xen/sched.h>
 #include <xen/rangeset.h>
 #include <asm/iocap.h>
+#include <asm/p2m.h>
+
+static inline int iomem_permit_access(struct domain *d, unsigned long s,
+                                      unsigned long e)
+{
+    bool flush = cache_flush_permitted(d);
+    int ret = rangeset_add_range(d->iomem_caps, s, e);
+
+    if ( !ret && !is_iommu_enabled(d) && !flush )

xen/include/xen/iocap.h line 31

Quoted 10 lines
xen/include/xen/iocap.h +10 -0
+        /*
+         * Only flush if the range(s) are empty before this addition and
+         * IOMMU is not enabled for the domain, otherwise it makes no
+         * difference for effective cache attribute calculation purposes.
+         */
+        memory_type_changed(d);
+
+    return ret;
+}
+static inline int iomem_deny_access(struct domain *d, unsigned long s,

A blank line would be nice between these two (and similarly for the x86-only pair). Omitting such blank lines is imo advisable only for trivial inline functions.

Jan

#5 lore raw

Re: [PATCH v3 2/2] x86/ept: limit calls to memory_type_changed()

Hi Han,

Quoted 29 lines · Jan Beulich
Quoted 19 lines · Roger Pau Monne

memory_type_changed() is currently only implemented for Intel EPT, and results in the invalidation of EMT attributes on all the entries in the EPT page tables. Such invalidation causes EPT_MISCONFIG vmexits when the guest tries to access any gfns for the first time, which results in the recalculation of the EMT for the accessed page. The vmexit and the recalculations are expensive, and as such should be avoided when possible.

Remove the call to memory_type_changed() from
XEN_DOMCTL_memory_mapping: there are no modifications of the iomem_caps ranges anymore that could alter the return of cache_flush_permitted() from that domctl.

Encapsulate calls to memory_type_changed() resulting from changes to the domain iomem_caps or ioport_caps ranges in the helpers themselves (io{ports,mem}_{permit,deny}_access()), and add a note in epte_get_entry_emt() to remind that changes to the logic there likely need to be propagaed to the IO capabilities helpers.

Quoted 5 lines

Note changes to the IO ports or memory ranges are not very common during guest runtime, but Citrix Hypervisor has an use case for them related to device passthrough.

Quoted 8 lines

with one minor remark at the end, which can be taken care of while committing.

Quoted 3 lines

---
Changes since v2:
- Split the Arm side changes into a pre-patch.

Despite this I'd prefer to have an Arm maintainer view on this as well. As previously pointed out the resulting code is going to be sub-optimal there.

On arm none of those will be called at runtime, it happens only during guest creation so the potential performance impact is very reduce.

Cheers
Bertrand

Quoted 35 lines
Quoted 19 lines
xen/include/xen/iocap.h +10 -0
@@ -7,13 +7,43 @@
 #ifndef __XEN_IOCAP_H__
 #define __XEN_IOCAP_H__
 
+#include <xen/sched.h>
 #include <xen/rangeset.h>
 #include <asm/iocap.h>
+#include <asm/p2m.h>
+
+static inline int iomem_permit_access(struct domain *d, unsigned long s,
+                                      unsigned long e)
+{
+    bool flush = cache_flush_permitted(d);
+    int ret = rangeset_add_range(d->iomem_caps, s, e);
+
+    if ( !ret && !is_iommu_enabled(d) && !flush )

xen/include/xen/iocap.h line 31

Quoted 10 lines
xen/include/xen/iocap.h +10 -0
+        /*
+         * Only flush if the range(s) are empty before this addition and
+         * IOMMU is not enabled for the domain, otherwise it makes no
+         * difference for effective cache attribute calculation purposes.
+         */
+        memory_type_changed(d);
+
+    return ret;
+}
+static inline int iomem_deny_access(struct domain *d, unsigned long s,

A blank line would be nice between these two (and similarly for the x86-only pair). Omitting such blank lines is imo advisable only for trivial inline functions.

Jan

#6 lore raw
In reply to Roger Pau Monne
Quoted 4 lines · Roger Pau Monne

The current calls to memory_type_changed() are wider than strictly necessary. Move them inside the iocap handlers and also limit to only issue them when required.

Quoted 8 lines

I would really like to get some feedback on the Arm change, since this is now a prereq for the actual fix.

Thanks, Roger.

Roger Pau Monne (2):
arm/vgic: drop const attribute from gic_iomem_deny_access() x86/ept: limit calls to memory_type_changed()

Are there intentions for having these on 4.17?

Jan

#7 lore raw

For 4.17 (was: Re: [PATCH v3 0/2] Move calls to memory_type_changed())

Quoted 8 lines · Jan Beulich
Quoted 7 lines · Roger Pau Monne

The current calls to memory_type_changed() are wider than strictly necessary. Move them inside the iocap handlers and also limit to only issue them when required.

I would really like to get some feedback on the Arm change, since this is now a prereq for the actual fix.

Quoted 7 lines
Quoted 5 lines

Thanks, Roger.

Roger Pau Monne (2):
arm/vgic: drop const attribute from gic_iomem_deny_access() x86/ept: limit calls to memory_type_changed()

Are there intentions for having these on 4.17?

I wasn't sure. From XenServer PoV it's certainly a bug fix, otherwise some workloads related to GPU passthrough are simply too slow to be usable.

I would certainly be fine with it making it's way into 4.17, let me add Henry:

Cons:
- Changes the number of issued memory_type_changed(), so there's a risk I misplaced some of the conditions and we end up with wrong cache types in the guest p2m due to missing memory_type_changed() calls. That however won't affect Xen itself, just the guest.

Pros:
- Removes unneeded memory_type_changed(), thus making some operations faster. It's effect it's greatly dependent on using a set of hypercalls against a domain, which doesn't seem common in upstream. It's possible other products based on Xen apart from XenServer will also see an speedup as a result.

Thanks, Roger.

#8 lore raw

RE: For 4.17 (was: Re: [PATCH v3 0/2] Move calls to memory_type_changed())

Hi Roger and Jan,

Quoted 35 lines

-----Original Message-----
From: Roger Pau Monné <[email protected]>
Subject: For 4.17 (was: Re: [PATCH v3 0/2] Move calls to memory_type_changed())

Quoted 8 lines · Jan Beulich
Quoted 7 lines · Roger Pau Monne

The current calls to memory_type_changed() are wider than strictly necessary. Move them inside the iocap handlers and also limit to only issue them when required.

I would really like to get some feedback on the Arm change, since this is now a prereq for the actual fix.

Quoted 7 lines
Quoted 5 lines

Thanks, Roger.

Roger Pau Monne (2):
arm/vgic: drop const attribute from gic_iomem_deny_access() x86/ept: limit calls to memory_type_changed()

Are there intentions for having these on 4.17?

I wasn't sure. From XenServer PoV it's certainly a bug fix, otherwise some workloads related to GPU passthrough are simply too slow to be usable.

I would certainly be fine with it making it's way into 4.17, let me add Henry:

Cons:
- Changes the number of issued memory_type_changed(), so there's a risk I misplaced some of the conditions and we end up with wrong cache types in the guest p2m due to missing memory_type_changed() calls. That however won't affect Xen itself, just the guest.

Quoted 7 lines

Pros:
- Removes unneeded memory_type_changed(), thus making some
operations
faster. It's effect it's greatly dependent on using a set of hypercalls against a domain, which doesn't seem common in upstream. It's possible other products based on Xen apart from XenServer will also see an speedup as a result.

Thanks for the information and the detailed summary!

I think my understanding is the same as what Jan has in
"x86/NUMA: correct memnode_shift calculation for single node system",
- we are still not in code freeze but in feature freeze, so properly-reviewed fixes are eligible for the release. For this specific series, (to me) it looks ok and I will not block the merging of this series if maintainers want to merge it :))

Kind regards,
Henry

Quoted 2 lines

Thanks, Roger.

#9 lore raw

Re: For 4.17 (was: Re: [PATCH v3 0/2] Move calls to memory_type_changed())

Quoted 41 lines · Henry Wang
Quoted 33 lines

-----Original Message-----
From: Roger Pau Monné <[email protected]>

Quoted 8 lines · Jan Beulich
Quoted 7 lines · Roger Pau Monne

The current calls to memory_type_changed() are wider than strictly necessary. Move them inside the iocap handlers and also limit to only issue them when required.

I would really like to get some feedback on the Arm change, since this is now a prereq for the actual fix.

Quoted 7 lines
Quoted 5 lines

Thanks, Roger.

Roger Pau Monne (2):
arm/vgic: drop const attribute from gic_iomem_deny_access() x86/ept: limit calls to memory_type_changed()

Are there intentions for having these on 4.17?

I wasn't sure. From XenServer PoV it's certainly a bug fix, otherwise some workloads related to GPU passthrough are simply too slow to be usable.

I would certainly be fine with it making it's way into 4.17, let me add Henry:

Cons:
- Changes the number of issued memory_type_changed(), so there's a risk I misplaced some of the conditions and we end up with wrong cache types in the guest p2m due to missing memory_type_changed() calls. That however won't affect Xen itself, just the guest.

Quoted 7 lines

Pros:
- Removes unneeded memory_type_changed(), thus making some
operations
faster. It's effect it's greatly dependent on using a set of hypercalls against a domain, which doesn't seem common in upstream. It's possible other products based on Xen apart from XenServer will also see an speedup as a result.

Quoted 8 lines

Thanks for the information and the detailed summary!

I think my understanding is the same as what Jan has in
"x86/NUMA: correct memnode_shift calculation for single node system",
- we are still not in code freeze but in feature freeze, so properly-reviewed fixes are eligible for the release. For this specific series, (to me) it looks ok and I will not block the merging of this series if maintainers want to merge it :))

Thanks. Then, according to my reply to patch 2, the only open thing is to have at least informal agreement there by (at least) one of the Arm maintainers. There's no guarantee this will arrive by tomorrow.

Jan