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

[Xen-devel] [PATCH] x86: wrap kexec feature with CONFIG_KEXEC



Add the appropriate #if checks around the kexec code in the x86 codebase
so that the feature can actually be turned off by the flag instead of
always required to be enabled on x86.

Signed-off-by: Jonathan Creekmore <jonathan.creekmore@xxxxxxxxx>
---
 xen/arch/x86/Makefile              |  4 ++--
 xen/arch/x86/apic.c                |  3 ++-
 xen/arch/x86/crash.c               |  2 ++
 xen/arch/x86/setup.c               | 14 ++++++++++++++
 xen/arch/x86/x86_64/compat/entry.S |  9 +++++++++
 xen/arch/x86/x86_64/entry.S        |  8 ++++++++
 xen/drivers/passthrough/vtd/dmar.h | 17 +++++++++++++++++
 xen/include/asm-x86/config.h       |  2 +-
 8 files changed, 55 insertions(+), 4 deletions(-)

diff --git a/xen/arch/x86/Makefile b/xen/arch/x86/Makefile
index 5f24951..5725a8d 100644
--- a/xen/arch/x86/Makefile
+++ b/xen/arch/x86/Makefile
@@ -56,8 +56,8 @@ obj-y += trace.o
 obj-y += traps.o
 obj-y += usercopy.o
 obj-y += x86_emulate.o
-obj-y += machine_kexec.o
-obj-y += crash.o
+obj-$(HAS_KEXEC) += machine_kexec.o
+obj-$(HAS_KEXEC) += crash.o
 obj-y += tboot.o
 obj-y += hpet.o
 obj-y += vm_event.o
diff --git a/xen/arch/x86/apic.c b/xen/arch/x86/apic.c
index 2c9ae4e..729adf5 100644
--- a/xen/arch/x86/apic.c
+++ b/xen/arch/x86/apic.c
@@ -307,6 +307,7 @@ void disable_local_APIC(void)
                ~(MSR_IA32_APICBASE_ENABLE|MSR_IA32_APICBASE_EXTD));
     }
 
+#ifdef CONFIG_KEXEC
     if ( kexecing && (current_local_apic_mode() != apic_boot_mode) )
     {
         uint64_t msr_content;
@@ -334,7 +335,7 @@ void disable_local_APIC(void)
             break;
         }
     }
-
+#endif
 }
 
 /*
diff --git a/xen/arch/x86/crash.c b/xen/arch/x86/crash.c
index 888a214..55f803a 100644
--- a/xen/arch/x86/crash.c
+++ b/xen/arch/x86/crash.c
@@ -64,7 +64,9 @@ static void noreturn do_nmi_crash(const struct cpu_user_regs 
*regs)
          */
         set_ist(&idt_tables[cpu][TRAP_machine_check], IST_NONE);
 
+#ifdef CONFIG_KEXEC
         kexec_crash_save_cpu();
+#endif
         __stop_this_cpu();
 
         this_cpu(crash_save_done) = 1;
diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
index ff34670..14ff15a 100644
--- a/xen/arch/x86/setup.c
+++ b/xen/arch/x86/setup.c
@@ -479,6 +479,8 @@ static void __init parse_video_info(void)
     }
 }
 
+#ifdef CONFIG_KEXEC
+
 static void __init kexec_reserve_area(struct e820map *e820)
 {
     unsigned long kdump_start = kexec_crash_area.start;
@@ -505,6 +507,8 @@ static void __init kexec_reserve_area(struct e820map *e820)
     }
 }
 
+#endif
+
 static void noinline init_done(void)
 {
     system_state = SYS_STATE_active;
@@ -617,9 +621,11 @@ void __init noreturn __start_xen(unsigned long mbi_p)
     }
     cmdline_parse(cmdline);
 
+#ifdef CONFIG_KEXEC
     /* Must be after command line argument parsing and before
      * allocing any xenheap structures wanted in lower memory. */
     kexec_early_calculations();
+#endif
 
     parse_video_info();
 
@@ -782,6 +788,7 @@ void __init noreturn __start_xen(unsigned long mbi_p)
     /* Create a temporary copy of the E820 map. */
     memcpy(&boot_e820, &e820, sizeof(e820));
 
+#ifdef CONFIG_KEXEC
     /* Early kexec reservation (explicit static start address). */
     nr_pages = 0;
     for ( i = 0; i < e820.nr_map; i++ )
@@ -789,6 +796,7 @@ void __init noreturn __start_xen(unsigned long mbi_p)
             nr_pages += e820.map[i].size >> PAGE_SHIFT;
     set_kexec_crash_area_size((u64)nr_pages << PAGE_SHIFT);
     kexec_reserve_area(&boot_e820);
+#endif
 
     initial_images = mod;
     nr_initial_images = mbi->mods_count;
@@ -973,6 +981,7 @@ void __init noreturn __start_xen(unsigned long mbi_p)
             }
         }
 
+#ifdef CONFIG_KEXEC
         /* Don't overlap with modules. */
         e = consider_modules(s, e, PAGE_ALIGN(kexec_crash_area.size),
                              mod, mbi->mods_count, -1);
@@ -981,6 +990,7 @@ void __init noreturn __start_xen(unsigned long mbi_p)
             e = (e - kexec_crash_area.size) & PAGE_MASK;
             kexec_crash_area.start = e;
         }
+#endif
     }
 
     if ( modules_headroom && !mod->reserved )
@@ -997,8 +1007,10 @@ void __init noreturn __start_xen(unsigned long mbi_p)
     reserve_e820_ram(&boot_e820, efi_enabled ? mbi->mem_upper : __pa(&_start),
                      __pa(&_end));
 
