[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen master] x86/svm: Drop svm_segment_register_t



commit f93b6575d10fd4da91def2acf80cd5c1d7082e84
Author:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
AuthorDate: Fri Jun 30 12:12:00 2017 +0000
Commit:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
CommitDate: Tue Jul 25 19:56:35 2017 +0100

    x86/svm: Drop svm_segment_register_t
    
    Most SVM code already uses struct segment_register.  Drop the typedef and
    adjust the definitions in struct vmcb_struct, and svm_dump_sel().  Introduce
    some build-time assertions that struct segment_register from the common
    emulation code is usable in struct vmcb_struct.
    
    While making these adjustments, fix some comments to not mix decimal and
    hexidecimal offsets, and drop all trailing whitespace in vmcb.h
    
    No functional change.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
    Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
    Reviewed-by: Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx>
---
 xen/arch/x86/hvm/svm/svmdebug.c    |  2 +-
 xen/arch/x86/hvm/svm/vmcb.c        | 16 ++++++++++++++++
 xen/include/asm-x86/hvm/svm/vmcb.h | 37 +++++++++++++++++--------------------
 3 files changed, 34 insertions(+), 21 deletions(-)

diff --git a/xen/arch/x86/hvm/svm/svmdebug.c b/xen/arch/x86/hvm/svm/svmdebug.c
index a3f8685..4902824 100644
--- a/xen/arch/x86/hvm/svm/svmdebug.c
+++ b/xen/arch/x86/hvm/svm/svmdebug.c
@@ -21,7 +21,7 @@
 #include <asm/msr-index.h>
 #include <asm/hvm/svm/svmdebug.h>
 
-static void svm_dump_sel(const char *name, const svm_segment_register_t *s)
+static void svm_dump_sel(const char *name, const struct segment_register *s)
 {
     printk("%s: %04x %04x %08x %016"PRIx64"\n",
            name, s->sel, s->attr.bytes, s->limit, s->base);
diff --git a/xen/arch/x86/hvm/svm/vmcb.c b/xen/arch/x86/hvm/svm/vmcb.c
index 96abf8d..2e67d8d 100644
--- a/xen/arch/x86/hvm/svm/vmcb.c
+++ b/xen/arch/x86/hvm/svm/vmcb.c
@@ -310,6 +310,22 @@ void __init setup_vmcb_dump(void)
     register_keyhandler('v', vmcb_dump, "dump AMD-V VMCBs", 1);
 }
 
+static void __init __maybe_unused build_assertions(void)
+{
+    struct segment_register sreg;
+
+    /* Check struct segment_register against the VMCB segment layout. */
+    BUILD_BUG_ON(sizeof(sreg)       != 16);
+    BUILD_BUG_ON(sizeof(sreg.sel)   != 2);
+    BUILD_BUG_ON(sizeof(sreg.attr)  != 2);
+    BUILD_BUG_ON(sizeof(sreg.limit) != 4);
+    BUILD_BUG_ON(sizeof(sreg.base)  != 8);
+    BUILD_BUG_ON(offsetof(struct segment_register, sel)   != 0);
+    BUILD_BUG_ON(offsetof(struct segment_register, attr)  != 2);
+    BUILD_BUG_ON(offsetof(struct segment_register, limit) != 4);
+    BUILD_BUG_ON(offsetof(struct segment_register, base)  != 8);
+}
+
 /*
  * Local variables:
  * mode: C
diff --git a/xen/include/asm-x86/hvm/svm/vmcb.h 
b/xen/include/asm-x86/hvm/svm/vmcb.h
index 30a228b..fa0d3e2 100644
--- a/xen/include/asm-x86/hvm/svm/vmcb.h
+++ b/xen/include/asm-x86/hvm/svm/vmcb.h
@@ -31,7 +31,7 @@ enum GenericIntercept1bits
     GENERAL1_INTERCEPT_SMI           = 1 << 2,
     GENERAL1_INTERCEPT_INIT          = 1 << 3,
     GENERAL1_INTERCEPT_VINTR         = 1 << 4,
-    GENERAL1_INTERCEPT_CR0_SEL_WRITE = 1 << 5, 
+    GENERAL1_INTERCEPT_CR0_SEL_WRITE = 1 << 5,
     GENERAL1_INTERCEPT_IDTR_READ     = 1 << 6,
     GENERAL1_INTERCEPT_GDTR_READ     = 1 << 7,
     GENERAL1_INTERCEPT_LDTR_READ     = 1 << 8,
@@ -304,13 +304,10 @@ enum VMEXIT_EXITCODE
     VMEXIT_INVALID          =  -1
 };
 
-/* Definition of segment state is borrowed by the generic HVM code. */
-typedef struct segment_register svm_segment_register_t;
-
 typedef union
 {
     u64 bytes;
-    struct 
+    struct
     {
         u64 vector:    8;
         u64 type:      3;
@@ -324,7 +321,7 @@ typedef union
 typedef union
 {
     u64 bytes;
-    struct 
+    struct
     {
         u64 tpr:          8;
         u64 irq:          1;
@@ -342,7 +339,7 @@ typedef union
 typedef union
 {
     u64 bytes;
-    struct 
+    struct
     {
         u64 type: 1;
         u64 rsv0: 1;
@@ -438,23 +435,23 @@ struct vmcb_struct {
     u8  guest_ins[15];          /* offset 0xD1 */
     u64 res10a[100];            /* offset 0xE0 pad to save area */
 
-    svm_segment_register_t es;  /* offset 1024 - cleanbit 8 */
-    svm_segment_register_t cs;  /* cleanbit 8 */
-    svm_segment_register_t ss;  /* cleanbit 8 */
-    svm_segment_register_t ds;  /* cleanbit 8 */
-    svm_segment_register_t fs;
-    svm_segment_register_t gs;
-    svm_segment_register_t gdtr; /* cleanbit 7 */
-    svm_segment_register_t ldtr;
-    svm_segment_register_t idtr; /* cleanbit 7 */
-    svm_segment_register_t tr;
+    struct segment_register es;  /* offset 0x400 - cleanbit 8 */
+    struct segment_register cs;  /* cleanbit 8 */
+    struct segment_register ss;  /* cleanbit 8 */
+    struct segment_register ds;  /* cleanbit 8 */
+    struct segment_register fs;
+    struct segment_register gs;
+    struct segment_register gdtr; /* cleanbit 7 */
+    struct segment_register ldtr;
+    struct segment_register idtr; /* cleanbit 7 */
+    struct segment_register tr;
     u64 res10[5];
     u8 res11[3];
     u8 _cpl;                    /* cleanbit 8 */
     u32 res12;
-    u64 _efer;                  /* offset 1024 + 0xD0  - cleanbit 5 */
+    u64 _efer;                  /* offset 0x400 + 0xD0 - cleanbit 5 */
     u64 res13[14];
-    u64 _cr4;                   /* offset 1024 + 0x148 - cleanbit 5 */
+    u64 _cr4;                   /* offset 0x400 + 0x148 - cleanbit 5 */
     u64 _cr3;                   /* cleanbit 5 */
     u64 _cr0;                   /* cleanbit 5 */
     u64 _dr7;                   /* cleanbit 6 */
@@ -508,7 +505,7 @@ struct arch_svm_struct {
     uint64_t guest_sysenter_cs;
     uint64_t guest_sysenter_esp;
     uint64_t guest_sysenter_eip;
-    
+
     /* AMD lightweight profiling MSR */
     uint64_t guest_lwp_cfg;      /* guest version */
     uint64_t cpu_lwp_cfg;        /* CPU version */
--
generated by git-patchbot for /home/xen/git/xen.git#master

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.