All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/mem_sharing: Rectify test for "empty" physmap entry in sharing_add_to_physmap
@ 2012-05-16 14:05 Andres Lagar-Cavilla
  2012-05-17  9:40 ` Tim Deegan
  0 siblings, 1 reply; 16+ messages in thread
From: Andres Lagar-Cavilla @ 2012-05-16 14:05 UTC (permalink / raw)
  To: xen-devel; +Cc: andres, tim

 xen/arch/x86/mm/mem_sharing.c |  7 ++++---
 xen/include/asm-x86/p2m.h     |  8 ++++++++
 2 files changed, 12 insertions(+), 3 deletions(-)


Signed-off-by: Andres Lagar-Cavilla <andres@lagarcavilla.org>

diff -r f83397dfb6c0 -r 3169fba29613 xen/arch/x86/mm/mem_sharing.c
--- a/xen/arch/x86/mm/mem_sharing.c
+++ b/xen/arch/x86/mm/mem_sharing.c
@@ -1073,9 +1073,10 @@ int mem_sharing_add_to_physmap(struct do
     if ( spage->sharing->handle != sh )
         goto err_unlock;
 
-    /* Make sure the target page is a hole in the physmap */
-    if ( mfn_valid(cmfn) ||
-         (!(p2m_is_ram(cmfn_type))) )
+    /* Make sure the target page is a hole in the physmap. These are typically
+     * p2m_mmio_dm, but also accept p2m_invalid and paged out pages. See the
+     * definition of p2m_is_hole in p2m.h. */
+    if ( !p2m_is_hole(cmfn_type) || mfn_valid(cmfn) )
     {
         ret = XENMEM_SHARING_OP_C_HANDLE_INVALID;
         goto err_unlock;
diff -r f83397dfb6c0 -r 3169fba29613 xen/include/asm-x86/p2m.h
--- a/xen/include/asm-x86/p2m.h
+++ b/xen/include/asm-x86/p2m.h
@@ -133,6 +133,13 @@ typedef unsigned int p2m_query_t;
                        | p2m_to_mask(p2m_ram_paging_in)       \
                        | p2m_to_mask(p2m_ram_shared))
 
+/* Types that represent a physmap hole that is ok to replace with a shared
+ * entry */
+#define P2M_HOLE_TYPES (p2m_to_mask(p2m_mmio_dm)        \
+                       | p2m_to_mask(p2m_invalid)       \
+                       | p2m_to_mask(p2m_ram_paging_in) \
+                       | p2m_to_mask(p2m_ram_paged))
+
 /* Grant mapping types, which map to a real machine frame in another
  * VM */
 #define P2M_GRANT_TYPES (p2m_to_mask(p2m_grant_map_rw)  \
@@ -173,6 +180,7 @@ typedef unsigned int p2m_query_t;
 
 /* Useful predicates */
 #define p2m_is_ram(_t) (p2m_to_mask(_t) & P2M_RAM_TYPES)
+#define p2m_is_hole(_t) (p2m_to_mask(_t) & P2M_HOLE_TYPES)
 #define p2m_is_mmio(_t) (p2m_to_mask(_t) & P2M_MMIO_TYPES)
 #define p2m_is_readonly(_t) (p2m_to_mask(_t) & P2M_RO_TYPES)
 #define p2m_is_magic(_t) (p2m_to_mask(_t) & P2M_MAGIC_TYPES)

^ permalink raw reply	[flat|nested] 16+ messages in thread
* [PATCH] x86/mem_sharing: Rectify test for "empty" physmap entry in sharing_add_to_physmap
@ 2012-04-18 13:06 Andres Lagar-Cavilla
  2012-04-18 13:59 ` Tim Deegan
  0 siblings, 1 reply; 16+ messages in thread
From: Andres Lagar-Cavilla @ 2012-04-18 13:06 UTC (permalink / raw)
  To: xen-devel; +Cc: andres, tim

 xen/arch/x86/mm/mem_sharing.c |  6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)


Signed-off-by: Andres Lagar-Cavilla <andres@lagarcavilla.org>

diff -r 8609bbbba141 -r 495d3df95c1d xen/arch/x86/mm/mem_sharing.c
--- a/xen/arch/x86/mm/mem_sharing.c
+++ b/xen/arch/x86/mm/mem_sharing.c
@@ -1073,9 +1073,11 @@ int mem_sharing_add_to_physmap(struct do
     if ( spage->sharing->handle != sh )
         goto err_unlock;
 
-    /* Make sure the target page is a hole in the physmap */
+    /* Make sure the target page is a hole in the physmap. This is not as
+     * simple a test as we'd like it to be. Non-existent p2m entries return
+     * invalid mfn and p2m_mmio_dm type when queried. */
     if ( mfn_valid(cmfn) ||
-         (!(p2m_is_ram(cmfn_type))) )
+         ( (!(p2m_is_ram(cmfn_type))) && (cmfn_type != p2m_mmio_dm) ) )
     {
         ret = XENMEM_SHARING_OP_C_HANDLE_INVALID;
         goto err_unlock;

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

end of thread, other threads:[~2012-05-23 16:17 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-16 14:05 [PATCH] x86/mem_sharing: Rectify test for "empty" physmap entry in sharing_add_to_physmap Andres Lagar-Cavilla
2012-05-17  9:40 ` Tim Deegan
2012-05-17 11:36   ` Andres Lagar-Cavilla
2012-05-17 12:02     ` Tim Deegan
2012-05-17 15:55       ` Andres Lagar-Cavilla
2012-05-18 15:22         ` Tim Deegan
2012-05-18 15:25           ` Andres Lagar-Cavilla
2012-05-23 14:34           ` Andres Lagar-Cavilla
2012-05-23 16:17             ` Tim Deegan
  -- strict thread matches above, loose matches on Subject: below --
2012-04-18 13:06 Andres Lagar-Cavilla
2012-04-18 13:59 ` Tim Deegan
2012-04-18 14:18   ` Andres Lagar-Cavilla
2012-04-18 15:01     ` Tim Deegan
2012-04-18 15:13       ` Andres Lagar-Cavilla
2012-04-18 15:17         ` Tim Deegan
2012-04-18 15:55           ` Andres Lagar-Cavilla

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.