xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH for-4.6] p2m/ept: Set the A bit only if PML is enabled
@ 2015-09-16  8:47 Ross Lagerwall
  2015-09-16 14:46 ` Wei Liu
                   ` (2 more replies)
  0 siblings, 3 replies; 20+ messages in thread
From: Ross Lagerwall @ 2015-09-16  8:47 UTC (permalink / raw)
  To: xen-devel
  Cc: Kevin Tian, Keir Fraser, Jun Nakajima, George Dunlap,
	Andrew Cooper, Eddie Dong, Kai Huang, Ross Lagerwall, Jan Beulich,
	Wei Liu

Since commit 191b3f3344ee ("p2m/ept: enable PML in p2m-ept for
log-dirty"), the A and D bits of EPT paging entries are set
unconditionally, regardless of whether PML is enabled or not. This
causes a regression in Xen 4.6 on some processors due to Intel Errata
AVR41 -- HVM guests get severe memory corruption when the A bit is
set. The errata affects the Atom C2000 family (Avaton).

Instead, only set the bits if PML is enabled.
---
 xen/arch/x86/mm/p2m-ept.c | 38 ++++++++++++++++++++++++++------------
 1 file changed, 26 insertions(+), 12 deletions(-)

diff --git a/xen/arch/x86/mm/p2m-ept.c b/xen/arch/x86/mm/p2m-ept.c
index 2f3df91..4bea818 100644
--- a/xen/arch/x86/mm/p2m-ept.c
+++ b/xen/arch/x86/mm/p2m-ept.c
@@ -130,14 +130,18 @@ static void ept_p2m_type_to_flags(struct p2m_domain *p2m, ept_entry_t *entry,
             break;
         case p2m_ram_rw:
             entry->r = entry->w = entry->x = 1;
-            entry->a = entry->d = 1;
+            if ( vmx_domain_pml_enabled(p2m->domain) )
+                    entry->a = entry->d = 1;
             break;
         case p2m_mmio_direct:
             entry->r = entry->x = 1;
             entry->w = !rangeset_contains_singleton(mmio_ro_ranges,
                                                     entry->mfn);
-            entry->a = 1;
-            entry->d = entry->w;
+            if ( vmx_domain_pml_enabled(p2m->domain) )
+            {
+                entry->a = 1;
+                entry->d = entry->w;
+            }
             break;
         case p2m_ram_logdirty:
             entry->r = entry->x = 1;
@@ -152,29 +156,38 @@ static void ept_p2m_type_to_flags(struct p2m_domain *p2m, ept_entry_t *entry,
                 entry->w = 1;
             else
                 entry->w = 0;
-            entry->a = 1;
-            /* For both PML or non-PML cases we clear D bit anyway */
-            entry->d = 0;
+            if ( vmx_domain_pml_enabled(p2m->domain) )
+            {
+                entry->a = 1;
+                entry->d = 0;
+            }
             break;
         case p2m_ram_ro:
         case p2m_ram_shared:
             entry->r = entry->x = 1;
             entry->w = 0;
-            entry->a = 1;
-            entry->d = 0;
+            if ( vmx_domain_pml_enabled(p2m->domain) )
+            {
+                entry->a = 1;
+                entry->d = 0;
+            }
             break;
         case p2m_grant_map_rw:
         case p2m_map_foreign:
             entry->r = entry->w = 1;
             entry->x = 0;
-            entry->a = entry->d = 1;
+            if ( vmx_domain_pml_enabled(p2m->domain) )
+                entry->a = entry->d = 1;
             break;
         case p2m_grant_map_ro:
         case p2m_mmio_write_dm:
             entry->r = 1;
             entry->w = entry->x = 0;
-            entry->a = 1;
-            entry->d = 0;
+            if ( vmx_domain_pml_enabled(p2m->domain) )
+            {
+                entry->a = 1;
+                entry->d = 0;
+            }
             break;
     }
 
@@ -233,7 +246,8 @@ static int ept_set_middle_entry(struct p2m_domain *p2m, ept_entry_t *ept_entry)
 
     ept_entry->r = ept_entry->w = ept_entry->x = 1;
     /* Manually set A bit to avoid overhead of MMU having to write it later. */
-    ept_entry->a = 1;
+    if ( vmx_domain_pml_enabled(p2m->domain) )
+        ept_entry->a = 1;
 
     ept_entry->suppress_ve = 1;
 
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2015-09-28  8:42 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-16  8:47 [PATCH for-4.6] p2m/ept: Set the A bit only if PML is enabled Ross Lagerwall
2015-09-16 14:46 ` Wei Liu
2015-09-16 15:17   ` Ross Lagerwall
2015-09-16 15:23     ` Wei Liu
2015-09-16 19:47 ` Andrew Cooper
2015-09-21 12:30   ` Jan Beulich
2015-09-21 14:33   ` Tim Deegan
2015-09-23 15:18 ` Wei Liu
2015-09-23 15:28   ` Konrad Rzeszutek Wilk
2015-09-23 15:43   ` George Dunlap
2015-09-23 15:46   ` Tim Deegan
2015-09-24  7:02     ` Jan Beulich
2015-09-24  9:10       ` Tim Deegan
2015-09-24  9:13         ` Andrew Cooper
2015-09-24  9:20           ` Tim Deegan
2015-09-24  9:41           ` Jan Beulich
2015-09-24  9:33         ` Jan Beulich
2015-09-24 10:45           ` Wei Liu
2015-09-24 10:49             ` Wei Liu
2015-09-28  8:42         ` Kai Huang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).