x86: check paging mode earlier in xenmem_add_to_physmap_one()
authorJan Beulich <jbeulich@suse.com>
Tue, 28 Nov 2017 12:14:43 +0000 (13:14 +0100)
committerJan Beulich <jbeulich@suse.com>
Tue, 28 Nov 2017 12:14:43 +0000 (13:14 +0100)
There's no point in deferring this until after some initial processing,
and it's actively wrong for the XENMAPSPACE_gmfn_foreign handling to not
have such a check at all.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: George Dunlap <george.dunlap@citrix.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
Release-acked-by: Julien Grall <julien.grall@linaro.org>
xen/arch/x86/mm.c

index 86c822d5771a45ecafcf6ad7fe16fe7bac6bfdad..6ec6e68afe61d4a0581ae4a6d1f4b5b8de1655f4 100644 (file)
@@ -4081,6 +4081,9 @@ int xenmem_add_to_physmap_one(
     mfn_t mfn = INVALID_MFN;
     p2m_type_t p2mt;
 
+    if ( !paging_mode_translate(d) )
+        return -EACCES;
+
     switch ( space )
     {
         case XENMAPSPACE_shared_info:
@@ -4117,7 +4120,7 @@ int xenmem_add_to_physmap_one(
             break;
     }
 
-    if ( !paging_mode_translate(d) || mfn_eq(mfn, INVALID_MFN) )
+    if ( mfn_eq(mfn, INVALID_MFN) )
     {
         rc = -EINVAL;
         goto put_both;