Skip to contentSkip to conversation

x86/EPT: miscellaneous further fixes to EMT determination

PATCH In review Jan Beulich 3 participants 16 messages Apr 23, 2014 – May 1, 2014

lore
Share & tools
lore
#0 lore raw

cover x86/EPT: miscellaneous further fixes to EMT determination

1: consider page order when checking for APIC MFN 2: refine direct MMIO checking when determining EMT 3: fix pinned cache attribute range checking 4: also force EMT re-evaluation if pinned ranges change

#1 lore raw

PATCH 1/4 x86/EPT: consider page order when checking for APIC MFN

This was overlooked in 3d90d6e6 ("x86/EPT: split super pages upon mismatching memory types").

xen/arch/x86/hvm/mtrr.c +5 -2
@@ -816,15 +816,18 @@ int epte_get_entry_emt(struct domain *d,
           !has_arch_pdevs(d)) )
     {
         ASSERT(!direct_mmio ||
-               mfn_x(mfn) == d->arch.hvm_domain.vmx.apic_access_mfn);
+               !((mfn_x(mfn) ^ d->arch.hvm_domain.vmx.apic_access_mfn) >>
+                 order));
         *ipat = 1;
         return MTRR_TYPE_WRBACK;
     }
 
     if ( direct_mmio )
     {
-        if ( mfn_x(mfn) != d->arch.hvm_domain.vmx.apic_access_mfn )
+        if ( (mfn_x(mfn) ^ d->arch.hvm_domain.vmx.apic_access_mfn) >> order )
             return MTRR_TYPE_UNCACHABLE;
+        if ( order )
+            return -1;
         *ipat = 1;
         return MTRR_TYPE_WRBACK;
     }

x86/EPT: consider page order when checking for APIC MFN

This was overlooked in 3d90d6e6 ("x86/EPT: split super pages upon mismatching memory types").

xen/arch/x86/hvm/mtrr.c +5 -2
@@ -816,15 +816,18 @@ int epte_get_entry_emt(struct domain *d,
           !has_arch_pdevs(d)) )
     {
         ASSERT(!direct_mmio ||
-               mfn_x(mfn) == d->arch.hvm_domain.vmx.apic_access_mfn);
+               !((mfn_x(mfn) ^ d->arch.hvm_domain.vmx.apic_access_mfn) >>
+                 order));
         *ipat = 1;
         return MTRR_TYPE_WRBACK;
     }
 
     if ( direct_mmio )
     {
-        if ( mfn_x(mfn) != d->arch.hvm_domain.vmx.apic_access_mfn )
+        if ( (mfn_x(mfn) ^ d->arch.hvm_domain.vmx.apic_access_mfn) >> order )
             return MTRR_TYPE_UNCACHABLE;
+        if ( order )
+            return -1;
         *ipat = 1;
         return MTRR_TYPE_WRBACK;
     }

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

Acked-by on v1 1/4
#2 lore raw

Re: [PATCH 1/4] x86/EPT: consider page order when checking for APIC MFN

Quoted 7 lines

From: Jan Beulich [mailto:[email protected]]
Sent: Wednesday, April 23, 2014 4:40 PM

This was overlooked in 3d90d6e6 ("x86/EPT: split super pages upon mismatching memory types").

Quoted 29 lines
xen/arch/x86/hvm/mtrr.c +1 -1
@@ -816,15 +816,18 @@ int epte_get_entry_emt(struct domain *d,
           !has_arch_pdevs(d)) )
     {
         ASSERT(!direct_mmio ||
-               mfn_x(mfn) ==
 d->arch.hvm_domain.vmx.apic_access_mfn);
+               !((mfn_x(mfn) ^

d->arch.hvm_domain.vmx.apic_access_mfn) >>

xen/arch/x86/hvm/mtrr.c +2 -1
+                 order));
         *ipat = 1;
         return MTRR_TYPE_WRBACK;
     }
 
     if ( direct_mmio )
     {
-        if ( mfn_x(mfn) != d->arch.hvm_domain.vmx.apic_access_mfn )
+        if ( (mfn_x(mfn) ^ d->arch.hvm_domain.vmx.apic_access_mfn) >>

order )

             return MTRR_TYPE_UNCACHABLE;
xen/arch/x86/hvm/mtrr.c +2 -0
+        if ( order )
+            return -1;
         *ipat = 1;
         return MTRR_TYPE_WRBACK;
     }
