File 5a1d5333-x86-check-paging-mode-earlier-in-xatp1.patch of Package xen.7317
# Commit f38f3dccf1e1a8aabcf57364326fc8f44cddc41a
# Date 2017-11-28 13:14:43 +0100
# Author Jan Beulich <jbeulich@suse.com>
# Committer Jan Beulich <jbeulich@suse.com>
x86: check paging mode earlier in xenmem_add_to_physmap_one()
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>
--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -4836,6 +4836,9 @@ int xenmem_add_to_physmap_one(
int rc = 0;
p2m_type_t p2mt;
+ if ( !paging_mode_translate(d) )
+ return -EACCES;
+
switch ( space )
{
case XENMAPSPACE_shared_info:
@@ -4890,7 +4893,7 @@ int xenmem_add_to_physmap_one(
break;
}
- if ( !paging_mode_translate(d) || (mfn == 0) )
+ if ( mfn == 0 )
{
if ( page )
put_page(page);