Skip to contentSkip to conversation

x86/mm: do not mark IO regions as Xen heap

PATCH In review Roger Pau Monne 3 participants 14 messages Sep 10, 2020 – Sep 22, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/mm: do not mark IO regions as Xen heap

arch_init_memory will treat all the gaps on the physical memory map between RAM regions as MMIO and use share_xen_page_with_guest in order to assign them to dom_io. This has the side effect of setting the Xen heap flag on such pages, and thus is_special_page would then return true which is an issue in epte_get_entry_emt because such pages will be forced to use write-back cache attributes.

Fix this by introducing a new helper to assign the MMIO regions to dom_io without setting the Xen heap flag on the pages, so that is_special_page will return false and the pages won't be forced to use write-back cache attributes.

Fixes 81fd0d3ca4b2cd ('x86/hvm: simplify 'mmio_direct' check in epte_get_entry_emt()')

---
Cc: Paul Durrant <[email protected]>

---
 xen/arch/x86/mm.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)
xen/arch/x86/mm.c +14 -2
index 35ec0e11f6..4daf4e038a 100644
@@ -271,6 +271,18 @@ static l4_pgentry_t __read_mostly split_l4e;
 #define root_pgt_pv_xen_slots ROOT_PAGETABLE_PV_XEN_SLOTS
 #endif
 
+static void __init assign_io_page(struct page_info *page)
+{
+    set_gpfn_from_mfn(mfn_x(page_to_mfn(page)), INVALID_M2P_ENTRY);
+
+    /* The incremented type count pins as writable. */
+    page->u.inuse.type_info = PGT_writable_page | PGT_validated | 1;
+
+    page_set_owner(page, dom_io);
+
+    page->count_info |= PGC_allocated | 1;
+}
+
 void __init arch_init_memory(void)
 {
     unsigned long i, pfn, rstart_pfn, rend_pfn, iostart_pfn, ioend_pfn;
@@ -291,7 +303,7 @@ void __init arch_init_memory(void)
      */
     BUG_ON(pvh_boot && trampoline_phys != 0x1000);
     for ( i = 0; i < 0x100; i++ )
-        share_xen_page_with_guest(mfn_to_page(_mfn(i)), dom_io, SHARE_rw);
+        assign_io_page(mfn_to_page(_mfn(i)));
 
     /* Any areas not specified as RAM by the e820 map are considered I/O. */
     for ( i = 0, pfn = 0; pfn < max_page; i++ )
@@ -332,7 +344,7 @@ void __init arch_init_memory(void)
             if ( !mfn_valid(_mfn(pfn)) )
                 continue;
 
-            share_xen_page_with_guest(mfn_to_page(_mfn(pfn)), dom_io, SHARE_rw);
+            assign_io_page(mfn_to_page(_mfn(pfn)));
         }
 
         /* Skip the RAM region. */
Signature · 1 line
2.28.0
#1 lore raw
Quoted 62 lines

-----Original Message-----
From: Roger Pau Monne <[email protected]>
Sent: 10 September 2020 14:35
To: [email protected]
Cc: Roger Pau Monne <[email protected]>; Jan Beulich <[email protected]>; Andrew Cooper <[email protected]>; Wei Liu <[email protected]>; Paul Durrant <[email protected]>
Subject: [PATCH] x86/mm: do not mark IO regions as Xen heap

arch_init_memory will treat all the gaps on the physical memory map between RAM regions as MMIO and use share_xen_page_with_guest in order to assign them to dom_io. This has the side effect of setting the Xen heap flag on such pages, and thus is_special_page would then return true which is an issue in epte_get_entry_emt because such pages will be forced to use write-back cache attributes.

Fix this by introducing a new helper to assign the MMIO regions to dom_io without setting the Xen heap flag on the pages, so that is_special_page will return false and the pages won't be forced to use write-back cache attributes.

Fixes 81fd0d3ca4b2cd ('x86/hvm: simplify 'mmio_direct' check in epte_get_entry_emt()')

