]> xenbits.xensource.com Git - people/andrewcoop/xen.git/commitdiff
x86/traps: Fold init_idt_traps() and trap_init() into their single callers
authorAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 1 Jan 2025 13:23:15 +0000 (13:23 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 6 Jan 2025 14:19:10 +0000 (14:19 +0000)
xen/arch/x86/include/asm/system.h
xen/arch/x86/traps-init.c
xen/arch/x86/traps.c

index 73364056c702a9cd7258e2757ae6f398636ae3bd..8ceaaf45d1a05e2e7434a30e4a7753ca861d1256 100644 (file)
@@ -263,8 +263,6 @@ static inline int local_irq_is_enabled(void)
 #define BROKEN_ACPI_Sx          0x0001
 #define BROKEN_INIT_AFTER_S1    0x0002
 
-void trap_init(void);
-void init_idt_traps(void);
 void load_system_tables(void);
 void subarch_percpu_traps_init(void);
 
index 90338d561b377ac1cc39e7a9d598b29be01f9f90..2858cc4ab9a486b650b021fec4590d8ab360b7e6 100644 (file)
@@ -3,6 +3,7 @@
  * Configuration of event handling for all CPUs.
  */
 #include <xen/init.h>
+#include <xen/param.h>
 
 #include <asm/idt.h>
 #include <asm/msr.h>
 
 DEFINE_PER_CPU_READ_MOSTLY(idt_entry_t *, idt);
 
+static bool __initdata opt_ler;
+boolean_param("ler", opt_ler);
+
+void nocall entry_PF(void);
+
+static void __init init_ler(void)
+{
+    unsigned int msr = 0;
+
+    if ( !opt_ler )
+        return;
+
+    /*
+     * Intel Pentium 4 is the only known CPU to not use the architectural MSR
+     * indicies.
+     */
+    switch ( boot_cpu_data.x86_vendor )
+    {
+    case X86_VENDOR_INTEL:
+        if ( boot_cpu_data.x86 == 0xf )
+        {
+            msr = MSR_P4_LER_FROM_LIP;
+            break;
+        }
+        fallthrough;
+    case X86_VENDOR_AMD:
+    case X86_VENDOR_HYGON:
+        msr = MSR_IA32_LASTINTFROMIP;
+        break;
+    }
+
+    if ( msr == 0 )
+    {
+        printk(XENLOG_WARNING "LER disabled: failed to identify MSRs\n");
+        return;
+    }
+
+    ler_msr = msr;
+    setup_force_cpu_cap(X86_FEATURE_XEN_LBR);
+}
+
 /*
  * Configure basic exception handling.  This is prior to parsing the command
  * line or configuring a console, and needs to be as simple as possible.
  */
 void __init early_traps_init(void)
 {
-    init_idt_traps();
+    /* Specify dedicated interrupt stacks for NMI, #DF, and #MC. */
+    enable_each_ist(bsp_idt);
+
+    /* CPU0 uses the master IDT. */
+    this_cpu(idt) = bsp_idt;
+
+    this_cpu(gdt) = boot_gdt;
+    if ( IS_ENABLED(CONFIG_PV32) )
+        this_cpu(compat_gdt) = boot_compat_gdt;
+
     load_system_tables();
 }
 
@@ -27,7 +78,19 @@ void __init early_traps_init(void)
  */
 void __init traps_init(void)
 {
-    trap_init();
+    /* Replace early pagefault with real pagefault handler. */
+    _update_gate_addr_lower(&bsp_idt[X86_EXC_PF], entry_PF);
+
+    init_ler();
+
+    /* 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);
+    if ( IS_ENABLED(CONFIG_PV32) )
+        this_cpu(compat_gdt_l1e) =
+            l1e_from_pfn(virt_to_mfn(boot_compat_gdt), __PAGE_HYPERVISOR_RW);
+
+    percpu_traps_init();
 }
 
 /*
index ce01630e9004734749317ad9ee76946cf3a68f55..9e4843ee16224e42e8845cc58197b5e0552b9242 100644 (file)
@@ -106,9 +106,6 @@ DEFINE_PER_CPU_PAGE_ALIGNED(struct tss_page, tss_page);
 static int debug_stack_lines = 20;
 integer_param("debug_stack_lines", debug_stack_lines);
 
-static bool __initdata opt_ler;
-boolean_param("ler", opt_ler);
-
 /* LastExceptionFromIP on this hardware.  Zero if LER is not in use. */
 unsigned int __ro_after_init ler_msr;
 
@@ -1862,74 +1859,6 @@ void asmlinkage do_entry_CP(struct cpu_user_regs *regs)
     panic("CONTROL-FLOW PROTECTION FAULT: #CP[%04x] %s\n", ec, err);
 }
 
-void nocall entry_PF(void);
-
-void __init init_idt_traps(void)
-{
-    /* Specify dedicated interrupt stacks for NMI, #DF, and #MC. */
-    enable_each_ist(bsp_idt);
-
-    /* CPU0 uses the master IDT. */
-    this_cpu(idt) = bsp_idt;
-
-    this_cpu(gdt) = boot_gdt;
-    if ( IS_ENABLED(CONFIG_PV32) )
-        this_cpu(compat_gdt) = boot_compat_gdt;
-}
-
-static void __init init_ler(void)
-{
-    unsigned int msr = 0;
-
-    if ( !opt_ler )
-        return;
-
-    /*
-     * Intel Pentium 4 is the only known CPU to not use the architectural MSR
-     * indicies.
-     */
-    switch ( boot_cpu_data.x86_vendor )
-    {
-    case X86_VENDOR_INTEL:
-        if ( boot_cpu_data.x86 == 0xf )
-        {
-            msr = MSR_P4_LER_FROM_LIP;
-            break;
-        }
-        fallthrough;
-    case X86_VENDOR_AMD:
-    case X86_VENDOR_HYGON:
-        msr = MSR_IA32_LASTINTFROMIP;
-        break;
-    }
-
-    if ( msr == 0 )
-    {
-        printk(XENLOG_WARNING "LER disabled: failed to identify MSRs\n");
-        return;
-    }
-
-    ler_msr = msr;
-    setup_force_cpu_cap(X86_FEATURE_XEN_LBR);
-}
-
-void __init trap_init(void)
-{
-    /* Replace early pagefault with real pagefault handler. */
-    _update_gate_addr_lower(&bsp_idt[X86_EXC_PF], entry_PF);
-
-    init_ler();
-
-    /* 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);
-    if ( IS_ENABLED(CONFIG_PV32) )
-        this_cpu(compat_gdt_l1e) =
-            l1e_from_pfn(virt_to_mfn(boot_compat_gdt), __PAGE_HYPERVISOR_RW);
-
-    percpu_traps_init();
-}
-
 void asm_domain_crash_synchronous(unsigned long addr)
 {
     /*