]> xenbits.xensource.com Git - people/liuw/xen.git/commitdiff
SVM: make nested page-fault tracing and logging consistent
authorJan Beulich <jbeulich@suse.com>
Tue, 12 Mar 2019 13:36:56 +0000 (14:36 +0100)
committerJan Beulich <jbeulich@suse.com>
Tue, 12 Mar 2019 13:36:56 +0000 (14:36 +0100)
Don't call __get_gfn_type_access() more than once, to make sure data
recorded for xentrace matches up with what gets logged in case of the
domain getting crashed.

As a side effect this also eliminates a type mismatch reported by
Norbert Manthey, as the first call now also needs to update the local
variable "p2mt".

Do a few cosmetics at the same time: Move a comment up a little, drop
the pointless "case 0" (seeing in particular the comment's wording),
and correct formatting.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
xen/arch/x86/hvm/svm/svm.c

index 23d72e81e38d1ea3538cd1bb50c73bcd6d9352d3..fec9be3ae0b577408eecaf4cb03c1f4e21a58289 100644 (file)
@@ -1797,17 +1797,18 @@ static void svm_do_nested_pgfault(struct vcpu *v,
         } _d;
 
         p2m = p2m_get_p2m(v);
+        mfn = __get_gfn_type_access(p2m, gfn, &p2mt, &p2ma, 0, NULL, 0);
+
         _d.gpa = gpa;
         _d.qualification = 0;
-        mfn = __get_gfn_type_access(p2m, gfn, &_d.p2mt, &p2ma, 0, NULL, 0);
         _d.mfn = mfn_x(mfn);
+        _d.p2mt = p2mt;
         
         __trace_var(TRC_HVM_NPF, 0, sizeof(_d), &_d);
     }
 
-    switch (ret) {
-    case 0:
-        break;
+    switch ( ret )
+    {
     case 1:
         return;
     case -1:
@@ -1817,10 +1818,12 @@ static void svm_do_nested_pgfault(struct vcpu *v,
         return;
     }
 
+    /* Everything else is an error. */
     if ( p2m == NULL )
+    {
         p2m = p2m_get_p2m(v);
-    /* Everything else is an error. */
-    mfn = __get_gfn_type_access(p2m, gfn, &p2mt, &p2ma, 0, NULL, 0);
+        mfn = __get_gfn_type_access(p2m, gfn, &p2mt, &p2ma, 0, NULL, 0);
+    }
     gdprintk(XENLOG_ERR,
          "SVM violation gpa %#"PRIpaddr", mfn %#lx, type %i\n",
          gpa, mfn_x(mfn), p2mt);