---
Cc: Paul Durrant <[email protected]>

---
 xen/arch/x86/mm.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)
xen/arch/x86/mm.c +13 -1
index 35ec0e11f6..4daf4e038a 100644
@@ -271,6 +271,18 @@ static l4_pgentry_t __read_mostly split_l4e;
 #define root_pgt_pv_xen_slots ROOT_PAGETABLE_PV_XEN_SLOTS
 #endif
 
+static void __init assign_io_page(struct page_info *page)
+{
+    set_gpfn_from_mfn(mfn_x(page_to_mfn(page)), INVALID_M2P_ENTRY);
+
+    /* The incremented type count pins as writable. */
+    page->u.inuse.type_info = PGT_writable_page | PGT_validated | 1;
+
+    page_set_owner(page, dom_io);
+
+    page->count_info |= PGC_allocated | 1;
+}
+
 void __init arch_init_memory(void)
 {
     unsigned long i, pfn, rstart_pfn, rend_pfn, iostart_pfn, ioend_pfn;
@@ -291,7 +303,7 @@ void __init arch_init_memory(void)
      */
     BUG_ON(pvh_boot && trampoline_phys != 0x1000);
     for ( i = 0; i < 0x100; i++ )
-        share_xen_page_with_guest(mfn_to_page(_mfn(i)), dom_io, SHARE_rw);
+        assign_io_page(mfn_to_page(_mfn(i)));
 
     /* Any areas not specified as RAM by the e820 map are considered I/O. */
     for ( i = 0, pfn = 0; pfn < max_page; i++ )

xen/arch/x86/mm.c void __init arch_init_memory(void) · line 347

Quoted 5 lines
xen/arch/x86/mm.c +1 -1
@@ -332,7 +344,7 @@ void __init arch_init_memory(void)
             if ( !mfn_valid(_mfn(pfn)) )
                 continue;
 
-            share_xen_page_with_guest(mfn_to_page(_mfn(pfn)), dom_io, SHARE_rw);
+            assign_io_page(mfn_to_page(_mfn(pfn)));

Now these calls to share_xen_page_with_guest() are gone, can we change share_xen_page_with_guest() to ASSERT that PGC_xen_heap is already set, and avoid (needlessly) ORing it in?

Paul

Quoted 5 lines
xen/arch/x86/mm.c +0 -1
         }
 
         /* Skip the RAM region. */
--

2.28.0

#2 lore raw
Quoted 16 lines · Paul Durrant
Quoted 16 lines

From: Roger Pau Monne <[email protected]>
Sent: 10 September 2020 14:35

xen/arch/x86/mm.c +1 -1
@@ -291,7 +303,7 @@ void __init arch_init_memory(void)
      */
     BUG_ON(pvh_boot && trampoline_phys != 0x1000);
     for ( i = 0; i < 0x100; i++ )
-        share_xen_page_with_guest(mfn_to_page(_mfn(i)), dom_io, SHARE_rw);
+        assign_io_page(mfn_to_page(_mfn(i)));
 
     /* Any areas not specified as RAM by the e820 map are considered I/O. */
     for ( i = 0, pfn = 0; pfn < max_page; i++ )
@@ -332,7 +344,7 @@ void __init arch_init_memory(void)
             if ( !mfn_valid(_mfn(pfn)) )
                 continue;
 
Quoted 6 lines

xen/arch/x86/mm.c void __init arch_init_memory(void) · line 347

Quoted 2 lines
xen/arch/x86/mm.c +1 -1
-            share_xen_page_with_guest(mfn_to_page(_mfn(pfn)), dom_io, SHARE_rw);
+            assign_io_page(mfn_to_page(_mfn(pfn)));

Now these calls to share_xen_page_with_guest() are gone, can we change share_xen_page_with_guest() to ASSERT that PGC_xen_heap is already set, and avoid (needlessly) ORing it in?

