Skip to contentSkip to conversation

xen/p2m: Fix p2m_flush_table for non-nested cases

PATCH In review George Dunlap 3 participants 4 messages Feb 8, 2017

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 xen/p2m: Fix p2m_flush_table for non-nested cases

Commit 71bb7304e7a7a35ea6df4b0cedebc35028e4c159 added flushing of nested p2m tables whenever the host p2m table changed. Unfortunately in the process, it added a filter to p2m_flush_table() function so that the p2m would only be flushed if it was being used as a nested p2m. This meant that the p2m was not being flushed at all for altp2m callers.

Only check np2m_base if p2m_class is set to p2m_nested.

NB that this is not a security issue: The only time this codepath is called is in cases where either nestedp2m or altp2m is enabled, and neither of them are in security support.

---
CC: Andrew Cooper <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Tim Deegan <[email protected]>
CC: Tamas K Lengyel <[email protected]>

---
 xen/arch/x86/mm/p2m.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
xen/arch/x86/mm/p2m.c +3 -1
index 6548e9f..0af2ec1 100644
@@ -1627,7 +1627,9 @@ p2m_flush_table(struct p2m_domain *p2m)
     ASSERT(page_list_empty(&p2m->pod.super));
     ASSERT(page_list_empty(&p2m->pod.single));
 
-    if ( p2m->np2m_base == P2M_BASE_EADDR )
+    /* No need to flush if it's already empty */
+    if ( p2m->p2m_class == p2m_nested &&
+         p2m->np2m_base == P2M_BASE_EADDR )
     {
         p2m_unlock(p2m);
         return;
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Reviewed-by on v2 1/1
#1 lore raw
Quoted 25 lines · George Dunlap

Commit 71bb7304e7a7a35ea6df4b0cedebc35028e4c159 added flushing of nested p2m tables whenever the host p2m table changed. Unfortunately in the process, it added a filter to p2m_flush_table() function so that the p2m would only be flushed if it was being used as a nested p2m. This meant that the p2m was not being flushed at all for altp2m callers.

Only check np2m_base if p2m_class is set to p2m_nested.

NB that this is not a security issue: The only time this codepath is called is in cases where either nestedp2m or altp2m is enabled, and neither of them are in security support.

---
 xen/arch/x86/mm/p2m.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
xen/arch/x86/mm/p2m.c +0 -0
index 6548e9f..0af2ec1 100644

xen/arch/x86/mm/p2m.c p2m_flush_table(struct p2m_domain *p2m) · line 1632

Quoted 7 lines
xen/arch/x86/mm/p2m.c +3 -1
@@ -1627,7 +1627,9 @@ p2m_flush_table(struct p2m_domain *p2m)
     ASSERT(page_list_empty(&p2m->pod.super));
     ASSERT(page_list_empty(&p2m->pod.single));
 
-    if ( p2m->np2m_base == P2M_BASE_EADDR )
+    /* No need to flush if it's already empty */
+    if ( p2m->p2m_class == p2m_nested &&
+         p2m->np2m_base == P2M_BASE_EADDR )

Looks like p2m_is_nestedp2m(p2m) is the usual idiom. Either way:

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

#2 lore raw
Quoted 29 lines · Tim Deegan
Quoted 28 lines · George Dunlap

Commit 71bb7304e7a7a35ea6df4b0cedebc35028e4c159 added flushing of nested p2m tables whenever the host p2m table changed. Unfortunately in the process, it added a filter to p2m_flush_table() function so that the p2m would only be flushed if it was being used as a nested p2m. This meant that the p2m was not being flushed at all for altp2m callers.

Only check np2m_base if p2m_class is set to p2m_nested.

NB that this is not a security issue: The only time this codepath is called is in cases where either nestedp2m or altp2m is enabled, and neither of them are in security support.

---
 xen/arch/x86/mm/p2m.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
xen/arch/x86/mm/p2m.c +0 -0
index 6548e9f..0af2ec1 100644
@@ -1627,7 +1627,9 @@ p2m_flush_table(struct p2m_domain *p2m)
     ASSERT(page_list_empty(&p2m->pod.super));
     ASSERT(page_list_empty(&p2m->pod.single));
 
Quoted 8 lines

xen/arch/x86/mm/p2m.c p2m_flush_table(struct p2m_domain *p2m) · line 1632

Quoted 4 lines
xen/arch/x86/mm/p2m.c +3 -1
-    if ( p2m->np2m_base == P2M_BASE_EADDR )
+    /* No need to flush if it's already empty */
+    if ( p2m->p2m_class == p2m_nested &&
+         p2m->np2m_base == P2M_BASE_EADDR )

Looks like p2m_is_nestedp2m(p2m) is the usual idiom. Either way:

Right -- I'll change it to the usual idiom and check it in after I've gotten a test report (or waited a reasonable amount of time).

-George

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

Tested-by Tamas K Lengyel
#3 lore raw
Quoted 37 lines · George Dunlap
Quoted 36 lines · Tim Deegan
Quoted 25 lines · George Dunlap

Commit 71bb7304e7a7a35ea6df4b0cedebc35028e4c159 added flushing of nested p2m tables whenever the host p2m table changed. Unfortunately in the process, it added a filter to p2m_flush_table() function so that the p2m would only be flushed if it was being used as a nested p2m. This meant that the p2m was not being flushed at all for altp2m callers.

Only check np2m_base if p2m_class is set to p2m_nested.

NB that this is not a security issue: The only time this codepath is called is in cases where either nestedp2m or altp2m is enabled, and neither of them are in security support.

---
 xen/arch/x86/mm/p2m.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
xen/arch/x86/mm/p2m.c +0 -0
index 6548e9f..0af2ec1 100644

xen/arch/x86/mm/p2m.c p2m_flush_table(struct p2m_domain *p2m) · line 1632

Quoted 7 lines
xen/arch/x86/mm/p2m.c +3 -1
@@ -1627,7 +1627,9 @@ p2m_flush_table(struct p2m_domain *p2m)
     ASSERT(page_list_empty(&p2m->pod.super));
     ASSERT(page_list_empty(&p2m->pod.single));
 
-    if ( p2m->np2m_base == P2M_BASE_EADDR )
+    /* No need to flush if it's already empty */
+    if ( p2m->p2m_class == p2m_nested &&
+         p2m->np2m_base == P2M_BASE_EADDR )

Looks like p2m_is_nestedp2m(p2m) is the usual idiom. Either way:

Quoted 4 lines
Quoted 1 line

Right -- I'll change it to the usual idiom and check it in after I've gotten a test report (or waited a reasonable amount of time).

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