+#ifdef CONFIG_KEXEC
     /* Late kexec reservation (dynamic start address). */
     kexec_reserve_area(&boot_e820);
+#endif
 
     setup_max_pdx(raw_max_page);
     if ( highmem_start )
@@ -1125,6 +1137,7 @@ void __init noreturn __start_xen(unsigned long mbi_p)
                          PFN_UP(mod[i].mod_end), PAGE_HYPERVISOR);
     }
 
+#ifdef CONFIG_KEXEC
     if ( kexec_crash_area.size )
     {
         unsigned long s = PFN_DOWN(kexec_crash_area.start);
@@ -1135,6 +1148,7 @@ void __init noreturn __start_xen(unsigned long mbi_p)
             map_pages_to_xen((unsigned long)__va(kexec_crash_area.start),
                              s, e - s, PAGE_HYPERVISOR);
     }
+#endif
 
     xen_virt_end = ((unsigned long)_end + (1UL << L2_PAGETABLE_SHIFT) - 1) &
                    ~((1UL << L2_PAGETABLE_SHIFT) - 1);
diff --git a/xen/arch/x86/x86_64/compat/entry.S 
b/xen/arch/x86/x86_64/compat/entry.S
index 1521779..e2fe49c 100644
--- a/xen/arch/x86/x86_64/compat/entry.S
+++ b/xen/arch/x86/x86_64/compat/entry.S
@@ -428,7 +428,11 @@ ENTRY(compat_hypercall_table)
         .quad do_hvm_op
         .quad do_sysctl                 /* 35 */
         .quad do_domctl
+#if CONFIG_KEXEC
         .quad compat_kexec_op
+#else
+        .quad do_ni_hypercall
+#endif
         .quad do_tmem_op
         .quad do_ni_hypercall           /* reserved for XenClient */
         .quad do_xenpmu_op              /* 40 */
@@ -479,6 +483,11 @@ ENTRY(compat_hypercall_args_table)
         .byte 2 /* do_hvm_op                */
         .byte 1 /* do_sysctl                */  /* 35 */
         .byte 1 /* do_domctl                */
+#if CONFIG_KEXEC
+        .byte 2 /* compat_kexec_op          */
+#else
+       .byte 0 /* do_ni_hypercall          */
+#endif
         .byte 2 /* compat_kexec_op          */
         .byte 1 /* do_tmem_op               */
         .byte 0 /* reserved for XenClient   */
diff --git a/xen/arch/x86/x86_64/entry.S b/xen/arch/x86/x86_64/entry.S
index 74677a2..357f3d5 100644
--- a/xen/arch/x86/x86_64/entry.S
+++ b/xen/arch/x86/x86_64/entry.S
@@ -761,7 +761,11 @@ ENTRY(hypercall_table)
         .quad do_hvm_op
         .quad do_sysctl             /* 35 */
         .quad do_domctl
+#ifdef CONFIG_KEXEC
         .quad do_kexec_op
+#else
+       .quad do_ni_hypercall
+#endif
         .quad do_tmem_op
         .quad do_ni_hypercall       /* reserved for XenClient */
         .quad do_xenpmu_op          /* 40 */
@@ -812,7 +816,11 @@ ENTRY(hypercall_args_table)
         .byte 2 /* do_hvm_op            */
         .byte 1 /* do_sysctl            */  /* 35 */
         .byte 1 /* do_domctl            */
+#ifdef CONFIG_KEXEC
         .byte 2 /* do_kexec             */
+#else
+        .byte 0 /* do_ni_hypercall      */
+#endif
         .byte 1 /* do_tmem_op           */
         .byte 0 /* reserved for XenClient */
         .byte 2 /* do_xenpmu_op         */  /* 40 */
diff --git a/xen/drivers/passthrough/vtd/dmar.h 
b/xen/drivers/passthrough/vtd/dmar.h
index 729b603..697e5e5 100644
--- a/xen/drivers/passthrough/vtd/dmar.h
+++ b/xen/drivers/passthrough/vtd/dmar.h
@@ -108,6 +108,7 @@ struct acpi_atsr_unit *acpi_find_matched_atsr_unit(const 
struct pci_dev *);
 
 #define DMAR_OPERATION_TIMEOUT MILLISECS(1000)
 
+#ifdef CONFIG_KEXEC
 #define IOMMU_WAIT_OP(iommu, offset, op, cond, sts) \
 do {                                                \
     s_time_t start_time = NOW();                    \
@@ -125,6 +126,22 @@ do {                                                \
         cpu_relax();                                            \
     }                                                           \
 } while (0)
+#else
+#define IOMMU_WAIT_OP(iommu, offset, op, cond, sts) \
+do {                                                \
+    s_time_t start_time = NOW();                    \
+    while (1) {                                     \
+        sts = op(iommu->reg, offset);               \
+        if ( cond )                                 \
+            break;                                  \
+        if ( NOW() > start_time + DMAR_OPERATION_TIMEOUT ) {    \
+         panic("%s:%d:%s: DMAR hardware is malfunctional",     \
+               __FILE__, __LINE__, __func__);                  \
+        }                                                       \
+        cpu_relax();                                            \
+    }                                                           \
+} while (0)
+#endif
 
 int vtd_hw_check(void);
 void disable_pmr(struct iommu *iommu);
diff --git a/xen/include/asm-x86/config.h b/xen/include/asm-x86/config.h
index 3e9be83..e84e489 100644
--- a/xen/include/asm-x86/config.h
+++ b/xen/include/asm-x86/config.h
@@ -1,6 +1,6 @@
 /******************************************************************************
  * config.h
- * 
+ *
  * A Linux-style configuration list.
  */
 
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

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