x86/mm: fix a reference counting error in MMU_MACHPHYS_UPDATE

Any domain which can pass the XSM check against a translated guest can cause a
page reference to be leaked.

While shuffling the order of checks, drop the quite-pointless MEM_LOG().  This
brings the check in line with similar checks in the vicinity.

Discovered while reviewing the XSA-109/110 followup series.

This is XSA-113.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Tim Deegan <tim@xen.org>

Index: xen-4.1.4/xen/arch/x86/mm.c
===================================================================
--- xen-4.1.4.orig/xen/arch/x86/mm.c	2015-03-04 17:49:21.000000000 +0200
+++ xen-4.1.4/xen/arch/x86/mm.c	2015-03-04 17:49:23.000000000 +0200
@@ -3884,6 +3884,12 @@
 
         case MMU_MACHPHYS_UPDATE:
 
+            if ( unlikely(paging_mode_translate(pg_owner)) )
+            {
+                rc = -EINVAL;
+                break;
+            }
+
             mfn = req.ptr >> PAGE_SHIFT;
             gpfn = req.val;
 
@@ -3897,12 +3903,6 @@
                 break;
             }
 
-            if ( unlikely(paging_mode_translate(pg_owner)) )
-            {
-                MEM_LOG("Mach-phys update on auto-translate guest");
-                break;
-            }
-
             set_gpfn_from_mfn(mfn, gpfn);
             okay = 1;
 
