x86: wrap kexec feature with CONFIG_KEXEC
PATCH v3 1/1 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.
---
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 | 1 + xen/arch/x86/Makefile | 4 ++-- xen/arch/x86/Rules.mk | 3 ++- xen/arch/x86/setup.c | 6 ++++++ xen/arch/x86/x86_64/compat/entry.S | 4 ++++ xen/arch/x86/x86_64/entry.S | 4 ++++ xen/include/asm-x86/config.h | 1 - xen/include/xen/kexec.h | 21 +++++++++++++++++++++ 8 files changed, 40 insertions(+), 4 deletions(-)
xen/Rules.mk +1 -0
@@ -10,6 +10,7 @@ lock_profile ?= n crash_debug ?= n frame_pointer ?= n lto ?= n +kexec ?= y include $(XEN_ROOT)/Config.mk
xen/arch/x86/Makefile +2 -2
@@ -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-$(HAS_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-$(HAS_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
xen/arch/x86/Rules.mk +2 -1
@@ -10,7 +10,7 @@ HAS_PCI := y HAS_PASSTHROUGH := y HAS_NS16550 := y HAS_EHCI := y -HAS_KEXEC := y +HAS_KEXEC := $(kexec) HAS_GDBSX := y HAS_PDX := y xenoprof := y
@@ -44,3 +44,4 @@ endif CFLAGS-$(shadow-paging) += -DCONFIG_SHADOW_PAGING CFLAGS-$(bigmem) += -DCONFIG_BIGMEM +CFLAGS-$(kexec) += -DCONFIG_KEXEC
xen/arch/x86/setup.c +6 -0
@@ -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 );
xen/arch/x86/x86_64/compat/entry.S +4 -0
@@ -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
xen/arch/x86/x86_64/entry.S +4 -0
@@ -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
xen/include/asm-x86/config.h +0 -1
@@ -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
xen/include/xen/kexec.h +21 -0
@@ -79,6 +79,27 @@ 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) +{ + (void )system_ram; +}#endif
Signature · 1 line
2.1.4
Quoted 5 lines · Jonathan Creekmore
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 <[email protected]>
This is still not quite correct with makefile level constructs. (Also you have broken the ARM build). Allow me to explain.
HAS_$foo is used to indicate whether there is support for $foo in a particular arch. This is statement of support, not an option. Therefore, xen/arch/x86/Rules.mk should remain unchanged.
The top xen/rules.mk 'kexec' option is ok, but you need a further clause after including the per-arch rules. Something like
ifeq($(HAS_KEXEC)$(kexec),yy)CONFIG_KEXEC := y
endif
Which will set a Makefile level CONFIG_KEXEC which indicates that the arch has support, and the developer wishes to enable it.
For the rest of the makefile changes, you should use things like obj-$(CONFIG_KEXEC) and CLFAGS-$(CONFIG_KEXEC) as opposed to $(HAS_KEXEC) and $(kexec)
With that fixed, I think this patch is ready, with one further tweak...
Quoted 14 lines
xen/include/xen/kexec.h +10
-0@@ -79,6 +79,27 @@ 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 ) +{ +
xen/include/xen/kexec.h void vmcoreinfo_append_str(const char *fmt, ...) · line 101
Quoted 10 lines
xen/include/xen/kexec.h +10
-0+} + +static inline void kexec_crash_save_cpu (void ) +{ + +} + +static inline void set_kexec_crash_area_size (u64 system_ram) +{ + (void )system_ram;
You shouldn't need this statement, as the callee's parameter should be evaluated by virtue of this being a static inline.
If it is to stop the compiler complaining about an unused parameter, please use the __unused attribute instead.
~Andrew