]> git.baikalelectronics.ru Git - kernel.git/commitdiff
powerpc/kasan: Disable address sanitization in kexec paths
authorDaniel Axtens <dja@axtens.net>
Wed, 18 May 2022 10:07:05 +0000 (20:07 +1000)
committerMichael Ellerman <mpe@ellerman.id.au>
Sun, 22 May 2022 05:58:29 +0000 (15:58 +1000)
The kexec code paths involve code that necessarily run in real mode, as
CPUs are disabled and control is transferred to the new kernel. Disable
address sanitization for the kexec code and the functions called in real
mode on CPUs being disabled.

[paulus@ozlabs.org: combined a few work-in-progress commits of
 Daniel's and wrote the commit message.]

Signed-off-by: Daniel Axtens <dja@axtens.net>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
[mpe: Move pseries_machine_kexec() into kexec.c so setup.c can be instrumented]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/YoTFSQ2TUSEaDdVC@cleo
arch/powerpc/kexec/Makefile
arch/powerpc/platforms/pseries/Makefile
arch/powerpc/platforms/pseries/kexec.c
arch/powerpc/platforms/pseries/pseries.h
arch/powerpc/platforms/pseries/setup.c
arch/powerpc/sysdev/xics/xics-common.c
arch/powerpc/sysdev/xive/common.c

index b6c52608cb490c1bab84a92ddd6f6c6e2fd1dd70..0c2abe7f99087495098d37be69041ef698819dc2 100644 (file)
@@ -13,3 +13,5 @@ obj-$(CONFIG_KEXEC_FILE)      += file_load.o ranges.o file_load_$(BITS).o elf_$(BITS)
 GCOV_PROFILE_core_$(BITS).o := n
 KCOV_INSTRUMENT_core_$(BITS).o := n
 UBSAN_SANITIZE_core_$(BITS).o := n
+KASAN_SANITIZE_core.o := n
+KASAN_SANITIZE_core_$(BITS) := n
index 9764e1a2ed5c6d82d8ab7f4c2ca6f3adeb7075a4..a1fab0955bf4e9b4695fe9b19f554d66a569e601 100644 (file)
@@ -33,3 +33,5 @@ obj-$(CONFIG_SUSPEND)         += suspend.o
 obj-$(CONFIG_PPC_VAS)          += vas.o vas-sysfs.o
 
 obj-$(CONFIG_ARCH_HAS_CC_PLATFORM)     += cc_platform.o
+
+KASAN_SANITIZE_kexec.o := n
index 145fcfbc017f2e8376b14beef0ea2fdc7353e874..ab6cdbebb35e2b9f3b8a30b1c9efafdceec59b3a 100644 (file)
@@ -61,3 +61,11 @@ void pseries_kexec_cpu_down(int crash_shutdown, int secondary)
        } else
                xics_kexec_teardown_cpu(secondary);
 }
+
+void pseries_machine_kexec(struct kimage *image)
+{
+       if (firmware_has_feature(FW_FEATURE_SET_MODE))
+               pseries_disable_reloc_on_exc();
+
+       default_machine_kexec(image);
+}
index af162aeeae86d8d0d5ad69dc0c08477216e4bce4..f5c916c839c9854931ee060774b907511a01871b 100644 (file)
@@ -38,6 +38,7 @@ static inline void smp_init_pseries(void) { }
 #endif
 
 extern void pseries_kexec_cpu_down(int crash_shutdown, int secondary);
+void pseries_machine_kexec(struct kimage *image);
 
 extern void pSeries_final_fixup(void);
 
index a3dab15b0a2fb4fd32784125f928bc85fca4cedb..c9fcc30a03651e5b21ce0e1d289545876e4f378e 100644 (file)
@@ -421,16 +421,6 @@ void pseries_disable_reloc_on_exc(void)
 }
 EXPORT_SYMBOL(pseries_disable_reloc_on_exc);
 
-#ifdef CONFIG_KEXEC_CORE
-static void pSeries_machine_kexec(struct kimage *image)
-{
-       if (firmware_has_feature(FW_FEATURE_SET_MODE))
-               pseries_disable_reloc_on_exc();
-
-       default_machine_kexec(image);
-}
-#endif
-
 #ifdef __LITTLE_ENDIAN__
 void pseries_big_endian_exceptions(void)
 {
@@ -1099,7 +1089,7 @@ define_machine(pseries) {
        .machine_check_exception = pSeries_machine_check_exception,
        .machine_check_log_err  = pSeries_machine_check_log_err,
 #ifdef CONFIG_KEXEC_CORE
-       .machine_kexec          = pSeries_machine_kexec,
+       .machine_kexec          = pseries_machine_kexec,
        .kexec_cpu_down         = pseries_kexec_cpu_down,
 #endif
 #ifdef CONFIG_MEMORY_HOTPLUG
index ce76f97599520292f6ca1ae6de6ea4515c805b2f..d3a4156e8788125d610f114ab21c6a3bc2c84452 100644 (file)
@@ -146,7 +146,7 @@ void __init xics_smp_probe(void)
 
 #endif /* CONFIG_SMP */
 
-void xics_teardown_cpu(void)
+noinstr void xics_teardown_cpu(void)
 {
        struct xics_cppr *os_cppr = this_cpu_ptr(&xics_cppr);
 
@@ -159,7 +159,7 @@ void xics_teardown_cpu(void)
        icp_ops->teardown_cpu();
 }
 
-void xics_kexec_teardown_cpu(int secondary)
+noinstr void xics_kexec_teardown_cpu(int secondary)
 {
        xics_teardown_cpu();
 
index e06d015ad1a087ab9a2d6980f54ee23cc800bf21..61b9f98dfd4a4bdb26ed3d759d2464368ff70272 100644 (file)
@@ -1241,7 +1241,7 @@ static int xive_setup_cpu_ipi(unsigned int cpu)
        return 0;
 }
 
-static void xive_cleanup_cpu_ipi(unsigned int cpu, struct xive_cpu *xc)
+noinstr static void xive_cleanup_cpu_ipi(unsigned int cpu, struct xive_cpu *xc)
 {
        unsigned int xive_ipi_irq = xive_ipi_cpu_to_irq(cpu);
 
@@ -1634,7 +1634,7 @@ void xive_flush_interrupt(void)
 
 #endif /* CONFIG_SMP */
 
-void xive_teardown_cpu(void)
+noinstr void xive_teardown_cpu(void)
 {
        struct xive_cpu *xc = __this_cpu_read(xive_cpu);
        unsigned int cpu = smp_processor_id();