From patchwork Mon Aug 5 12:43:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 11076827 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4890C14DB for ; Mon, 5 Aug 2019 12:45:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2F936288D0 for ; Mon, 5 Aug 2019 12:45:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 23707288F7; Mon, 5 Aug 2019 12:45:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3651A284F5 for ; Mon, 5 Aug 2019 12:45:19 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hucKb-0000cv-Co; Mon, 05 Aug 2019 12:43:17 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hucKa-0000cX-Cc for xen-devel@lists.xenproject.org; Mon, 05 Aug 2019 12:43:16 +0000 X-Inumbo-ID: 95f9c430-b77e-11e9-98fa-fb38854f42ba Received: from esa2.hc3370-68.iphmx.com (unknown [216.71.145.153]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 95f9c430-b77e-11e9-98fa-fb38854f42ba; Mon, 05 Aug 2019 12:43:12 +0000 (UTC) Authentication-Results: esa2.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=andrew.cooper3@citrix.com; spf=Pass smtp.mailfrom=Andrew.Cooper3@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa2.hc3370-68.iphmx.com: no sender authenticity information available from domain of andrew.cooper3@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa2.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="andrew.cooper3@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa2.hc3370-68.iphmx.com: domain of Andrew.Cooper3@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa2.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="Andrew.Cooper3@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ~all" Received-SPF: None (esa2.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa2.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: sMscg5SJLSEIy+f8nnxntp1V4z/XA/yImLrvMo+KGxBfxqHsf7ZArVFCfpwzajAnFDlL1dQNeR 9uF67LP8TUTY+JvL71R/tKPkYD2/wtOXXdxuvSjnPnr/nBCYsX3kG10EoT/4M5uoK0Norlb/c6 D8UxW0e8LZHgNdlvPQaGsB+pjPzOAJuO1M2UoImU7Jnx5wHAjJSgfYboiJPJE1AvWTqGoK/lZ6 qTKGmYkZyPd/DRzgROeYEmDmYc3Hzu7EL3fMLeZx+yxLGE54xS7lGHTVu2DkWg2/qivjfEcKg2 Nuo= X-SBRS: 2.7 X-MesageID: 3859934 X-Ironport-Server: esa2.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.64,349,1559534400"; d="scan'208";a="3859934" From: Andrew Cooper To: Xen-devel Date: Mon, 5 Aug 2019 13:43:00 +0100 Message-ID: <20190805124301.12887-4-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190805124301.12887-1-andrew.cooper3@citrix.com> References: <20190805124301.12887-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 3/4] x86/desc: Shorten boot_{, comat_}gdt[] variable names X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP The current names, boot_cpu_{,compat_}gdt_table, have a table suffix which is redundant with the T of GDT, and the cpu infix doesn't provide any meaningful context. Drop them both. Likewise, shorten the {,compat_}gdt{,_l1e} variables. Finally, rename gdt_descr to boot_gdtr to more clearly identify its purpose. Signed-off-by: Andrew Cooper Reviewed-by: Roger Pau Monné Acked-by: Jan Beulich --- CC: Jan Beulich CC: Wei Liu CC: Roger Pau Monné --- xen/arch/x86/boot/x86_64.S | 10 +++++----- xen/arch/x86/cpu/common.c | 4 ++-- xen/arch/x86/domain.c | 7 +++---- xen/arch/x86/efi/efi-boot.h | 2 +- xen/arch/x86/hvm/svm/svm.c | 2 +- xen/arch/x86/hvm/vmx/vmcs.c | 2 +- xen/arch/x86/smpboot.c | 18 +++++++++--------- xen/arch/x86/traps.c | 30 ++++++++++++++---------------- xen/common/efi/runtime.c | 2 +- xen/include/asm-x86/desc.h | 12 ++++++------ xen/include/asm-x86/ldt.h | 3 +-- 11 files changed, 44 insertions(+), 48 deletions(-) diff --git a/xen/arch/x86/boot/x86_64.S b/xen/arch/x86/boot/x86_64.S index cf47e019f5..3909363ca3 100644 --- a/xen/arch/x86/boot/x86_64.S +++ b/xen/arch/x86/boot/x86_64.S @@ -3,7 +3,7 @@ ENTRY(__high_start) /* Install relocated data selectors. */ - lgdt gdt_descr(%rip) + lgdt boot_gdtr(%rip) mov $(__HYPERVISOR_DS64),%ecx mov %ecx,%ds mov %ecx,%es @@ -44,16 +44,16 @@ multiboot_ptr: .long 0 .word 0 -GLOBAL(gdt_descr) +GLOBAL(boot_gdtr) .word LAST_RESERVED_GDT_BYTE - .quad boot_cpu_gdt_table - FIRST_RESERVED_GDT_BYTE + .quad boot_gdt - FIRST_RESERVED_GDT_BYTE GLOBAL(stack_start) .quad cpu0_stack .section .data.page_aligned, "aw", @progbits .align PAGE_SIZE, 0 -GLOBAL(boot_cpu_gdt_table) +GLOBAL(boot_gdt) .quad 0x0000000000000000 /* unused */ .quad 0x00af9a000000ffff /* 0xe008 ring 0 code, 64-bit mode */ .quad 0x00cf92000000ffff /* 0xe010 ring 0 data */ @@ -68,7 +68,7 @@ GLOBAL(boot_cpu_gdt_table) .align PAGE_SIZE, 0 /* NB. Even rings != 0 get access to the full 4Gb, as only the */ /* (compatibility) machine->physical mapping table lives there. */ -GLOBAL(boot_cpu_compat_gdt_table) +GLOBAL(boot_compat_gdt) .quad 0x0000000000000000 /* unused */ .quad 0x00af9a000000ffff /* 0xe008 ring 0 code, 64-bit mode */ .quad 0x00cf92000000ffff /* 0xe010 ring 0 data */ diff --git a/xen/arch/x86/cpu/common.c b/xen/arch/x86/cpu/common.c index 7478e21177..dc2dea4d6d 100644 --- a/xen/arch/x86/cpu/common.c +++ b/xen/arch/x86/cpu/common.c @@ -709,9 +709,9 @@ void load_system_tables(void) struct tss_struct *tss = &this_cpu(init_tss); seg_desc_t *gdt = - this_cpu(gdt_table) - FIRST_RESERVED_GDT_ENTRY; + this_cpu(gdt) - FIRST_RESERVED_GDT_ENTRY; seg_desc_t *compat_gdt = - this_cpu(compat_gdt_table) - FIRST_RESERVED_GDT_ENTRY; + this_cpu(compat_gdt) - FIRST_RESERVED_GDT_ENTRY; const struct desc_ptr gdtr = { .base = (unsigned long)gdt, diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index 5933b3f51b..612afb683f 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -1666,8 +1666,8 @@ static inline bool need_full_gdt(const struct domain *d) static void update_xen_slot_in_full_gdt(const struct vcpu *v, unsigned int cpu) { l1e_write(pv_gdt_ptes(v) + FIRST_RESERVED_GDT_PAGE, - !is_pv_32bit_vcpu(v) ? per_cpu(gdt_table_l1e, cpu) - : per_cpu(compat_gdt_table_l1e, cpu)); + !is_pv_32bit_vcpu(v) ? per_cpu(gdt_l1e, cpu) + : per_cpu(compat_gdt_l1e, cpu)); } static void load_full_gdt(const struct vcpu *v, unsigned int cpu) @@ -1686,8 +1686,7 @@ static void load_default_gdt(unsigned int cpu) { struct desc_ptr gdt_desc = { .limit = LAST_RESERVED_GDT_BYTE, - .base = (unsigned long)(per_cpu(gdt_table, cpu) - - FIRST_RESERVED_GDT_ENTRY), + .base = (unsigned long)(per_cpu(gdt, cpu) - FIRST_RESERVED_GDT_ENTRY), }; lgdt(&gdt_desc); diff --git a/xen/arch/x86/efi/efi-boot.h b/xen/arch/x86/efi/efi-boot.h index 2f59d8bdbd..5324149f93 100644 --- a/xen/arch/x86/efi/efi-boot.h +++ b/xen/arch/x86/efi/efi-boot.h @@ -250,7 +250,7 @@ static void __init noreturn efi_arch_post_exit_boot(void) "mov %[cr4], %%cr4\n\t" #endif /* Load data segments. */ - "lgdt gdt_descr(%%rip)\n\t" + "lgdt boot_gdtr(%%rip)\n\t" "mov %[ds], %%ss\n\t" "mov %[ds], %%ds\n\t" "mov %[ds], %%es\n\t" diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c index d81401dbc0..deafa3864e 100644 --- a/xen/arch/x86/hvm/svm/svm.c +++ b/xen/arch/x86/hvm/svm/svm.c @@ -1568,7 +1568,7 @@ bool svm_load_segs(unsigned int ldt_ents, unsigned long ldt_base, { /* Keep GDT in sync. */ seg_desc_t *desc = - this_cpu(gdt_table) + LDT_ENTRY - FIRST_RESERVED_GDT_ENTRY; + this_cpu(gdt) + LDT_ENTRY - FIRST_RESERVED_GDT_ENTRY; _set_tssldt_desc(desc, ldt_base, ldt_ents * 8 - 1, SYS_DESC_ldt); diff --git a/xen/arch/x86/hvm/vmx/vmcs.c b/xen/arch/x86/hvm/vmx/vmcs.c index 45d18493df..098613822a 100644 --- a/xen/arch/x86/hvm/vmx/vmcs.c +++ b/xen/arch/x86/hvm/vmx/vmcs.c @@ -793,7 +793,7 @@ static void vmx_set_host_env(struct vcpu *v) unsigned int cpu = smp_processor_id(); __vmwrite(HOST_GDTR_BASE, - (unsigned long)(this_cpu(gdt_table) - FIRST_RESERVED_GDT_ENTRY)); + (unsigned long)(this_cpu(gdt) - FIRST_RESERVED_GDT_ENTRY)); __vmwrite(HOST_IDTR_BASE, (unsigned long)idt_tables[cpu]); __vmwrite(HOST_TR_BASE, (unsigned long)&per_cpu(init_tss, cpu)); diff --git a/xen/arch/x86/smpboot.c b/xen/arch/x86/smpboot.c index 65e9ceeece..8d5fef0012 100644 --- a/xen/arch/x86/smpboot.c +++ b/xen/arch/x86/smpboot.c @@ -944,11 +944,11 @@ static void cpu_smpboot_free(unsigned int cpu, bool remove) free_domheap_page(mfn_to_page(mfn)); } - FREE_XENHEAP_PAGE(per_cpu(compat_gdt_table, cpu)); + FREE_XENHEAP_PAGE(per_cpu(compat_gdt, cpu)); if ( remove ) { - FREE_XENHEAP_PAGE(per_cpu(gdt_table, cpu)); + FREE_XENHEAP_PAGE(per_cpu(gdt, cpu)); FREE_XENHEAP_PAGE(idt_tables[cpu]); if ( stack_base[cpu] ) @@ -976,22 +976,22 @@ static int cpu_smpboot_alloc(unsigned int cpu) goto out; memguard_guard_stack(stack_base[cpu]); - gdt = per_cpu(gdt_table, cpu) ?: alloc_xenheap_pages(0, memflags); + gdt = per_cpu(gdt, cpu) ?: alloc_xenheap_pages(0, memflags); if ( gdt == NULL ) goto out; - per_cpu(gdt_table, cpu) = gdt; - per_cpu(gdt_table_l1e, cpu) = + per_cpu(gdt, cpu) = gdt; + per_cpu(gdt_l1e, cpu) = l1e_from_pfn(virt_to_mfn(gdt), __PAGE_HYPERVISOR_RW); - memcpy(gdt, boot_cpu_gdt_table, NR_RESERVED_GDT_PAGES * PAGE_SIZE); + memcpy(gdt, boot_gdt, NR_RESERVED_GDT_PAGES * PAGE_SIZE); BUILD_BUG_ON(NR_CPUS > 0x10000); gdt[PER_CPU_GDT_ENTRY - FIRST_RESERVED_GDT_ENTRY].a = cpu; - per_cpu(compat_gdt_table, cpu) = gdt = alloc_xenheap_pages(0, memflags); + per_cpu(compat_gdt, cpu) = gdt = alloc_xenheap_pages(0, memflags); if ( gdt == NULL ) goto out; - per_cpu(compat_gdt_table_l1e, cpu) = + per_cpu(compat_gdt_l1e, cpu) = l1e_from_pfn(virt_to_mfn(gdt), __PAGE_HYPERVISOR_RW); - memcpy(gdt, boot_cpu_compat_gdt_table, NR_RESERVED_GDT_PAGES * PAGE_SIZE); + memcpy(gdt, boot_compat_gdt, NR_RESERVED_GDT_PAGES * PAGE_SIZE); gdt[PER_CPU_GDT_ENTRY - FIRST_RESERVED_GDT_ENTRY].a = cpu; if ( idt_tables[cpu] == NULL ) diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c index 38d12013db..162f708ac3 100644 --- a/xen/arch/x86/traps.c +++ b/xen/arch/x86/traps.c @@ -96,10 +96,10 @@ 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(seg_desc_t *, gdt_table); -DEFINE_PER_CPU_READ_MOSTLY(l1_pgentry_t, gdt_table_l1e); -DEFINE_PER_CPU_READ_MOSTLY(seg_desc_t *, compat_gdt_table); -DEFINE_PER_CPU_READ_MOSTLY(l1_pgentry_t, compat_gdt_table_l1e); +DEFINE_PER_CPU_READ_MOSTLY(seg_desc_t *, gdt); +DEFINE_PER_CPU_READ_MOSTLY(l1_pgentry_t, gdt_l1e); +DEFINE_PER_CPU_READ_MOSTLY(seg_desc_t *, compat_gdt); +DEFINE_PER_CPU_READ_MOSTLY(l1_pgentry_t, compat_gdt_l1e); /* Master table, used by CPU0. */ idt_entry_t __section(".bss.page_aligned") __aligned(PAGE_SIZE) @@ -1899,17 +1899,17 @@ void load_TR(void) { struct tss_struct *tss = &this_cpu(init_tss); struct desc_ptr old_gdt, tss_gdt = { - .base = (long)(this_cpu(gdt_table) - FIRST_RESERVED_GDT_ENTRY), + .base = (long)(this_cpu(gdt) - FIRST_RESERVED_GDT_ENTRY), .limit = LAST_RESERVED_GDT_BYTE }; _set_tssldt_desc( - this_cpu(gdt_table) + TSS_ENTRY - FIRST_RESERVED_GDT_ENTRY, + this_cpu(gdt) + TSS_ENTRY - FIRST_RESERVED_GDT_ENTRY, (unsigned long)tss, offsetof(struct tss_struct, __cacheline_filler) - 1, SYS_DESC_tss_avail); _set_tssldt_desc( - this_cpu(compat_gdt_table) + TSS_ENTRY - FIRST_RESERVED_GDT_ENTRY, + this_cpu(compat_gdt) + TSS_ENTRY - FIRST_RESERVED_GDT_ENTRY, (unsigned long)tss, offsetof(struct tss_struct, __cacheline_filler) - 1, SYS_DESC_tss_busy); @@ -2000,8 +2000,8 @@ void __init init_idt_traps(void) /* CPU0 uses the master IDT. */ idt_tables[0] = idt_table; - this_cpu(gdt_table) = boot_cpu_gdt_table; - this_cpu(compat_gdt_table) = boot_cpu_compat_gdt_table; + this_cpu(gdt) = boot_gdt; + this_cpu(compat_gdt) = boot_compat_gdt; } extern void (*const autogen_entrypoints[NR_VECTORS])(void); @@ -2029,13 +2029,11 @@ void __init trap_init(void) } } - /* Cache {,compat_}gdt_table_l1e now that physically relocation is done. */ - this_cpu(gdt_table_l1e) = - l1e_from_pfn(virt_to_mfn(boot_cpu_gdt_table), - __PAGE_HYPERVISOR_RW); - this_cpu(compat_gdt_table_l1e) = - l1e_from_pfn(virt_to_mfn(boot_cpu_compat_gdt_table), - __PAGE_HYPERVISOR_RW); + /* Cache {,compat_}gdt_l1e now that physically relocation is done. */ + this_cpu(gdt_l1e) = + l1e_from_pfn(virt_to_mfn(boot_gdt), __PAGE_HYPERVISOR_RW); + this_cpu(compat_gdt_l1e) = + l1e_from_pfn(virt_to_mfn(boot_compat_gdt), __PAGE_HYPERVISOR_RW); percpu_traps_init(); diff --git a/xen/common/efi/runtime.c b/xen/common/efi/runtime.c index 3d118d571d..ab53ebcc55 100644 --- a/xen/common/efi/runtime.c +++ b/xen/common/efi/runtime.c @@ -104,7 +104,7 @@ struct efi_rs_state efi_rs_enter(void) { struct desc_ptr gdt_desc = { .limit = LAST_RESERVED_GDT_BYTE, - .base = (unsigned long)(per_cpu(gdt_table, smp_processor_id()) - + .base = (unsigned long)(per_cpu(gdt, smp_processor_id()) - FIRST_RESERVED_GDT_ENTRY) }; diff --git a/xen/include/asm-x86/desc.h b/xen/include/asm-x86/desc.h index c011c03ae2..0be9348d29 100644 --- a/xen/include/asm-x86/desc.h +++ b/xen/include/asm-x86/desc.h @@ -204,12 +204,12 @@ struct __packed desc_ptr { unsigned long base; }; -extern seg_desc_t boot_cpu_gdt_table[]; -DECLARE_PER_CPU(seg_desc_t *, gdt_table); -DECLARE_PER_CPU(l1_pgentry_t, gdt_table_l1e); -extern seg_desc_t boot_cpu_compat_gdt_table[]; -DECLARE_PER_CPU(seg_desc_t *, compat_gdt_table); -DECLARE_PER_CPU(l1_pgentry_t, compat_gdt_table_l1e); +extern seg_desc_t boot_gdt[]; +DECLARE_PER_CPU(seg_desc_t *, gdt); +DECLARE_PER_CPU(l1_pgentry_t, gdt_l1e); +extern seg_desc_t boot_compat_gdt[]; +DECLARE_PER_CPU(seg_desc_t *, compat_gdt); +DECLARE_PER_CPU(l1_pgentry_t, compat_gdt_l1e); DECLARE_PER_CPU(bool, full_gdt_loaded); extern void load_TR(void); diff --git a/xen/include/asm-x86/ldt.h b/xen/include/asm-x86/ldt.h index da502329fb..1383f55308 100644 --- a/xen/include/asm-x86/ldt.h +++ b/xen/include/asm-x86/ldt.h @@ -13,8 +13,7 @@ static inline void load_LDT(struct vcpu *v) lldt(0); else { - desc = (!is_pv_32bit_vcpu(v) - ? this_cpu(gdt_table) : this_cpu(compat_gdt_table)) + desc = (!is_pv_32bit_vcpu(v) ? this_cpu(gdt) : this_cpu(compat_gdt)) + LDT_ENTRY - FIRST_RESERVED_GDT_ENTRY; _set_tssldt_desc(desc, LDT_VIRT_START(v), ents*8-1, SYS_DESC_ldt); lldt(LDT_ENTRY << 3);