]> xenbits.xensource.com Git - people/royger/xen.git/commitdiff
x86/IDT: Rename idt_table[] to bsp_idt[]
authorAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 2 Jan 2025 17:17:30 +0000 (17:17 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 7 Mar 2025 14:34:08 +0000 (14:34 +0000)
Having variables named idt_table[] and idt_tables[] is not ideal.

Use X86_IDT_VECTORS and remove IDT_ENTRIES.  State the size of bsp_idt[] in
idt.h so that load_system_tables() and cpu_smpboot_alloc() can use sizeof()
rather than opencoding the calculation.

Move the variable into a new traps-setup.c, to make a start at splitting
traps.c in half.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/Makefile
xen/arch/x86/cpu/common.c
xen/arch/x86/include/asm/idt.h
xen/arch/x86/pv/traps.c
xen/arch/x86/smpboot.c
xen/arch/x86/traps-setup.c [new file with mode: 0644]
xen/arch/x86/traps.c

index b35fd5196ce2218061702791580377f308df1886..c763f80b0b22aae39b3d6ee83cddc45ee86f022b 100644 (file)
@@ -65,6 +65,7 @@ obj-y += spec_ctrl.o
 obj-y += srat.o
 obj-y += string.o
 obj-y += time.o
+obj-y += traps-setup.o
 obj-y += traps.o
 obj-$(CONFIG_INTEL) += tsx.o
 obj-y += usercopy.o
index 1540ab0007a062f7a88a462ef66005870c632b3b..e8b355ebcf366860bda84b04646e92c437375f10 100644 (file)
@@ -831,7 +831,7 @@ void load_system_tables(void)
        };
        const struct desc_ptr idtr = {
                .base = (unsigned long)idt_tables[cpu],
-               .limit = (IDT_ENTRIES * sizeof(idt_entry_t)) - 1,
+               .limit = sizeof(bsp_idt) - 1,
        };
 
        /*
index 3689fdecbec3d0ff5f5c40c6a8fe3f1e85c34d0a..f00368f28c86cbe550aa28f3279ad976ee759a82 100644 (file)
@@ -28,8 +28,7 @@ typedef union {
     };
 } idt_entry_t;
 
-#define IDT_ENTRIES 256
-extern idt_entry_t idt_table[];
+extern idt_entry_t bsp_idt[X86_IDT_VECTORS];
 extern idt_entry_t *idt_tables[];
 
 /*
index 77b034e4dc73ae35a42ee1e625624a2e21cd0a25..4aeb6cab5238bc49504d189f9516cb3b2aa0e673 100644 (file)
@@ -148,12 +148,12 @@ void __init pv_trap_init(void)
 {
 #ifdef CONFIG_PV32
     /* The 32-on-64 hypercall vector is only accessible from ring 1. */
-    _set_gate(idt_table + HYPERCALL_VECTOR,
+    _set_gate(bsp_idt + HYPERCALL_VECTOR,
               SYS_DESC_irq_gate, 1, entry_int82);
 #endif
 
     /* Fast trap for int80 (faster than taking the #GP-fixup path). */
-    _set_gate(idt_table + LEGACY_SYSCALL_VECTOR, SYS_DESC_irq_gate, 3,
+    _set_gate(bsp_idt + LEGACY_SYSCALL_VECTOR, SYS_DESC_irq_gate, 3,
               &entry_int80);
 
     open_softirq(NMI_SOFTIRQ, nmi_softirq);
index f3d60d5bae35394c189ff68e61e375790a2d3b81..dc65f9e4526994f6a68a08cc36024946175b8a95 100644 (file)
@@ -1080,7 +1080,7 @@ static int cpu_smpboot_alloc(unsigned int cpu)
         idt_tables[cpu] = alloc_xenheap_pages(0, memflags);
     if ( idt_tables[cpu] == NULL )
         goto out;
-    memcpy(idt_tables[cpu], idt_table, IDT_ENTRIES * sizeof(idt_entry_t));
+    memcpy(idt_tables[cpu], bsp_idt, sizeof(bsp_idt));
     disable_each_ist(idt_tables[cpu]);
 
     for ( stub_page = 0, i = cpu & ~(STUBS_PER_PAGE - 1);
diff --git a/xen/arch/x86/traps-setup.c b/xen/arch/x86/traps-setup.c
new file mode 100644 (file)
index 0000000..b172ea9
--- /dev/null
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Configuration of event handling for all CPUs.
+ */
+#include <asm/idt.h>
+#include <asm/page.h>
+
+idt_entry_t __section(".bss.page_aligned") __aligned(PAGE_SIZE)
+    bsp_idt[X86_IDT_VECTORS];
index 4d1aaa78e71158951a730ac417d8e288e4aa3c74..7a68996b02f7161df26d3c7d59837eaea296f9af 100644 (file)
@@ -98,10 +98,6 @@ DEFINE_PER_CPU_READ_MOSTLY(seg_desc_t *, compat_gdt);
 DEFINE_PER_CPU_READ_MOSTLY(l1_pgentry_t, compat_gdt_l1e);
 #endif
 
-/* Master table, used by CPU0. */
-idt_entry_t __section(".bss.page_aligned") __aligned(PAGE_SIZE)
-    idt_table[IDT_ENTRIES];
-
 /* Pointer to the IDT of every CPU. */
 idt_entry_t *idt_tables[NR_CPUS] __read_mostly;
 
@@ -1874,7 +1870,7 @@ void asmlinkage do_entry_CP(struct cpu_user_regs *regs)
 static void __init noinline __set_intr_gate(unsigned int n,
                                             uint32_t dpl, void *addr)
 {
-    _set_gate(&idt_table[n], SYS_DESC_irq_gate, dpl, addr);
+    _set_gate(&bsp_idt[n], SYS_DESC_irq_gate, dpl, addr);
 }
 
 static void __init set_swint_gate(unsigned int n, void *addr)
@@ -1940,10 +1936,10 @@ void __init init_idt_traps(void)
     set_intr_gate (X86_EXC_CP,  entry_CP);
 
     /* Specify dedicated interrupt stacks for NMI, #DF, and #MC. */
-    enable_each_ist(idt_table);
+    enable_each_ist(bsp_idt);
 
     /* CPU0 uses the master IDT. */
-    idt_tables[0] = idt_table;
+    idt_tables[0] = bsp_idt;
 
     this_cpu(gdt) = boot_gdt;
     if ( IS_ENABLED(CONFIG_PV32) )
@@ -2001,13 +1997,13 @@ void __init trap_init(void)
         if ( autogen_entrypoints[vector] )
         {
             /* Found autogen entry: check we won't clobber an existing trap. */
-            ASSERT(idt_table[vector].b == 0);
+            ASSERT(bsp_idt[vector].b == 0);
             set_intr_gate(vector, autogen_entrypoints[vector]);
         }
         else
         {
             /* No entry point: confirm we have an existing trap in place. */
-            ASSERT(idt_table[vector].b != 0);
+            ASSERT(bsp_idt[vector].b != 0);
         }
     }