At least for the first use from pv_shim_setup_dom() I'm not sure this holds. I'm also uncertain we want to enforce this - it ought to be fine to hand a page allocated via alloc_domheap_page() to this function. The choice of alloc_xenheap_page() should be merely is an always mapped page is wanted (without extra effort to map).

Jan

Reviewed-by on v1 1/1
#3 lore raw
In reply to Roger Pau Monne
Quoted 7 lines · Roger Pau Monne

arch_init_memory will treat all the gaps on the physical memory map between RAM regions as MMIO and use share_xen_page_with_guest in order to assign them to dom_io. This has the side effect of setting the Xen heap flag on such pages, and thus is_special_page would then return true which is an issue in epte_get_entry_emt because such pages will be forced to use write-back cache attributes.

Quoted 8 lines

Fix this by introducing a new helper to assign the MMIO regions to dom_io without setting the Xen heap flag on the pages, so that is_special_page will return false and the pages won't be forced to use write-back cache attributes.

Fixes 81fd0d3ca4b2cd ('x86/hvm: simplify 'mmio_direct' check in epte_get_entry_emt()')

albeit I'm inclined to add, while committing, a comment ...

Quoted 7 lines
xen/arch/x86/mm.c +1 -0
@@ -271,6 +271,18 @@ static l4_pgentry_t __read_mostly split_l4e;
 #define root_pgt_pv_xen_slots ROOT_PAGETABLE_PV_XEN_SLOTS
 #endif
 
+static void __init assign_io_page(struct page_info *page)

xen/arch/x86/mm.c static l4_pgentry_t __read_mostly split_l4e; · line 284

Quoted 10 lines
xen/arch/x86/mm.c +10 -0
+{
+    set_gpfn_from_mfn(mfn_x(page_to_mfn(page)), INVALID_M2P_ENTRY);
+
+    /* The incremented type count pins as writable. */
+    page->u.inuse.type_info = PGT_writable_page | PGT_validated | 1;
+
+    page_set_owner(page, dom_io);
+
+    page->count_info |= PGC_allocated | 1;
+}

... clarifying its relationship with share_xen_page_with_guest().

Jan

#4 lore raw
Quoted 26 lines · Jan Beulich
Quoted 7 lines · Roger Pau Monne

arch_init_memory will treat all the gaps on the physical memory map between RAM regions as MMIO and use share_xen_page_with_guest in order to assign them to dom_io. This has the side effect of setting the Xen heap flag on such pages, and thus is_special_page would then return true which is an issue in epte_get_entry_emt because such pages will be forced to use write-back cache attributes.

Quoted 8 lines

Fix this by introducing a new helper to assign the MMIO regions to dom_io without setting the Xen heap flag on the pages, so that is_special_page will return false and the pages won't be forced to use write-back cache attributes.

Fixes 81fd0d3ca4b2cd ('x86/hvm: simplify 'mmio_direct' check in epte_get_entry_emt()')

albeit I'm inclined to add, while committing, a comment ...

Quoted 6 lines
xen/arch/x86/mm.c +0 -0
@@ -271,6 +271,18 @@ static l4_pgentry_t __read_mostly split_l4e;
 #define root_pgt_pv_xen_slots ROOT_PAGETABLE_PV_XEN_SLOTS
 #endif
 
Quoted 13 lines

xen/arch/x86/mm.c static l4_pgentry_t __read_mostly split_l4e; · line 284

Quoted 11 lines
xen/arch/x86/mm.c +11 -0
+static void __init assign_io_page(struct page_info *page)
+{
+    set_gpfn_from_mfn(mfn_x(page_to_mfn(page)), INVALID_M2P_ENTRY);
+
+    /* The incremented type count pins as writable. */
+    page->u.inuse.type_info = PGT_writable_page | PGT_validated | 1;
+
+    page_set_owner(page, dom_io);
+
+    page->count_info |= PGC_allocated | 1;
+}

... clarifying its relationship with share_xen_page_with_guest().

