x86: wrap kexec feature with CONFIG_KEXEC
PATCH v4 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 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 | 5 +++++ 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 | 21 +++++++++++++++++++++ 8 files changed, 44 insertions(+), 5 deletions(-)
xen/Rules.mk +5 -0
@@ -10,6 +10,7 @@ lock_profile ?= n crash_debug ?= n frame_pointer ?= n lto ?= n +kexec ?= y include $(XEN_ROOT)/Config.mk
@@ -71,6 +72,10 @@ endif ifneq ($(max_phys_irqs),) CFLAGS-y += -DMAX_PHYS_IRQS=$(max_phys_irqs) endif +ifeq ($(HAS_KEXEC)$(kexec),yy) +CONFIG_KEXEC := y +endif +CFLAGS-$(CONFIG_KEXEC) += -DCONFIG_KEXEC AFLAGS-y += -D__ASSEMBLY__ -include $(BASEDIR)/include/xen/config.h
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-$(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
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/common/Makefile +2 -2
@@ -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
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) +{ + +}#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]>
xen/Rules.mk endif · line 76
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 31.08.15 at 23:32, <[email protected]> wrote:
xen/Rules.mk +2
-0@@ -71,6 +72,10 @@ endif ifneq ($(max_phys_irqs),) CFLAGS-y += -DMAX_PHYS_IRQS=$(max_phys_irqs) endif +ifeq ($(HAS_KEXEC)$(kexec),yy) +CONFIG_KEXEC := y
Apart from this line not matching blank padding wide with the ones surrounding it I also dislike the conditional. We try to use the list mechanism wherever possible. In this case I would hence prefer something like
CONFIG_KEXEC-$(HAS_KEXEC) := $(kexec)CONFIG_KEXEC := $(CONFIG_KEXEC-y)
Quoted 17 lines
xen/include/xen/kexec.h +11
-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 102
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) +{ + +}
All the blank lines inside the functions should be removed. I'd even consider making all of these single line items.
Neither of the changes look to be a problem to get done upon commit, so as long as you agree I wouldn't see a need for you to send a v5 (but of course it would be appreciated as it would make eventual committing [once the tree re-opens] simpler).
Jan
Quoted 3 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.
David