vmm(4): reorder segment registers to match SDM.
authordv <dv@openbsd.org>
Sat, 6 Jan 2024 13:17:20 +0000 (13:17 +0000)
committerdv <dv@openbsd.org>
Sat, 6 Jan 2024 13:17:20 +0000 (13:17 +0000)
Shuffles around the defines so the segment register indexes match
the values used by both Intel and AMD in vm exit information.
Simplifies some upcoming changes.

ok mlarkin@

sys/arch/amd64/amd64/vmm_machdep.c
sys/arch/amd64/include/vmmvar.h

index 8d85574..eafbcf8 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: vmm_machdep.c,v 1.12 2023/12/10 21:25:14 dv Exp $ */
+/* $OpenBSD: vmm_machdep.c,v 1.13 2024/01/06 13:17:20 dv Exp $ */
 /*
  * Copyright (c) 2014 Mike Larkin <mlarkin@openbsd.org>
  *
@@ -213,18 +213,18 @@ const struct {
        uint64_t arid;
        uint64_t baseid;
 } vmm_vmx_sreg_vmcs_fields[] = {
+       { VMCS_GUEST_IA32_ES_SEL, VMCS_GUEST_IA32_ES_LIMIT,
+         VMCS_GUEST_IA32_ES_AR, VMCS_GUEST_IA32_ES_BASE },
        { VMCS_GUEST_IA32_CS_SEL, VMCS_GUEST_IA32_CS_LIMIT,
          VMCS_GUEST_IA32_CS_AR, VMCS_GUEST_IA32_CS_BASE },
+       { VMCS_GUEST_IA32_SS_SEL, VMCS_GUEST_IA32_SS_LIMIT,
+         VMCS_GUEST_IA32_SS_AR, VMCS_GUEST_IA32_SS_BASE },
        { VMCS_GUEST_IA32_DS_SEL, VMCS_GUEST_IA32_DS_LIMIT,
          VMCS_GUEST_IA32_DS_AR, VMCS_GUEST_IA32_DS_BASE },
-       { VMCS_GUEST_IA32_ES_SEL, VMCS_GUEST_IA32_ES_LIMIT,
-         VMCS_GUEST_IA32_ES_AR, VMCS_GUEST_IA32_ES_BASE },
        { VMCS_GUEST_IA32_FS_SEL, VMCS_GUEST_IA32_FS_LIMIT,
          VMCS_GUEST_IA32_FS_AR, VMCS_GUEST_IA32_FS_BASE },
        { VMCS_GUEST_IA32_GS_SEL, VMCS_GUEST_IA32_GS_LIMIT,
          VMCS_GUEST_IA32_GS_AR, VMCS_GUEST_IA32_GS_BASE },
-       { VMCS_GUEST_IA32_SS_SEL, VMCS_GUEST_IA32_SS_LIMIT,
-         VMCS_GUEST_IA32_SS_AR, VMCS_GUEST_IA32_SS_BASE },
        { VMCS_GUEST_IA32_LDTR_SEL, VMCS_GUEST_IA32_LDTR_LIMIT,
          VMCS_GUEST_IA32_LDTR_AR, VMCS_GUEST_IA32_LDTR_BASE },
        { VMCS_GUEST_IA32_TR_SEL, VMCS_GUEST_IA32_TR_LIMIT,
index 0047143..5f66201 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: vmmvar.h,v 1.95 2023/11/28 00:17:48 dv Exp $  */
+/*     $OpenBSD: vmmvar.h,v 1.96 2024/01/06 13:17:20 dv Exp $  */
 /*
  * Copyright (c) 2014 Mike Larkin <mlarkin@openbsd.org>
  *
@@ -397,12 +397,12 @@ struct vcpu_segment_info {
 #define VCPU_REGS_PDPTE3       9
 #define VCPU_REGS_NCRS         (VCPU_REGS_PDPTE3 + 1)
 
-#define VCPU_REGS_CS           0
-#define VCPU_REGS_DS           1
-#define VCPU_REGS_ES           2
-#define VCPU_REGS_FS           3
-#define VCPU_REGS_GS           4
-#define VCPU_REGS_SS           5
+#define VCPU_REGS_ES           0
+#define VCPU_REGS_CS           1
+#define VCPU_REGS_SS           2
+#define VCPU_REGS_DS           3
+#define VCPU_REGS_FS           4
+#define VCPU_REGS_GS           5
 #define VCPU_REGS_LDTR         6
 #define VCPU_REGS_TR           7
 #define VCPU_REGS_NSREGS       (VCPU_REGS_TR + 1)