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.creekm...@gmail.com>
Reviewed-by: Andrew Cooper <andrew.coop...@citrix.com>
Acked-by: David Vrabel <david.vra...@citrix.com>

---
Changed since v4:
  * Made static inline stubs into single-line functions
  * Remove makefile conditional in favor of list mechanism

Changed since v3:
  * Correct makefile to meet the standards for feature flags
  * Remove unnecessary nooping of the unused parameter

Changed since v2:
  * Switch macros over to static inline functions
  * #ifdef code segments that would cause larger code changes without it
  * Move do_ni_hypercall defines closer to the hypercall tables
  * Add kexec flag to the toplevel makefile

Changed since v1:
  * Reorder kexec files to be alphabetical in the makefile
  * Create macros for the kexec functions that are called when disabled
  * #define the kexec hypercalls to do_ni_hypercall when disabled
  * Remove unnecessary macro duplication
  * Remove unrelated whitespace changes
---
 xen/Rules.mk                       | 6 ++++++
 xen/arch/x86/Makefile              | 4 ++--
 xen/arch/x86/setup.c               | 6 ++++++
 xen/arch/x86/x86_64/compat/entry.S | 4 ++++
 xen/arch/x86/x86_64/entry.S        | 4 ++++
 xen/common/Makefile                | 4 ++--
 xen/include/asm-x86/config.h       | 1 -
 xen/include/xen/kexec.h            | 6 ++++++
 8 files changed, 30 insertions(+), 5 deletions(-)

diff --git a/xen/Rules.mk b/xen/Rules.mk
index feb08d6..bf19d20 100644
--- a/xen/Rules.mk
+++ b/xen/Rules.mk
@@ -10,6 +10,7 @@ lock_profile  ?= n
 crash_debug   ?= n
 frame_pointer ?= n
 lto           ?= n
+kexec         ?= y
 
 include $(XEN_ROOT)/Config.mk
 
@@ -72,6 +73,11 @@ ifneq ($(max_phys_irqs),)
 CFLAGS-y                += -DMAX_PHYS_IRQS=$(max_phys_irqs)
 endif
 
+CONFIG_KEXEC-$(HAS_KEXEC) := $(kexec)
+CONFIG_KEXEC              := $(CONFIG_KEXEC-y)
+
+CFLAGS-$(CONFIG_KEXEC)  += -DCONFIG_KEXEC
+
 AFLAGS-y                += -D__ASSEMBLY__ -include 
$(BASEDIR)/include/xen/config.h
 
 # Clang's built-in assembler can't handle .code16/.code32/.code64 yet
diff --git a/xen/arch/x86/Makefile b/xen/arch/x86/Makefile
index 5f24951..39a8059 100644
--- a/xen/arch/x86/Makefile
+++ b/xen/arch/x86/Makefile
@@ -14,6 +14,7 @@ obj-bin-y += bzimage.init.o
 obj-bin-y += clear_page.o
 obj-bin-y += copy_page.o
 obj-y += compat.o
+obj-$(CONFIG_KEXEC) += crash.o
 obj-y += debug.o
 obj-y += delay.o
 obj-bin-y += dmi_scan.init.o
@@ -31,6 +32,7 @@ obj-y += io_apic.o
 obj-y += msi.o
 obj-y += ioport_emulate.o
 obj-y += irq.o
+obj-$(CONFIG_KEXEC) += machine_kexec.o
 obj-y += microcode_amd.o
 obj-y += microcode_intel.o
 # This must come after the vendor specific files.
@@ -56,8 +58,6 @@ 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-y += tboot.o
 obj-y += hpet.o
 obj-y += vm_event.o
diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
index ff34670..319d175 100644
--- a/xen/arch/x86/setup.c
+++ b/xen/arch/x86/setup.c
@@ -481,6 +481,7 @@ static void __init parse_video_info(void)
 
 static void __init kexec_reserve_area(struct e820map *e820)
 {
+#ifdef CONFIG_KEXEC
     unsigned long kdump_start = kexec_crash_area.start;
     unsigned long kdump_size  = kexec_crash_area.size;
     static bool_t __initdata is_reserved = 0;
@@ -503,6 +504,7 @@ static void __init kexec_reserve_area(struct e820map *e820)
         printk("Kdump: %luMB (%lukB) at %#lx\n",
                kdump_size >> 20, kdump_size >> 10, kdump_start);
     }
+#endif
 }
 
 static void noinline init_done(void)
@@ -973,6 +975,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 +984,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 )
@@ -1125,6 +1129,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 +1140,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..3088aa7 100644
--- a/xen/arch/x86/x86_64/compat/entry.S
+++ b/xen/arch/x86/x86_64/compat/entry.S
@@ -390,6 +390,10 @@ compat_crash_page_fault:
 
 .section .rodata, "a", @progbits
 
+#ifndef CONFIG_KEXEC
+#define compat_kexec_op do_ni_hypercall
+#endif
+
 ENTRY(compat_hypercall_table)
         .quad compat_set_trap_table     /*  0 */
         .quad do_mmu_update
diff --git a/xen/arch/x86/x86_64/entry.S b/xen/arch/x86/x86_64/entry.S
index 74677a2..28c3214 100644
--- a/xen/arch/x86/x86_64/entry.S
+++ b/xen/arch/x86/x86_64/entry.S
@@ -723,6 +723,10 @@ ENTRY(exception_table)
         .endr
         .size exception_table, . - exception_table
 
+#ifndef CONFIG_KEXEC
+#define do_kexec_op do_ni_hypercall
+#endif
+
 ENTRY(hypercall_table)
         .quad do_set_trap_table     /*  0 */
         .quad do_mmu_update
diff --git a/xen/common/Makefile b/xen/common/Makefile
index 3fdf931..1726fac 100644
--- a/xen/common/Makefile
+++ b/xen/common/Makefile
@@ -13,8 +13,8 @@ obj-y += guestcopy.o
 obj-y += irq.o
 obj-y += kernel.o
 obj-y += keyhandler.o
-obj-$(HAS_KEXEC) += kexec.o
-obj-$(HAS_KEXEC) += kimage.o
+obj-$(CONFIG_KEXEC) += kexec.o
+obj-$(CONFIG_KEXEC) += kimage.o
 obj-y += lib.o
 obj-y += lzo.o
 obj-$(HAS_MEM_ACCESS) += mem_access.o
diff --git a/xen/include/asm-x86/config.h b/xen/include/asm-x86/config.h
index 3e9be83..52f7ca8 100644
--- a/xen/include/asm-x86/config.h
+++ b/xen/include/asm-x86/config.h
@@ -48,7 +48,6 @@
 #define CONFIG_HOTPLUG_CPU 1
 
 #define CONFIG_XENOPROF 1
-#define CONFIG_KEXEC 1
 #define CONFIG_WATCHDOG 1
 
 #define CONFIG_MULTIBOOT 1
diff --git a/xen/include/xen/kexec.h b/xen/include/xen/kexec.h
index b7d121d..baaeb88 100644
--- a/xen/include/xen/kexec.h
+++ b/xen/include/xen/kexec.h
@@ -79,6 +79,12 @@ void vmcoreinfo_append_str(const char *fmt, ...)
 #else /* !CONFIG_KEXEC */
 
 #define crashinfo_maxaddr_bits 0
+#define kexecing 0
+
+static inline void kexec_early_calculations(void) {}
+static inline void kexec_crash(void) {}
+static inline void kexec_crash_save_cpu(void) {}
+static inline void set_kexec_crash_area_size(u64 system_ram) {}
 
 #endif
 
-- 
2.1.4


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

Reply via email to