Sure, I think the relation is quite vague now, since this is no longer sharing the page (as it's not added to xenpage_list) but rather assigning it to dom_io.

In general I feel this is all quite confusing, and would benefit from having some clear rules about what flags and assigned domains non-RAM pages have, and how they should be added to the p2m.

Thanks, Roger.

#5 lore raw
Quoted 22 lines · Roger Pau Monné
Quoted 7 lines · Jan Beulich
Quoted 6 lines · Roger Pau Monne
xen/arch/x86/mm.c +0 -0
@@ -271,6 +271,18 @@ static l4_pgentry_t __read_mostly split_l4e;
 #define root_pgt_pv_xen_slots ROOT_PAGETABLE_PV_XEN_SLOTS
 #endif
 
Quoted 13 lines

xen/arch/x86/mm.c static l4_pgentry_t __read_mostly split_l4e; · line 284

Quoted 11 lines
xen/arch/x86/mm.c +11 -0
+static void __init assign_io_page(struct page_info *page)
+{
+    set_gpfn_from_mfn(mfn_x(page_to_mfn(page)), INVALID_M2P_ENTRY);
+
+    /* The incremented type count pins as writable. */
+    page->u.inuse.type_info = PGT_writable_page | PGT_validated | 1;
+
+    page_set_owner(page, dom_io);
+
+    page->count_info |= PGC_allocated | 1;
+}

... clarifying its relationship with share_xen_page_with_guest().

Quoted 7 lines

Sure, I think the relation is quite vague now, since this is no longer sharing the page (as it's not added to xenpage_list) but rather assigning it to dom_io.

In general I feel this is all quite confusing, and would benefit from having some clear rules about what flags and assigned domains non-RAM pages have, and how they should be added to the p2m.

Some might call this "organically grown" ... ;-)

Jan

#6 lore raw
In reply to Jan Beulich
Quoted 26 lines · Jan Beulich
Quoted 7 lines · Roger Pau Monne

arch_init_memory will treat all the gaps on the physical memory map between RAM regions as MMIO and use share_xen_page_with_guest in order to assign them to dom_io. This has the side effect of setting the Xen heap flag on such pages, and thus is_special_page would then return true which is an issue in epte_get_entry_emt because such pages will be forced to use write-back cache attributes.

Quoted 8 lines

Fix this by introducing a new helper to assign the MMIO regions to dom_io without setting the Xen heap flag on the pages, so that is_special_page will return false and the pages won't be forced to use write-back cache attributes.

Fixes 81fd0d3ca4b2cd ('x86/hvm: simplify 'mmio_direct' check in epte_get_entry_emt()')

albeit I'm inclined to add, while committing, a comment ...

Quoted 6 lines
xen/arch/x86/mm.c +0 -0
@@ -271,6 +271,18 @@ static l4_pgentry_t __read_mostly split_l4e;
 #define root_pgt_pv_xen_slots ROOT_PAGETABLE_PV_XEN_SLOTS
 #endif
 
Quoted 13 lines

xen/arch/x86/mm.c static l4_pgentry_t __read_mostly split_l4e; · line 284

Quoted 11 lines
xen/arch/x86/mm.c +11 -0
+static void __init assign_io_page(struct page_info *page)
+{
+    set_gpfn_from_mfn(mfn_x(page_to_mfn(page)), INVALID_M2P_ENTRY);
+
+    /* The incremented type count pins as writable. */
+    page->u.inuse.type_info = PGT_writable_page | PGT_validated | 1;
+
+    page_set_owner(page, dom_io);
+
+    page->count_info |= PGC_allocated | 1;
+}

... clarifying its relationship with share_xen_page_with_guest().

I'm also going to add an assertion to share_xen_page_with_guest() to document and make sure dom_io won't again be passed there.

Jan

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

arch_init_memory will treat all the gaps on the physical memory map between RAM regions as MMIO and use share_xen_page_with_guest in order to assign them to dom_io. This has the side effect of setting the Xen heap flag on such pages, and thus is_special_page would then return true which is an issue in epte_get_entry_emt because such pages will be forced to use write-back cache attributes.

Quoted 8 lines

Fix this by introducing a new helper to assign the MMIO regions to dom_io without setting the Xen heap flag on the pages, so that is_special_page will return false and the pages won't be forced to use write-back cache attributes.

Fixes 81fd0d3ca4b2cd ('x86/hvm: simplify 'mmio_direct' check in epte_get_entry_emt()')

I'm sorry for noticing this only now, but there is a place where we actually build on these pages being marked "special": In xenmem_add_to_physmap_one() we have

    if ( mfn_valid(prev_mfn) )
    {
        if ( is_special_page(mfn_to_page(prev_mfn)) )
            /* Special pages are simply unhooked from this phys slot. */
            rc = guest_physmap_remove_page(d, gpfn, prev_mfn, PAGE_ORDER_4K);
        else
            /* Normal domain memory is freed, to avoid leaking memory. */
            rc = guest_remove_page(d, gfn_x(gpfn));
    }

As you'll notice MMIO pages not satisfying mfn_valid() will simply bypass any updates here, but the subsequent guest_physmap_add_page() will have the P2M entry updated anyway. MMIO pages which satisfy mfn_valid(), however, would previously have been passed into guest_physmap_remove_page() (which generally would succeed) while now guest_remove_page() will (afaict) fail (get_page() there won't succeed).