#3 lore raw

PATCH 2/4 x86/EPT: refine direct MMIO checking when determining EMT

In reply to Jan Beulich

With need_iommu() only ever true when iommu_enabled is also true, and with the former getting set when a PCI device gets added to a guest, the checks can be consolidated. The range set check are left in place just in case raw MMIO or I/O port ranges get passed to a guest.

xen/arch/x86/hvm/mtrr.c +3 -4
@@ -810,10 +810,9 @@ int epte_get_entry_emt(struct domain *d,
         return -1;
     }
 
-    if ( !iommu_enabled ||
-         (rangeset_is_empty(d->iomem_caps) &&
-          rangeset_is_empty(d->arch.ioport_caps) &&
-          !has_arch_pdevs(d)) )
+    if ( !need_iommu(d) &&
+         rangeset_is_empty(d->iomem_caps) &&
+         rangeset_is_empty(d->arch.ioport_caps) )
     {
         ASSERT(!direct_mmio ||
                !((mfn_x(mfn) ^ d->arch.hvm_domain.vmx.apic_access_mfn) >>

x86/EPT: refine direct MMIO checking when determining EMT

With need_iommu() only ever true when iommu_enabled is also true, and with the former getting set when a PCI device gets added to a guest, the checks can be consolidated. The range set check are left in place just in case raw MMIO or I/O port ranges get passed to a guest.

xen/arch/x86/hvm/mtrr.c +3 -4
@@ -810,10 +810,9 @@ int epte_get_entry_emt(struct domain *d,
         return -1;
     }
 
-    if ( !iommu_enabled ||
-         (rangeset_is_empty(d->iomem_caps) &&
-          rangeset_is_empty(d->arch.ioport_caps) &&
-          !has_arch_pdevs(d)) )
+    if ( !need_iommu(d) &&
+         rangeset_is_empty(d->iomem_caps) &&
+         rangeset_is_empty(d->arch.ioport_caps) )
     {
         ASSERT(!direct_mmio ||
                !((mfn_x(mfn) ^ d->arch.hvm_domain.vmx.apic_access_mfn) >>

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#4 lore raw

PATCH v2 2/4 x86/EPT: refine direct MMIO checking when determining EMT

With need_iommu() only ever true when iommu_enabled is also true, and with the former getting set when a PCI device gets added to a guest, the checks can be consolidated. The range set check are left in place just in case raw MMIO or I/O port ranges get passed to a guest.

At once drop open-coding of cache_flush_permitted().

---
v2: Also drop open-coding of cache_flush_permitted().

xen/arch/x86/hvm/mtrr.c +2 -4
@@ -20,6 +20,7 @@
 #include <public/hvm/e820.h>
 #include <xen/types.h>
 #include <asm/e820.h>
+#include <asm/iocap.h>
 #include <asm/mm.h>
 #include <asm/paging.h>
 #include <asm/p2m.h>
@@ -810,10 +811,7 @@ int epte_get_entry_emt(struct domain *d,
         return -1;
     }
 
-    if ( !iommu_enabled ||
-         (rangeset_is_empty(d->iomem_caps) &&
-          rangeset_is_empty(d->arch.ioport_caps) &&
-          !has_arch_pdevs(d)) )
+    if ( !need_iommu(d) && !cache_flush_permitted(d) )
     {
         ASSERT(!direct_mmio ||
                !((mfn_x(mfn) ^ d->arch.hvm_domain.vmx.apic_access_mfn) >>

x86/EPT: refine direct MMIO checking when determining EMT

With need_iommu() only ever true when iommu_enabled is also true, and with the former getting set when a PCI device gets added to a guest, the checks can be consolidated. The range set check are left in place just in case raw MMIO or I/O port ranges get passed to a guest.

At once drop open-coding of cache_flush_permitted().

---
v2: Also drop open-coding of cache_flush_permitted().

xen/arch/x86/hvm/mtrr.c +2 -4
@@ -20,6 +20,7 @@
 #include <public/hvm/e820.h>
 #include <xen/types.h>
 #include <asm/e820.h>
+#include <asm/iocap.h>
 #include <asm/mm.h>
 #include <asm/paging.h>
 #include <asm/p2m.h>
@@ -810,10 +811,7 @@ int epte_get_entry_emt(struct domain *d,
         return -1;
     }
 
-    if ( !iommu_enabled ||
-         (rangeset_is_empty(d->iomem_caps) &&
-          rangeset_is_empty(d->arch.ioport_caps) &&
-          !has_arch_pdevs(d)) )
+    if ( !need_iommu(d) && !cache_flush_permitted(d) )
     {
         ASSERT(!direct_mmio ||
                !((mfn_x(mfn) ^ d->arch.hvm_domain.vmx.apic_access_mfn) >>

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#5 lore raw

Re: [PATCH 2/4 v2] x86/EPT: refine direct MMIO checking when determining EMT

Quoted 25 lines

From: Jan Beulich [mailto:[email protected]]
Sent: Friday, April 25, 2014 8:06 PM

With need_iommu() only ever true when iommu_enabled is also true, and with the former getting set when a PCI device gets added to a guest, the checks can be consolidated. The range set check are left in place just in case raw MMIO or I/O port ranges get passed to a guest.

At once drop open-coding of cache_flush_permitted().

---
v2: Also drop open-coding of cache_flush_permitted().

xen/arch/x86/hvm/mtrr.c +1 -0
@@ -20,6 +20,7 @@
 #include <public/hvm/e820.h>
 #include <xen/types.h>
 #include <asm/e820.h>
+#include <asm/iocap.h>
 #include <asm/mm.h>
 #include <asm/paging.h>
 #include <asm/p2m.h>

xen/arch/x86/hvm/mtrr.c int epte_get_entry_emt(struct domain *d, · line 814

Quoted 8 lines
xen/arch/x86/hvm/mtrr.c +1 -4
@@ -810,10 +811,7 @@ int epte_get_entry_emt(struct domain *d,
         return -1;
     }
 
-    if ( !iommu_enabled ||
-         (rangeset_is_empty(d->iomem_caps) &&
-          rangeset_is_empty(d->arch.ioport_caps) &&
-          !has_arch_pdevs(d)) )
+    if ( !need_iommu(d) && !cache_flush_permitted(d) )

&&->||

Quoted 5 lines
xen/arch/x86/hvm/mtrr.c +0 -0
     {
         ASSERT(!direct_mmio ||
                !((mfn_x(mfn) ^

d->arch.hvm_domain.vmx.apic_access_mfn) >>

#6 lore raw

Re: [PATCH 2/4 v2] x86/EPT: refine direct MMIO checking when determining EMT

Quoted 6 lines
Quoted 6 lines
Quoted 1 line · On 28.04.14 at 09:59, <[email protected]> wrote:

From: Jan Beulich [mailto:[email protected]]

xen/arch/x86/hvm/mtrr.c +0 -0
@@ -810,10 +811,7 @@ int epte_get_entry_emt(struct domain *d,
         return -1;
     }
 
Quoted 7 lines

xen/arch/x86/hvm/mtrr.c int epte_get_entry_emt(struct domain *d, · line 814

Quoted 5 lines
xen/arch/x86/hvm/mtrr.c +1 -4
-    if ( !iommu_enabled ||
-         (rangeset_is_empty(d->iomem_caps) &&
-          rangeset_is_empty(d->arch.ioport_caps) &&
-          !has_arch_pdevs(d)) )
+    if ( !need_iommu(d) && !cache_flush_permitted(d) )

&&->||

No, specifically not - we shouldn't force WB in either case.

Jan

#7 lore raw

Re: [PATCH 2/4 v2] x86/EPT: refine direct MMIO checking when determining EMT

Quoted 17 lines

From: Jan Beulich [mailto:[email protected]]
Sent: Monday, April 28, 2014 4:25 PM

Quoted 6 lines
Quoted 6 lines
Quoted 1 line · On 28.04.14 at 09:59, <[email protected]> wrote:

From: Jan Beulich [mailto:[email protected]]

xen/arch/x86/hvm/mtrr.c +0 -0
@@ -810,10 +811,7 @@ int epte_get_entry_emt(struct domain *d,
         return -1;
     }
 
Quoted 7 lines

xen/arch/x86/hvm/mtrr.c int epte_get_entry_emt(struct domain *d, · line 814

Quoted 5 lines
xen/arch/x86/hvm/mtrr.c +1 -4
-    if ( !iommu_enabled ||
-         (rangeset_is_empty(d->iomem_caps) &&
-          rangeset_is_empty(d->arch.ioport_caps) &&
-          !has_arch_pdevs(d)) )
+    if ( !need_iommu(d) && !cache_flush_permitted(d) )

&&->||

Quoted 2 lines

No, specifically not - we shouldn't force WB in either case.

well, I gave original comments with the impression that it's a cleanup patch instead of fixing anything, e.g. iommu_enabled->need_iommu, and open-coding to cache_flush_permitted. Based on that thought, && changes original meaning.

so you actually fix the conditions here. I didn't follow up latest advance in device assignment recently. Could you elaborate in which situation I/O resources are assigned while iommu is not required?

Thanks
Kevin

#8 lore raw

Re: [PATCH 2/4 v2] x86/EPT: refine direct MMIO checking when determining EMT

Quoted 25 lines
Quoted 18 lines
Quoted 1 line · On 28.04.14 at 11:06, <[email protected]> wrote:

From: Jan Beulich [mailto:[email protected]]
Sent: Monday, April 28, 2014 4:25 PM

Quoted 6 lines
Quoted 6 lines
Quoted 1 line · On 28.04.14 at 09:59, <[email protected]> wrote:

From: Jan Beulich [mailto:[email protected]]

xen/arch/x86/hvm/mtrr.c +0 -0
@@ -810,10 +811,7 @@ int epte_get_entry_emt(struct domain *d,
         return -1;
     }
 
Quoted 7 lines

xen/arch/x86/hvm/mtrr.c int epte_get_entry_emt(struct domain *d, · line 814

Quoted 5 lines
xen/arch/x86/hvm/mtrr.c +1 -4
-    if ( !iommu_enabled ||
-         (rangeset_is_empty(d->iomem_caps) &&
-          rangeset_is_empty(d->arch.ioport_caps) &&
-          !has_arch_pdevs(d)) )
+    if ( !need_iommu(d) && !cache_flush_permitted(d) )

&&->||

Quoted 2 lines

No, specifically not - we shouldn't force WB in either case.

well, I gave original comments with the impression that it's a cleanup patch instead of fixing anything, e.g. iommu_enabled->need_iommu, and open-coding to cache_flush_permitted. Based on that thought, && changes original meaning.

Quoted 5 lines

so you actually fix the conditions here. I didn't follow up latest advance in device
assignment recently. Could you elaborate in which situation I/O resources are
assigned while iommu is not required?

It's not so much a question of "required": IOMMU setup only happens when a PCI device gets assigned to a guest. It specifically does not happen (and would make no sense, because the IOMMU concepts are PCI device based) when a raw MMIO or port range gets assigned. While the latter is insecure, I don't think we currently do anything to disallow this, and hence we shouldn't break it here.

Jan

#9 lore raw

Re: [PATCH 2/4 v2] x86/EPT: refine direct MMIO checking when determining EMT

Quoted 36 lines

From: Jan Beulich [mailto:[email protected]]
Sent: Monday, April 28, 2014 5:52 PM

Quoted 18 lines
Quoted 18 lines
Quoted 1 line · On 28.04.14 at 11:06, <[email protected]> wrote:

From: Jan Beulich [mailto:[email protected]]
Sent: Monday, April 28, 2014 4:25 PM

Quoted 13 lines

xen/arch/x86/hvm/mtrr.c int epte_get_entry_emt(struct domain *d, · line 814

Quoted 11 lines
Quoted 1 line · On 28.04.14 at 09:59, <[email protected]> wrote:

From: Jan Beulich [mailto:[email protected]]

xen/arch/x86/hvm/mtrr.c +1 -4
@@ -810,10 +811,7 @@ int epte_get_entry_emt(struct domain *d,
         return -1;
     }
 
-    if ( !iommu_enabled ||
-         (rangeset_is_empty(d->iomem_caps) &&
-          rangeset_is_empty(d->arch.ioport_caps) &&
-          !has_arch_pdevs(d)) )
+    if ( !need_iommu(d) && !cache_flush_permitted(d) )

&&->||

Quoted 5 lines
Quoted 2 lines

No, specifically not - we shouldn't force WB in either case.

well, I gave original comments with the impression that it's a cleanup patch instead of fixing anything, e.g. iommu_enabled->need_iommu, and

open-coding

Quoted 1 line

to cache_flush_permitted. Based on that thought, && changes original

meaning.

Quoted 6 lines

so you actually fix the conditions here. I didn't follow up latest advance in device
assignment recently. Could you elaborate in which situation I/O resources are
assigned while iommu is not required?

Quoted 7 lines

It's not so much a question of "required": IOMMU setup only happens when a PCI device gets assigned to a guest. It specifically does not happen (and would make no sense, because the IOMMU concepts are PCI device based) when a raw MMIO or port range gets assigned. While the latter is insecure, I don't think we currently do anything to disallow this, and hence we shouldn't break it here.

Got it. Acked-by: Kevin Tian <[email protected]>

Acked-by on v1 2/4
#10 lore raw

Re: [PATCH 2/4] x86/EPT: refine direct MMIO checking when determining EMT

In reply to Jan Beulich
Quoted 9 lines

From: Jan Beulich [mailto:[email protected]]
Sent: Wednesday, April 23, 2014 4:40 PM

With need_iommu() only ever true when iommu_enabled is also true, and with the former getting set when a PCI device gets added to a guest, the checks can be consolidated. The range set check are left in place just in case raw MMIO or I/O port ranges get passed to a guest.

Quoted 20 lines
xen/arch/x86/hvm/mtrr.c +3 -4
@@ -810,10 +810,9 @@ int epte_get_entry_emt(struct domain *d,
         return -1;
     }
 
-    if ( !iommu_enabled ||
-         (rangeset_is_empty(d->iomem_caps) &&
-          rangeset_is_empty(d->arch.ioport_caps) &&
-          !has_arch_pdevs(d)) )
+    if ( !need_iommu(d) &&
+         rangeset_is_empty(d->iomem_caps) &&
+         rangeset_is_empty(d->arch.ioport_caps) )
     {
         ASSERT(!direct_mmio ||
                !((mfn_x(mfn) ^

d->arch.hvm_domain.vmx.apic_access_mfn) >>

#11 lore raw

PATCH 3/4 x86/EPT: fix pinned cache attribute range checking

In reply to Jan Beulich

This wasn't done properly by 4d66f069 ("x86: fix pinned cache attribute handling"): The passed in GFN shouldn't be assumed to be order aligned.

xen/arch/x86/hvm/mtrr.c +5 -4
@@ -589,6 +589,7 @@ int hvm_get_mem_pinned_cacheattr(
     uint32_t *type)
 {
     struct hvm_mem_pinned_cacheattr_range *range;
+    uint64_t mask = ~(uint64_t)0 << order;
     int rc = 0;
 
     *type = ~0;
@@ -601,15 +602,15 @@ int hvm_get_mem_pinned_cacheattr(
                               &d->arch.hvm_domain.pinned_cacheattr_ranges,
                               list )
     {
-        if ( (guest_fn >= range->start) &&
-             (guest_fn + (1UL << order) - 1 <= range->end) )
+        if ( ((guest_fn & mask) >= range->start) &&
+             ((guest_fn | ~mask) <= range->end) )
         {
             *type = range->type;
             rc = 1;
             break;
         }
-        if ( (guest_fn <= range->end) &&
-             (range->start <= guest_fn + (1UL << order) - 1) )
+        if ( ((guest_fn & mask) <= range->end) &&
+             (range->start <= (guest_fn | ~mask)) )
         {
             rc = -1;
             break;

x86/EPT: fix pinned cache attribute range checking

This wasn't done properly by 4d66f069 ("x86: fix pinned cache attribute handling"): The passed in GFN shouldn't be assumed to be order aligned.

xen/arch/x86/hvm/mtrr.c +5 -4
@@ -589,6 +589,7 @@ int hvm_get_mem_pinned_cacheattr(
     uint32_t *type)
 {
     struct hvm_mem_pinned_cacheattr_range *range;
+    uint64_t mask = ~(uint64_t)0 << order;
     int rc = 0;
 
     *type = ~0;
@@ -601,15 +602,15 @@ int hvm_get_mem_pinned_cacheattr(
                               &d->arch.hvm_domain.pinned_cacheattr_ranges,
                               list )
     {
-        if ( (guest_fn >= range->start) &&
-             (guest_fn + (1UL << order) - 1 <= range->end) )
+        if ( ((guest_fn & mask) >= range->start) &&
+             ((guest_fn | ~mask) <= range->end) )
         {
             *type = range->type;
             rc = 1;
             break;
         }
-        if ( (guest_fn <= range->end) &&
-             (range->start <= guest_fn + (1UL << order) - 1) )
+        if ( ((guest_fn & mask) <= range->end) &&
+             (range->start <= (guest_fn | ~mask)) )
         {
             rc = -1;
             break;

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

Acked-by on v1 3/4
#12 lore raw

Re: [PATCH 3/4] x86/EPT: fix pinned cache attribute range checking

Quoted 7 lines

From: Jan Beulich [mailto:[email protected]]
Sent: Wednesday, April 23, 2014 4:41 PM

This wasn't done properly by 4d66f069 ("x86: fix pinned cache attribute handling"): The passed in GFN shouldn't be assumed to be order aligned.

Quoted 34 lines
xen/arch/x86/hvm/mtrr.c +5 -4
@@ -589,6 +589,7 @@ int hvm_get_mem_pinned_cacheattr(
     uint32_t *type)
 {
     struct hvm_mem_pinned_cacheattr_range *range;
+    uint64_t mask = ~(uint64_t)0 << order;
     int rc = 0;
 
     *type = ~0;
@@ -601,15 +602,15 @@ int hvm_get_mem_pinned_cacheattr(
 
 &d->arch.hvm_domain.pinned_cacheattr_ranges,
                               list )
     {
-        if ( (guest_fn >= range->start) &&
-             (guest_fn + (1UL << order) - 1 <= range->end) )
+        if ( ((guest_fn & mask) >= range->start) &&
+             ((guest_fn | ~mask) <= range->end) )
         {
             *type = range->type;
             rc = 1;
             break;
         }
-        if ( (guest_fn <= range->end) &&
-             (range->start <= guest_fn + (1UL << order) - 1) )
+        if ( ((guest_fn & mask) <= range->end) &&
+             (range->start <= (guest_fn | ~mask)) )
         {
             rc = -1;
             break;
#13 lore raw

PATCH 4/4 x86/EPT: also force EMT re-evaluation if pinned ranges change

In reply to Jan Beulich

This was inadvertently left out of aa9114ed ("x86/EPT: force re-evaluation of memory type as necessary"). Note that this intentionally doesn't use memory_type_changed(): Changes to the pinned ranges are independent of IOMMU presence, which that function uses to determine whether to call the underlying p2m_memory_type_changed().

xen/arch/x86/hvm/mtrr.c +2 -0
@@ -650,6 +650,7 @@ int32_t hvm_set_mem_pinned_cacheattr(
                 rcu_read_unlock(&pinned_cacheattr_rcu_lock);
                 list_del_rcu(&range->list);
                 call_rcu(&range->rcu, free_pinned_cacheattr_entry);
+                p2m_memory_type_changed(d);
                 return 0;
             }
         rcu_read_unlock(&pinned_cacheattr_rcu_lock);
@@ -695,6 +696,7 @@ int32_t hvm_set_mem_pinned_cacheattr(
     range->type = type;
 
     list_add_rcu(&range->list, &d->arch.hvm_domain.pinned_cacheattr_ranges);
+    p2m_memory_type_changed(d);
 
     return 0;
 }

x86/EPT: also force EMT re-evaluation if pinned ranges change

This was inadvertently left out of aa9114ed ("x86/EPT: force re-evaluation of memory type as necessary"). Note that this intentionally doesn't use memory_type_changed(): Changes to the pinned ranges are independent of IOMMU presence, which that function uses to determine whether to call the underlying p2m_memory_type_changed().

xen/arch/x86/hvm/mtrr.c +2 -0
@@ -650,6 +650,7 @@ int32_t hvm_set_mem_pinned_cacheattr(
                 rcu_read_unlock(&pinned_cacheattr_rcu_lock);
                 list_del_rcu(&range->list);
                 call_rcu(&range->rcu, free_pinned_cacheattr_entry);
+                p2m_memory_type_changed(d);
                 return 0;
             }
         rcu_read_unlock(&pinned_cacheattr_rcu_lock);
@@ -695,6 +696,7 @@ int32_t hvm_set_mem_pinned_cacheattr(
     range->type = type;
 
     list_add_rcu(&range->list, &d->arch.hvm_domain.pinned_cacheattr_ranges);
+    p2m_memory_type_changed(d);
 
     return 0;
 }

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

Acked-by on v1 4/4
#14 lore raw

Re: [PATCH 4/4] x86/EPT: also force EMT re-evaluation if pinned ranges change

Quoted 10 lines

From: Jan Beulich [mailto:[email protected]]
Sent: Wednesday, April 23, 2014 4:42 PM

This was inadvertently left out of aa9114ed ("x86/EPT: force re-evaluation of memory type as necessary"). Note that this intentionally doesn't use memory_type_changed(): Changes to the pinned ranges are independent of IOMMU presence, which that function uses to determine whether to call the underlying p2m_memory_type_changed().

Quoted 22 lines
xen/arch/x86/hvm/mtrr.c +2 -0
@@ -650,6 +650,7 @@ int32_t hvm_set_mem_pinned_cacheattr(
                 rcu_read_unlock(&pinned_cacheattr_rcu_lock);
                 list_del_rcu(&range->list);
                 call_rcu(&range->rcu, free_pinned_cacheattr_entry);
+                p2m_memory_type_changed(d);
                 return 0;
             }
         rcu_read_unlock(&pinned_cacheattr_rcu_lock);
@@ -695,6 +696,7 @@ int32_t hvm_set_mem_pinned_cacheattr(
     range->type = type;
 
     list_add_rcu(&range->list,
 &d->arch.hvm_domain.pinned_cacheattr_ranges);
+    p2m_memory_type_changed(d);
 
     return 0;

}