changeset:   24318:f25a004a6de8
user:        Andres Lagar-Cavilla <andres@lagarcavilla.org>
date:        Thu Dec 01 17:21:24 2011 +0000
files:       xen/arch/x86/mm.c
description:
x86/mm: Fix checks during foreign mapping of paged pages

Check that the valid mfn is the one we are mapping, not the
mfn of the page table of the foreign domain.

Signed-off-by: Andres Lagar-Cavilla <andres@lagarcavilla.org>
Acked-by: Tim Deegan <tim@xen.org>
Committed-by: Tim Deegan <tim@xen.org>


---
 xen/arch/x86/mm.c |   24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

Index: xen-4.1.3-testing/xen/arch/x86/mm.c
===================================================================
--- xen-4.1.3-testing.orig/xen/arch/x86/mm.c
+++ xen-4.1.3-testing/xen/arch/x86/mm.c
@@ -3494,8 +3494,9 @@ int do_mmu_update(
                 {
                     l1_pgentry_t l1e = l1e_from_intpte(req.val);
                     p2m_type_t l1e_p2mt;
+		    unsigned long l1emfn = mfn_x(
                     gfn_to_mfn(p2m_get_hostp2m(pg_owner),
-                        l1e_get_pfn(l1e), &l1e_p2mt);
+                        l1e_get_pfn(l1e), &l1e_p2mt));
 
                     if ( p2m_is_paged(l1e_p2mt) )
                     {
@@ -3504,7 +3505,8 @@ int do_mmu_update(
                         rc = -ENOENT;
                         break;
                     }
-                    else if ( p2m_ram_paging_in_start == l1e_p2mt && !mfn_valid(mfn) )
+                    else if ( p2m_ram_paging_in_start == l1e_p2mt &&
+                                !mfn_valid(l1emfn) )
                     {
                         rc = -ENOENT;
                         break;
@@ -3536,7 +3538,8 @@ int do_mmu_update(
                 {
                     l2_pgentry_t l2e = l2e_from_intpte(req.val);
                     p2m_type_t l2e_p2mt;
-                    gfn_to_mfn(p2m_get_hostp2m(pg_owner), l2e_get_pfn(l2e), &l2e_p2mt);
+		    unsigned long l2emfn = mfn_x(
+                    gfn_to_mfn(p2m_get_hostp2m(pg_owner), l2e_get_pfn(l2e), &l2e_p2mt));
 
                     if ( p2m_is_paged(l2e_p2mt) )
                     {
@@ -3545,7 +3548,8 @@ int do_mmu_update(
                         rc = -ENOENT;
                         break;
                     }
-                    else if ( p2m_ram_paging_in_start == l2e_p2mt && !mfn_valid(mfn) )
+                    else if ( p2m_ram_paging_in_start == l2e_p2mt &&
+                                !mfn_valid(l2emfn) )
                     {
                         rc = -ENOENT;
                         break;
@@ -3565,7 +3569,8 @@ int do_mmu_update(
                 {
                     l3_pgentry_t l3e = l3e_from_intpte(req.val);
                     p2m_type_t l3e_p2mt;
-                    gfn_to_mfn(p2m_get_hostp2m(pg_owner), l3e_get_pfn(l3e), &l3e_p2mt);
+		    unsigned long l3emfn = mfn_x(
+                    gfn_to_mfn(p2m_get_hostp2m(pg_owner), l3e_get_pfn(l3e), &l3e_p2mt));
 
                     if ( p2m_is_paged(l3e_p2mt) )
                     {
@@ -3574,7 +3579,8 @@ int do_mmu_update(
                         rc = -ENOENT;
                         break;
                     }
-                    else if ( p2m_ram_paging_in_start == l3e_p2mt && !mfn_valid(mfn) )
+                    else if ( p2m_ram_paging_in_start == l3e_p2mt &&
+                                !mfn_valid(l3emfn) )
                     {
                         rc = -ENOENT;
                         break;
@@ -3594,8 +3600,9 @@ int do_mmu_update(
                 {
                     l4_pgentry_t l4e = l4e_from_intpte(req.val);
                     p2m_type_t l4e_p2mt;
+		    unsigned long l4emfn = mfn_x(
                     gfn_to_mfn(p2m_get_hostp2m(pg_owner),
-                        l4e_get_pfn(l4e), &l4e_p2mt);
+                        l4e_get_pfn(l4e), &l4e_p2mt));
 
                     if ( p2m_is_paged(l4e_p2mt) )
                     {
@@ -3604,7 +3611,8 @@ int do_mmu_update(
                         rc = -ENOENT;
                         break;
                     }
-                    else if ( p2m_ram_paging_in_start == l4e_p2mt && !mfn_valid(mfn) )
+                    else if ( p2m_ram_paging_in_start == l4e_p2mt &&
+                                !mfn_valid(l4emfn) )
                     {
                         rc = -ENOENT;
                         break;