I haven't come to a clear conclusion yet how best to address this.

Jan

#8 lore raw
Quoted 31 lines · Jan Beulich
Quoted 7 lines · Roger Pau Monne

arch_init_memory will treat all the gaps on the physical memory map between RAM regions as MMIO and use share_xen_page_with_guest in order to assign them to dom_io. This has the side effect of setting the Xen heap flag on such pages, and thus is_special_page would then return true which is an issue in epte_get_entry_emt because such pages will be forced to use write-back cache attributes.

Quoted 8 lines

Fix this by introducing a new helper to assign the MMIO regions to dom_io without setting the Xen heap flag on the pages, so that is_special_page will return false and the pages won't be forced to use write-back cache attributes.

Fixes 81fd0d3ca4b2cd ('x86/hvm: simplify 'mmio_direct' check in epte_get_entry_emt()')

I'm sorry for noticing this only now, but there is a place where we actually build on these pages being marked "special": In xenmem_add_to_physmap_one() we have

    if ( mfn_valid(prev_mfn) )
    {
        if ( is_special_page(mfn_to_page(prev_mfn)) )
            /* Special pages are simply unhooked from this phys slot. */
            rc = guest_physmap_remove_page(d, gpfn, prev_mfn, PAGE_ORDER_4K);
        else
            /* Normal domain memory is freed, to avoid leaking memory. */
            rc = guest_remove_page(d, gfn_x(gpfn));
    }
Quoted 7 lines

As you'll notice MMIO pages not satisfying mfn_valid() will simply bypass any updates here, but the subsequent guest_physmap_add_page() will have the P2M entry updated anyway. MMIO pages which satisfy mfn_valid(), however, would previously have been passed into guest_physmap_remove_page() (which generally would succeed) while now guest_remove_page() will (afaict) fail (get_page() there won't succeed).

Would Xen even get to the get_page in guest_remove_page on that case?

There's a p2m_mmio_direct type check that will succeed for MMIO ranges, and that just clears the p2m entry and returns before doing any get_page.

Roger.

#9 lore raw
Quoted 40 lines · Roger Pau Monné
Quoted 31 lines · Jan Beulich
Quoted 7 lines · Roger Pau Monne

arch_init_memory will treat all the gaps on the physical memory map between RAM regions as MMIO and use share_xen_page_with_guest in order to assign them to dom_io. This has the side effect of setting the Xen heap flag on such pages, and thus is_special_page would then return true which is an issue in epte_get_entry_emt because such pages will be forced to use write-back cache attributes.

Quoted 8 lines

