Skip to contentSkip to conversation

x86/vmx: Print the problematic MSR if a vmentry fails

PATCH Superseded Andrew Cooper 3 participants 12 messages Oct 13, 2016 – Oct 20, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 x86/vmx: Print the problematic MSR if a vmentry fails

Sample error looks like:

(XEN) Failed vm entry (exit reason 0x80000022) caused by MSR loading (entry 13).
(XEN) msr 0000068a, val 1fff800000102af0, (mbz 0)
(XEN) ************* VMCS Area **************

---
CC: Jan Beulich <[email protected]>
CC: Jun Nakajima <[email protected]>
CC: Kevin Tian <[email protected]>

---
 xen/arch/x86/hvm/vmx/vmx.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
xen/arch/x86/hvm/vmx/vmx.c +16 -1
index b9102ce..38cbcea 100644
@@ -3104,8 +3104,23 @@ static void vmx_failed_vmentry(unsigned int exit_reason,
         printk("caused by invalid guest state (%ld).\n", exit_qualification);
         break;
     case EXIT_REASON_MSR_LOADING:
-        printk("caused by MSR entry %ld loading.\n", exit_qualification);
+    {
+        unsigned long idx = exit_qualification - 1;
+        struct vmx_msr_entry *msr;
+
+        printk("caused by MSR loading (entry %ld).\n", idx);
+
+        if ( idx > (PAGE_SIZE / sizeof(*msr)) )
+            printk("  Entry out of range\n");
+        else
+        {
+            msr = &curr->arch.hvm_vmx.msr_area[idx];
+
+            printk("  msr %08x, val %016"PRIx64", (mbz %#x)\n",
+                   msr->index, msr->data, msr->mbz);
+        }
         break;
+    }
     case EXIT_REASON_MCE_DURING_VMENTRY:
         printk("caused by machine check.\n");
         HVMTRACE_0D(MCE);
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#1 lore raw

PATCH 2/2 x86/vmx: Reduce the verbosity of the vmentry failure error reporting

Identify the affected vcpu at the start of the message. While tweaking this area, add extra newlines between cases.

---
CC: Jan Beulich <[email protected]>
CC: Jun Nakajima <[email protected]>
CC: Kevin Tian <[email protected]>

---
 xen/arch/x86/hvm/vmx/vmx.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
xen/arch/x86/hvm/vmx/vmx.c +8 -5
index 38cbcea..554f9e8 100644
@@ -3096,19 +3096,20 @@ static void vmx_failed_vmentry(unsigned int exit_reason,
     unsigned long exit_qualification;
     struct vcpu *curr = current;
 
-    printk("Failed vm entry (exit reason %#x) ", exit_reason);
+    printk("%pv vmentry failure (reason %#x): ", curr, exit_reason);
     __vmread(EXIT_QUALIFICATION, &exit_qualification);
     switch ( failed_vmentry_reason )
     {
     case EXIT_REASON_INVALID_GUEST_STATE:
-        printk("caused by invalid guest state (%ld).\n", exit_qualification);
+        printk("Invalid guest state (%ld)\n", exit_qualification);
         break;
+
     case EXIT_REASON_MSR_LOADING:
     {
         unsigned long idx = exit_qualification - 1;
         struct vmx_msr_entry *msr;
 
-        printk("caused by MSR loading (entry %ld).\n", idx);
+        printk("MSR loading (entry %ld)\n", idx);
 
         if ( idx > (PAGE_SIZE / sizeof(*msr)) )
             printk("  Entry out of range\n");
@@ -3121,13 +3122,15 @@ static void vmx_failed_vmentry(unsigned int exit_reason,
         }
         break;
     }
+
     case EXIT_REASON_MCE_DURING_VMENTRY:
-        printk("caused by machine check.\n");
+        printk("MCE\n");
         HVMTRACE_0D(MCE);
         /* Already handled. */
         break;
+
     default:
-        printk("reason not known yet!");
+        printk("Unknown\n");
         break;
     }
 
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Reviewed-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] x86/vmx: Reduce the verbosity of the vmentry failure error reporting

Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 13.10.16 at 13:15, <[email protected]> wrote:

Identify the affected vcpu at the start of the message. While tweaking this area, add extra newlines between cases.

with ...

Quoted 4 lines
xen/arch/x86/hvm/vmx/vmx.c +0 -0
@@ -3096,19 +3096,20 @@ static void vmx_failed_vmentry(unsigned int exit_reason,
     unsigned long exit_qualification;

xen/arch/x86/hvm/vmx/vmx.c static void vmx_failed_vmentry(unsigned int exit_reason, · line 3104

Quoted 10 lines
xen/arch/x86/hvm/vmx/vmx.c +2 -2
     struct vcpu *curr = current;
 
-    printk("Failed vm entry (exit reason %#x) ", exit_reason);
+    printk("%pv vmentry failure (reason %#x): ", curr, exit_reason);
     __vmread(EXIT_QUALIFICATION, &exit_qualification);
     switch ( failed_vmentry_reason )
     {
     case EXIT_REASON_INVALID_GUEST_STATE:
-        printk("caused by invalid guest state (%ld).\n", exit_qualification);
+        printk("Invalid guest state (%ld)\n", exit_qualification);

... %lu here.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

Reviewed-by on v1 1/2
#3 lore raw
In reply to Andrew Cooper
Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 13.10.16 at 13:15, <[email protected]> wrote:

Sample error looks like:

(XEN) Failed vm entry (exit reason 0x80000022) caused by MSR loading (entry 13).
(XEN) msr 0000068a, val 1fff800000102af0, (mbz 0)
(XEN) ************* VMCS Area **************

with

xen/arch/x86/hvm/vmx/vmx.c static void vmx_failed_vmentry(unsigned int exit_reason, · line 3109

Quoted 10 lines
xen/arch/x86/hvm/vmx/vmx.c +3 -1
@@ -3104,8 +3104,23 @@ static void vmx_failed_vmentry(unsigned int exit_reason,
         printk("caused by invalid guest state (%ld).\n", exit_qualification);
         break;
     case EXIT_REASON_MSR_LOADING:
-        printk("caused by MSR entry %ld loading.\n", exit_qualification);
+    {
+        unsigned long idx = exit_qualification - 1;
+        struct vmx_msr_entry *msr;

... preferably const here (and the declaration perhaps moved into the more narrow scope it's needed in), ...

xen/arch/x86/hvm/vmx/vmx.c static void vmx_failed_vmentry(unsigned int exit_reason, · line 3111

Quoted 1 line
xen/arch/x86/hvm/vmx/vmx.c +1 -0
+        printk("caused by MSR loading (entry %ld).\n", idx);

... %lu (plus ideally the full stop dropped) here, and ...

xen/arch/x86/hvm/vmx/vmx.c static void vmx_failed_vmentry(unsigned int exit_reason, · line 3113

Quoted 1 line
xen/arch/x86/hvm/vmx/vmx.c +1 -0
+        if ( idx > (PAGE_SIZE / sizeof(*msr)) )

... >= here.

xen/arch/x86/hvm/vmx/vmx.c static void vmx_failed_vmentry(unsigned int exit_reason, · line 3119

Quoted 6 lines
xen/arch/x86/hvm/vmx/vmx.c +6 -0
+            printk("  Entry out of range\n");
+        else
+        {
+            msr = &curr->arch.hvm_vmx.msr_area[idx];
+
+            printk("  msr %08x, val %016"PRIx64", (mbz %#x)\n",

I'm also unsure about the usefulness of the commas here - at least the second one seems a little strange with the value in parentheses.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#4 lore raw
Quoted 11 lines · Jan Beulich
Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 13.10.16 at 13:15, <[email protected]> wrote:

Sample error looks like:

(XEN) Failed vm entry (exit reason 0x80000022) caused by MSR loading (entry 13).
(XEN) msr 0000068a, val 1fff800000102af0, (mbz 0)
(XEN) ************* VMCS Area **************

with

Quoted 11 lines

xen/arch/x86/hvm/vmx/vmx.c static void vmx_failed_vmentry(unsigned int exit_reason, · line 3109

Quoted 10 lines
xen/arch/x86/hvm/vmx/vmx.c +3 -1
@@ -3104,8 +3104,23 @@ static void vmx_failed_vmentry(unsigned int exit_reason,
         printk("caused by invalid guest state (%ld).\n", exit_qualification);
         break;
     case EXIT_REASON_MSR_LOADING:
-        printk("caused by MSR entry %ld loading.\n", exit_qualification);
+    {
+        unsigned long idx = exit_qualification - 1;
+        struct vmx_msr_entry *msr;

... preferably const here

Will do.

Quoted 2 lines

(and the declaration perhaps moved into
the more narrow scope it's needed in), ...

Cant, due to its use in the sizeof() expression. (I tried that first)

Quoted 3 lines

xen/arch/x86/hvm/vmx/vmx.c static void vmx_failed_vmentry(unsigned int exit_reason, · line 3111

Quoted 2 lines
xen/arch/x86/hvm/vmx/vmx.c +1 -0
+        printk("caused by MSR loading (entry %ld).\n", idx);

... %lu (plus ideally the full stop dropped) here, and ...

Ok for %lu. The full stop is dealt with in the following patch, so will leave this as-is for consistency of both patches.

Quoted 4 lines

xen/arch/x86/hvm/vmx/vmx.c static void vmx_failed_vmentry(unsigned int exit_reason, · line 3113

Quoted 2 lines
xen/arch/x86/hvm/vmx/vmx.c +1 -0
+        if ( idx > (PAGE_SIZE / sizeof(*msr)) )

... >= here.

Quoted 8 lines

xen/arch/x86/hvm/vmx/vmx.c static void vmx_failed_vmentry(unsigned int exit_reason, · line 3119

Quoted 6 lines
xen/arch/x86/hvm/vmx/vmx.c +6 -0
+            printk("  Entry out of range\n");
+        else
+        {
+            msr = &curr->arch.hvm_vmx.msr_area[idx];
+
+            printk("  msr %08x, val %016"PRIx64", (mbz %#x)\n",

I'm also unsure about the usefulness of the commas here - at least the second one seems a little strange with the value in parentheses.

Ok.

~Andrew

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#5 lore raw

PATCH v2 1/2 x86/vmx: Print the problematic MSR if a vmentry fails

In reply to Andrew Cooper

Sample error looks like:

(XEN) Failed vm entry (exit reason 0x80000022) caused by MSR loading (entry 13).
(XEN) msr 0000068a, val 1fff800000102af0, (mbz 0)
(XEN) ************* VMCS Area **************

---
CC: Jun Nakajima <[email protected]>
CC: Kevin Tian <[email protected]>

v2:
* const, %lu, remove some commas, boundary check

---
 xen/arch/x86/hvm/vmx/vmx.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
xen/arch/x86/hvm/vmx/vmx.c +16 -1
index b9102ce..b406989 100644
@@ -3104,8 +3104,23 @@ static void vmx_failed_vmentry(unsigned int exit_reason,
         printk("caused by invalid guest state (%ld).\n", exit_qualification);
         break;
     case EXIT_REASON_MSR_LOADING:
-        printk("caused by MSR entry %ld loading.\n", exit_qualification);
+    {
+        unsigned long idx = exit_qualification - 1;
+        const struct vmx_msr_entry *msr;
+
+        printk("caused by MSR loading (entry %lu).\n", idx);
+
+        if ( idx >= (PAGE_SIZE / sizeof(*msr)) )
+            printk("  Entry out of range\n");
+        else
+        {
+            msr = &curr->arch.hvm_vmx.msr_area[idx];
+
+            printk("  msr %08x val %016"PRIx64" (mbz %#x)\n",
+                   msr->index, msr->data, msr->mbz);
+        }
         break;
+    }
     case EXIT_REASON_MCE_DURING_VMENTRY:
         printk("caused by machine check.\n");
         HVMTRACE_0D(MCE);
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#6 lore raw

PATCH v2 2/2 x86/vmx: Reduce the verbosity of the vmentry failure error reporting

Identify the affected vcpu at the start of the message. While tweaking this area, add extra newlines between cases.

---
CC: Jun Nakajima <[email protected]>
CC: Kevin Tian <[email protected]>

v2:
* %lu

---
 xen/arch/x86/hvm/vmx/vmx.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
xen/arch/x86/hvm/vmx/vmx.c +8 -5
index b406989..db12cdb 100644
@@ -3096,19 +3096,20 @@ static void vmx_failed_vmentry(unsigned int exit_reason,
     unsigned long exit_qualification;
     struct vcpu *curr = current;
 
-    printk("Failed vm entry (exit reason %#x) ", exit_reason);
+    printk("%pv vmentry failure (reason %#x): ", curr, exit_reason);
     __vmread(EXIT_QUALIFICATION, &exit_qualification);
     switch ( failed_vmentry_reason )
     {
     case EXIT_REASON_INVALID_GUEST_STATE:
-        printk("caused by invalid guest state (%ld).\n", exit_qualification);
+        printk("Invalid guest state (%lu)\n", exit_qualification);
         break;
+
     case EXIT_REASON_MSR_LOADING:
     {
         unsigned long idx = exit_qualification - 1;
         const struct vmx_msr_entry *msr;
 
-        printk("caused by MSR loading (entry %lu).\n", idx);
+        printk("MSR loading (entry %lu)\n", idx);
 
         if ( idx >= (PAGE_SIZE / sizeof(*msr)) )
             printk("  Entry out of range\n");
@@ -3121,13 +3122,15 @@ static void vmx_failed_vmentry(unsigned int exit_reason,
         }
         break;
     }
+
     case EXIT_REASON_MCE_DURING_VMENTRY:
-        printk("caused by machine check.\n");
+        printk("MCE\n");
         HVMTRACE_0D(MCE);
         /* Already handled. */
         break;
+
     default:
-        printk("reason not known yet!");
+        printk("Unknown\n");
         break;
     }
 
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Acked-by on v2 2/2
#7 lore raw

Re: [PATCH v2 2/2] x86/vmx: Reduce the verbosity of the vmentry failure error reporting

Quoted 12 lines

From: Andrew Cooper [mailto:[email protected]]
Sent: Thursday, October 13, 2016 9:46 PM

Identify the affected vcpu at the start of the message. While tweaking this area, add extra newlines between cases.

---
CC: Jun Nakajima <[email protected]>
CC: Kevin Tian <[email protected]>

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#8 lore raw
In reply to Andrew Cooper
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 13.10.16 at 15:46, <[email protected]> wrote:

Sample error looks like:

(XEN) Failed vm entry (exit reason 0x80000022) caused by MSR loading (entry 13).
(XEN) msr 0000068a, val 1fff800000102af0, (mbz 0)

A _really_ minor remark: This is no longer in line with what gets actually logged.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#9 lore raw
Quoted 7 lines · Jan Beulich
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 13.10.16 at 15:46, <[email protected]> wrote:

Sample error looks like:

(XEN) Failed vm entry (exit reason 0x80000022) caused by MSR loading (entry 13).
(XEN) msr 0000068a, val 1fff800000102af0, (mbz 0)

A _really_ minor remark: This is no longer in line with what gets actually logged.

Oops yes. Fixed locally.

~Andrew

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

Acked-by
#10 lore raw
Quoted 7 lines

From: Andrew Cooper [mailto:[email protected]]
Sent: Friday, October 14, 2016 5:29 PM

Quoted 3 lines · Jan Beulich
Quoted 3 lines
Quoted 1 line
Quoted 1 line · On 13.10.16 at 15:46, <[email protected]> wrote:

Sample error looks like:

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

(XEN) Failed vm entry (exit reason 0x80000022) caused by MSR loading (entry 13).
(XEN) msr 0000068a, val 1fff800000102af0, (mbz 0)

A _really_ minor remark: This is no longer in line with what gets actually logged.

Oops yes. Fixed locally.

~Andrew

Sorry overlooked this patch. If still required,

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#11 lore raw
Quoted 9 lines · Kevin
Quoted 9 lines

From: Andrew Cooper [mailto:[email protected]]
Sent: Friday, October 14, 2016 5:29 PM

Quoted 5 lines · Jan Beulich
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 13.10.16 at 15:46, <[email protected]> wrote:

Sample error looks like:

(XEN) Failed vm entry (exit reason 0x80000022) caused by MSR loading (entry 13).
(XEN) msr 0000068a, val 1fff800000102af0, (mbz 0)

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

A _really_ minor remark: This is no longer in line with what gets actually logged.

Oops yes. Fixed locally.

~Andrew

Sorry overlooked this patch. If still required,

Thanks. (I was about to get around to pinging you)

~Andrew

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel