diff mbox series

[v1,7/7] xenalyze: handle more potential exit reason values from vmx.h

Message ID 20230601142742.15489-8-olaf@aepfle.de (mailing list archive)
State New, archived
Headers show
Series xentrace changes | expand

Commit Message

Olaf Hering June 1, 2023, 2:27 p.m. UTC
Copy and use more constants from vmx.h, to turn numbers into strings.
Adjust the REASON_MAX value accordingly.
Remove the size constraint from string array, the compiler will grow it
as needed.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
---
 tools/xentrace/xenalyze.c | 28 ++++++++++++++++++++++++----
 1 file changed, 24 insertions(+), 4 deletions(-)

Comments

George Dunlap July 28, 2023, 8:35 p.m. UTC | #1
On Thu, Jun 1, 2023 at 3:28 PM Olaf Hering <olaf@aepfle.de> wrote:

> Copy and use more constants from vmx.h, to turn numbers into strings.
> Adjust the REASON_MAX value accordingly.
> Remove the size constraint from string array, the compiler will grow it
> as needed.
>
> Signed-off-by: Olaf Hering <olaf@aepfle.de>
>

Thanks for doing this.

Everything looks good (including adding the missing strings), except for
the removal of the fixed array size.  Call me paranoid, but if we define it
as REASON_MAX length, then there will never be any way that a value less
than REASON_MAX causes a segfault (and if we assign a value higher than
REASON_MAX, the compiler will complain); whereas if we make it variable, we
leave open the possibility that someone won't update REASON_MAX properly,
resulting in either segfaults (if REASON_MAX is too high) or missing
strings (if REASON_MAX is too low).

 -George
Olaf Hering Aug. 1, 2023, 12:13 p.m. UTC | #2
Fri, 28 Jul 2023 21:35:54 +0100 George Dunlap <george.dunlap@cloud.com>:

> Everything looks good (including adding the missing strings), except for
> the removal of the fixed array size.  Call me paranoid, but if we define it
> as REASON_MAX length, then there will never be any way that a value less
> than REASON_MAX causes a segfault (and if we assign a value higher than
> REASON_MAX, the compiler will complain); whereas if we make it variable, we
> leave open the possibility that someone won't update REASON_MAX properly,
> resulting in either segfaults (if REASON_MAX is too high) or missing
> strings (if REASON_MAX is too low).

I think the code needs to be rearranged to work with "array_size" instead.


Olaf
diff mbox series

Patch

diff --git a/tools/xentrace/xenalyze.c b/tools/xentrace/xenalyze.c
index 9635ff453a..9af17d45bf 100644
--- a/tools/xentrace/xenalyze.c
+++ b/tools/xentrace/xenalyze.c
@@ -482,6 +482,7 @@  struct {
 #define EXIT_REASON_MCE_DURING_VMENTRY  41
 #define EXIT_REASON_TPR_BELOW_THRESHOLD 43
 #define EXIT_REASON_APIC_ACCESS         44
+#define EXIT_REASON_EOI_INDUCED         45
 #define EXIT_REASON_ACCESS_GDTR_OR_IDTR 46
 #define EXIT_REASON_ACCESS_LDTR_OR_TR   47
 #define EXIT_REASON_EPT_VIOLATION       48
@@ -492,10 +493,18 @@  struct {
 #define EXIT_REASON_INVVPID             53
 #define EXIT_REASON_WBINVD              54
 #define EXIT_REASON_XSETBV              55
-
-#define HVM_VMX_EXIT_REASON_MAX (EXIT_REASON_XSETBV+1)
-
-const char * hvm_vmx_exit_reason_name[HVM_VMX_EXIT_REASON_MAX] = {
+#define EXIT_REASON_APIC_WRITE          56
+#define EXIT_REASON_INVPCID             58
+#define EXIT_REASON_VMFUNC              59
+#define EXIT_REASON_PML_FULL            62
+#define EXIT_REASON_XSAVES              63
+#define EXIT_REASON_XRSTORS             64
+#define EXIT_REASON_BUS_LOCK            74
+#define EXIT_REASON_NOTIFY              75
+
+#define HVM_VMX_EXIT_REASON_MAX (EXIT_REASON_NOTIFY+1)
+
+const char * hvm_vmx_exit_reason_name[] = {
     [EXIT_REASON_EXCEPTION_NMI]="EXCEPTION_NMI",
     [EXIT_REASON_EXTERNAL_INTERRUPT]="EXTERNAL_INTERRUPT",
     [EXIT_REASON_TRIPLE_FAULT]="TRIPLE_FAULT",
@@ -538,6 +547,9 @@  const char * hvm_vmx_exit_reason_name[HVM_VMX_EXIT_REASON_MAX] = {
     [EXIT_REASON_MCE_DURING_VMENTRY]="MCE_DURING_VMENTRY",
     [EXIT_REASON_TPR_BELOW_THRESHOLD]="TPR_BELOW_THRESHOLD",
     [EXIT_REASON_APIC_ACCESS]="APIC_ACCESS",
+    [EXIT_REASON_EOI_INDUCED]="EOI_INDUCED",
+    [EXIT_REASON_ACCESS_GDTR_OR_IDTR]="ACCESS_GDTR_OR_IDTR",
+    [EXIT_REASON_ACCESS_LDTR_OR_TR]="ACCESS_LDTR_OR_TR",
     [EXIT_REASON_EPT_VIOLATION]="EPT_VIOLATION",
     [EXIT_REASON_EPT_MISCONFIG]="EPT_MISCONFIG",
     [EXIT_REASON_INVEPT]="INVEPT",
@@ -546,6 +558,14 @@  const char * hvm_vmx_exit_reason_name[HVM_VMX_EXIT_REASON_MAX] = {
     [EXIT_REASON_INVVPID]="INVVPID",
     [EXIT_REASON_WBINVD]="WBINVD",
     [EXIT_REASON_XSETBV]="XSETBV",
+    [EXIT_REASON_APIC_WRITE]="APIC_WRITE",
+    [EXIT_REASON_INVPCID]="INVPCID",
+    [EXIT_REASON_VMFUNC]="VMFUNC",
+    [EXIT_REASON_PML_FULL]="PML_FULL",
+    [EXIT_REASON_XSAVES]="XSAVES",
+    [EXIT_REASON_XRSTORS]="XRSTORS",
+    [EXIT_REASON_BUS_LOCK]="BUS_LOCK",
+    [EXIT_REASON_NOTIFY]="NOTIFY",
 };
 
 /* SVM data */