Fix this by introducing a new helper to assign the MMIO regions to dom_io without setting the Xen heap flag on the pages, so that is_special_page will return false and the pages won't be forced to use write-back cache attributes.

Fixes 81fd0d3ca4b2cd ('x86/hvm: simplify 'mmio_direct' check in epte_get_entry_emt()')

I'm sorry for noticing this only now, but there is a place where we actually build on these pages being marked "special": In xenmem_add_to_physmap_one() we have

    if ( mfn_valid(prev_mfn) )
    {
        if ( is_special_page(mfn_to_page(prev_mfn)) )
            /* Special pages are simply unhooked from this phys slot. */
            rc = guest_physmap_remove_page(d, gpfn, prev_mfn, PAGE_ORDER_4K);
        else
            /* Normal domain memory is freed, to avoid leaking memory. */
            rc = guest_remove_page(d, gfn_x(gpfn));
    }
Quoted 7 lines

As you'll notice MMIO pages not satisfying mfn_valid() will simply bypass any updates here, but the subsequent guest_physmap_add_page() will have the P2M entry updated anyway. MMIO pages which satisfy mfn_valid(), however, would previously have been passed into guest_physmap_remove_page() (which generally would succeed) while now guest_remove_page() will (afaict) fail (get_page() there won't succeed).

Quoted 5 lines

Would Xen even get to the get_page in guest_remove_page on that case?

There's a p2m_mmio_direct type check that will succeed for MMIO ranges, and that just clears the p2m entry and returns before doing any get_page.

Oh, I did overlook this indeed.

Jan

#10 lore raw
In reply to Roger Pau Monne
Quoted 7 lines · Roger Pau Monne

arch_init_memory will treat all the gaps on the physical memory map between RAM regions as MMIO and use share_xen_page_with_guest in order to assign them to dom_io. This has the side effect of setting the Xen heap flag on such pages, and thus is_special_page would then return true which is an issue in epte_get_entry_emt because such pages will be forced to use write-back cache attributes.

Quoted 6 lines

Fix this by introducing a new helper to assign the MMIO regions to dom_io without setting the Xen heap flag on the pages, so that is_special_page will return false and the pages won't be forced to use write-back cache attributes.

Fixes 81fd0d3ca4b2cd ('x86/hvm: simplify 'mmio_direct' check in epte_get_entry_emt()')

Is this really the correct commit? I had this queued for backport, and ended up discarding it from the queue based on this tag, just to then noticing that I remembered correctly that I did backport ca24b2ffdbd9 ("x86/hvm: set 'ipat' in EPT for special pages") to the stable trees already. Isn't it _this_ commit which the change here fixes?

Jan

#11 lore raw
Quoted 13 lines · Jan Beulich
Quoted 12 lines · Roger Pau Monne

arch_init_memory will treat all the gaps on the physical memory map between RAM regions as MMIO and use share_xen_page_with_guest in order to assign them to dom_io. This has the side effect of setting the Xen heap flag on such pages, and thus is_special_page would then return true which is an issue in epte_get_entry_emt because such pages will be forced to use write-back cache attributes.

Fix this by introducing a new helper to assign the MMIO regions to dom_io without setting the Xen heap flag on the pages, so that is_special_page will return false and the pages won't be forced to use write-back cache attributes.

Quoted 8 lines
Quoted 1 line
Fixes 81fd0d3ca4b2cd ('x86/hvm: simplify 'mmio_direct' check in epte_get_entry_emt()')

Is this really the correct commit? I had this queued for backport, and ended up discarding it from the queue based on this tag, just to then noticing that I remembered correctly that I did backport ca24b2ffdbd9 ("x86/hvm: set 'ipat' in EPT for special pages") to the stable trees already. Isn't it _this_ commit which the change here fixes?

My bisection pointed to that exact commit as the one that broke my PVH dom0 setup, so yes, I'm quite sure that's the commit at least on the box that I've bisected it.

