]> xenbits.xensource.com Git - people/liuw/xen.git/commitdiff
x86: Switch "struct desc_struct" to being seg_desc_t
authorAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 6 Dec 2018 14:05:29 +0000 (14:05 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 10 Dec 2018 15:43:25 +0000 (15:43 +0000)
The struct suffix is redundant in the name, and a future change will want to
turn it into a union, rather than a structure.  As this represents a segment
descriptor, give it an appropriate typedef.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
15 files changed:
xen/arch/x86/cpu/common.c
xen/arch/x86/domain.c
xen/arch/x86/hvm/hvm.c
xen/arch/x86/hvm/svm/svm.c
xen/arch/x86/mm.c
xen/arch/x86/pv/descriptor-tables.c
xen/arch/x86/pv/emul-gate-op.c
xen/arch/x86/pv/emulate.c
xen/arch/x86/pv/emulate.h
xen/arch/x86/smpboot.c
xen/arch/x86/traps.c
xen/arch/x86/x86_64/mm.c
xen/include/asm-x86/desc.h
xen/include/asm-x86/ldt.h
xen/include/asm-x86/mm.h

index 90f4a9b0b6fa4b3ee9a6f0494a2d260348127312..de6c5c903f326db2053a0cfef54f24d22277c68b 100644 (file)
@@ -724,9 +724,9 @@ void load_system_tables(void)
                stack_top = stack_bottom & ~(STACK_SIZE - 1);
 
        struct tss_struct *tss = &this_cpu(init_tss);
-       struct desc_struct *gdt =
+       seg_desc_t *gdt =
                this_cpu(gdt_table) - FIRST_RESERVED_GDT_ENTRY;
-       struct desc_struct *compat_gdt =
+       seg_desc_t *compat_gdt =
                this_cpu(compat_gdt_table) - FIRST_RESERVED_GDT_ENTRY;
 
        const struct desc_ptr gdtr = {
index b4d59487ad3bb0aef96d75ddd5731dc40f946ce8..f0e0cdbb0ee4886df1e92574c3530eb44818057e 100644 (file)
@@ -1665,7 +1665,7 @@ static void __context_switch(void)
     struct vcpu          *p = per_cpu(curr_vcpu, cpu);
     struct vcpu          *n = current;
     struct domain        *pd = p->domain, *nd = n->domain;
-    struct desc_struct   *gdt;
+    seg_desc_t           *gdt;
     struct desc_ptr       gdt_desc;
 
     ASSERT(p != n);
index 0039e8cf38855913271af2e7bf20f3c9e0d3e85b..d64b6b6c20bd0cb6af9ef520950db00f80f47e48 100644 (file)
@@ -2695,7 +2695,7 @@ static int task_switch_load_seg(
     enum x86_segment seg, uint16_t sel, unsigned int cpl, unsigned int eflags)
 {
     struct segment_register desctab, segr;
-    struct desc_struct *pdesc = NULL, desc;
+    seg_desc_t *pdesc = NULL, desc;
     u8 dpl, rpl;
     bool_t writable;
     int fault_type = TRAP_invalid_tss;
@@ -2876,7 +2876,7 @@ void hvm_task_switch(
     struct vcpu *v = current;
     struct cpu_user_regs *regs = guest_cpu_user_regs();
     struct segment_register gdt, tr, prev_tr, segr;
-    struct desc_struct *optss_desc = NULL, *nptss_desc = NULL, tss_desc;
+    seg_desc_t *optss_desc = NULL, *nptss_desc = NULL, tss_desc;
     bool_t otd_writable, ntd_writable;
     unsigned int eflags, new_cpl;
     pagefault_info_t pfinfo;
index b9a8900ced6d5b45be44bf712473c50193b475b1..40937bfa4743227f0c5345d8a2a5eebe9ebcd84f 100644 (file)
@@ -1636,8 +1636,8 @@ bool svm_load_segs(unsigned int ldt_ents, unsigned long ldt_base,
     else
     {
         /* Keep GDT in sync. */
-        struct desc_struct *desc = this_cpu(gdt_table) + LDT_ENTRY -
-                                   FIRST_RESERVED_GDT_ENTRY;
+        seg_desc_t *desc =
+            this_cpu(gdt_table) + LDT_ENTRY - FIRST_RESERVED_GDT_ENTRY;
 
         _set_tssldt_desc(desc, ldt_base, ldt_ents * 8 - 1, SYS_DESC_ldt);
 
index b3350eee35b57f173fdad34082750aa32f85f7b3..1431f347f3df5d49fcad4d9d3372439b1a6d2e59 100644 (file)
@@ -626,7 +626,7 @@ const char __section(".bss.page_aligned.const") __aligned(PAGE_SIZE)
 static int alloc_segdesc_page(struct page_info *page)
 {
     const struct domain *owner = page_get_owner(page);
-    struct desc_struct *descs = __map_domain_page(page);
+    seg_desc_t *descs = __map_domain_page(page);
     unsigned i;
 
     for ( i = 0; i < 512; i++ )
index 8b2d55fc2ec1ec9a425cd62c40a23677ad33aa2f..caa62eb88d637516d13ddffc3a7eb328ef719099 100644 (file)
@@ -212,16 +212,16 @@ long do_update_descriptor(uint64_t pa, uint64_t desc)
     unsigned long gmfn = pa >> PAGE_SHIFT;
     unsigned long mfn;
     unsigned int  offset;
-    struct desc_struct *gdt_pent, d;
+    seg_desc_t *gdt_pent, d;
     struct page_info *page;
     long ret = -EINVAL;
 
-    offset = ((unsigned int)pa & ~PAGE_MASK) / sizeof(struct desc_struct);
+    offset = ((unsigned int)pa & ~PAGE_MASK) / sizeof(seg_desc_t);
 
     *(uint64_t *)&d = desc;
 
     page = get_page_from_gfn(currd, gmfn, NULL, P2M_ALLOC);
-    if ( (((unsigned int)pa % sizeof(struct desc_struct)) != 0) ||
+    if ( (((unsigned int)pa % sizeof(seg_desc_t)) != 0) ||
          !page ||
          !check_descriptor(currd, &d) )
     {
index d1c8aa6f7bd77fea9551c4efa355291145f5167e..6dbf3c12a019c393bf5be87b37d11b26455ad336 100644 (file)
@@ -47,8 +47,8 @@ static int read_gate_descriptor(unsigned int gate_sel,
                                 unsigned long *off,
                                 unsigned int *ar)
 {
-    struct desc_struct desc;
-    const struct desc_struct *pdesc = gdt_ldt_desc_ptr(gate_sel);
+    seg_desc_t desc;
+    const seg_desc_t *pdesc = gdt_ldt_desc_ptr(gate_sel);
 
     if ( (gate_sel < 4) ||
          ((gate_sel >= FIRST_RESERVED_GDT_BYTE) && !(gate_sel & 4)) ||
index 757ffd159c78324a6b65a069232ad4e226bdab12..877dfda75e4d78b5654ee3366c0846c2a00f3e26 100644 (file)
@@ -29,7 +29,7 @@ int pv_emul_read_descriptor(unsigned int sel, const struct vcpu *v,
                             unsigned long *base, unsigned long *limit,
                             unsigned int *ar, bool insn_fetch)
 {
-    struct desc_struct desc;
+    seg_desc_t desc;
 
     if ( sel < 4)
         desc.b = desc.a = 0;
index 9d587947f5aba1fae6ee88fcf5ad2ef88558f58c..fd2aa0a4848c9fec685ae3233e79e6ca079a25e7 100644 (file)
@@ -18,10 +18,10 @@ static inline int pv_emul_is_mem_write(const struct x86_emulate_state *state,
 }
 
 /* Return a pointer to the GDT/LDT descriptor referenced by sel. */
-static inline const struct desc_struct *gdt_ldt_desc_ptr(unsigned int sel)
+static inline const seg_desc_t *gdt_ldt_desc_ptr(unsigned int sel)
 {
     const struct vcpu *curr = current;
-    const struct desc_struct *tbl = (void *)
+    const seg_desc_t *tbl = (void *)
         ((sel & X86_XEC_TI) ? LDT_VIRT_START(curr) : GDT_VIRT_START(curr));
 
     return &tbl[sel >> 3];
index 567cece748a0cc6f5a64a0a599188830c08fdc7b..7d1226d7bc67faa31264e841557b2a14552d7a90 100644 (file)
@@ -972,7 +972,7 @@ static int cpu_smpboot_alloc(unsigned int cpu)
 {
     unsigned int i, order, memflags = 0;
     nodeid_t node = cpu_to_node(cpu);
-    struct desc_struct *gdt;
+    seg_desc_t *gdt;
     unsigned long stub_page;
     int rc = -ENOMEM;
 
index 9471d89022338074b7e714558ab27c3d5655cb20..05ddc39bfef98a30f8fbbb01fe2a7449fc638f62 100644 (file)
@@ -96,8 +96,8 @@ string_param("nmi", opt_nmi);
 DEFINE_PER_CPU(uint64_t, efer);
 static DEFINE_PER_CPU(unsigned long, last_extable_addr);
 
-DEFINE_PER_CPU_READ_MOSTLY(struct desc_struct *, gdt_table);
-DEFINE_PER_CPU_READ_MOSTLY(struct desc_struct *, compat_gdt_table);
+DEFINE_PER_CPU_READ_MOSTLY(seg_desc_t *, gdt_table);
+DEFINE_PER_CPU_READ_MOSTLY(seg_desc_t *, compat_gdt_table);
 
 /* Master table, used by CPU0. */
 idt_entry_t __section(".bss.page_aligned") __aligned(PAGE_SIZE)
index 11977f267146007f18cf225244a72b80643f878a..126a486d2ee40697346b785ed0f0d26b662994a1 100644 (file)
@@ -1075,7 +1075,7 @@ long do_set_segment_base(unsigned int which, unsigned long base)
 
 
 /* Returns TRUE if given descriptor is valid for GDT or LDT. */
-int check_descriptor(const struct domain *dom, struct desc_struct *d)
+int check_descriptor(const struct domain *dom, seg_desc_t *d)
 {
     u32 a = d->a, b = d->b;
     u16 cs;
index 58efc1d896834ff082b493978c703819870907a6..5a8afb6eb28d934748a0ae7d5ea016b1657d578c 100644 (file)
 #define SYS_DESC_irq_gate     14
 #define SYS_DESC_trap_gate    15
 
-struct desc_struct {
-    u32 a, b;
-};
+typedef struct {
+    uint32_t a, b;
+} seg_desc_t;
 
 typedef union {
     struct {
@@ -201,10 +201,10 @@ struct __packed desc_ptr {
        unsigned long base;
 };
 
-extern struct desc_struct boot_cpu_gdt_table[];
-DECLARE_PER_CPU(struct desc_struct *, gdt_table);
-extern struct desc_struct boot_cpu_compat_gdt_table[];
-DECLARE_PER_CPU(struct desc_struct *, compat_gdt_table);
+extern seg_desc_t boot_cpu_gdt_table[];
+DECLARE_PER_CPU(seg_desc_t *, gdt_table);
+extern seg_desc_t boot_cpu_compat_gdt_table[];
+DECLARE_PER_CPU(seg_desc_t *, compat_gdt_table);
 
 extern void load_TR(void);
 
index a6236b21aaf2532dc9d0f2b79122962b38005ac8..da502329fb37910a2a8b9066446b2d92caeecd33 100644 (file)
@@ -6,7 +6,7 @@
 
 static inline void load_LDT(struct vcpu *v)
 {
-    struct desc_struct *desc;
+    seg_desc_t *desc;
     unsigned long ents;
 
     if ( (ents = v->arch.pv.ldt_ents) == 0 )
index 1ea173c555c4c1a42036e41bdc776c7206870ecc..6faa563167dbbf9c513e59ecd58e55fa439d420c 100644 (file)
@@ -438,7 +438,7 @@ static inline int get_page_and_type(struct page_info *page,
     ASSERT(((_p)->count_info & PGC_count_mask) != 0);          \
     ASSERT(page_get_owner(_p) == (_d))
 
-int check_descriptor(const struct domain *, struct desc_struct *d);
+int check_descriptor(const struct domain *d, seg_desc_t *desc);
 
 extern paddr_t mem_hotplug;