ca24b2ffdbd9 was still fine because previous to the is_special_page check loop there was still the if ( direct_mmio ) ... handling, which made all MMIO regions except for the APIC access page forcefully have it's cache attributes set to UC.

Roger.

#12 lore raw
Quoted 23 lines · Roger Pau Monné
Quoted 13 lines · Jan Beulich
Quoted 12 lines · Roger Pau Monne

arch_init_memory will treat all the gaps on the physical memory map between RAM regions as MMIO and use share_xen_page_with_guest in order to assign them to dom_io. This has the side effect of setting the Xen heap flag on such pages, and thus is_special_page would then return true which is an issue in epte_get_entry_emt because such pages will be forced to use write-back cache attributes.

Fix this by introducing a new helper to assign the MMIO regions to dom_io without setting the Xen heap flag on the pages, so that is_special_page will return false and the pages won't be forced to use write-back cache attributes.

Quoted 8 lines
Quoted 1 line
Fixes 81fd0d3ca4b2cd ('x86/hvm: simplify 'mmio_direct' check in epte_get_entry_emt()')

Is this really the correct commit? I had this queued for backport, and ended up discarding it from the queue based on this tag, just to then noticing that I remembered correctly that I did backport ca24b2ffdbd9 ("x86/hvm: set 'ipat' in EPT for special pages") to the stable trees already. Isn't it _this_ commit which the change here fixes?

Quoted 8 lines

My bisection pointed to that exact commit as the one that broke my PVH dom0 setup, so yes, I'm quite sure that's the commit at least on the box that I've bisected it.

ca24b2ffdbd9 was still fine because previous to the is_special_page check loop there was still the if ( direct_mmio ) ... handling, which made all MMIO regions except for the APIC access page forcefully have it's cache attributes set to UC.

Ah yes, I see - thanks. Makes me less sure whether the patch here really wants backporting. It's certainly an improvement in its own right to remove the difference between mfn_valid() and !mfn_valid() MMIO pages, leading e.g. to different treatment by _sh_propagate(). Will need to give this some more thought, and of course your and others thoughts would also be appreciated.

Jan

#13 lore raw
Quoted 28 lines · Jan Beulich
Quoted 27 lines · Roger Pau Monné
Quoted 13 lines · Jan Beulich
Quoted 12 lines · Roger Pau Monne

arch_init_memory will treat all the gaps on the physical memory map between RAM regions as MMIO and use share_xen_page_with_guest in order to assign them to dom_io. This has the side effect of setting the Xen heap flag on such pages, and thus is_special_page would then return true which is an issue in epte_get_entry_emt because such pages will be forced to use write-back cache attributes.

Fix this by introducing a new helper to assign the MMIO regions to dom_io without setting the Xen heap flag on the pages, so that is_special_page will return false and the pages won't be forced to use write-back cache attributes.

Quoted 8 lines
Quoted 1 line
Fixes 81fd0d3ca4b2cd ('x86/hvm: simplify 'mmio_direct' check in epte_get_entry_emt()')

Is this really the correct commit? I had this queued for backport, and ended up discarding it from the queue based on this tag, just to then noticing that I remembered correctly that I did backport ca24b2ffdbd9 ("x86/hvm: set 'ipat' in EPT for special pages") to the stable trees already. Isn't it _this_ commit which the change here fixes?

My bisection pointed to that exact commit as the one that broke my PVH dom0 setup, so yes, I'm quite sure that's the commit at least on the box that I've bisected it.

Quoted 7 lines
Quoted 4 lines

ca24b2ffdbd9 was still fine because previous to the is_special_page check loop there was still the if ( direct_mmio ) ... handling, which made all MMIO regions except for the APIC access page forcefully have it's cache attributes set to UC.

Ah yes, I see - thanks. Makes me less sure whether the patch here really wants backporting.

As long as 81fd0d3ca4b2cd is not backported, then I would argue to not backport this either. I don't see much benefit in backporting this alone, and the risk of introducing a non intended functionality change as a result of not marking MMIO pages as Xen heap is possible.

Thanks, Roger.