Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'mm-nonmm-stable-2023-08-28-22-48' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

Pull non-MM updates from Andrew Morton:

- An extensive rework of kexec and crash Kconfig from Eric DeVolder
("refactor Kconfig to consolidate KEXEC and CRASH options")

- kernel.h slimming work from Andy Shevchenko ("kernel.h: Split out a
couple of macros to args.h")

- gdb feature work from Kuan-Ying Lee ("Add GDB memory helper
commands")

- vsprintf inclusion rationalization from Andy Shevchenko
("lib/vsprintf: Rework header inclusions")

- Switch the handling of kdump from a udev scheme to in-kernel
handling, by Eric DeVolder ("crash: Kernel handling of CPU and memory
hot un/plug")

- Many singleton patches to various parts of the tree

* tag 'mm-nonmm-stable-2023-08-28-22-48' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm: (81 commits)
document while_each_thread(), change first_tid() to use for_each_thread()
drivers/char/mem.c: shrink character device's devlist[] array
x86/crash: optimize CPU changes
crash: change crash_prepare_elf64_headers() to for_each_possible_cpu()
crash: hotplug support for kexec_load()
x86/crash: add x86 crash hotplug support
crash: memory and CPU hotplug sysfs attributes
kexec: exclude elfcorehdr from the segment digest
crash: add generic infrastructure for crash hotplug support
crash: move a few code bits to setup support of crash hotplug
kstrtox: consistently use _tolower()
kill do_each_thread()
nilfs2: fix WARNING in mark_buffer_dirty due to discarded buffer reuse
scripts/bloat-o-meter: count weak symbol sizes
treewide: drop CONFIG_EMBEDDED
lockdep: fix static memory detection even more
lib/vsprintf: declare no_hash_pointers in sprintf.h
lib/vsprintf: split out sprintf() and friends
kernel/fork: stop playing lockless games for exe_file replacement
adfs: delete unused "union adfs_dirtail" definition
...

+2838 -1377
+8
Documentation/ABI/testing/sysfs-devices-memory
··· 110 110 link is created for memory section 9 on node0. 111 111 112 112 /sys/devices/system/node/node0/memory9 -> ../../memory/memory9 113 + 114 + What: /sys/devices/system/memory/crash_hotplug 115 + Date: Aug 2023 116 + Contact: Linux kernel mailing list <linux-kernel@vger.kernel.org> 117 + Description: 118 + (RO) indicates whether or not the kernel directly supports 119 + modifying the crash elfcorehdr for memory hot un/plug and/or 120 + on/offline changes.
+8
Documentation/ABI/testing/sysfs-devices-system-cpu
··· 688 688 (RO) the list of CPUs that are isolated and don't 689 689 participate in load balancing. These CPUs are set by 690 690 boot parameter "isolcpus=". 691 + 692 + What: /sys/devices/system/cpu/crash_hotplug 693 + Date: Aug 2023 694 + Contact: Linux kernel mailing list <linux-kernel@vger.kernel.org> 695 + Description: 696 + (RO) indicates whether or not the kernel directly supports 697 + modifying the crash elfcorehdr for CPU hot un/plug and/or 698 + on/offline changes.
+8
Documentation/admin-guide/mm/memory-hotplug.rst
··· 291 291 Availability depends on the CONFIG_ARCH_MEMORY_PROBE 292 292 kernel configuration option. 293 293 ``uevent`` read-write: generic udev file for device subsystems. 294 + ``crash_hotplug`` read-only: when changes to the system memory map 295 + occur due to hot un/plug of memory, this file contains 296 + '1' if the kernel updates the kdump capture kernel memory 297 + map itself (via elfcorehdr), or '0' if userspace must update 298 + the kdump capture kernel memory map. 299 + 300 + Availability depends on the CONFIG_MEMORY_HOTPLUG kernel 301 + configuration option. 294 302 ====================== ========================================================= 295 303 296 304 .. note::
+18
Documentation/core-api/cpu_hotplug.rst
··· 741 741 742 742 can process the event further. 743 743 744 + When changes to the CPUs in the system occur, the sysfs file 745 + /sys/devices/system/cpu/crash_hotplug contains '1' if the kernel 746 + updates the kdump capture kernel list of CPUs itself (via elfcorehdr), 747 + or '0' if userspace must update the kdump capture kernel list of CPUs. 748 + 749 + The availability depends on the CONFIG_HOTPLUG_CPU kernel configuration 750 + option. 751 + 752 + To skip userspace processing of CPU hot un/plug events for kdump 753 + (i.e. the unload-then-reload to obtain a current list of CPUs), this sysfs 754 + file can be used in a udev rule as follows: 755 + 756 + SUBSYSTEM=="cpu", ATTRS{crash_hotplug}=="1", GOTO="kdump_reload_end" 757 + 758 + For a CPU hot un/plug event, if the architecture supports kernel updates 759 + of the elfcorehdr (which contains the list of CPUs), then the rule skips 760 + the unload-then-reload of the kdump capture kernel. 761 + 744 762 Kernel Inline Documentations Reference 745 763 ====================================== 746 764
+3 -14
arch/Kconfig
··· 11 11 12 12 menu "General architecture-dependent options" 13 13 14 - config CRASH_CORE 15 - bool 16 - 17 - config KEXEC_CORE 18 - select CRASH_CORE 19 - bool 20 - 21 - config KEXEC_ELF 22 - bool 23 - 24 - config HAVE_IMA_KEXEC 25 - bool 26 - 27 14 config ARCH_HAS_SUBPAGE_FAULTS 28 15 bool 29 16 help ··· 735 748 depends on $(success,$(AR) --help | head -n 1 | grep -qi llvm) 736 749 depends on ARCH_SUPPORTS_LTO_CLANG 737 750 depends on !FTRACE_MCOUNT_USE_RECORDMCOUNT 738 - depends on !KASAN || KASAN_HW_TAGS 751 + # https://github.com/ClangBuiltLinux/linux/issues/1721 752 + depends on (!KASAN || KASAN_HW_TAGS || CLANG_VERSION >= 170000) || !DEBUG_INFO 753 + depends on (!KCOV || CLANG_VERSION >= 170000) || !DEBUG_INFO 739 754 depends on !GCOV_KERNEL 740 755 help 741 756 The compiler and Kconfig options support building with Clang's
+1 -1
arch/arc/configs/axs101_defconfig
··· 9 9 # CONFIG_UTS_NS is not set 10 10 # CONFIG_PID_NS is not set 11 11 CONFIG_BLK_DEV_INITRD=y 12 - CONFIG_EMBEDDED=y 12 + CONFIG_EXPERT=y 13 13 CONFIG_PERF_EVENTS=y 14 14 # CONFIG_VM_EVENT_COUNTERS is not set 15 15 # CONFIG_SLUB_DEBUG is not set
+1 -1
arch/arc/configs/axs103_defconfig
··· 9 9 # CONFIG_UTS_NS is not set 10 10 # CONFIG_PID_NS is not set 11 11 CONFIG_BLK_DEV_INITRD=y 12 - CONFIG_EMBEDDED=y 12 + CONFIG_EXPERT=y 13 13 CONFIG_PERF_EVENTS=y 14 14 # CONFIG_VM_EVENT_COUNTERS is not set 15 15 # CONFIG_SLUB_DEBUG is not set
+1 -1
arch/arc/configs/axs103_smp_defconfig
··· 9 9 # CONFIG_UTS_NS is not set 10 10 # CONFIG_PID_NS is not set 11 11 CONFIG_BLK_DEV_INITRD=y 12 - CONFIG_EMBEDDED=y 12 + CONFIG_EXPERT=y 13 13 CONFIG_PERF_EVENTS=y 14 14 # CONFIG_VM_EVENT_COUNTERS is not set 15 15 # CONFIG_COMPAT_BRK is not set
+1 -1
arch/arc/configs/haps_hs_smp_defconfig
··· 11 11 # CONFIG_UTS_NS is not set 12 12 # CONFIG_PID_NS is not set 13 13 CONFIG_BLK_DEV_INITRD=y 14 - CONFIG_EMBEDDED=y 14 + CONFIG_EXPERT=y 15 15 CONFIG_PERF_EVENTS=y 16 16 # CONFIG_VM_EVENT_COUNTERS is not set 17 17 # CONFIG_COMPAT_BRK is not set
+1 -1
arch/arc/configs/hsdk_defconfig
··· 9 9 # CONFIG_PID_NS is not set 10 10 CONFIG_BLK_DEV_INITRD=y 11 11 CONFIG_BLK_DEV_RAM=y 12 - CONFIG_EMBEDDED=y 12 + CONFIG_EXPERT=y 13 13 CONFIG_PERF_EVENTS=y 14 14 # CONFIG_VM_EVENT_COUNTERS is not set 15 15 # CONFIG_COMPAT_BRK is not set
+1 -1
arch/arc/configs/nsim_700_defconfig
··· 12 12 # CONFIG_PID_NS is not set 13 13 CONFIG_BLK_DEV_INITRD=y 14 14 CONFIG_KALLSYMS_ALL=y 15 - CONFIG_EMBEDDED=y 15 + CONFIG_EXPERT=y 16 16 CONFIG_PERF_EVENTS=y 17 17 # CONFIG_SLUB_DEBUG is not set 18 18 # CONFIG_COMPAT_BRK is not set
+1 -1
arch/arc/configs/nsimosci_defconfig
··· 11 11 # CONFIG_PID_NS is not set 12 12 CONFIG_BLK_DEV_INITRD=y 13 13 CONFIG_KALLSYMS_ALL=y 14 - CONFIG_EMBEDDED=y 14 + CONFIG_EXPERT=y 15 15 CONFIG_PERF_EVENTS=y 16 16 # CONFIG_SLUB_DEBUG is not set 17 17 # CONFIG_COMPAT_BRK is not set
+1 -1
arch/arc/configs/nsimosci_hs_defconfig
··· 11 11 # CONFIG_PID_NS is not set 12 12 CONFIG_BLK_DEV_INITRD=y 13 13 CONFIG_KALLSYMS_ALL=y 14 - CONFIG_EMBEDDED=y 14 + CONFIG_EXPERT=y 15 15 CONFIG_PERF_EVENTS=y 16 16 # CONFIG_SLUB_DEBUG is not set 17 17 # CONFIG_COMPAT_BRK is not set
+1 -1
arch/arc/configs/tb10x_defconfig
··· 16 16 # CONFIG_RD_GZIP is not set 17 17 CONFIG_KALLSYMS_ALL=y 18 18 # CONFIG_AIO is not set 19 - CONFIG_EMBEDDED=y 19 + CONFIG_EXPERT=y 20 20 # CONFIG_COMPAT_BRK is not set 21 21 CONFIG_ISA_ARCOMPACT=y 22 22 CONFIG_MODULES=y
+1 -1
arch/arc/configs/vdk_hs38_defconfig
··· 4 4 CONFIG_IKCONFIG=y 5 5 CONFIG_IKCONFIG_PROC=y 6 6 CONFIG_BLK_DEV_INITRD=y 7 - CONFIG_EMBEDDED=y 7 + CONFIG_EXPERT=y 8 8 CONFIG_PERF_EVENTS=y 9 9 # CONFIG_VM_EVENT_COUNTERS is not set 10 10 # CONFIG_SLUB_DEBUG is not set
+1 -1
arch/arc/configs/vdk_hs38_smp_defconfig
··· 4 4 CONFIG_IKCONFIG=y 5 5 CONFIG_IKCONFIG_PROC=y 6 6 CONFIG_BLK_DEV_INITRD=y 7 - CONFIG_EMBEDDED=y 7 + CONFIG_EXPERT=y 8 8 CONFIG_PERF_EVENTS=y 9 9 # CONFIG_VM_EVENT_COUNTERS is not set 10 10 # CONFIG_SLUB_DEBUG is not set
+5 -26
arch/arm/Kconfig
··· 250 250 bool 251 251 252 252 config ARM_PATCH_PHYS_VIRT 253 - bool "Patch physical to virtual translations at runtime" if EMBEDDED 253 + bool "Patch physical to virtual translations at runtime" if !ARCH_MULTIPLATFORM 254 254 default y 255 255 depends on MMU 256 256 help ··· 1645 1645 copied, saving some precious ROM space. A possible drawback is a 1646 1646 slightly longer boot delay. 1647 1647 1648 - config KEXEC 1649 - bool "Kexec system call (EXPERIMENTAL)" 1650 - depends on (!SMP || PM_SLEEP_SMP) 1651 - depends on MMU 1652 - select KEXEC_CORE 1653 - help 1654 - kexec is a system call that implements the ability to shutdown your 1655 - current kernel, and to start another kernel. It is like a reboot 1656 - but it is independent of the system firmware. And like a reboot 1657 - you can start any kernel with it, not just Linux. 1658 - 1659 - It is an ongoing process to be certain the hardware in a machine 1660 - is properly shutdown, so do not be surprised if this code does not 1661 - initially work for you. 1648 + config ARCH_SUPPORTS_KEXEC 1649 + def_bool (!SMP || PM_SLEEP_SMP) && MMU 1662 1650 1663 1651 config ATAGS_PROC 1664 1652 bool "Export atags in procfs" ··· 1656 1668 Should the atags used to boot the kernel be exported in an "atags" 1657 1669 file in procfs. Useful with kexec. 1658 1670 1659 - config CRASH_DUMP 1660 - bool "Build kdump crash kernel (EXPERIMENTAL)" 1661 - help 1662 - Generate crash dump after being started by kexec. This should 1663 - be normally only set in special crash dump kernels which are 1664 - loaded in the main kernel with kexec-tools into a specially 1665 - reserved region and then later executed after a crash by 1666 - kdump/kexec. The crash dump kernel must be compiled to a 1667 - memory address not used by the main kernel 1668 - 1669 - For more details see Documentation/admin-guide/kdump/kdump.rst 1671 + config ARCH_SUPPORTS_CRASH_DUMP 1672 + def_bool y 1670 1673 1671 1674 config AUTO_ZRELADDR 1672 1675 bool "Auto calculation of the decompressed kernel image address" if !ARCH_MULTIPLATFORM
+1 -1
arch/arm/configs/aspeed_g4_defconfig
··· 15 15 # CONFIG_UID16 is not set 16 16 # CONFIG_SYSFS_SYSCALL is not set 17 17 # CONFIG_AIO is not set 18 - CONFIG_EMBEDDED=y 18 + CONFIG_EXPERT=y 19 19 CONFIG_PERF_EVENTS=y 20 20 # CONFIG_ARCH_MULTI_V7 is not set 21 21 CONFIG_ARCH_ASPEED=y
+1 -1
arch/arm/configs/aspeed_g5_defconfig
··· 15 15 # CONFIG_UID16 is not set 16 16 # CONFIG_SYSFS_SYSCALL is not set 17 17 # CONFIG_AIO is not set 18 - CONFIG_EMBEDDED=y 18 + CONFIG_EXPERT=y 19 19 CONFIG_PERF_EVENTS=y 20 20 CONFIG_ARCH_MULTI_V6=y 21 21 CONFIG_ARCH_ASPEED=y
+1 -1
arch/arm/configs/at91_dt_defconfig
··· 7 7 CONFIG_BLK_DEV_INITRD=y 8 8 CONFIG_CC_OPTIMIZE_FOR_SIZE=y 9 9 CONFIG_KALLSYMS_ALL=y 10 - CONFIG_EMBEDDED=y 10 + CONFIG_EXPERT=y 11 11 CONFIG_ARCH_MULTI_V4T=y 12 12 CONFIG_ARCH_MULTI_V5=y 13 13 # CONFIG_ARCH_MULTI_V7 is not set
+1 -1
arch/arm/configs/axm55xx_defconfig
··· 21 21 CONFIG_SCHED_AUTOGROUP=y 22 22 CONFIG_RELAY=y 23 23 CONFIG_BLK_DEV_INITRD=y 24 - CONFIG_EMBEDDED=y 24 + CONFIG_EXPERT=y 25 25 CONFIG_PROFILING=y 26 26 CONFIG_ARCH_AXXIA=y 27 27 CONFIG_ARM_LPAE=y
+1 -1
arch/arm/configs/bcm2835_defconfig
··· 19 19 CONFIG_BLK_DEV_INITRD=y 20 20 CONFIG_CC_OPTIMIZE_FOR_SIZE=y 21 21 CONFIG_KALLSYMS_ALL=y 22 - CONFIG_EMBEDDED=y 22 + CONFIG_EXPERT=y 23 23 CONFIG_PROFILING=y 24 24 CONFIG_CC_STACKPROTECTOR_REGULAR=y 25 25 CONFIG_ARCH_MULTI_V6=y
+1 -1
arch/arm/configs/clps711x_defconfig
··· 3 3 CONFIG_LOG_BUF_SHIFT=14 4 4 CONFIG_BLK_DEV_INITRD=y 5 5 CONFIG_RD_LZMA=y 6 - CONFIG_EMBEDDED=y 6 + CONFIG_EXPERT=y 7 7 CONFIG_JUMP_LABEL=y 8 8 CONFIG_PARTITION_ADVANCED=y 9 9 CONFIG_ARCH_CLPS711X=y
+1 -1
arch/arm/configs/keystone_defconfig
··· 14 14 # CONFIG_ELF_CORE is not set 15 15 # CONFIG_BASE_FULL is not set 16 16 CONFIG_KALLSYMS_ALL=y 17 - CONFIG_EMBEDDED=y 17 + CONFIG_EXPERT=y 18 18 CONFIG_PROFILING=y 19 19 CONFIG_ARCH_KEYSTONE=y 20 20 CONFIG_ARM_LPAE=y
+1 -1
arch/arm/configs/lpc18xx_defconfig
··· 14 14 # CONFIG_SIGNALFD is not set 15 15 # CONFIG_EVENTFD is not set 16 16 # CONFIG_AIO is not set 17 - CONFIG_EMBEDDED=y 17 + CONFIG_EXPERT=y 18 18 # CONFIG_MMU is not set 19 19 CONFIG_ARCH_LPC18XX=y 20 20 CONFIG_SET_MEM_PARAM=y
+1 -1
arch/arm/configs/lpc32xx_defconfig
··· 9 9 CONFIG_SYSFS_DEPRECATED_V2=y 10 10 CONFIG_BLK_DEV_INITRD=y 11 11 CONFIG_CC_OPTIMIZE_FOR_SIZE=y 12 - CONFIG_EMBEDDED=y 12 + CONFIG_EXPERT=y 13 13 # CONFIG_ARCH_MULTI_V7 is not set 14 14 CONFIG_ARCH_LPC32XX=y 15 15 CONFIG_AEABI=y
+1 -1
arch/arm/configs/milbeaut_m10v_defconfig
··· 3 3 CONFIG_HIGH_RES_TIMERS=y 4 4 CONFIG_CGROUPS=y 5 5 CONFIG_BLK_DEV_INITRD=y 6 - CONFIG_EMBEDDED=y 6 + CONFIG_EXPERT=y 7 7 CONFIG_PERF_EVENTS=y 8 8 CONFIG_ARCH_MILBEAUT=y 9 9 CONFIG_ARCH_MILBEAUT_M10V=y
+1 -1
arch/arm/configs/moxart_defconfig
··· 10 10 # CONFIG_TIMERFD is not set 11 11 # CONFIG_EVENTFD is not set 12 12 # CONFIG_AIO is not set 13 - CONFIG_EMBEDDED=y 13 + CONFIG_EXPERT=y 14 14 # CONFIG_BLK_DEV_BSG is not set 15 15 CONFIG_ARCH_MULTI_V4=y 16 16 # CONFIG_ARCH_MULTI_V7 is not set
+1 -1
arch/arm/configs/multi_v4t_defconfig
··· 2 2 CONFIG_SYSVIPC=y 3 3 CONFIG_LOG_BUF_SHIFT=14 4 4 CONFIG_BLK_DEV_INITRD=y 5 - CONFIG_EMBEDDED=y 5 + CONFIG_EXPERT=y 6 6 CONFIG_ARCH_MULTI_V4T=y 7 7 # CONFIG_ARCH_MULTI_V7 is not set 8 8 CONFIG_ARCH_AT91=y
+1 -1
arch/arm/configs/multi_v7_defconfig
··· 3 3 CONFIG_HIGH_RES_TIMERS=y 4 4 CONFIG_CGROUPS=y 5 5 CONFIG_BLK_DEV_INITRD=y 6 - CONFIG_EMBEDDED=y 6 + CONFIG_EXPERT=y 7 7 CONFIG_PERF_EVENTS=y 8 8 CONFIG_ARCH_VIRT=y 9 9 CONFIG_ARCH_AIROHA=y
+1 -1
arch/arm/configs/pxa_defconfig
··· 11 11 CONFIG_LOG_BUF_SHIFT=13 12 12 CONFIG_BLK_DEV_INITRD=y 13 13 CONFIG_KALLSYMS_ALL=y 14 - CONFIG_EMBEDDED=y 14 + CONFIG_EXPERT=y 15 15 CONFIG_PROFILING=y 16 16 # CONFIG_ARCH_MULTI_V7 is not set 17 17 CONFIG_ARCH_PXA=y
+1 -1
arch/arm/configs/qcom_defconfig
··· 7 7 CONFIG_CGROUPS=y 8 8 CONFIG_BLK_DEV_INITRD=y 9 9 CONFIG_KALLSYMS_ALL=y 10 - CONFIG_EMBEDDED=y 10 + CONFIG_EXPERT=y 11 11 CONFIG_PROFILING=y 12 12 CONFIG_ARCH_QCOM=y 13 13 CONFIG_ARCH_MSM8X60=y
+1 -1
arch/arm/configs/sama5_defconfig
··· 5 5 CONFIG_LOG_BUF_SHIFT=14 6 6 CONFIG_CGROUPS=y 7 7 CONFIG_BLK_DEV_INITRD=y 8 - CONFIG_EMBEDDED=y 8 + CONFIG_EXPERT=y 9 9 CONFIG_ARCH_AT91=y 10 10 CONFIG_SOC_SAMA5D2=y 11 11 CONFIG_SOC_SAMA5D3=y
+1 -1
arch/arm/configs/sama7_defconfig
··· 12 12 # CONFIG_FHANDLE is not set 13 13 # CONFIG_IO_URING is not set 14 14 CONFIG_KALLSYMS_ALL=y 15 - CONFIG_EMBEDDED=y 15 + CONFIG_EXPERT=y 16 16 CONFIG_ARCH_AT91=y 17 17 CONFIG_SOC_SAMA7G5=y 18 18 CONFIG_ATMEL_CLOCKSOURCE_TCB=y
+1 -1
arch/arm/configs/socfpga_defconfig
··· 7 7 CONFIG_CPUSETS=y 8 8 CONFIG_NAMESPACES=y 9 9 CONFIG_BLK_DEV_INITRD=y 10 - CONFIG_EMBEDDED=y 10 + CONFIG_EXPERT=y 11 11 CONFIG_PROFILING=y 12 12 CONFIG_ARCH_INTEL_SOCFPGA=y 13 13 CONFIG_ARM_THUMBEE=y
+1 -1
arch/arm/configs/stm32_defconfig
··· 11 11 # CONFIG_SIGNALFD is not set 12 12 # CONFIG_EVENTFD is not set 13 13 # CONFIG_AIO is not set 14 - CONFIG_EMBEDDED=y 14 + CONFIG_EXPERT=y 15 15 # CONFIG_BLK_DEV_BSG is not set 16 16 # CONFIG_MMU is not set 17 17 CONFIG_ARCH_STM32=y
+1 -1
arch/arm/configs/tegra_defconfig
··· 14 14 CONFIG_USER_NS=y 15 15 CONFIG_BLK_DEV_INITRD=y 16 16 # CONFIG_ELF_CORE is not set 17 - CONFIG_EMBEDDED=y 17 + CONFIG_EXPERT=y 18 18 CONFIG_PERF_EVENTS=y 19 19 CONFIG_ARCH_TEGRA=y 20 20 CONFIG_SMP=y
+1 -1
arch/arm/configs/vf610m4_defconfig
··· 5 5 # CONFIG_RD_XZ is not set 6 6 # CONFIG_RD_LZ4 is not set 7 7 CONFIG_KALLSYMS_ALL=y 8 - CONFIG_EMBEDDED=y 8 + CONFIG_EXPERT=y 9 9 # CONFIG_MMU is not set 10 10 CONFIG_ARCH_MXC=y 11 11 CONFIG_SOC_VF610=y
+1 -1
arch/arm/include/asm/irq.h
··· 32 32 #include <linux/cpumask.h> 33 33 34 34 extern void arch_trigger_cpumask_backtrace(const cpumask_t *mask, 35 - bool exclude_self); 35 + int exclude_cpu); 36 36 #define arch_trigger_cpumask_backtrace arch_trigger_cpumask_backtrace 37 37 #endif 38 38
+2 -2
arch/arm/kernel/smp.c
··· 846 846 __ipi_send_mask(ipi_desc[IPI_CPU_BACKTRACE], mask); 847 847 } 848 848 849 - void arch_trigger_cpumask_backtrace(const cpumask_t *mask, bool exclude_self) 849 + void arch_trigger_cpumask_backtrace(const cpumask_t *mask, int exclude_cpu) 850 850 { 851 - nmi_trigger_cpumask_backtrace(mask, exclude_self, raise_nmi); 851 + nmi_trigger_cpumask_backtrace(mask, exclude_cpu, raise_nmi); 852 852 }
+15 -47
arch/arm64/Kconfig
··· 1460 1460 1461 1461 If in doubt, say N here. 1462 1462 1463 - config KEXEC 1464 - depends on PM_SLEEP_SMP 1465 - select KEXEC_CORE 1466 - bool "kexec system call" 1467 - help 1468 - kexec is a system call that implements the ability to shutdown your 1469 - current kernel, and to start another kernel. It is like a reboot 1470 - but it is independent of the system firmware. And like a reboot 1471 - you can start any kernel with it, not just Linux. 1463 + config ARCH_SUPPORTS_KEXEC 1464 + def_bool PM_SLEEP_SMP 1472 1465 1473 - config KEXEC_FILE 1474 - bool "kexec file based system call" 1475 - select KEXEC_CORE 1476 - select HAVE_IMA_KEXEC if IMA 1477 - help 1478 - This is new version of kexec system call. This system call is 1479 - file based and takes file descriptors as system call argument 1480 - for kernel and initramfs as opposed to list of segments as 1481 - accepted by previous system call. 1466 + config ARCH_SUPPORTS_KEXEC_FILE 1467 + def_bool y 1482 1468 1483 - config KEXEC_SIG 1484 - bool "Verify kernel signature during kexec_file_load() syscall" 1469 + config ARCH_SELECTS_KEXEC_FILE 1470 + def_bool y 1485 1471 depends on KEXEC_FILE 1486 - help 1487 - Select this option to verify a signature with loaded kernel 1488 - image. If configured, any attempt of loading a image without 1489 - valid signature will fail. 1472 + select HAVE_IMA_KEXEC if IMA 1490 1473 1491 - In addition to that option, you need to enable signature 1492 - verification for the corresponding kernel image type being 1493 - loaded in order for this to work. 1474 + config ARCH_SUPPORTS_KEXEC_SIG 1475 + def_bool y 1494 1476 1495 - config KEXEC_IMAGE_VERIFY_SIG 1496 - bool "Enable Image signature verification support" 1497 - default y 1498 - depends on KEXEC_SIG 1499 - depends on EFI && SIGNED_PE_FILE_VERIFICATION 1500 - help 1501 - Enable Image signature verification support. 1477 + config ARCH_SUPPORTS_KEXEC_IMAGE_VERIFY_SIG 1478 + def_bool y 1502 1479 1503 - comment "Support for PE file signature verification disabled" 1504 - depends on KEXEC_SIG 1505 - depends on !EFI || !SIGNED_PE_FILE_VERIFICATION 1480 + config ARCH_DEFAULT_KEXEC_IMAGE_VERIFY_SIG 1481 + def_bool y 1506 1482 1507 - config CRASH_DUMP 1508 - bool "Build kdump crash kernel" 1509 - help 1510 - Generate crash dump after being started by kexec. This should 1511 - be normally only set in special crash dump kernels which are 1512 - loaded in the main kernel with kexec-tools into a specially 1513 - reserved region and then later executed after a crash by 1514 - kdump/kexec. 1515 - 1516 - For more details see Documentation/admin-guide/kdump/kdump.rst 1483 + config ARCH_SUPPORTS_CRASH_DUMP 1484 + def_bool y 1517 1485 1518 1486 config TRANS_TABLE 1519 1487 def_bool y
+1 -1
arch/hexagon/configs/comet_defconfig
··· 14 14 CONFIG_IKCONFIG_PROC=y 15 15 CONFIG_LOG_BUF_SHIFT=18 16 16 CONFIG_BLK_DEV_INITRD=y 17 - CONFIG_EMBEDDED=y 17 + CONFIG_EXPERT=y 18 18 # CONFIG_VM_EVENT_COUNTERS is not set 19 19 # CONFIG_BLK_DEV_BSG is not set 20 20 CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
+6 -24
arch/ia64/Kconfig
··· 362 362 the "force" module parameter, e.g., with the "aml_nfw.force" 363 363 kernel command line option. 364 364 365 - config KEXEC 366 - bool "kexec system call" 367 - depends on !SMP || HOTPLUG_CPU 368 - select KEXEC_CORE 369 - help 370 - kexec is a system call that implements the ability to shutdown your 371 - current kernel, and to start another kernel. It is like a reboot 372 - but it is independent of the system firmware. And like a reboot 373 - you can start any kernel with it, not just Linux. 374 - 375 - The name comes from the similarity to the exec system call. 376 - 377 - It is an ongoing process to be certain the hardware in a machine 378 - is properly shutdown, so do not be surprised if this code does not 379 - initially work for you. As of this writing the exact hardware 380 - interface is strongly in flux, so no good recommendation can be 381 - made. 382 - 383 - config CRASH_DUMP 384 - bool "kernel crash dumps" 385 - depends on IA64_MCA_RECOVERY && (!SMP || HOTPLUG_CPU) 386 - help 387 - Generate crash dump after being started by kexec. 388 - 389 365 endmenu 366 + 367 + config ARCH_SUPPORTS_KEXEC 368 + def_bool !SMP || HOTPLUG_CPU 369 + 370 + config ARCH_SUPPORTS_CRASH_DUMP 371 + def_bool IA64_MCA_RECOVERY && (!SMP || HOTPLUG_CPU) 390 372 391 373 menu "Power management and ACPI options" 392 374
+17
arch/ia64/include/asm/cmpxchg.h
··· 13 13 #define arch_cmpxchg_local arch_cmpxchg 14 14 #define arch_cmpxchg64_local arch_cmpxchg64 15 15 16 + #ifdef CONFIG_IA64_DEBUG_CMPXCHG 17 + # define CMPXCHG_BUGCHECK_DECL int _cmpxchg_bugcheck_count = 128; 18 + # define CMPXCHG_BUGCHECK(v) \ 19 + do { \ 20 + if (_cmpxchg_bugcheck_count-- <= 0) { \ 21 + void *ip; \ 22 + extern int _printk(const char *fmt, ...); \ 23 + ip = (void *) ia64_getreg(_IA64_REG_IP); \ 24 + _printk("CMPXCHG_BUGCHECK: stuck at %p on word %p\n", ip, (v));\ 25 + break; \ 26 + } \ 27 + } while (0) 28 + #else /* !CONFIG_IA64_DEBUG_CMPXCHG */ 29 + # define CMPXCHG_BUGCHECK_DECL 30 + # define CMPXCHG_BUGCHECK(v) 31 + #endif /* !CONFIG_IA64_DEBUG_CMPXCHG */ 32 + 16 33 #endif /* _ASM_IA64_CMPXCHG_H */
-17
arch/ia64/include/uapi/asm/cmpxchg.h
··· 133 133 #define cmpxchg64_local cmpxchg64 134 134 #endif 135 135 136 - #ifdef CONFIG_IA64_DEBUG_CMPXCHG 137 - # define CMPXCHG_BUGCHECK_DECL int _cmpxchg_bugcheck_count = 128; 138 - # define CMPXCHG_BUGCHECK(v) \ 139 - do { \ 140 - if (_cmpxchg_bugcheck_count-- <= 0) { \ 141 - void *ip; \ 142 - extern int _printk(const char *fmt, ...); \ 143 - ip = (void *) ia64_getreg(_IA64_REG_IP); \ 144 - _printk("CMPXCHG_BUGCHECK: stuck at %p on word %p\n", ip, (v));\ 145 - break; \ 146 - } \ 147 - } while (0) 148 - #else /* !CONFIG_IA64_DEBUG_CMPXCHG */ 149 - # define CMPXCHG_BUGCHECK_DECL 150 - # define CMPXCHG_BUGCHECK(v) 151 - #endif /* !CONFIG_IA64_DEBUG_CMPXCHG */ 152 - 153 136 #endif /* !__ASSEMBLY__ */ 154 137 155 138 #endif /* _UAPI_ASM_IA64_CMPXCHG_H */
+2 -2
arch/ia64/kernel/mca.c
··· 1630 1630 } 1631 1631 printk("\n\n"); 1632 1632 if (read_trylock(&tasklist_lock)) { 1633 - do_each_thread (g, t) { 1633 + for_each_process_thread(g, t) { 1634 1634 printk("\nBacktrace of pid %d (%s)\n", t->pid, t->comm); 1635 1635 show_stack(t, NULL, KERN_DEFAULT); 1636 - } while_each_thread (g, t); 1636 + } 1637 1637 read_unlock(&tasklist_lock); 1638 1638 } 1639 1639 /* FIXME: This will not restore zapped printk locks. */
+7 -19
arch/loongarch/Kconfig
··· 538 538 bool 539 539 default y 540 540 541 - config KEXEC 542 - bool "Kexec system call" 543 - select KEXEC_CORE 544 - help 545 - kexec is a system call that implements the ability to shutdown your 546 - current kernel, and to start another kernel. It is like a reboot 547 - but it is independent of the system firmware. And like a reboot 548 - you can start any kernel with it, not just Linux. 541 + config ARCH_SUPPORTS_KEXEC 542 + def_bool y 549 543 550 - The name comes from the similarity to the exec system call. 544 + config ARCH_SUPPORTS_CRASH_DUMP 545 + def_bool y 551 546 552 - config CRASH_DUMP 553 - bool "Build kdump crash kernel" 547 + config ARCH_SELECTS_CRASH_DUMP 548 + def_bool y 549 + depends on CRASH_DUMP 554 550 select RELOCATABLE 555 - help 556 - Generate crash dump after being started by kexec. This should 557 - be normally only set in special crash dump kernels which are 558 - loaded in the main kernel with kexec-tools into a specially 559 - reserved region and then later executed after a crash by 560 - kdump/kexec. 561 - 562 - For more details see Documentation/admin-guide/kdump/kdump.rst 563 551 564 552 config RELOCATABLE 565 553 bool "Relocatable kernel"
+1 -1
arch/loongarch/include/asm/irq.h
··· 40 40 #define NR_IRQS_LEGACY 16 41 41 42 42 #define arch_trigger_cpumask_backtrace arch_trigger_cpumask_backtrace 43 - void arch_trigger_cpumask_backtrace(const struct cpumask *mask, bool exclude_self); 43 + void arch_trigger_cpumask_backtrace(const struct cpumask *mask, int exclude_cpu); 44 44 45 45 #define MAX_IO_PICS 2 46 46 #define NR_IRQS (64 + (256 * MAX_IO_PICS))
+2 -2
arch/loongarch/kernel/process.c
··· 338 338 } 339 339 } 340 340 341 - void arch_trigger_cpumask_backtrace(const cpumask_t *mask, bool exclude_self) 341 + void arch_trigger_cpumask_backtrace(const cpumask_t *mask, int exclude_cpu) 342 342 { 343 - nmi_trigger_cpumask_backtrace(mask, exclude_self, raise_backtrace); 343 + nmi_trigger_cpumask_backtrace(mask, exclude_cpu, raise_backtrace); 344 344 } 345 345 346 346 #ifdef CONFIG_64BIT
+2 -17
arch/m68k/Kconfig
··· 89 89 bool 90 90 depends on MMU && !MMU_MOTOROLA && !MMU_COLDFIRE 91 91 92 - config KEXEC 93 - bool "kexec system call" 94 - depends on M68KCLASSIC && MMU 95 - select KEXEC_CORE 96 - help 97 - kexec is a system call that implements the ability to shutdown your 98 - current kernel, and to start another kernel. It is like a reboot 99 - but it is independent of the system firmware. And like a reboot 100 - you can start any kernel with it, not just Linux. 101 - 102 - The name comes from the similarity to the exec system call. 103 - 104 - It is an ongoing process to be certain the hardware in a machine 105 - is properly shutdown, so do not be surprised if this code does not 106 - initially work for you. As of this writing the exact hardware 107 - interface is strongly in flux, so no good recommendation can be 108 - made. 92 + config ARCH_SUPPORTS_KEXEC 93 + def_bool M68KCLASSIC && MMU 109 94 110 95 config BOOTINFO_PROC 111 96 bool "Export bootinfo in procfs"
+1 -1
arch/m68k/configs/amcore_defconfig
··· 8 8 # CONFIG_AIO is not set 9 9 # CONFIG_ADVISE_SYSCALLS is not set 10 10 # CONFIG_MEMBARRIER is not set 11 - CONFIG_EMBEDDED=y 11 + CONFIG_EXPERT=y 12 12 # CONFIG_VM_EVENT_COUNTERS is not set 13 13 # CONFIG_SLUB_DEBUG is not set 14 14 # CONFIG_COMPAT_BRK is not set
+1 -1
arch/m68k/configs/m5475evb_defconfig
··· 8 8 # CONFIG_EVENTFD is not set 9 9 # CONFIG_SHMEM is not set 10 10 # CONFIG_AIO is not set 11 - CONFIG_EMBEDDED=y 11 + CONFIG_EXPERT=y 12 12 CONFIG_MODULES=y 13 13 # CONFIG_BLK_DEV_BSG is not set 14 14 CONFIG_COLDFIRE=y
+1 -1
arch/m68k/configs/stmark2_defconfig
··· 9 9 # CONFIG_AIO is not set 10 10 # CONFIG_ADVISE_SYSCALLS is not set 11 11 # CONFIG_MEMBARRIER is not set 12 - CONFIG_EMBEDDED=y 12 + CONFIG_EXPERT=y 13 13 # CONFIG_VM_EVENT_COUNTERS is not set 14 14 # CONFIG_COMPAT_BRK is not set 15 15 CONFIG_COLDFIRE=y
+1 -1
arch/microblaze/configs/mmu_defconfig
··· 7 7 CONFIG_SYSFS_DEPRECATED_V2=y 8 8 # CONFIG_BASE_FULL is not set 9 9 CONFIG_KALLSYMS_ALL=y 10 - CONFIG_EMBEDDED=y 10 + CONFIG_EXPERT=y 11 11 CONFIG_XILINX_MICROBLAZE0_USE_MSR_INSTR=1 12 12 CONFIG_XILINX_MICROBLAZE0_USE_PCMP_INSTR=1 13 13 CONFIG_XILINX_MICROBLAZE0_USE_BARREL=1
+4 -26
arch/mips/Kconfig
··· 2878 2878 config SCHED_HRTICK 2879 2879 def_bool HIGH_RES_TIMERS 2880 2880 2881 - config KEXEC 2882 - bool "Kexec system call" 2883 - select KEXEC_CORE 2884 - help 2885 - kexec is a system call that implements the ability to shutdown your 2886 - current kernel, and to start another kernel. It is like a reboot 2887 - but it is independent of the system firmware. And like a reboot 2888 - you can start any kernel with it, not just Linux. 2881 + config ARCH_SUPPORTS_KEXEC 2882 + def_bool y 2889 2883 2890 - The name comes from the similarity to the exec system call. 2891 - 2892 - It is an ongoing process to be certain the hardware in a machine 2893 - is properly shutdown, so do not be surprised if this code does not 2894 - initially work for you. As of this writing the exact hardware 2895 - interface is strongly in flux, so no good recommendation can be 2896 - made. 2897 - 2898 - config CRASH_DUMP 2899 - bool "Kernel crash dumps" 2900 - help 2901 - Generate crash dump after being started by kexec. 2902 - This should be normally only set in special crash dump kernels 2903 - which are loaded in the main kernel with kexec-tools into 2904 - a specially reserved region and then later executed after 2905 - a crash by kdump/kexec. The crash dump kernel must be compiled 2906 - to a memory address not used by the main kernel or firmware using 2907 - PHYSICAL_START. 2884 + config ARCH_SUPPORTS_CRASH_DUMP 2885 + def_bool y 2908 2886 2909 2887 config PHYSICAL_START 2910 2888 hex "Physical address where the kernel is loaded"
+1 -1
arch/mips/cavium-octeon/setup.c
··· 1240 1240 */ 1241 1241 octeon_dummy_iospace = vzalloc(IO_SPACE_LIMIT); 1242 1242 set_io_port_base((unsigned long)octeon_dummy_iospace); 1243 - ioport_resource.start = MAX_RESOURCE; 1243 + ioport_resource.start = RESOURCE_SIZE_MAX; 1244 1244 ioport_resource.end = 0; 1245 1245 return 0; 1246 1246 }
+1 -1
arch/mips/configs/ath25_defconfig
··· 11 11 CONFIG_CC_OPTIMIZE_FOR_SIZE=y 12 12 # CONFIG_FHANDLE is not set 13 13 # CONFIG_AIO is not set 14 - CONFIG_EMBEDDED=y 14 + CONFIG_EXPERT=y 15 15 # CONFIG_VM_EVENT_COUNTERS is not set 16 16 # CONFIG_SLUB_DEBUG is not set 17 17 # CONFIG_COMPAT_BRK is not set
+1 -1
arch/mips/configs/ath79_defconfig
··· 5 5 # CONFIG_RD_GZIP is not set 6 6 # CONFIG_AIO is not set 7 7 # CONFIG_KALLSYMS is not set 8 - CONFIG_EMBEDDED=y 8 + CONFIG_EXPERT=y 9 9 # CONFIG_VM_EVENT_COUNTERS is not set 10 10 # CONFIG_SLUB_DEBUG is not set 11 11 # CONFIG_COMPAT_BRK is not set
+1 -1
arch/mips/configs/bcm47xx_defconfig
··· 2 2 CONFIG_HIGH_RES_TIMERS=y 3 3 CONFIG_BLK_DEV_INITRD=y 4 4 CONFIG_CC_OPTIMIZE_FOR_SIZE=y 5 - CONFIG_EMBEDDED=y 5 + CONFIG_EXPERT=y 6 6 CONFIG_BCM47XX=y 7 7 CONFIG_PCI=y 8 8 # CONFIG_SUSPEND is not set
+1 -1
arch/mips/configs/ci20_defconfig
··· 18 18 CONFIG_USER_NS=y 19 19 CONFIG_CC_OPTIMIZE_FOR_SIZE=y 20 20 CONFIG_KALLSYMS_ALL=y 21 - CONFIG_EMBEDDED=y 21 + CONFIG_EXPERT=y 22 22 CONFIG_MACH_INGENIC_SOC=y 23 23 CONFIG_JZ4780_CI20=y 24 24 CONFIG_HIGHMEM=y
+1 -1
arch/mips/configs/cu1000-neo_defconfig
··· 15 15 CONFIG_USER_NS=y 16 16 CONFIG_CC_OPTIMIZE_FOR_SIZE=y 17 17 CONFIG_KALLSYMS_ALL=y 18 - CONFIG_EMBEDDED=y 18 + CONFIG_EXPERT=y 19 19 # CONFIG_VM_EVENT_COUNTERS is not set 20 20 # CONFIG_COMPAT_BRK is not set 21 21 CONFIG_MACH_INGENIC_SOC=y
+1 -1
arch/mips/configs/cu1830-neo_defconfig
··· 15 15 CONFIG_USER_NS=y 16 16 CONFIG_CC_OPTIMIZE_FOR_SIZE=y 17 17 CONFIG_KALLSYMS_ALL=y 18 - CONFIG_EMBEDDED=y 18 + CONFIG_EXPERT=y 19 19 # CONFIG_VM_EVENT_COUNTERS is not set 20 20 # CONFIG_COMPAT_BRK is not set 21 21 CONFIG_MACH_INGENIC_SOC=y
+1 -1
arch/mips/configs/db1xxx_defconfig
··· 17 17 CONFIG_CGROUP_DEVICE=y 18 18 CONFIG_CGROUP_CPUACCT=y 19 19 CONFIG_KALLSYMS_ALL=y 20 - CONFIG_EMBEDDED=y 20 + CONFIG_EXPERT=y 21 21 CONFIG_MIPS_ALCHEMY=y 22 22 CONFIG_HZ_100=y 23 23 CONFIG_PCI=y
+1 -1
arch/mips/configs/gcw0_defconfig
··· 2 2 CONFIG_NO_HZ_IDLE=y 3 3 CONFIG_HIGH_RES_TIMERS=y 4 4 CONFIG_PREEMPT_VOLUNTARY=y 5 - CONFIG_EMBEDDED=y 5 + CONFIG_EXPERT=y 6 6 CONFIG_PROFILING=y 7 7 CONFIG_MACH_INGENIC_SOC=y 8 8 CONFIG_JZ4770_GCW0=y
+1 -1
arch/mips/configs/generic_defconfig
··· 17 17 CONFIG_BLK_DEV_INITRD=y 18 18 CONFIG_BPF_SYSCALL=y 19 19 CONFIG_USERFAULTFD=y 20 - CONFIG_EMBEDDED=y 20 + CONFIG_EXPERT=y 21 21 # CONFIG_SLUB_DEBUG is not set 22 22 # CONFIG_COMPAT_BRK is not set 23 23 CONFIG_CPU_LITTLE_ENDIAN=y
+1 -1
arch/mips/configs/loongson2k_defconfig
··· 18 18 CONFIG_SYSFS_DEPRECATED=y 19 19 CONFIG_RELAY=y 20 20 CONFIG_BLK_DEV_INITRD=y 21 - CONFIG_EMBEDDED=y 21 + CONFIG_EXPERT=y 22 22 CONFIG_MACH_LOONGSON64=y 23 23 # CONFIG_CPU_LOONGSON3_CPUCFG_EMULATION is not set 24 24 CONFIG_HZ_256=y
+1 -1
arch/mips/configs/loongson3_defconfig
··· 26 26 CONFIG_RELAY=y 27 27 CONFIG_BLK_DEV_INITRD=y 28 28 CONFIG_BPF_SYSCALL=y 29 - CONFIG_EMBEDDED=y 29 + CONFIG_EXPERT=y 30 30 CONFIG_PERF_EVENTS=y 31 31 CONFIG_MACH_LOONGSON64=y 32 32 CONFIG_CPU_HAS_MSA=y
+1 -1
arch/mips/configs/malta_qemu_32r6_defconfig
··· 5 5 CONFIG_IKCONFIG=y 6 6 CONFIG_IKCONFIG_PROC=y 7 7 CONFIG_LOG_BUF_SHIFT=15 8 - CONFIG_EMBEDDED=y 8 + CONFIG_EXPERT=y 9 9 CONFIG_MIPS_MALTA=y 10 10 CONFIG_CPU_LITTLE_ENDIAN=y 11 11 CONFIG_CPU_MIPS32_R6=y
+1 -1
arch/mips/configs/maltaaprp_defconfig
··· 5 5 CONFIG_IKCONFIG=y 6 6 CONFIG_IKCONFIG_PROC=y 7 7 CONFIG_LOG_BUF_SHIFT=15 8 - CONFIG_EMBEDDED=y 8 + CONFIG_EXPERT=y 9 9 CONFIG_MIPS_MALTA=y 10 10 CONFIG_CPU_LITTLE_ENDIAN=y 11 11 CONFIG_CPU_MIPS32_R2=y
+1 -1
arch/mips/configs/maltasmvp_defconfig
··· 5 5 CONFIG_IKCONFIG=y 6 6 CONFIG_IKCONFIG_PROC=y 7 7 CONFIG_LOG_BUF_SHIFT=15 8 - CONFIG_EMBEDDED=y 8 + CONFIG_EXPERT=y 9 9 CONFIG_MIPS_MALTA=y 10 10 CONFIG_CPU_LITTLE_ENDIAN=y 11 11 CONFIG_CPU_MIPS32_R2=y
+1 -1
arch/mips/configs/maltasmvp_eva_defconfig
··· 5 5 CONFIG_IKCONFIG=y 6 6 CONFIG_IKCONFIG_PROC=y 7 7 CONFIG_LOG_BUF_SHIFT=15 8 - CONFIG_EMBEDDED=y 8 + CONFIG_EXPERT=y 9 9 CONFIG_MIPS_MALTA=y 10 10 CONFIG_CPU_LITTLE_ENDIAN=y 11 11 CONFIG_CPU_MIPS32_R2=y
+1 -1
arch/mips/configs/maltaup_defconfig
··· 6 6 CONFIG_IKCONFIG=y 7 7 CONFIG_IKCONFIG_PROC=y 8 8 CONFIG_LOG_BUF_SHIFT=15 9 - CONFIG_EMBEDDED=y 9 + CONFIG_EXPERT=y 10 10 CONFIG_MIPS_MALTA=y 11 11 CONFIG_CPU_LITTLE_ENDIAN=y 12 12 CONFIG_CPU_MIPS32_R2=y
+1 -1
arch/mips/configs/omega2p_defconfig
··· 17 17 CONFIG_USER_NS=y 18 18 CONFIG_CC_OPTIMIZE_FOR_SIZE=y 19 19 CONFIG_KALLSYMS_ALL=y 20 - CONFIG_EMBEDDED=y 20 + CONFIG_EXPERT=y 21 21 # CONFIG_VM_EVENT_COUNTERS is not set 22 22 # CONFIG_SLUB_DEBUG is not set 23 23 # CONFIG_COMPAT_BRK is not set
+1 -1
arch/mips/configs/pic32mzda_defconfig
··· 7 7 CONFIG_LOG_BUF_SHIFT=14 8 8 CONFIG_RELAY=y 9 9 CONFIG_CC_OPTIMIZE_FOR_SIZE=y 10 - CONFIG_EMBEDDED=y 10 + CONFIG_EXPERT=y 11 11 # CONFIG_COMPAT_BRK is not set 12 12 CONFIG_MACH_PIC32=y 13 13 CONFIG_DTB_PIC32_MZDA_SK=y
+1 -1
arch/mips/configs/qi_lb60_defconfig
··· 3 3 # CONFIG_CROSS_MEMORY_ATTACH is not set 4 4 CONFIG_LOG_BUF_SHIFT=14 5 5 CONFIG_KALLSYMS_ALL=y 6 - CONFIG_EMBEDDED=y 6 + CONFIG_EXPERT=y 7 7 # CONFIG_VM_EVENT_COUNTERS is not set 8 8 # CONFIG_COMPAT_BRK is not set 9 9 CONFIG_MACH_INGENIC_SOC=y
+1 -1
arch/mips/configs/rs90_defconfig
··· 15 15 # CONFIG_IO_URING is not set 16 16 # CONFIG_ADVISE_SYSCALLS is not set 17 17 # CONFIG_KALLSYMS is not set 18 - CONFIG_EMBEDDED=y 18 + CONFIG_EXPERT=y 19 19 # CONFIG_PERF_EVENTS is not set 20 20 CONFIG_PROFILING=y 21 21 CONFIG_MACH_INGENIC_SOC=y
+1 -1
arch/mips/configs/rt305x_defconfig
··· 7 7 CONFIG_CC_OPTIMIZE_FOR_SIZE=y 8 8 # CONFIG_AIO is not set 9 9 CONFIG_KALLSYMS_ALL=y 10 - CONFIG_EMBEDDED=y 10 + CONFIG_EXPERT=y 11 11 # CONFIG_VM_EVENT_COUNTERS is not set 12 12 # CONFIG_SLUB_DEBUG is not set 13 13 # CONFIG_COMPAT_BRK is not set
+1 -1
arch/mips/configs/vocore2_defconfig
··· 17 17 CONFIG_USER_NS=y 18 18 CONFIG_CC_OPTIMIZE_FOR_SIZE=y 19 19 CONFIG_KALLSYMS_ALL=y 20 - CONFIG_EMBEDDED=y 20 + CONFIG_EXPERT=y 21 21 # CONFIG_VM_EVENT_COUNTERS is not set 22 22 # CONFIG_SLUB_DEBUG is not set 23 23 # CONFIG_COMPAT_BRK is not set
+1 -1
arch/mips/configs/xway_defconfig
··· 7 7 CONFIG_CC_OPTIMIZE_FOR_SIZE=y 8 8 # CONFIG_AIO is not set 9 9 CONFIG_KALLSYMS_ALL=y 10 - CONFIG_EMBEDDED=y 10 + CONFIG_EXPERT=y 11 11 # CONFIG_VM_EVENT_COUNTERS is not set 12 12 # CONFIG_SLUB_DEBUG is not set 13 13 # CONFIG_COMPAT_BRK is not set
+1 -1
arch/mips/include/asm/irq.h
··· 77 77 extern int get_c0_fdc_int(void); 78 78 79 79 void arch_trigger_cpumask_backtrace(const struct cpumask *mask, 80 - bool exclude_self); 80 + int exclude_cpu); 81 81 #define arch_trigger_cpumask_backtrace arch_trigger_cpumask_backtrace 82 82 83 83 #endif /* _ASM_IRQ_H */
+2 -2
arch/mips/kernel/process.c
··· 750 750 } 751 751 } 752 752 753 - void arch_trigger_cpumask_backtrace(const cpumask_t *mask, bool exclude_self) 753 + void arch_trigger_cpumask_backtrace(const cpumask_t *mask, int exclude_cpu) 754 754 { 755 - nmi_trigger_cpumask_backtrace(mask, exclude_self, raise_backtrace); 755 + nmi_trigger_cpumask_backtrace(mask, exclude_cpu, raise_backtrace); 756 756 } 757 757 758 758 int mips_get_process_fp_mode(struct task_struct *task)
+1 -1
arch/nios2/configs/10m50_defconfig
··· 9 9 # CONFIG_EVENTFD is not set 10 10 # CONFIG_SHMEM is not set 11 11 # CONFIG_AIO is not set 12 - CONFIG_EMBEDDED=y 12 + CONFIG_EXPERT=y 13 13 CONFIG_MODULES=y 14 14 CONFIG_MODULE_UNLOAD=y 15 15 CONFIG_NIOS2_MEM_BASE=0x8000000
+1 -1
arch/nios2/configs/3c120_defconfig
··· 9 9 # CONFIG_EVENTFD is not set 10 10 # CONFIG_SHMEM is not set 11 11 # CONFIG_AIO is not set 12 - CONFIG_EMBEDDED=y 12 + CONFIG_EXPERT=y 13 13 CONFIG_MODULES=y 14 14 CONFIG_MODULE_UNLOAD=y 15 15 CONFIG_NIOS2_MEM_BASE=0x10000000
+1 -1
arch/openrisc/configs/or1klitex_defconfig
··· 6 6 CONFIG_BLK_DEV_INITRD=y 7 7 CONFIG_CC_OPTIMIZE_FOR_SIZE=y 8 8 CONFIG_SGETMASK_SYSCALL=y 9 - CONFIG_EMBEDDED=y 9 + CONFIG_EXPERT=y 10 10 CONFIG_OPENRISC_BUILTIN_DTB="or1klitex" 11 11 CONFIG_HZ_100=y 12 12 CONFIG_OPENRISC_HAVE_SHADOW_GPRS=y
+11 -23
arch/parisc/Kconfig
··· 359 359 default "8" if 64BIT 360 360 default "16" 361 361 362 - config KEXEC 363 - bool "Kexec system call" 364 - select KEXEC_CORE 365 - help 366 - kexec is a system call that implements the ability to shutdown your 367 - current kernel, and to start another kernel. It is like a reboot 368 - but it is independent of the system firmware. And like a reboot 369 - you can start any kernel with it, not just Linux. 370 - 371 - It is an ongoing process to be certain the hardware in a machine 372 - shutdown, so do not be surprised if this code does not 373 - initially work for you. 374 - 375 - config KEXEC_FILE 376 - bool "kexec file based system call" 377 - select KEXEC_CORE 378 - select KEXEC_ELF 379 - help 380 - This enables the kexec_file_load() System call. This is 381 - file based and takes file descriptors as system call argument 382 - for kernel and initramfs as opposed to list of segments as 383 - accepted by previous system call. 384 - 385 362 endmenu 363 + 364 + config ARCH_SUPPORTS_KEXEC 365 + def_bool y 366 + 367 + config ARCH_SUPPORTS_KEXEC_FILE 368 + def_bool y 369 + 370 + config ARCH_SELECTS_KEXEC_FILE 371 + def_bool y 372 + depends on KEXEC_FILE 373 + select KEXEC_ELF 386 374 387 375 source "drivers/parisc/Kconfig"
+17 -38
arch/powerpc/Kconfig
··· 592 592 default "y" if PPC_POWERNV 593 593 select ARCH_SUPPORTS_MEMORY_FAILURE 594 594 595 - config KEXEC 596 - bool "kexec system call" 597 - depends on PPC_BOOK3S || PPC_E500 || (44x && !SMP) 598 - select KEXEC_CORE 599 - help 600 - kexec is a system call that implements the ability to shutdown your 601 - current kernel, and to start another kernel. It is like a reboot 602 - but it is independent of the system firmware. And like a reboot 603 - you can start any kernel with it, not just Linux. 595 + config ARCH_SUPPORTS_KEXEC 596 + def_bool PPC_BOOK3S || PPC_E500 || (44x && !SMP) 604 597 605 - The name comes from the similarity to the exec system call. 598 + config ARCH_SUPPORTS_KEXEC_FILE 599 + def_bool PPC64 && CRYPTO=y && CRYPTO_SHA256=y 606 600 607 - It is an ongoing process to be certain the hardware in a machine 608 - is properly shutdown, so do not be surprised if this code does not 609 - initially work for you. As of this writing the exact hardware 610 - interface is strongly in flux, so no good recommendation can be 611 - made. 612 - 613 - config KEXEC_FILE 614 - bool "kexec file based system call" 615 - select KEXEC_CORE 616 - select HAVE_IMA_KEXEC if IMA 617 - select KEXEC_ELF 618 - depends on PPC64 619 - depends on CRYPTO=y 620 - depends on CRYPTO_SHA256=y 621 - help 622 - This is a new version of the kexec system call. This call is 623 - file based and takes in file descriptors as system call arguments 624 - for kernel and initramfs as opposed to a list of segments as is the 625 - case for the older kexec call. 626 - 627 - config ARCH_HAS_KEXEC_PURGATORY 601 + config ARCH_SUPPORTS_KEXEC_PURGATORY 628 602 def_bool KEXEC_FILE 603 + 604 + config ARCH_SELECTS_KEXEC_FILE 605 + def_bool y 606 + depends on KEXEC_FILE 607 + select KEXEC_ELF 608 + select HAVE_IMA_KEXEC if IMA 629 609 630 610 config PPC64_BIG_ENDIAN_ELF_ABI_V2 631 611 # Option is available to BFD, but LLD does not support ELFv1 so this is ··· 666 686 loaded at, which tends to be non-zero and therefore test the 667 687 relocation code. 668 688 669 - config CRASH_DUMP 670 - bool "Build a dump capture kernel" 671 - depends on PPC64 || PPC_BOOK3S_32 || PPC_85xx || (44x && !SMP) 689 + config ARCH_SUPPORTS_CRASH_DUMP 690 + def_bool PPC64 || PPC_BOOK3S_32 || PPC_85xx || (44x && !SMP) 691 + 692 + config ARCH_SELECTS_CRASH_DUMP 693 + def_bool y 694 + depends on CRASH_DUMP 672 695 select RELOCATABLE if PPC64 || 44x || PPC_85xx 673 - help 674 - Build a kernel suitable for use as a dump capture kernel. 675 - The same kernel binary can be used as production kernel and dump 676 - capture kernel. 677 696 678 697 config FA_DUMP 679 698 bool "Firmware-assisted dump"
+1 -1
arch/powerpc/configs/40x/klondike_defconfig
··· 4 4 CONFIG_SYSFS_DEPRECATED=y 5 5 CONFIG_SYSFS_DEPRECATED_V2=y 6 6 CONFIG_BLK_DEV_INITRD=y 7 - CONFIG_EMBEDDED=y 7 + CONFIG_EXPERT=y 8 8 CONFIG_MODULES=y 9 9 CONFIG_MODULE_UNLOAD=y 10 10 CONFIG_APM8018X=y
+1 -1
arch/powerpc/configs/44x/fsp2_defconfig
··· 15 15 # CONFIG_RD_LZ4 is not set 16 16 CONFIG_KALLSYMS_ALL=y 17 17 CONFIG_BPF_SYSCALL=y 18 - CONFIG_EMBEDDED=y 18 + CONFIG_EXPERT=y 19 19 CONFIG_PROFILING=y 20 20 CONFIG_MODULES=y 21 21 CONFIG_MODULE_UNLOAD=y
+1 -1
arch/powerpc/configs/52xx/tqm5200_defconfig
··· 3 3 CONFIG_BLK_DEV_INITRD=y 4 4 # CONFIG_KALLSYMS is not set 5 5 # CONFIG_EPOLL is not set 6 - CONFIG_EMBEDDED=y 6 + CONFIG_EXPERT=y 7 7 CONFIG_MODULES=y 8 8 CONFIG_MODULE_UNLOAD=y 9 9 CONFIG_MODVERSIONS=y
+1 -1
arch/powerpc/configs/mgcoge_defconfig
··· 9 9 # CONFIG_RD_GZIP is not set 10 10 CONFIG_KALLSYMS_ALL=y 11 11 # CONFIG_PCSPKR_PLATFORM is not set 12 - CONFIG_EMBEDDED=y 12 + CONFIG_EXPERT=y 13 13 CONFIG_PARTITION_ADVANCED=y 14 14 # CONFIG_PPC_PMAC is not set 15 15 CONFIG_PPC_82xx=y
+1 -1
arch/powerpc/configs/microwatt_defconfig
··· 8 8 CONFIG_BLK_DEV_INITRD=y 9 9 CONFIG_CC_OPTIMIZE_FOR_SIZE=y 10 10 CONFIG_KALLSYMS_ALL=y 11 - CONFIG_EMBEDDED=y 11 + CONFIG_EXPERT=y 12 12 # CONFIG_VM_EVENT_COUNTERS is not set 13 13 # CONFIG_SLUB_DEBUG is not set 14 14 # CONFIG_COMPAT_BRK is not set
+1 -1
arch/powerpc/configs/ps3_defconfig
··· 3 3 CONFIG_HIGH_RES_TIMERS=y 4 4 CONFIG_BLK_DEV_INITRD=y 5 5 CONFIG_CC_OPTIMIZE_FOR_SIZE=y 6 - CONFIG_EMBEDDED=y 6 + CONFIG_EXPERT=y 7 7 # CONFIG_PERF_EVENTS is not set 8 8 CONFIG_PROFILING=y 9 9 CONFIG_PPC64=y
+1 -1
arch/powerpc/include/asm/irq.h
··· 55 55 56 56 #if defined(CONFIG_PPC_BOOK3S_64) && defined(CONFIG_NMI_IPI) 57 57 extern void arch_trigger_cpumask_backtrace(const cpumask_t *mask, 58 - bool exclude_self); 58 + int exclude_cpu); 59 59 #define arch_trigger_cpumask_backtrace arch_trigger_cpumask_backtrace 60 60 #endif 61 61
+2 -2
arch/powerpc/kernel/stacktrace.c
··· 221 221 } 222 222 } 223 223 224 - void arch_trigger_cpumask_backtrace(const cpumask_t *mask, bool exclude_self) 224 + void arch_trigger_cpumask_backtrace(const cpumask_t *mask, int exclude_cpu) 225 225 { 226 - nmi_trigger_cpumask_backtrace(mask, exclude_self, raise_backtrace_ipi); 226 + nmi_trigger_cpumask_backtrace(mask, exclude_cpu, raise_backtrace_ipi); 227 227 } 228 228 #endif /* defined(CONFIG_PPC_BOOK3S_64) && defined(CONFIG_NMI_IPI) */
+2 -2
arch/powerpc/kernel/watchdog.c
··· 245 245 __cpumask_clear_cpu(c, &wd_smp_cpus_ipi); 246 246 } 247 247 } else { 248 - trigger_allbutself_cpu_backtrace(); 248 + trigger_allbutcpu_cpu_backtrace(cpu); 249 249 cpumask_clear(&wd_smp_cpus_ipi); 250 250 } 251 251 ··· 416 416 xchg(&__wd_nmi_output, 1); // see wd_lockup_ipi 417 417 418 418 if (sysctl_hardlockup_all_cpu_backtrace) 419 - trigger_allbutself_cpu_backtrace(); 419 + trigger_allbutcpu_cpu_backtrace(cpu); 420 420 421 421 if (hardlockup_panic) 422 422 nmi_panic(regs, "Hard LOCKUP");
+1 -1
arch/riscv/Kbuild
··· 5 5 obj-y += errata/ 6 6 obj-$(CONFIG_KVM) += kvm/ 7 7 8 - obj-$(CONFIG_ARCH_HAS_KEXEC_PURGATORY) += purgatory/ 8 + obj-$(CONFIG_ARCH_SUPPORTS_KEXEC_PURGATORY) += purgatory/ 9 9 10 10 # for cleaning 11 11 subdir- += boot
+14 -32
arch/riscv/Kconfig
··· 656 656 657 657 If unsure what to do here, say N. 658 658 659 - config KEXEC 660 - bool "Kexec system call" 661 - depends on MMU 659 + config ARCH_SUPPORTS_KEXEC 660 + def_bool MMU 661 + 662 + config ARCH_SELECTS_KEXEC 663 + def_bool y 664 + depends on KEXEC 662 665 select HOTPLUG_CPU if SMP 663 - select KEXEC_CORE 664 - help 665 - kexec is a system call that implements the ability to shutdown your 666 - current kernel, and to start another kernel. It is like a reboot 667 - but it is independent of the system firmware. And like a reboot 668 - you can start any kernel with it, not just Linux. 669 666 670 - The name comes from the similarity to the exec system call. 667 + config ARCH_SUPPORTS_KEXEC_FILE 668 + def_bool 64BIT && MMU 671 669 672 - config KEXEC_FILE 673 - bool "kexec file based systmem call" 674 - depends on 64BIT && MMU 670 + config ARCH_SELECTS_KEXEC_FILE 671 + def_bool y 672 + depends on KEXEC_FILE 675 673 select HAVE_IMA_KEXEC if IMA 676 - select KEXEC_CORE 677 674 select KEXEC_ELF 678 - help 679 - This is new version of kexec system call. This system call is 680 - file based and takes file descriptors as system call argument 681 - for kernel and initramfs as opposed to list of segments as 682 - accepted by previous system call. 683 675 684 - If you don't know what to do here, say Y. 685 - 686 - config ARCH_HAS_KEXEC_PURGATORY 676 + config ARCH_SUPPORTS_KEXEC_PURGATORY 687 677 def_bool KEXEC_FILE 688 678 depends on CRYPTO=y 689 679 depends on CRYPTO_SHA256=y 690 680 691 - config CRASH_DUMP 692 - bool "Build kdump crash kernel" 693 - help 694 - Generate crash dump after being started by kexec. This should 695 - be normally only set in special crash dump kernels which are 696 - loaded in the main kernel with kexec-tools into a specially 697 - reserved region and then later executed after a crash by 698 - kdump/kexec. 699 - 700 - For more details see Documentation/admin-guide/kdump/kdump.rst 681 + config ARCH_SUPPORTS_CRASH_DUMP 682 + def_bool y 701 683 702 684 config COMPAT 703 685 bool "Kernel support for 32-bit U-mode"
+1 -1
arch/riscv/configs/nommu_k210_defconfig
··· 21 21 # CONFIG_IO_URING is not set 22 22 # CONFIG_ADVISE_SYSCALLS is not set 23 23 # CONFIG_KALLSYMS is not set 24 - CONFIG_EMBEDDED=y 24 + CONFIG_EXPERT=y 25 25 # CONFIG_VM_EVENT_COUNTERS is not set 26 26 # CONFIG_COMPAT_BRK is not set 27 27 CONFIG_SLUB=y
+1 -1
arch/riscv/configs/nommu_k210_sdcard_defconfig
··· 13 13 # CONFIG_IO_URING is not set 14 14 # CONFIG_ADVISE_SYSCALLS is not set 15 15 # CONFIG_KALLSYMS is not set 16 - CONFIG_EMBEDDED=y 16 + CONFIG_EXPERT=y 17 17 # CONFIG_VM_EVENT_COUNTERS is not set 18 18 # CONFIG_COMPAT_BRK is not set 19 19 CONFIG_SLUB=y
+2 -2
arch/riscv/kernel/elf_kexec.c
··· 260 260 cmdline = modified_cmdline; 261 261 } 262 262 263 - #ifdef CONFIG_ARCH_HAS_KEXEC_PURGATORY 263 + #ifdef CONFIG_ARCH_SUPPORTS_KEXEC_PURGATORY 264 264 /* Add purgatory to the image */ 265 265 kbuf.top_down = true; 266 266 kbuf.mem = KEXEC_BUF_MEM_UNKNOWN; ··· 274 274 sizeof(kernel_start), 0); 275 275 if (ret) 276 276 pr_err("Error update purgatory ret=%d\n", ret); 277 - #endif /* CONFIG_ARCH_HAS_KEXEC_PURGATORY */ 277 + #endif /* CONFIG_ARCH_SUPPORTS_KEXEC_PURGATORY */ 278 278 279 279 /* Add the initrd to the image */ 280 280 if (initrd != NULL) {
+1 -1
arch/s390/Kbuild
··· 7 7 obj-$(CONFIG_APPLDATA_BASE) += appldata/ 8 8 obj-y += net/ 9 9 obj-$(CONFIG_PCI) += pci/ 10 - obj-$(CONFIG_ARCH_HAS_KEXEC_PURGATORY) += purgatory/ 10 + obj-$(CONFIG_ARCH_SUPPORTS_KEXEC_PURGATORY) += purgatory/ 11 11 12 12 # for cleaning 13 13 subdir- += boot tools
+20 -46
arch/s390/Kconfig
··· 215 215 select HAVE_VIRT_CPU_ACCOUNTING_IDLE 216 216 select IOMMU_HELPER if PCI 217 217 select IOMMU_SUPPORT if PCI 218 + select KEXEC 218 219 select MMU_GATHER_MERGE_VMAS 219 220 select MMU_GATHER_NO_GATHER 220 221 select MMU_GATHER_RCU_TABLE_FREE ··· 246 245 default 5 247 246 248 247 source "kernel/livepatch/Kconfig" 248 + 249 + config ARCH_SUPPORTS_KEXEC 250 + def_bool y 251 + 252 + config ARCH_SUPPORTS_KEXEC_FILE 253 + def_bool CRYPTO && CRYPTO_SHA256 && CRYPTO_SHA256_S390 254 + 255 + config ARCH_SUPPORTS_KEXEC_SIG 256 + def_bool MODULE_SIG_FORMAT 257 + 258 + config ARCH_SUPPORTS_KEXEC_PURGATORY 259 + def_bool KEXEC_FILE 260 + 261 + config ARCH_SUPPORTS_CRASH_DUMP 262 + def_bool y 263 + help 264 + Refer to <file:Documentation/arch/s390/zfcpdump.rst> for more details on this. 265 + This option also enables s390 zfcpdump. 266 + See also <file:Documentation/arch/s390/zfcpdump.rst> 249 267 250 268 menu "Processor type and features" 251 269 ··· 504 484 505 485 source "kernel/Kconfig.hz" 506 486 507 - config KEXEC 508 - def_bool y 509 - select KEXEC_CORE 510 - 511 - config KEXEC_FILE 512 - bool "kexec file based system call" 513 - select KEXEC_CORE 514 - depends on CRYPTO 515 - depends on CRYPTO_SHA256 516 - depends on CRYPTO_SHA256_S390 517 - help 518 - Enable the kexec file based system call. In contrast to the normal 519 - kexec system call this system call takes file descriptors for the 520 - kernel and initramfs as arguments. 521 - 522 - config ARCH_HAS_KEXEC_PURGATORY 523 - def_bool y 524 - depends on KEXEC_FILE 525 - 526 - config KEXEC_SIG 527 - bool "Verify kernel signature during kexec_file_load() syscall" 528 - depends on KEXEC_FILE && MODULE_SIG_FORMAT 529 - help 530 - This option makes kernel signature verification mandatory for 531 - the kexec_file_load() syscall. 532 - 533 - In addition to that option, you need to enable signature 534 - verification for the corresponding kernel image type being 535 - loaded in order for this to work. 536 - 537 487 config CERT_STORE 538 488 bool "Get user certificates via DIAG320" 539 489 depends on KEYS ··· 733 743 734 744 To compile this driver as a module, choose M here: the module 735 745 will be called vfio_ap. 736 - 737 - endmenu 738 - 739 - menu "Dump support" 740 - 741 - config CRASH_DUMP 742 - bool "kernel crash dumps" 743 - select KEXEC 744 - help 745 - Generate crash dump after being started by kexec. 746 - Crash dump kernels are loaded in the main kernel with kexec-tools 747 - into a specially reserved region and then later executed after 748 - a crash by kdump/kexec. 749 - Refer to <file:Documentation/arch/s390/zfcpdump.rst> for more details on this. 750 - This option also enables s390 zfcpdump. 751 - See also <file:Documentation/arch/s390/zfcpdump.rst> 752 746 753 747 endmenu 754 748
+6 -36
arch/sh/Kconfig
··· 549 549 550 550 source "kernel/Kconfig.hz" 551 551 552 - config KEXEC 553 - bool "kexec system call (EXPERIMENTAL)" 554 - depends on MMU 555 - select KEXEC_CORE 556 - help 557 - kexec is a system call that implements the ability to shutdown your 558 - current kernel, and to start another kernel. It is like a reboot 559 - but it is independent of the system firmware. And like a reboot 560 - you can start any kernel with it, not just Linux. 552 + config ARCH_SUPPORTS_KEXEC 553 + def_bool MMU 561 554 562 - The name comes from the similarity to the exec system call. 555 + config ARCH_SUPPORTS_CRASH_DUMP 556 + def_bool BROKEN_ON_SMP 563 557 564 - It is an ongoing process to be certain the hardware in a machine 565 - is properly shutdown, so do not be surprised if this code does not 566 - initially work for you. As of this writing the exact hardware 567 - interface is strongly in flux, so no good recommendation can be 568 - made. 569 - 570 - config CRASH_DUMP 571 - bool "kernel crash dumps (EXPERIMENTAL)" 572 - depends on BROKEN_ON_SMP 573 - help 574 - Generate crash dump after being started by kexec. 575 - This should be normally only set in special crash dump kernels 576 - which are loaded in the main kernel with kexec-tools into 577 - a specially reserved region and then later executed after 578 - a crash by kdump/kexec. The crash dump kernel must be compiled 579 - to a memory address not used by the main kernel using 580 - PHYSICAL_START. 581 - 582 - For more details see Documentation/admin-guide/kdump/kdump.rst 583 - 584 - config KEXEC_JUMP 585 - bool "kexec jump (EXPERIMENTAL)" 586 - depends on KEXEC && HIBERNATION 587 - help 588 - Jump between original kernel and kexeced kernel and invoke 589 - code via KEXEC 558 + config ARCH_SUPPORTS_KEXEC_JUMP 559 + def_bool y 590 560 591 561 config PHYSICAL_START 592 562 hex "Physical address where the kernel is loaded" if (EXPERT || CRASH_DUMP)
+1 -1
arch/sh/configs/rsk7264_defconfig
··· 9 9 CONFIG_SYSFS_DEPRECATED_V2=y 10 10 CONFIG_CC_OPTIMIZE_FOR_SIZE=y 11 11 CONFIG_KALLSYMS_ALL=y 12 - CONFIG_EMBEDDED=y 12 + CONFIG_EXPERT=y 13 13 CONFIG_PERF_COUNTERS=y 14 14 # CONFIG_VM_EVENT_COUNTERS is not set 15 15 CONFIG_MMAP_ALLOW_UNINITIALIZED=y
+1 -1
arch/sh/configs/rsk7269_defconfig
··· 1 1 CONFIG_LOG_BUF_SHIFT=14 2 2 CONFIG_CC_OPTIMIZE_FOR_SIZE=y 3 - CONFIG_EMBEDDED=y 3 + CONFIG_EXPERT=y 4 4 # CONFIG_VM_EVENT_COUNTERS is not set 5 5 # CONFIG_BLK_DEV_BSG is not set 6 6 CONFIG_SWAP_IO_SPACE=y
+1 -1
arch/sparc/include/asm/irq_64.h
··· 87 87 } 88 88 89 89 void arch_trigger_cpumask_backtrace(const struct cpumask *mask, 90 - bool exclude_self); 90 + int exclude_cpu); 91 91 #define arch_trigger_cpumask_backtrace arch_trigger_cpumask_backtrace 92 92 93 93 extern void *hardirq_stack[NR_CPUS];
+3 -3
arch/sparc/kernel/process_64.c
··· 236 236 } 237 237 } 238 238 239 - void arch_trigger_cpumask_backtrace(const cpumask_t *mask, bool exclude_self) 239 + void arch_trigger_cpumask_backtrace(const cpumask_t *mask, int exclude_cpu) 240 240 { 241 241 struct thread_info *tp = current_thread_info(); 242 242 struct pt_regs *regs = get_irq_regs(); ··· 252 252 253 253 memset(global_cpu_snapshot, 0, sizeof(global_cpu_snapshot)); 254 254 255 - if (cpumask_test_cpu(this_cpu, mask) && !exclude_self) 255 + if (cpumask_test_cpu(this_cpu, mask) && this_cpu != exclude_cpu) 256 256 __global_reg_self(tp, regs, this_cpu); 257 257 258 258 smp_fetch_global_regs(); ··· 260 260 for_each_cpu(cpu, mask) { 261 261 struct global_reg_snapshot *gp; 262 262 263 - if (exclude_self && cpu == this_cpu) 263 + if (cpu == exclude_cpu) 264 264 continue; 265 265 266 266 gp = &global_cpu_snapshot[cpu].reg;
+20 -71
arch/x86/Kconfig
··· 2006 2006 2007 2007 source "kernel/Kconfig.hz" 2008 2008 2009 - config KEXEC 2010 - bool "kexec system call" 2011 - select KEXEC_CORE 2012 - help 2013 - kexec is a system call that implements the ability to shutdown your 2014 - current kernel, and to start another kernel. It is like a reboot 2015 - but it is independent of the system firmware. And like a reboot 2016 - you can start any kernel with it, not just Linux. 2009 + config ARCH_SUPPORTS_KEXEC 2010 + def_bool y 2017 2011 2018 - The name comes from the similarity to the exec system call. 2012 + config ARCH_SUPPORTS_KEXEC_FILE 2013 + def_bool X86_64 && CRYPTO && CRYPTO_SHA256 2019 2014 2020 - It is an ongoing process to be certain the hardware in a machine 2021 - is properly shutdown, so do not be surprised if this code does not 2022 - initially work for you. As of this writing the exact hardware 2023 - interface is strongly in flux, so no good recommendation can be 2024 - made. 2025 - 2026 - config KEXEC_FILE 2027 - bool "kexec file based system call" 2028 - select KEXEC_CORE 2015 + config ARCH_SELECTS_KEXEC_FILE 2016 + def_bool y 2017 + depends on KEXEC_FILE 2029 2018 select HAVE_IMA_KEXEC if IMA 2030 - depends on X86_64 2031 - depends on CRYPTO=y 2032 - depends on CRYPTO_SHA256=y 2033 - help 2034 - This is new version of kexec system call. This system call is 2035 - file based and takes file descriptors as system call argument 2036 - for kernel and initramfs as opposed to list of segments as 2037 - accepted by previous system call. 2038 2019 2039 - config ARCH_HAS_KEXEC_PURGATORY 2020 + config ARCH_SUPPORTS_KEXEC_PURGATORY 2040 2021 def_bool KEXEC_FILE 2041 2022 2042 - config KEXEC_SIG 2043 - bool "Verify kernel signature during kexec_file_load() syscall" 2044 - depends on KEXEC_FILE 2045 - help 2023 + config ARCH_SUPPORTS_KEXEC_SIG 2024 + def_bool y 2046 2025 2047 - This option makes the kexec_file_load() syscall check for a valid 2048 - signature of the kernel image. The image can still be loaded without 2049 - a valid signature unless you also enable KEXEC_SIG_FORCE, though if 2050 - there's a signature that we can check, then it must be valid. 2026 + config ARCH_SUPPORTS_KEXEC_SIG_FORCE 2027 + def_bool y 2051 2028 2052 - In addition to this option, you need to enable signature 2053 - verification for the corresponding kernel image type being 2054 - loaded in order for this to work. 2029 + config ARCH_SUPPORTS_KEXEC_BZIMAGE_VERIFY_SIG 2030 + def_bool y 2055 2031 2056 - config KEXEC_SIG_FORCE 2057 - bool "Require a valid signature in kexec_file_load() syscall" 2058 - depends on KEXEC_SIG 2059 - help 2060 - This option makes kernel signature verification mandatory for 2061 - the kexec_file_load() syscall. 2032 + config ARCH_SUPPORTS_KEXEC_JUMP 2033 + def_bool y 2062 2034 2063 - config KEXEC_BZIMAGE_VERIFY_SIG 2064 - bool "Enable bzImage signature verification support" 2065 - depends on KEXEC_SIG 2066 - depends on SIGNED_PE_FILE_VERIFICATION 2067 - select SYSTEM_TRUSTED_KEYRING 2068 - help 2069 - Enable bzImage signature verification support. 2035 + config ARCH_SUPPORTS_CRASH_DUMP 2036 + def_bool X86_64 || (X86_32 && HIGHMEM) 2070 2037 2071 - config CRASH_DUMP 2072 - bool "kernel crash dumps" 2073 - depends on X86_64 || (X86_32 && HIGHMEM) 2074 - help 2075 - Generate crash dump after being started by kexec. 2076 - This should be normally only set in special crash dump kernels 2077 - which are loaded in the main kernel with kexec-tools into 2078 - a specially reserved region and then later executed after 2079 - a crash by kdump/kexec. The crash dump kernel must be compiled 2080 - to a memory address not used by the main kernel or BIOS using 2081 - PHYSICAL_START, or it must be built as a relocatable image 2082 - (CONFIG_RELOCATABLE=y). 2083 - For more details see Documentation/admin-guide/kdump/kdump.rst 2084 - 2085 - config KEXEC_JUMP 2086 - bool "kexec jump" 2087 - depends on KEXEC && HIBERNATION 2088 - help 2089 - Jump between original kernel and kexeced kernel and invoke 2090 - code in physical address mode via KEXEC 2038 + config ARCH_SUPPORTS_CRASH_HOTPLUG 2039 + def_bool y 2091 2040 2092 2041 config PHYSICAL_START 2093 2042 hex "Physical address where the kernel is loaded" if (EXPERT || CRASH_DUMP)
+1 -1
arch/x86/include/asm/irq.h
··· 42 42 43 43 #ifdef CONFIG_X86_LOCAL_APIC 44 44 void arch_trigger_cpumask_backtrace(const struct cpumask *mask, 45 - bool exclude_self); 45 + int exclude_cpu); 46 46 47 47 #define arch_trigger_cpumask_backtrace arch_trigger_cpumask_backtrace 48 48 #endif
+18
arch/x86/include/asm/kexec.h
··· 209 209 extern crash_vmclear_fn __rcu *crash_vmclear_loaded_vmcss; 210 210 extern void kdump_nmi_shootdown_cpus(void); 211 211 212 + #ifdef CONFIG_CRASH_HOTPLUG 213 + void arch_crash_handle_hotplug_event(struct kimage *image); 214 + #define arch_crash_handle_hotplug_event arch_crash_handle_hotplug_event 215 + 216 + #ifdef CONFIG_HOTPLUG_CPU 217 + int arch_crash_hotplug_cpu_support(void); 218 + #define crash_hotplug_cpu_support arch_crash_hotplug_cpu_support 219 + #endif 220 + 221 + #ifdef CONFIG_MEMORY_HOTPLUG 222 + int arch_crash_hotplug_memory_support(void); 223 + #define crash_hotplug_memory_support arch_crash_hotplug_memory_support 224 + #endif 225 + 226 + unsigned int arch_crash_get_elfcorehdr_size(void); 227 + #define crash_get_elfcorehdr_size arch_crash_get_elfcorehdr_size 228 + #endif 229 + 212 230 #endif /* __ASSEMBLY__ */ 213 231 214 232 #endif /* _ASM_X86_KEXEC_H */
+3 -8
arch/x86/include/asm/rmwcc.h
··· 2 2 #ifndef _ASM_X86_RMWcc 3 3 #define _ASM_X86_RMWcc 4 4 5 - /* This counts to 12. Any more, it will return 13th argument. */ 6 - #define __RMWcc_ARGS(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _n, X...) _n 7 - #define RMWcc_ARGS(X...) __RMWcc_ARGS(, ##X, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0) 8 - 9 - #define __RMWcc_CONCAT(a, b) a ## b 10 - #define RMWcc_CONCAT(a, b) __RMWcc_CONCAT(a, b) 5 + #include <linux/args.h> 11 6 12 7 #define __CLOBBERS_MEM(clb...) "memory", ## clb 13 8 ··· 43 48 #define GEN_UNARY_RMWcc_3(op, var, cc) \ 44 49 GEN_UNARY_RMWcc_4(op, var, cc, "%[var]") 45 50 46 - #define GEN_UNARY_RMWcc(X...) RMWcc_CONCAT(GEN_UNARY_RMWcc_, RMWcc_ARGS(X))(X) 51 + #define GEN_UNARY_RMWcc(X...) CONCATENATE(GEN_UNARY_RMWcc_, COUNT_ARGS(X))(X) 47 52 48 53 #define GEN_BINARY_RMWcc_6(op, var, cc, vcon, _val, arg0) \ 49 54 __GEN_RMWcc(op " %[val], " arg0, var, cc, \ ··· 52 57 #define GEN_BINARY_RMWcc_5(op, var, cc, vcon, val) \ 53 58 GEN_BINARY_RMWcc_6(op, var, cc, vcon, val, "%[var]") 54 59 55 - #define GEN_BINARY_RMWcc(X...) RMWcc_CONCAT(GEN_BINARY_RMWcc_, RMWcc_ARGS(X))(X) 60 + #define GEN_BINARY_RMWcc(X...) CONCATENATE(GEN_BINARY_RMWcc_, COUNT_ARGS(X))(X) 56 61 57 62 #define GEN_UNARY_SUFFIXED_RMWcc(op, suffix, var, cc, clobbers...) \ 58 63 __GEN_RMWcc(op " %[var]\n\t" suffix, var, cc, \
-18
arch/x86/include/asm/sections.h
··· 2 2 #ifndef _ASM_X86_SECTIONS_H 3 3 #define _ASM_X86_SECTIONS_H 4 4 5 - #define arch_is_kernel_initmem_freed arch_is_kernel_initmem_freed 6 - 7 5 #include <asm-generic/sections.h> 8 6 #include <asm/extable.h> 9 7 ··· 15 17 extern char __end_of_kernel_reserve[]; 16 18 17 19 extern unsigned long _brk_start, _brk_end; 18 - 19 - static inline bool arch_is_kernel_initmem_freed(unsigned long addr) 20 - { 21 - /* 22 - * If _brk_start has not been cleared, brk allocation is incomplete, 23 - * and we can not make assumptions about its use. 24 - */ 25 - if (_brk_start) 26 - return 0; 27 - 28 - /* 29 - * After brk allocation is complete, space between _brk_end and _end 30 - * is available for allocation. 31 - */ 32 - return addr >= _brk_end && addr < (unsigned long)&_end; 33 - } 34 20 35 21 #endif /* _ASM_X86_SECTIONS_H */
+4 -5
arch/x86/kernel/Makefile
··· 33 33 KMSAN_SANITIZE_head$(BITS).o := n 34 34 KMSAN_SANITIZE_nmi.o := n 35 35 36 - # If instrumentation of this dir is enabled, boot hangs during first second. 37 - # Probably could be more selective here, but note that files related to irqs, 38 - # boot, dumpstack/stacktrace, etc are either non-interesting or can lead to 39 - # non-deterministic coverage. 40 - KCOV_INSTRUMENT := n 36 + # If instrumentation of the following files is enabled, boot hangs during 37 + # first second. 38 + KCOV_INSTRUMENT_head$(BITS).o := n 39 + KCOV_INSTRUMENT_sev.o := n 41 40 42 41 CFLAGS_irq.o := -I $(srctree)/$(src)/../include/asm/trace 43 42
+2 -2
arch/x86/kernel/apic/hw_nmi.c
··· 34 34 apic->send_IPI_mask(mask, NMI_VECTOR); 35 35 } 36 36 37 - void arch_trigger_cpumask_backtrace(const cpumask_t *mask, bool exclude_self) 37 + void arch_trigger_cpumask_backtrace(const cpumask_t *mask, int exclude_cpu) 38 38 { 39 - nmi_trigger_cpumask_backtrace(mask, exclude_self, 39 + nmi_trigger_cpumask_backtrace(mask, exclude_cpu, 40 40 nmi_raise_cpu_backtrace); 41 41 } 42 42
+135 -7
arch/x86/kernel/crash.c
··· 158 158 crash_save_cpu(regs, safe_smp_processor_id()); 159 159 } 160 160 161 - #ifdef CONFIG_KEXEC_FILE 162 - 161 + #if defined(CONFIG_KEXEC_FILE) || defined(CONFIG_CRASH_HOTPLUG) 163 162 static int get_nr_ram_ranges_callback(struct resource *res, void *arg) 164 163 { 165 164 unsigned int *nr_ranges = arg; ··· 230 231 231 232 /* Prepare elf headers. Return addr and size */ 232 233 static int prepare_elf_headers(struct kimage *image, void **addr, 233 - unsigned long *sz) 234 + unsigned long *sz, unsigned long *nr_mem_ranges) 234 235 { 235 236 struct crash_mem *cmem; 236 237 int ret; ··· 248 249 if (ret) 249 250 goto out; 250 251 252 + /* Return the computed number of memory ranges, for hotplug usage */ 253 + *nr_mem_ranges = cmem->nr_ranges; 254 + 251 255 /* By default prepare 64bit headers */ 252 256 ret = crash_prepare_elf64_headers(cmem, IS_ENABLED(CONFIG_X86_64), addr, sz); 253 257 ··· 258 256 vfree(cmem); 259 257 return ret; 260 258 } 259 + #endif 261 260 261 + #ifdef CONFIG_KEXEC_FILE 262 262 static int add_e820_entry(struct boot_params *params, struct e820_entry *entry) 263 263 { 264 264 unsigned int nr_e820_entries; ··· 375 371 int crash_load_segments(struct kimage *image) 376 372 { 377 373 int ret; 374 + unsigned long pnum = 0; 378 375 struct kexec_buf kbuf = { .image = image, .buf_min = 0, 379 376 .buf_max = ULONG_MAX, .top_down = false }; 380 377 381 378 /* Prepare elf headers and add a segment */ 382 - ret = prepare_elf_headers(image, &kbuf.buffer, &kbuf.bufsz); 379 + ret = prepare_elf_headers(image, &kbuf.buffer, &kbuf.bufsz, &pnum); 383 380 if (ret) 384 381 return ret; 385 382 386 - image->elf_headers = kbuf.buffer; 387 - image->elf_headers_sz = kbuf.bufsz; 383 + image->elf_headers = kbuf.buffer; 384 + image->elf_headers_sz = kbuf.bufsz; 385 + kbuf.memsz = kbuf.bufsz; 388 386 389 - kbuf.memsz = kbuf.bufsz; 387 + #ifdef CONFIG_CRASH_HOTPLUG 388 + /* 389 + * The elfcorehdr segment size accounts for VMCOREINFO, kernel_map, 390 + * maximum CPUs and maximum memory ranges. 391 + */ 392 + if (IS_ENABLED(CONFIG_MEMORY_HOTPLUG)) 393 + pnum = 2 + CONFIG_NR_CPUS_DEFAULT + CONFIG_CRASH_MAX_MEMORY_RANGES; 394 + else 395 + pnum += 2 + CONFIG_NR_CPUS_DEFAULT; 396 + 397 + if (pnum < (unsigned long)PN_XNUM) { 398 + kbuf.memsz = pnum * sizeof(Elf64_Phdr); 399 + kbuf.memsz += sizeof(Elf64_Ehdr); 400 + 401 + image->elfcorehdr_index = image->nr_segments; 402 + 403 + /* Mark as usable to crash kernel, else crash kernel fails on boot */ 404 + image->elf_headers_sz = kbuf.memsz; 405 + } else { 406 + pr_err("number of Phdrs %lu exceeds max\n", pnum); 407 + } 408 + #endif 409 + 390 410 kbuf.buf_align = ELF_CORE_HEADER_ALIGN; 391 411 kbuf.mem = KEXEC_BUF_MEM_UNKNOWN; 392 412 ret = kexec_add_buffer(&kbuf); ··· 423 395 return ret; 424 396 } 425 397 #endif /* CONFIG_KEXEC_FILE */ 398 + 399 + #ifdef CONFIG_CRASH_HOTPLUG 400 + 401 + #undef pr_fmt 402 + #define pr_fmt(fmt) "crash hp: " fmt 403 + 404 + /* These functions provide the value for the sysfs crash_hotplug nodes */ 405 + #ifdef CONFIG_HOTPLUG_CPU 406 + int arch_crash_hotplug_cpu_support(void) 407 + { 408 + return crash_check_update_elfcorehdr(); 409 + } 410 + #endif 411 + 412 + #ifdef CONFIG_MEMORY_HOTPLUG 413 + int arch_crash_hotplug_memory_support(void) 414 + { 415 + return crash_check_update_elfcorehdr(); 416 + } 417 + #endif 418 + 419 + unsigned int arch_crash_get_elfcorehdr_size(void) 420 + { 421 + unsigned int sz; 422 + 423 + /* kernel_map, VMCOREINFO and maximum CPUs */ 424 + sz = 2 + CONFIG_NR_CPUS_DEFAULT; 425 + if (IS_ENABLED(CONFIG_MEMORY_HOTPLUG)) 426 + sz += CONFIG_CRASH_MAX_MEMORY_RANGES; 427 + sz *= sizeof(Elf64_Phdr); 428 + return sz; 429 + } 430 + 431 + /** 432 + * arch_crash_handle_hotplug_event() - Handle hotplug elfcorehdr changes 433 + * @image: a pointer to kexec_crash_image 434 + * 435 + * Prepare the new elfcorehdr and replace the existing elfcorehdr. 436 + */ 437 + void arch_crash_handle_hotplug_event(struct kimage *image) 438 + { 439 + void *elfbuf = NULL, *old_elfcorehdr; 440 + unsigned long nr_mem_ranges; 441 + unsigned long mem, memsz; 442 + unsigned long elfsz = 0; 443 + 444 + /* 445 + * As crash_prepare_elf64_headers() has already described all 446 + * possible CPUs, there is no need to update the elfcorehdr 447 + * for additional CPU changes. 448 + */ 449 + if ((image->file_mode || image->elfcorehdr_updated) && 450 + ((image->hp_action == KEXEC_CRASH_HP_ADD_CPU) || 451 + (image->hp_action == KEXEC_CRASH_HP_REMOVE_CPU))) 452 + return; 453 + 454 + /* 455 + * Create the new elfcorehdr reflecting the changes to CPU and/or 456 + * memory resources. 457 + */ 458 + if (prepare_elf_headers(image, &elfbuf, &elfsz, &nr_mem_ranges)) { 459 + pr_err("unable to create new elfcorehdr"); 460 + goto out; 461 + } 462 + 463 + /* 464 + * Obtain address and size of the elfcorehdr segment, and 465 + * check it against the new elfcorehdr buffer. 466 + */ 467 + mem = image->segment[image->elfcorehdr_index].mem; 468 + memsz = image->segment[image->elfcorehdr_index].memsz; 469 + if (elfsz > memsz) { 470 + pr_err("update elfcorehdr elfsz %lu > memsz %lu", 471 + elfsz, memsz); 472 + goto out; 473 + } 474 + 475 + /* 476 + * Copy new elfcorehdr over the old elfcorehdr at destination. 477 + */ 478 + old_elfcorehdr = kmap_local_page(pfn_to_page(mem >> PAGE_SHIFT)); 479 + if (!old_elfcorehdr) { 480 + pr_err("mapping elfcorehdr segment failed\n"); 481 + goto out; 482 + } 483 + 484 + /* 485 + * Temporarily invalidate the crash image while the 486 + * elfcorehdr is updated. 487 + */ 488 + xchg(&kexec_crash_image, NULL); 489 + memcpy_flushcache(old_elfcorehdr, elfbuf, elfsz); 490 + xchg(&kexec_crash_image, image); 491 + kunmap_local(old_elfcorehdr); 492 + pr_debug("updated elfcorehdr\n"); 493 + 494 + out: 495 + vfree(elfbuf); 496 + } 497 + #endif
+8
arch/x86/pci/amd_bus.c
··· 51 51 return NULL; 52 52 } 53 53 54 + static inline resource_size_t cap_resource(u64 val) 55 + { 56 + if (val > RESOURCE_SIZE_MAX) 57 + return RESOURCE_SIZE_MAX; 58 + 59 + return val; 60 + } 61 + 54 62 /** 55 63 * early_root_info_init() 56 64 * called before pcibios_scan_root and pci_scan_bus
+1 -1
arch/x86/pci/bus_numa.c
··· 101 101 if (start > end) 102 102 return; 103 103 104 - if (start == MAX_RESOURCE) 104 + if (start == RESOURCE_SIZE_MAX) 105 105 return; 106 106 107 107 if (!merge)
+1 -1
arch/xtensa/configs/cadence_csp_defconfig
··· 21 21 # CONFIG_RD_LZO is not set 22 22 # CONFIG_RD_LZ4 is not set 23 23 CONFIG_CC_OPTIMIZE_FOR_SIZE=y 24 - CONFIG_EMBEDDED=y 24 + CONFIG_EXPERT=y 25 25 CONFIG_PROFILING=y 26 26 CONFIG_MODULES=y 27 27 CONFIG_MODULE_FORCE_LOAD=y
+13
drivers/base/cpu.c
··· 282 282 static DEVICE_ATTR(nohz_full, 0444, print_cpus_nohz_full, NULL); 283 283 #endif 284 284 285 + #ifdef CONFIG_CRASH_HOTPLUG 286 + static ssize_t crash_hotplug_show(struct device *dev, 287 + struct device_attribute *attr, 288 + char *buf) 289 + { 290 + return sysfs_emit(buf, "%d\n", crash_hotplug_cpu_support()); 291 + } 292 + static DEVICE_ATTR_ADMIN_RO(crash_hotplug); 293 + #endif 294 + 285 295 static void cpu_device_release(struct device *dev) 286 296 { 287 297 /* ··· 478 468 &dev_attr_isolated.attr, 479 469 #ifdef CONFIG_NO_HZ_FULL 480 470 &dev_attr_nohz_full.attr, 471 + #endif 472 + #ifdef CONFIG_CRASH_HOTPLUG 473 + &dev_attr_crash_hotplug.attr, 481 474 #endif 482 475 #ifdef CONFIG_GENERIC_CPU_AUTOPROBE 483 476 &dev_attr_modalias.attr,
+13
drivers/base/memory.c
··· 497 497 498 498 static DEVICE_ATTR_RW(auto_online_blocks); 499 499 500 + #ifdef CONFIG_CRASH_HOTPLUG 501 + #include <linux/kexec.h> 502 + static ssize_t crash_hotplug_show(struct device *dev, 503 + struct device_attribute *attr, char *buf) 504 + { 505 + return sysfs_emit(buf, "%d\n", crash_hotplug_memory_support()); 506 + } 507 + static DEVICE_ATTR_RO(crash_hotplug); 508 + #endif 509 + 500 510 /* 501 511 * Some architectures will have custom drivers to do this, and 502 512 * will not need to do it from userspace. The fake hot-add code ··· 906 896 907 897 &dev_attr_block_size_bytes.attr, 908 898 &dev_attr_auto_online_blocks.attr, 899 + #ifdef CONFIG_CRASH_HOTPLUG 900 + &dev_attr_crash_hotplug.attr, 901 + #endif 909 902 NULL 910 903 }; 911 904
+9 -9
drivers/char/mem.c
··· 692 692 693 693 static const struct memdev { 694 694 const char *name; 695 - umode_t mode; 696 695 const struct file_operations *fops; 697 696 fmode_t fmode; 697 + umode_t mode; 698 698 } devlist[] = { 699 699 #ifdef CONFIG_DEVMEM 700 - [DEVMEM_MINOR] = { "mem", 0, &mem_fops, FMODE_UNSIGNED_OFFSET }, 700 + [DEVMEM_MINOR] = { "mem", &mem_fops, FMODE_UNSIGNED_OFFSET, 0 }, 701 701 #endif 702 - [3] = { "null", 0666, &null_fops, FMODE_NOWAIT }, 702 + [3] = { "null", &null_fops, FMODE_NOWAIT, 0666 }, 703 703 #ifdef CONFIG_DEVPORT 704 - [4] = { "port", 0, &port_fops, 0 }, 704 + [4] = { "port", &port_fops, 0, 0 }, 705 705 #endif 706 - [5] = { "zero", 0666, &zero_fops, FMODE_NOWAIT }, 707 - [7] = { "full", 0666, &full_fops, 0 }, 708 - [8] = { "random", 0666, &random_fops, FMODE_NOWAIT }, 709 - [9] = { "urandom", 0666, &urandom_fops, FMODE_NOWAIT }, 706 + [5] = { "zero", &zero_fops, FMODE_NOWAIT, 0666 }, 707 + [7] = { "full", &full_fops, 0, 0666 }, 708 + [8] = { "random", &random_fops, FMODE_NOWAIT, 0666 }, 709 + [9] = { "urandom", &urandom_fops, FMODE_NOWAIT, 0666 }, 710 710 #ifdef CONFIG_PRINTK 711 - [11] = { "kmsg", 0644, &kmsg_fops, 0 }, 711 + [11] = { "kmsg", &kmsg_fops, 0, 0644 }, 712 712 #endif 713 713 }; 714 714
+1
drivers/gpu/drm/i915/display/intel_dpll_mgr.c
··· 21 21 * DEALINGS IN THE SOFTWARE. 22 22 */ 23 23 24 + #include <linux/math.h> 24 25 #include <linux/string_helpers.h> 25 26 26 27 #include "i915_reg.h"
-7
drivers/gpu/drm/i915/display/intel_dpll_mgr.h
··· 29 29 30 30 #include "intel_wakeref.h" 31 31 32 - /*FIXME: Move this to a more appropriate place. */ 33 - #define abs_diff(a, b) ({ \ 34 - typeof(a) __a = (a); \ 35 - typeof(b) __b = (b); \ 36 - (void) (&__a == &__b); \ 37 - __a > __b ? (__a - __b) : (__b - __a); }) 38 - 39 32 enum tc_port; 40 33 struct drm_i915_private; 41 34 struct intel_atomic_state;
+7 -8
drivers/gpu/ipu-v3/ipu-image-convert.c
··· 7 7 8 8 #include <linux/interrupt.h> 9 9 #include <linux/dma-mapping.h> 10 + #include <linux/math.h> 11 + 10 12 #include <video/imx-ipu-image-convert.h> 13 + 11 14 #include "ipu-prv.h" 12 15 13 16 /* ··· 546 543 unsigned int in_pos; 547 544 unsigned int in_pos_aligned; 548 545 unsigned int in_pos_rounded; 549 - unsigned int abs_diff; 546 + unsigned int diff; 550 547 551 548 /* 552 549 * Tiles in the right row / bottom column may not be allowed to ··· 578 575 (in_edge - in_pos_rounded) % in_burst) 579 576 continue; 580 577 581 - if (in_pos < in_pos_aligned) 582 - abs_diff = in_pos_aligned - in_pos; 583 - else 584 - abs_diff = in_pos - in_pos_aligned; 585 - 586 - if (abs_diff < min_diff) { 578 + diff = abs_diff(in_pos, in_pos_aligned); 579 + if (diff < min_diff) { 587 580 in_seam = in_pos_rounded; 588 581 out_seam = out_pos; 589 - min_diff = abs_diff; 582 + min_diff = diff; 590 583 } 591 584 } 592 585
+1
drivers/irqchip/Kconfig
··· 89 89 config AL_FIC 90 90 bool "Amazon's Annapurna Labs Fabric Interrupt Controller" 91 91 depends on OF 92 + depends on HAS_IOMEM 92 93 select GENERIC_IRQ_CHIP 93 94 select IRQ_DOMAIN 94 95 help
+1
drivers/net/ethernet/altera/Kconfig
··· 2 2 config ALTERA_TSE 3 3 tristate "Altera Triple-Speed Ethernet MAC support" 4 4 depends on HAS_DMA 5 + depends on HAS_IOMEM 5 6 select PHYLIB 6 7 select PHYLINK 7 8 select PCS_LYNX
+1 -6
drivers/tty/serial/omap-serial.c
··· 222 222 unsigned int baud, unsigned int mode) 223 223 { 224 224 unsigned int n = port->uartclk / (mode * baud); 225 - int abs_diff; 226 225 227 226 if (n == 0) 228 227 n = 1; 229 228 230 - abs_diff = baud - (port->uartclk / (mode * n)); 231 - if (abs_diff < 0) 232 - abs_diff = -abs_diff; 233 - 234 - return abs_diff; 229 + return abs_diff(baud, port->uartclk / (mode * n)); 235 230 } 236 231 237 232 /*
+2 -2
drivers/tty/tty_io.c
··· 3031 3031 } while_each_pid_task(session, PIDTYPE_SID, p); 3032 3032 3033 3033 /* Now kill any processes that happen to have the tty open */ 3034 - do_each_thread(g, p) { 3034 + for_each_process_thread(g, p) { 3035 3035 if (p->signal->tty == tty) { 3036 3036 tty_notice(tty, "SAK: killed process %d (%s): by controlling tty\n", 3037 3037 task_pid_nr(p), p->comm); ··· 3048 3048 PIDTYPE_SID); 3049 3049 } 3050 3050 task_unlock(p); 3051 - } while_each_thread(g, p); 3051 + } 3052 3052 read_unlock(&tasklist_lock); 3053 3053 put_pid(session); 3054 3054 }
+1 -6
drivers/video/fbdev/core/svgalib.c
··· 14 14 #include <linux/kernel.h> 15 15 #include <linux/string.h> 16 16 #include <linux/fb.h> 17 + #include <linux/math.h> 17 18 #include <linux/svga.h> 18 19 #include <asm/types.h> 19 20 #include <asm/io.h> ··· 373 372 * F_VCO = (F_BASE * M) / N 374 373 * F_OUT = F_VCO / (2^R) 375 374 */ 376 - 377 - static inline u32 abs_diff(u32 a, u32 b) 378 - { 379 - return (a > b) ? (a - b) : (b - a); 380 - } 381 - 382 375 int svga_compute_pll(const struct svga_pll *pll, u32 f_wanted, u16 *m, u16 *n, u16 *r, int node) 383 376 { 384 377 u16 am, an, ar;
-5
fs/adfs/dir_f.h
··· 58 58 __u8 dircheckbyte; 59 59 } __attribute__((packed)); 60 60 61 - union adfs_dirtail { 62 - struct adfs_olddirtail old; 63 - struct adfs_newdirtail new; 64 - }; 65 - 66 61 #endif
+1 -4
fs/efs/efs.h
··· 1 1 /* SPDX-License-Identifier: GPL-2.0 */ 2 2 /* 3 - * Copyright (c) 1999 Al Smith 3 + * Copyright (c) 1999 Al Smith, <Al.Smith@aeschi.ch.eu.org> 4 4 * 5 5 * Portions derived from work (c) 1995,1996 Christian Vogelgsang. 6 6 * Portions derived from IRIX header files (c) 1988 Silicon Graphics ··· 18 18 #include <linux/uaccess.h> 19 19 20 20 #define EFS_VERSION "1.0a" 21 - 22 - static const char cprt[] = "EFS: "EFS_VERSION" - (c) 1999 Al Smith <Al.Smith@aeschi.ch.eu.org>"; 23 - 24 21 25 22 /* 1 block is 512 bytes */ 26 23 #define EFS_BLOCKSIZE_BITS 9
+2 -2
fs/exec.c
··· 1277 1277 1278 1278 /* 1279 1279 * Must be called _before_ exec_mmap() as bprm->mm is 1280 - * not visible until then. This also enables the update 1281 - * to be lockless. 1280 + * not visible until then. Doing it here also ensures 1281 + * we don't race against replace_mm_exe_file(). 1282 1282 */ 1283 1283 retval = set_mm_exe_file(bprm->mm, bprm->file); 1284 1284 if (retval)
+2 -2
fs/fs_struct.c
··· 62 62 int count = 0; 63 63 64 64 read_lock(&tasklist_lock); 65 - do_each_thread(g, p) { 65 + for_each_process_thread(g, p) { 66 66 task_lock(p); 67 67 fs = p->fs; 68 68 if (fs) { ··· 79 79 spin_unlock(&fs->lock); 80 80 } 81 81 task_unlock(p); 82 - } while_each_thread(g, p); 82 + } 83 83 read_unlock(&tasklist_lock); 84 84 while (count--) 85 85 path_put(old_root);
+3 -3
fs/hfsplus/extents.c
··· 448 448 if (sbi->alloc_file->i_size * 8 < 449 449 sbi->total_blocks - sbi->free_blocks + 8) { 450 450 /* extend alloc file */ 451 - pr_err("extend alloc file! (%llu,%u,%u)\n", 452 - sbi->alloc_file->i_size * 8, 453 - sbi->total_blocks, sbi->free_blocks); 451 + pr_err_ratelimited("extend alloc file! (%llu,%u,%u)\n", 452 + sbi->alloc_file->i_size * 8, 453 + sbi->total_blocks, sbi->free_blocks); 454 454 return -ENOSPC; 455 455 } 456 456
+2 -1
fs/nilfs2/alloc.c
··· 205 205 int ret; 206 206 207 207 spin_lock(lock); 208 - if (prev->bh && blkoff == prev->blkoff) { 208 + if (prev->bh && blkoff == prev->blkoff && 209 + likely(buffer_uptodate(prev->bh))) { 209 210 get_bh(prev->bh); 210 211 *bhp = prev->bh; 211 212 spin_unlock(lock);
+5 -2
fs/nilfs2/inode.c
··· 1025 1025 int err; 1026 1026 1027 1027 spin_lock(&nilfs->ns_inode_lock); 1028 - if (ii->i_bh == NULL) { 1028 + if (ii->i_bh == NULL || unlikely(!buffer_uptodate(ii->i_bh))) { 1029 1029 spin_unlock(&nilfs->ns_inode_lock); 1030 1030 err = nilfs_ifile_get_inode_block(ii->i_root->ifile, 1031 1031 inode->i_ino, pbh); ··· 1034 1034 spin_lock(&nilfs->ns_inode_lock); 1035 1035 if (ii->i_bh == NULL) 1036 1036 ii->i_bh = *pbh; 1037 - else { 1037 + else if (unlikely(!buffer_uptodate(ii->i_bh))) { 1038 + __brelse(ii->i_bh); 1039 + ii->i_bh = *pbh; 1040 + } else { 1038 1041 brelse(*pbh); 1039 1042 *pbh = ii->i_bh; 1040 1043 }
+20 -20
fs/ocfs2/cluster/netdebug.c
··· 44 44 45 45 void o2net_debug_add_nst(struct o2net_send_tracking *nst) 46 46 { 47 - spin_lock(&o2net_debug_lock); 47 + spin_lock_bh(&o2net_debug_lock); 48 48 list_add(&nst->st_net_debug_item, &send_tracking); 49 - spin_unlock(&o2net_debug_lock); 49 + spin_unlock_bh(&o2net_debug_lock); 50 50 } 51 51 52 52 void o2net_debug_del_nst(struct o2net_send_tracking *nst) 53 53 { 54 - spin_lock(&o2net_debug_lock); 54 + spin_lock_bh(&o2net_debug_lock); 55 55 if (!list_empty(&nst->st_net_debug_item)) 56 56 list_del_init(&nst->st_net_debug_item); 57 - spin_unlock(&o2net_debug_lock); 57 + spin_unlock_bh(&o2net_debug_lock); 58 58 } 59 59 60 60 static struct o2net_send_tracking ··· 84 84 { 85 85 struct o2net_send_tracking *nst, *dummy_nst = seq->private; 86 86 87 - spin_lock(&o2net_debug_lock); 87 + spin_lock_bh(&o2net_debug_lock); 88 88 nst = next_nst(dummy_nst); 89 - spin_unlock(&o2net_debug_lock); 89 + spin_unlock_bh(&o2net_debug_lock); 90 90 91 91 return nst; 92 92 } ··· 95 95 { 96 96 struct o2net_send_tracking *nst, *dummy_nst = seq->private; 97 97 98 - spin_lock(&o2net_debug_lock); 98 + spin_lock_bh(&o2net_debug_lock); 99 99 nst = next_nst(dummy_nst); 100 100 list_del_init(&dummy_nst->st_net_debug_item); 101 101 if (nst) 102 102 list_add(&dummy_nst->st_net_debug_item, 103 103 &nst->st_net_debug_item); 104 - spin_unlock(&o2net_debug_lock); 104 + spin_unlock_bh(&o2net_debug_lock); 105 105 106 106 return nst; /* unused, just needs to be null when done */ 107 107 } ··· 112 112 ktime_t now; 113 113 s64 sock, send, status; 114 114 115 - spin_lock(&o2net_debug_lock); 115 + spin_lock_bh(&o2net_debug_lock); 116 116 nst = next_nst(dummy_nst); 117 117 if (!nst) 118 118 goto out; ··· 145 145 (long long)status); 146 146 147 147 out: 148 - spin_unlock(&o2net_debug_lock); 148 + spin_unlock_bh(&o2net_debug_lock); 149 149 150 150 return 0; 151 151 } ··· 191 191 192 192 void o2net_debug_add_sc(struct o2net_sock_container *sc) 193 193 { 194 - spin_lock(&o2net_debug_lock); 194 + spin_lock_bh(&o2net_debug_lock); 195 195 list_add(&sc->sc_net_debug_item, &sock_containers); 196 - spin_unlock(&o2net_debug_lock); 196 + spin_unlock_bh(&o2net_debug_lock); 197 197 } 198 198 199 199 void o2net_debug_del_sc(struct o2net_sock_container *sc) 200 200 { 201 - spin_lock(&o2net_debug_lock); 201 + spin_lock_bh(&o2net_debug_lock); 202 202 list_del_init(&sc->sc_net_debug_item); 203 - spin_unlock(&o2net_debug_lock); 203 + spin_unlock_bh(&o2net_debug_lock); 204 204 } 205 205 206 206 struct o2net_sock_debug { ··· 236 236 struct o2net_sock_debug *sd = seq->private; 237 237 struct o2net_sock_container *sc, *dummy_sc = sd->dbg_sock; 238 238 239 - spin_lock(&o2net_debug_lock); 239 + spin_lock_bh(&o2net_debug_lock); 240 240 sc = next_sc(dummy_sc); 241 - spin_unlock(&o2net_debug_lock); 241 + spin_unlock_bh(&o2net_debug_lock); 242 242 243 243 return sc; 244 244 } ··· 248 248 struct o2net_sock_debug *sd = seq->private; 249 249 struct o2net_sock_container *sc, *dummy_sc = sd->dbg_sock; 250 250 251 - spin_lock(&o2net_debug_lock); 251 + spin_lock_bh(&o2net_debug_lock); 252 252 sc = next_sc(dummy_sc); 253 253 list_del_init(&dummy_sc->sc_net_debug_item); 254 254 if (sc) 255 255 list_add(&dummy_sc->sc_net_debug_item, &sc->sc_net_debug_item); 256 - spin_unlock(&o2net_debug_lock); 256 + spin_unlock_bh(&o2net_debug_lock); 257 257 258 258 return sc; /* unused, just needs to be null when done */ 259 259 } ··· 349 349 struct o2net_sock_debug *sd = seq->private; 350 350 struct o2net_sock_container *sc, *dummy_sc = sd->dbg_sock; 351 351 352 - spin_lock(&o2net_debug_lock); 352 + spin_lock_bh(&o2net_debug_lock); 353 353 sc = next_sc(dummy_sc); 354 354 355 355 if (sc) { ··· 359 359 sc_show_sock_stats(seq, sc); 360 360 } 361 361 362 - spin_unlock(&o2net_debug_lock); 362 + spin_unlock_bh(&o2net_debug_lock); 363 363 364 364 return 0; 365 365 }
+13 -13
fs/ocfs2/cluster/quorum.c
··· 93 93 int lowest_hb, lowest_reachable = 0, fence = 0; 94 94 struct o2quo_state *qs = &o2quo_state; 95 95 96 - spin_lock(&qs->qs_lock); 96 + spin_lock_bh(&qs->qs_lock); 97 97 98 98 lowest_hb = find_first_bit(qs->qs_hb_bm, O2NM_MAX_NODES); 99 99 if (lowest_hb != O2NM_MAX_NODES) ··· 146 146 147 147 out: 148 148 if (fence) { 149 - spin_unlock(&qs->qs_lock); 149 + spin_unlock_bh(&qs->qs_lock); 150 150 o2quo_fence_self(); 151 151 } else { 152 152 mlog(ML_NOTICE, "not fencing this node, heartbeating: %d, " 153 153 "connected: %d, lowest: %d (%sreachable)\n", 154 154 qs->qs_heartbeating, qs->qs_connected, lowest_hb, 155 155 lowest_reachable ? "" : "un"); 156 - spin_unlock(&qs->qs_lock); 156 + spin_unlock_bh(&qs->qs_lock); 157 157 158 158 } 159 159 ··· 196 196 { 197 197 struct o2quo_state *qs = &o2quo_state; 198 198 199 - spin_lock(&qs->qs_lock); 199 + spin_lock_bh(&qs->qs_lock); 200 200 201 201 qs->qs_heartbeating++; 202 202 mlog_bug_on_msg(qs->qs_heartbeating == O2NM_MAX_NODES, ··· 211 211 else 212 212 o2quo_clear_hold(qs, node); 213 213 214 - spin_unlock(&qs->qs_lock); 214 + spin_unlock_bh(&qs->qs_lock); 215 215 } 216 216 217 217 /* hb going down releases any holds we might have had due to this node from ··· 220 220 { 221 221 struct o2quo_state *qs = &o2quo_state; 222 222 223 - spin_lock(&qs->qs_lock); 223 + spin_lock_bh(&qs->qs_lock); 224 224 225 225 qs->qs_heartbeating--; 226 226 mlog_bug_on_msg(qs->qs_heartbeating < 0, ··· 233 233 234 234 o2quo_clear_hold(qs, node); 235 235 236 - spin_unlock(&qs->qs_lock); 236 + spin_unlock_bh(&qs->qs_lock); 237 237 } 238 238 239 239 /* this tells us that we've decided that the node is still heartbeating ··· 245 245 { 246 246 struct o2quo_state *qs = &o2quo_state; 247 247 248 - spin_lock(&qs->qs_lock); 248 + spin_lock_bh(&qs->qs_lock); 249 249 250 250 mlog(0, "node %u\n", node); 251 251 252 252 qs->qs_pending = 1; 253 253 o2quo_clear_hold(qs, node); 254 254 255 - spin_unlock(&qs->qs_lock); 255 + spin_unlock_bh(&qs->qs_lock); 256 256 } 257 257 258 258 /* This is analogous to hb_up. as a node's connection comes up we delay the ··· 264 264 { 265 265 struct o2quo_state *qs = &o2quo_state; 266 266 267 - spin_lock(&qs->qs_lock); 267 + spin_lock_bh(&qs->qs_lock); 268 268 269 269 qs->qs_connected++; 270 270 mlog_bug_on_msg(qs->qs_connected == O2NM_MAX_NODES, ··· 279 279 else 280 280 o2quo_clear_hold(qs, node); 281 281 282 - spin_unlock(&qs->qs_lock); 282 + spin_unlock_bh(&qs->qs_lock); 283 283 } 284 284 285 285 /* we've decided that we won't ever be connecting to the node again. if it's ··· 290 290 { 291 291 struct o2quo_state *qs = &o2quo_state; 292 292 293 - spin_lock(&qs->qs_lock); 293 + spin_lock_bh(&qs->qs_lock); 294 294 295 295 if (test_bit(node, qs->qs_conn_bm)) { 296 296 qs->qs_connected--; ··· 307 307 mlog(0, "node %u, %d total\n", node, qs->qs_connected); 308 308 309 309 310 - spin_unlock(&qs->qs_lock); 310 + spin_unlock_bh(&qs->qs_lock); 311 311 } 312 312 313 313 void o2quo_init(void)
+4 -7
fs/ocfs2/journal.c
··· 114 114 if (osb->replay_map) 115 115 return 0; 116 116 117 - replay_map = kzalloc(sizeof(struct ocfs2_replay_map) + 118 - (osb->max_slots * sizeof(char)), GFP_KERNEL); 119 - 117 + replay_map = kzalloc(struct_size(replay_map, rm_replay_slots, 118 + osb->max_slots), 119 + GFP_KERNEL); 120 120 if (!replay_map) { 121 121 mlog_errno(-ENOMEM); 122 122 return -ENOMEM; ··· 178 178 osb->recovery_thread_task = NULL; 179 179 init_waitqueue_head(&osb->recovery_event); 180 180 181 - rm = kzalloc(sizeof(struct ocfs2_recovery_map) + 182 - osb->max_slots * sizeof(unsigned int), 181 + rm = kzalloc(struct_size(rm, rm_entries, osb->max_slots), 183 182 GFP_KERNEL); 184 183 if (!rm) { 185 184 mlog_errno(-ENOMEM); 186 185 return -ENOMEM; 187 186 } 188 187 189 - rm->rm_entries = (unsigned int *)((char *)rm + 190 - sizeof(struct ocfs2_recovery_map)); 191 188 osb->recovery_map = rm; 192 189 193 190 return 0;
+1 -1
fs/ocfs2/journal.h
··· 29 29 30 30 struct ocfs2_recovery_map { 31 31 unsigned int rm_used; 32 - unsigned int *rm_entries; 32 + unsigned int rm_entries[]; 33 33 }; 34 34 35 35
+4
fs/ocfs2/namei.c
··· 1535 1535 status = ocfs2_add_entry(handle, new_dentry, old_inode, 1536 1536 OCFS2_I(old_inode)->ip_blkno, 1537 1537 new_dir_bh, &target_insert); 1538 + if (status < 0) { 1539 + mlog_errno(status); 1540 + goto bail; 1541 + } 1538 1542 } 1539 1543 1540 1544 inode_set_ctime_current(old_inode);
+1 -2
fs/ocfs2/super.c
··· 1517 1517 seq_printf(s, ",localflocks,"); 1518 1518 1519 1519 if (osb->osb_cluster_stack[0]) 1520 - seq_show_option_n(s, "cluster_stack", osb->osb_cluster_stack, 1521 - OCFS2_STACK_LABEL_LEN); 1520 + seq_show_option(s, "cluster_stack", osb->osb_cluster_stack); 1522 1521 if (opts & OCFS2_MOUNT_USRQUOTA) 1523 1522 seq_printf(s, ",usrquota"); 1524 1523 if (opts & OCFS2_MOUNT_GRPQUOTA)
+2 -3
fs/proc/base.c
··· 3815 3815 /* If we haven't found our starting place yet start 3816 3816 * with the leader and walk nr threads forward. 3817 3817 */ 3818 - pos = task = task->group_leader; 3819 - do { 3818 + for_each_thread(task, pos) { 3820 3819 if (!nr--) 3821 3820 goto found; 3822 - } while_each_thread(task, pos); 3821 + }; 3823 3822 fail: 3824 3823 pos = NULL; 3825 3824 goto out;
+1
include/kunit/test.h
··· 12 12 #include <kunit/assert.h> 13 13 #include <kunit/try-catch.h> 14 14 15 + #include <linux/args.h> 15 16 #include <linux/compiler.h> 16 17 #include <linux/container_of.h> 17 18 #include <linux/err.h>
+28
include/linux/args.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + 3 + #ifndef _LINUX_ARGS_H 4 + #define _LINUX_ARGS_H 5 + 6 + /* 7 + * How do these macros work? 8 + * 9 + * In __COUNT_ARGS() _0 to _12 are just placeholders from the start 10 + * in order to make sure _n is positioned over the correct number 11 + * from 12 to 0 (depending on X, which is a variadic argument list). 12 + * They serve no purpose other than occupying a position. Since each 13 + * macro parameter must have a distinct identifier, those identifiers 14 + * are as good as any. 15 + * 16 + * In COUNT_ARGS() we use actual integers, so __COUNT_ARGS() returns 17 + * that as _n. 18 + */ 19 + 20 + /* This counts to 12. Any more, it will return 13th argument. */ 21 + #define __COUNT_ARGS(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _n, X...) _n 22 + #define COUNT_ARGS(X...) __COUNT_ARGS(, ##X, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0) 23 + 24 + /* Concatenate two parameters, but allow them to be expanded beforehand. */ 25 + #define __CONCAT(a, b) a ## b 26 + #define CONCATENATE(a, b) __CONCAT(a, b) 27 + 28 + #endif /* _LINUX_ARGS_H */
+32 -37
include/linux/arm-smccc.h
··· 5 5 #ifndef __LINUX_ARM_SMCCC_H 6 6 #define __LINUX_ARM_SMCCC_H 7 7 8 + #include <linux/args.h> 8 9 #include <linux/init.h> 9 10 #include <uapi/linux/const.h> 10 11 ··· 414 413 415 414 #endif 416 415 417 - #define ___count_args(_0, _1, _2, _3, _4, _5, _6, _7, _8, x, ...) x 416 + #define __constraint_read_2 "r" (arg0) 417 + #define __constraint_read_3 __constraint_read_2, "r" (arg1) 418 + #define __constraint_read_4 __constraint_read_3, "r" (arg2) 419 + #define __constraint_read_5 __constraint_read_4, "r" (arg3) 420 + #define __constraint_read_6 __constraint_read_5, "r" (arg4) 421 + #define __constraint_read_7 __constraint_read_6, "r" (arg5) 422 + #define __constraint_read_8 __constraint_read_7, "r" (arg6) 423 + #define __constraint_read_9 __constraint_read_8, "r" (arg7) 418 424 419 - #define __count_args(...) \ 420 - ___count_args(__VA_ARGS__, 7, 6, 5, 4, 3, 2, 1, 0) 421 - 422 - #define __constraint_read_0 "r" (arg0) 423 - #define __constraint_read_1 __constraint_read_0, "r" (arg1) 424 - #define __constraint_read_2 __constraint_read_1, "r" (arg2) 425 - #define __constraint_read_3 __constraint_read_2, "r" (arg3) 426 - #define __constraint_read_4 __constraint_read_3, "r" (arg4) 427 - #define __constraint_read_5 __constraint_read_4, "r" (arg5) 428 - #define __constraint_read_6 __constraint_read_5, "r" (arg6) 429 - #define __constraint_read_7 __constraint_read_6, "r" (arg7) 430 - 431 - #define __declare_arg_0(a0, res) \ 425 + #define __declare_arg_2(a0, res) \ 432 426 struct arm_smccc_res *___res = res; \ 433 427 register unsigned long arg0 asm("r0") = (u32)a0 434 428 435 - #define __declare_arg_1(a0, a1, res) \ 429 + #define __declare_arg_3(a0, a1, res) \ 436 430 typeof(a1) __a1 = a1; \ 437 431 struct arm_smccc_res *___res = res; \ 438 432 register unsigned long arg0 asm("r0") = (u32)a0; \ 439 433 register typeof(a1) arg1 asm("r1") = __a1 440 434 441 - #define __declare_arg_2(a0, a1, a2, res) \ 435 + #define __declare_arg_4(a0, a1, a2, res) \ 442 436 typeof(a1) __a1 = a1; \ 443 437 typeof(a2) __a2 = a2; \ 444 438 struct arm_smccc_res *___res = res; \ ··· 441 445 register typeof(a1) arg1 asm("r1") = __a1; \ 442 446 register typeof(a2) arg2 asm("r2") = __a2 443 447 444 - #define __declare_arg_3(a0, a1, a2, a3, res) \ 448 + #define __declare_arg_5(a0, a1, a2, a3, res) \ 445 449 typeof(a1) __a1 = a1; \ 446 450 typeof(a2) __a2 = a2; \ 447 451 typeof(a3) __a3 = a3; \ ··· 451 455 register typeof(a2) arg2 asm("r2") = __a2; \ 452 456 register typeof(a3) arg3 asm("r3") = __a3 453 457 454 - #define __declare_arg_4(a0, a1, a2, a3, a4, res) \ 458 + #define __declare_arg_6(a0, a1, a2, a3, a4, res) \ 455 459 typeof(a4) __a4 = a4; \ 456 - __declare_arg_3(a0, a1, a2, a3, res); \ 460 + __declare_arg_5(a0, a1, a2, a3, res); \ 457 461 register typeof(a4) arg4 asm("r4") = __a4 458 462 459 - #define __declare_arg_5(a0, a1, a2, a3, a4, a5, res) \ 463 + #define __declare_arg_7(a0, a1, a2, a3, a4, a5, res) \ 460 464 typeof(a5) __a5 = a5; \ 461 - __declare_arg_4(a0, a1, a2, a3, a4, res); \ 465 + __declare_arg_6(a0, a1, a2, a3, a4, res); \ 462 466 register typeof(a5) arg5 asm("r5") = __a5 463 467 464 - #define __declare_arg_6(a0, a1, a2, a3, a4, a5, a6, res) \ 468 + #define __declare_arg_8(a0, a1, a2, a3, a4, a5, a6, res) \ 465 469 typeof(a6) __a6 = a6; \ 466 - __declare_arg_5(a0, a1, a2, a3, a4, a5, res); \ 470 + __declare_arg_7(a0, a1, a2, a3, a4, a5, res); \ 467 471 register typeof(a6) arg6 asm("r6") = __a6 468 472 469 - #define __declare_arg_7(a0, a1, a2, a3, a4, a5, a6, a7, res) \ 473 + #define __declare_arg_9(a0, a1, a2, a3, a4, a5, a6, a7, res) \ 470 474 typeof(a7) __a7 = a7; \ 471 - __declare_arg_6(a0, a1, a2, a3, a4, a5, a6, res); \ 475 + __declare_arg_8(a0, a1, a2, a3, a4, a5, a6, res); \ 472 476 register typeof(a7) arg7 asm("r7") = __a7 473 - 474 - #define ___declare_args(count, ...) __declare_arg_ ## count(__VA_ARGS__) 475 - #define __declare_args(count, ...) ___declare_args(count, __VA_ARGS__) 476 - 477 - #define ___constraints(count) \ 478 - : __constraint_read_ ## count \ 479 - : smccc_sve_clobbers "memory" 480 - #define __constraints(count) ___constraints(count) 481 477 482 478 /* 483 479 * We have an output list that is not necessarily used, and GCC feels ··· 482 494 register unsigned long r1 asm("r1"); \ 483 495 register unsigned long r2 asm("r2"); \ 484 496 register unsigned long r3 asm("r3"); \ 485 - __declare_args(__count_args(__VA_ARGS__), __VA_ARGS__); \ 497 + CONCATENATE(__declare_arg_, \ 498 + COUNT_ARGS(__VA_ARGS__))(__VA_ARGS__); \ 486 499 asm volatile(SMCCC_SVE_CHECK \ 487 500 inst "\n" : \ 488 501 "=r" (r0), "=r" (r1), "=r" (r2), "=r" (r3) \ 489 - __constraints(__count_args(__VA_ARGS__))); \ 502 + : CONCATENATE(__constraint_read_, \ 503 + COUNT_ARGS(__VA_ARGS__)) \ 504 + : smccc_sve_clobbers "memory"); \ 490 505 if (___res) \ 491 506 *___res = (typeof(*___res)){r0, r1, r2, r3}; \ 492 507 } while (0) ··· 533 542 */ 534 543 #define __fail_smccc_1_1(...) \ 535 544 do { \ 536 - __declare_args(__count_args(__VA_ARGS__), __VA_ARGS__); \ 537 - asm ("" : __constraints(__count_args(__VA_ARGS__))); \ 545 + CONCATENATE(__declare_arg_, \ 546 + COUNT_ARGS(__VA_ARGS__))(__VA_ARGS__); \ 547 + asm ("" : \ 548 + : CONCATENATE(__constraint_read_, \ 549 + COUNT_ARGS(__VA_ARGS__)) \ 550 + : smccc_sve_clobbers "memory"); \ 538 551 if (___res) \ 539 552 ___res->a0 = SMCCC_RET_NOT_SUPPORTED; \ 540 553 } while (0)
+27
include/linux/crash_core.h
··· 28 28 VMCOREINFO_BYTES) 29 29 30 30 typedef u32 note_buf_t[CRASH_CORE_NOTE_BYTES/4]; 31 + /* Per cpu memory for storing cpu states in case of system crash. */ 32 + extern note_buf_t __percpu *crash_notes; 31 33 32 34 void crash_update_vmcoreinfo_safecopy(void *ptr); 33 35 void crash_save_vmcoreinfo(void); ··· 85 83 unsigned long long *crash_size, unsigned long long *crash_base); 86 84 int parse_crashkernel_low(char *cmdline, unsigned long long system_ram, 87 85 unsigned long long *crash_size, unsigned long long *crash_base); 86 + 87 + /* Alignment required for elf header segment */ 88 + #define ELF_CORE_HEADER_ALIGN 4096 89 + 90 + struct crash_mem { 91 + unsigned int max_nr_ranges; 92 + unsigned int nr_ranges; 93 + struct range ranges[]; 94 + }; 95 + 96 + extern int crash_exclude_mem_range(struct crash_mem *mem, 97 + unsigned long long mstart, 98 + unsigned long long mend); 99 + extern int crash_prepare_elf64_headers(struct crash_mem *mem, int need_kernel_map, 100 + void **addr, unsigned long *sz); 101 + 102 + struct kimage; 103 + struct kexec_segment; 104 + 105 + #define KEXEC_CRASH_HP_NONE 0 106 + #define KEXEC_CRASH_HP_ADD_CPU 1 107 + #define KEXEC_CRASH_HP_REMOVE_CPU 2 108 + #define KEXEC_CRASH_HP_ADD_MEMORY 3 109 + #define KEXEC_CRASH_HP_REMOVE_MEMORY 4 110 + #define KEXEC_CRASH_HP_INVALID_CPU -1U 88 111 89 112 #endif /* LINUX_CRASH_CORE_H */
+14 -13
include/linux/genl_magic_func.h
··· 2 2 #ifndef GENL_MAGIC_FUNC_H 3 3 #define GENL_MAGIC_FUNC_H 4 4 5 + #include <linux/args.h> 5 6 #include <linux/build_bug.h> 6 7 #include <linux/genl_magic_struct.h> 7 8 ··· 24 23 #define GENL_struct(tag_name, tag_number, s_name, s_fields) \ 25 24 [tag_name] = { .type = NLA_NESTED }, 26 25 27 - static struct nla_policy CONCAT_(GENL_MAGIC_FAMILY, _tla_nl_policy)[] = { 26 + static struct nla_policy CONCATENATE(GENL_MAGIC_FAMILY, _tla_nl_policy)[] = { 28 27 #include GENL_MAGIC_INCLUDE_FILE 29 28 }; 30 29 ··· 210 209 * Magic: define op number to op name mapping {{{1 211 210 * {{{2 212 211 */ 213 - static const char *CONCAT_(GENL_MAGIC_FAMILY, _genl_cmd_to_str)(__u8 cmd) 212 + static const char *CONCATENATE(GENL_MAGIC_FAMILY, _genl_cmd_to_str)(__u8 cmd) 214 213 { 215 214 switch (cmd) { 216 215 #undef GENL_op ··· 236 235 .cmd = op_name, \ 237 236 }, 238 237 239 - #define ZZZ_genl_ops CONCAT_(GENL_MAGIC_FAMILY, _genl_ops) 238 + #define ZZZ_genl_ops CONCATENATE(GENL_MAGIC_FAMILY, _genl_ops) 240 239 static struct genl_ops ZZZ_genl_ops[] __read_mostly = { 241 240 #include GENL_MAGIC_INCLUDE_FILE 242 241 }; ··· 249 248 * and provide register/unregister functions. 250 249 * {{{2 251 250 */ 252 - #define ZZZ_genl_family CONCAT_(GENL_MAGIC_FAMILY, _genl_family) 251 + #define ZZZ_genl_family CONCATENATE(GENL_MAGIC_FAMILY, _genl_family) 253 252 static struct genl_family ZZZ_genl_family; 254 253 /* 255 254 * Magic: define multicast groups 256 255 * Magic: define multicast group registration helper 257 256 */ 258 - #define ZZZ_genl_mcgrps CONCAT_(GENL_MAGIC_FAMILY, _genl_mcgrps) 257 + #define ZZZ_genl_mcgrps CONCATENATE(GENL_MAGIC_FAMILY, _genl_mcgrps) 259 258 static const struct genl_multicast_group ZZZ_genl_mcgrps[] = { 260 259 #undef GENL_mc_group 261 260 #define GENL_mc_group(group) { .name = #group, }, 262 261 #include GENL_MAGIC_INCLUDE_FILE 263 262 }; 264 263 265 - enum CONCAT_(GENL_MAGIC_FAMILY, group_ids) { 264 + enum CONCATENATE(GENL_MAGIC_FAMILY, group_ids) { 266 265 #undef GENL_mc_group 267 - #define GENL_mc_group(group) CONCAT_(GENL_MAGIC_FAMILY, _group_ ## group), 266 + #define GENL_mc_group(group) CONCATENATE(GENL_MAGIC_FAMILY, _group_ ## group), 268 267 #include GENL_MAGIC_INCLUDE_FILE 269 268 }; 270 269 271 270 #undef GENL_mc_group 272 271 #define GENL_mc_group(group) \ 273 - static int CONCAT_(GENL_MAGIC_FAMILY, _genl_multicast_ ## group)( \ 272 + static int CONCATENATE(GENL_MAGIC_FAMILY, _genl_multicast_ ## group)( \ 274 273 struct sk_buff *skb, gfp_t flags) \ 275 274 { \ 276 275 unsigned int group_id = \ 277 - CONCAT_(GENL_MAGIC_FAMILY, _group_ ## group); \ 276 + CONCATENATE(GENL_MAGIC_FAMILY, _group_ ## group); \ 278 277 return genlmsg_multicast(&ZZZ_genl_family, skb, 0, \ 279 278 group_id, flags); \ 280 279 } ··· 290 289 #ifdef GENL_MAGIC_FAMILY_HDRSZ 291 290 .hdrsize = NLA_ALIGN(GENL_MAGIC_FAMILY_HDRSZ), 292 291 #endif 293 - .maxattr = ARRAY_SIZE(CONCAT_(GENL_MAGIC_FAMILY, _tla_nl_policy))-1, 294 - .policy = CONCAT_(GENL_MAGIC_FAMILY, _tla_nl_policy), 292 + .maxattr = ARRAY_SIZE(CONCATENATE(GENL_MAGIC_FAMILY, _tla_nl_policy))-1, 293 + .policy = CONCATENATE(GENL_MAGIC_FAMILY, _tla_nl_policy), 295 294 .ops = ZZZ_genl_ops, 296 295 .n_ops = ARRAY_SIZE(ZZZ_genl_ops), 297 296 .mcgrps = ZZZ_genl_mcgrps, ··· 300 299 .module = THIS_MODULE, 301 300 }; 302 301 303 - int CONCAT_(GENL_MAGIC_FAMILY, _genl_register)(void) 302 + int CONCATENATE(GENL_MAGIC_FAMILY, _genl_register)(void) 304 303 { 305 304 return genl_register_family(&ZZZ_genl_family); 306 305 } 307 306 308 - void CONCAT_(GENL_MAGIC_FAMILY, _genl_unregister)(void) 307 + void CONCATENATE(GENL_MAGIC_FAMILY, _genl_unregister)(void) 309 308 { 310 309 genl_unregister_family(&ZZZ_genl_family); 311 310 }
+3 -5
include/linux/genl_magic_struct.h
··· 14 14 # error "you need to define GENL_MAGIC_INCLUDE_FILE before inclusion" 15 15 #endif 16 16 17 + #include <linux/args.h> 17 18 #include <linux/genetlink.h> 18 19 #include <linux/types.h> 19 20 20 - #define CONCAT__(a,b) a ## b 21 - #define CONCAT_(a,b) CONCAT__(a,b) 22 - 23 - extern int CONCAT_(GENL_MAGIC_FAMILY, _genl_register)(void); 24 - extern void CONCAT_(GENL_MAGIC_FAMILY, _genl_unregister)(void); 21 + extern int CONCATENATE(GENL_MAGIC_FAMILY, _genl_register)(void); 22 + extern void CONCATENATE(GENL_MAGIC_FAMILY, _genl_unregister)(void); 25 23 26 24 /* 27 25 * Extension of genl attribute validation policies {{{2
+1 -36
include/linux/kernel.h
··· 29 29 #include <linux/panic.h> 30 30 #include <linux/printk.h> 31 31 #include <linux/build_bug.h> 32 + #include <linux/sprintf.h> 32 33 #include <linux/static_call_types.h> 33 34 #include <linux/instruction_pointer.h> 34 35 #include <asm/byteorder.h> ··· 203 202 #endif 204 203 205 204 void do_exit(long error_code) __noreturn; 206 - 207 - extern int num_to_str(char *buf, int size, 208 - unsigned long long num, unsigned int width); 209 - 210 - /* lib/printf utilities */ 211 - 212 - extern __printf(2, 3) int sprintf(char *buf, const char * fmt, ...); 213 - extern __printf(2, 0) int vsprintf(char *buf, const char *, va_list); 214 - extern __printf(3, 4) 215 - int snprintf(char *buf, size_t size, const char *fmt, ...); 216 - extern __printf(3, 0) 217 - int vsnprintf(char *buf, size_t size, const char *fmt, va_list args); 218 - extern __printf(3, 4) 219 - int scnprintf(char *buf, size_t size, const char *fmt, ...); 220 - extern __printf(3, 0) 221 - int vscnprintf(char *buf, size_t size, const char *fmt, va_list args); 222 - extern __printf(2, 3) __malloc 223 - char *kasprintf(gfp_t gfp, const char *fmt, ...); 224 - extern __printf(2, 0) __malloc 225 - char *kvasprintf(gfp_t gfp, const char *fmt, va_list args); 226 - extern __printf(2, 0) 227 - const char *kvasprintf_const(gfp_t gfp, const char *fmt, va_list args); 228 - 229 - extern __scanf(2, 3) 230 - int sscanf(const char *, const char *, ...); 231 - extern __scanf(2, 0) 232 - int vsscanf(const char *, const char *, va_list); 233 - 234 - extern int no_hash_pointers_enable(char *str); 235 205 236 206 extern int get_option(char **str, int *pint); 237 207 extern char *get_options(const char *str, int nints, int *ints); ··· 428 456 } 429 457 static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { } 430 458 #endif /* CONFIG_TRACING */ 431 - 432 - /* This counts to 12. Any more, it will return 13th argument. */ 433 - #define __COUNT_ARGS(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _n, X...) _n 434 - #define COUNT_ARGS(X...) __COUNT_ARGS(, ##X, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0) 435 - 436 - #define __CONCAT(a, b) a ## b 437 - #define CONCATENATE(a, b) __CONCAT(a, b) 438 459 439 460 /* Rebuild everything on CONFIG_FTRACE_MCOUNT_RECORD */ 440 461 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
+31 -17
include/linux/kexec.h
··· 33 33 #include <linux/compat.h> 34 34 #include <linux/ioport.h> 35 35 #include <linux/module.h> 36 + #include <linux/highmem.h> 36 37 #include <asm/kexec.h> 37 38 38 39 /* Verify architecture specific macros are defined */ ··· 231 230 } 232 231 #endif 233 232 234 - /* Alignment required for elf header segment */ 235 - #define ELF_CORE_HEADER_ALIGN 4096 236 - 237 - struct crash_mem { 238 - unsigned int max_nr_ranges; 239 - unsigned int nr_ranges; 240 - struct range ranges[]; 241 - }; 242 - 243 - extern int crash_exclude_mem_range(struct crash_mem *mem, 244 - unsigned long long mstart, 245 - unsigned long long mend); 246 - extern int crash_prepare_elf64_headers(struct crash_mem *mem, int need_kernel_map, 247 - void **addr, unsigned long *sz); 248 - 249 233 #ifndef arch_kexec_apply_relocations_add 250 234 /* 251 235 * arch_kexec_apply_relocations_add - apply relocations of type RELA ··· 320 334 unsigned int preserve_context : 1; 321 335 /* If set, we are using file mode kexec syscall */ 322 336 unsigned int file_mode:1; 337 + #ifdef CONFIG_CRASH_HOTPLUG 338 + /* If set, allow changes to elfcorehdr of kexec_load'd image */ 339 + unsigned int update_elfcorehdr:1; 340 + #endif 323 341 324 342 #ifdef ARCH_HAS_KIMAGE_ARCH 325 343 struct kimage_arch arch; ··· 348 358 349 359 /* Information for loading purgatory */ 350 360 struct purgatory_info purgatory_info; 361 + #endif 362 + 363 + #ifdef CONFIG_CRASH_HOTPLUG 364 + int hp_action; 365 + int elfcorehdr_index; 366 + bool elfcorehdr_updated; 351 367 #endif 352 368 353 369 #ifdef CONFIG_IMA_KEXEC ··· 400 404 401 405 /* List of defined/legal kexec flags */ 402 406 #ifndef CONFIG_KEXEC_JUMP 403 - #define KEXEC_FLAGS KEXEC_ON_CRASH 407 + #define KEXEC_FLAGS (KEXEC_ON_CRASH | KEXEC_UPDATE_ELFCOREHDR) 404 408 #else 405 - #define KEXEC_FLAGS (KEXEC_ON_CRASH | KEXEC_PRESERVE_CONTEXT) 409 + #define KEXEC_FLAGS (KEXEC_ON_CRASH | KEXEC_PRESERVE_CONTEXT | KEXEC_UPDATE_ELFCOREHDR) 406 410 #endif 407 411 408 412 /* List of defined/legal kexec file flags */ ··· 484 488 485 489 #ifndef arch_kexec_pre_free_pages 486 490 static inline void arch_kexec_pre_free_pages(void *vaddr, unsigned int pages) { } 491 + #endif 492 + 493 + #ifndef arch_crash_handle_hotplug_event 494 + static inline void arch_crash_handle_hotplug_event(struct kimage *image) { } 495 + #endif 496 + 497 + int crash_check_update_elfcorehdr(void); 498 + 499 + #ifndef crash_hotplug_cpu_support 500 + static inline int crash_hotplug_cpu_support(void) { return 0; } 501 + #endif 502 + 503 + #ifndef crash_hotplug_memory_support 504 + static inline int crash_hotplug_memory_support(void) { return 0; } 505 + #endif 506 + 507 + #ifndef crash_get_elfcorehdr_size 508 + static inline unsigned int crash_get_elfcorehdr_size(void) { return 0; } 487 509 #endif 488 510 489 511 #else /* !CONFIG_KEXEC_CORE */
-1
include/linux/kthread.h
··· 88 88 int kthread_stop(struct task_struct *k); 89 89 bool kthread_should_stop(void); 90 90 bool kthread_should_park(void); 91 - bool __kthread_should_park(struct task_struct *k); 92 91 bool kthread_should_stop_or_park(void); 93 92 bool kthread_freezable_should_stop(bool *was_frozen); 94 93 void *kthread_func(struct task_struct *k);
+2
include/linux/limits.h
··· 10 10 #define SSIZE_MAX ((ssize_t)(SIZE_MAX >> 1)) 11 11 #define PHYS_ADDR_MAX (~(phys_addr_t)0) 12 12 13 + #define RESOURCE_SIZE_MAX ((resource_size_t)~0) 14 + 13 15 #define U8_MAX ((u8)~0U) 14 16 #define S8_MAX ((s8)(U8_MAX >> 1)) 15 17 #define S8_MIN ((s8)(-S8_MAX - 1))
+19
include/linux/math.h
··· 156 156 ({ signed type __x = (x); __x < 0 ? -__x : __x; }), other) 157 157 158 158 /** 159 + * abs_diff - return absolute value of the difference between the arguments 160 + * @a: the first argument 161 + * @b: the second argument 162 + * 163 + * @a and @b have to be of the same type. With this restriction we compare 164 + * signed to signed and unsigned to unsigned. The result is the subtraction 165 + * the smaller of the two from the bigger, hence result is always a positive 166 + * value. 167 + * 168 + * Return: an absolute value of the difference between the @a and @b. 169 + */ 170 + #define abs_diff(a, b) ({ \ 171 + typeof(a) __a = (a); \ 172 + typeof(b) __b = (b); \ 173 + (void)(&__a == &__b); \ 174 + __a > __b ? (__a - __b) : (__b - __a); \ 175 + }) 176 + 177 + /** 159 178 * reciprocal_scale - "scale" a value into range [0, ep_ro) 160 179 * @val: value 161 180 * @ep_ro: right open interval endpoint
+7 -7
include/linux/nmi.h
··· 157 157 #ifdef arch_trigger_cpumask_backtrace 158 158 static inline bool trigger_all_cpu_backtrace(void) 159 159 { 160 - arch_trigger_cpumask_backtrace(cpu_online_mask, false); 160 + arch_trigger_cpumask_backtrace(cpu_online_mask, -1); 161 161 return true; 162 162 } 163 163 164 - static inline bool trigger_allbutself_cpu_backtrace(void) 164 + static inline bool trigger_allbutcpu_cpu_backtrace(int exclude_cpu) 165 165 { 166 - arch_trigger_cpumask_backtrace(cpu_online_mask, true); 166 + arch_trigger_cpumask_backtrace(cpu_online_mask, exclude_cpu); 167 167 return true; 168 168 } 169 169 170 170 static inline bool trigger_cpumask_backtrace(struct cpumask *mask) 171 171 { 172 - arch_trigger_cpumask_backtrace(mask, false); 172 + arch_trigger_cpumask_backtrace(mask, -1); 173 173 return true; 174 174 } 175 175 176 176 static inline bool trigger_single_cpu_backtrace(int cpu) 177 177 { 178 - arch_trigger_cpumask_backtrace(cpumask_of(cpu), false); 178 + arch_trigger_cpumask_backtrace(cpumask_of(cpu), -1); 179 179 return true; 180 180 } 181 181 182 182 /* generic implementation */ 183 183 void nmi_trigger_cpumask_backtrace(const cpumask_t *mask, 184 - bool exclude_self, 184 + int exclude_cpu, 185 185 void (*raise)(cpumask_t *mask)); 186 186 bool nmi_cpu_backtrace(struct pt_regs *regs); 187 187 ··· 190 190 { 191 191 return false; 192 192 } 193 - static inline bool trigger_allbutself_cpu_backtrace(void) 193 + static inline bool trigger_allbutcpu_cpu_backtrace(int exclude_cpu) 194 194 { 195 195 return false; 196 196 }
+1 -1
include/linux/pci.h
··· 23 23 #ifndef LINUX_PCI_H 24 24 #define LINUX_PCI_H 25 25 26 - 26 + #include <linux/args.h> 27 27 #include <linux/mod_devicetable.h> 28 28 29 29 #include <linux/types.h>
-8
include/linux/range.h
··· 31 31 32 32 void sort_range(struct range *range, int nr_range); 33 33 34 - #define MAX_RESOURCE ((resource_size_t)~0) 35 - static inline resource_size_t cap_resource(u64 val) 36 - { 37 - if (val > MAX_RESOURCE) 38 - return MAX_RESOURCE; 39 - 40 - return val; 41 - } 42 34 #endif
+2 -5
include/linux/sched/signal.h
··· 649 649 extern bool current_is_single_threaded(void); 650 650 651 651 /* 652 - * Careful: do_each_thread/while_each_thread is a double loop so 653 - * 'break' will not work as expected - use goto instead. 652 + * Without tasklist/siglock it is only rcu-safe if g can't exit/exec, 653 + * otherwise next_thread(t) will never reach g after list_del_rcu(g). 654 654 */ 655 - #define do_each_thread(g, t) \ 656 - for (g = t = &init_task ; (g = t = next_task(g)) != &init_task ; ) do 657 - 658 655 #define while_each_thread(g, t) \ 659 656 while ((t = next_thread(t)) != g) 660 657
+27
include/linux/sprintf.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + #ifndef _LINUX_KERNEL_SPRINTF_H_ 3 + #define _LINUX_KERNEL_SPRINTF_H_ 4 + 5 + #include <linux/compiler_attributes.h> 6 + #include <linux/types.h> 7 + 8 + int num_to_str(char *buf, int size, unsigned long long num, unsigned int width); 9 + 10 + __printf(2, 3) int sprintf(char *buf, const char * fmt, ...); 11 + __printf(2, 0) int vsprintf(char *buf, const char *, va_list); 12 + __printf(3, 4) int snprintf(char *buf, size_t size, const char *fmt, ...); 13 + __printf(3, 0) int vsnprintf(char *buf, size_t size, const char *fmt, va_list args); 14 + __printf(3, 4) int scnprintf(char *buf, size_t size, const char *fmt, ...); 15 + __printf(3, 0) int vscnprintf(char *buf, size_t size, const char *fmt, va_list args); 16 + __printf(2, 3) __malloc char *kasprintf(gfp_t gfp, const char *fmt, ...); 17 + __printf(2, 0) __malloc char *kvasprintf(gfp_t gfp, const char *fmt, va_list args); 18 + __printf(2, 0) const char *kvasprintf_const(gfp_t gfp, const char *fmt, va_list args); 19 + 20 + __scanf(2, 3) int sscanf(const char *, const char *, ...); 21 + __scanf(2, 0) int vsscanf(const char *, const char *, va_list); 22 + 23 + /* These are for specific cases, do not use without real need */ 24 + extern bool no_hash_pointers; 25 + int no_hash_pointers_enable(char *str); 26 + 27 + #endif /* _LINUX_KERNEL_SPRINTF_H */
+2
include/trace/bpf_probe.h
··· 12 12 #undef __perf_task 13 13 #define __perf_task(t) (t) 14 14 15 + #include <linux/args.h> 16 + 15 17 /* cast any integer, pointer, or small struct to u64 */ 16 18 #define UINTTYPE(size) \ 17 19 __typeof__(__builtin_choose_expr(size == 1, (u8)1, \
+1
include/uapi/linux/kexec.h
··· 12 12 /* kexec flags for different usage scenarios */ 13 13 #define KEXEC_ON_CRASH 0x00000001 14 14 #define KEXEC_PRESERVE_CONTEXT 0x00000002 15 + #define KEXEC_UPDATE_ELFCOREHDR 0x00000004 15 16 #define KEXEC_ARCH_MASK 0xffff0000 16 17 17 18 /*
+2 -8
init/Kconfig
··· 1791 1791 1792 1792 If unsure, say N. 1793 1793 1794 - config EMBEDDED 1795 - bool "Embedded system" 1796 - select EXPERT 1797 - help 1798 - This option should be enabled if compiling the kernel for 1799 - an embedded system so certain expert options are available 1800 - for configuration. 1801 - 1802 1794 config HAVE_PERF_EVENTS 1803 1795 bool 1804 1796 help ··· 1919 1927 # 1920 1928 config TRACEPOINTS 1921 1929 bool 1930 + 1931 + source "kernel/Kconfig.kexec" 1922 1932 1923 1933 endmenu # General setup 1924 1934
+2 -4
ipc/sem.c
··· 152 152 struct list_head list_id; /* per semaphore array list: 153 153 * all undos for one array */ 154 154 int semid; /* semaphore set identifier */ 155 - short *semadj; /* array of adjustments */ 155 + short semadj[]; /* array of adjustments */ 156 156 /* one per semaphore */ 157 157 }; 158 158 ··· 1938 1938 rcu_read_unlock(); 1939 1939 1940 1940 /* step 2: allocate new undo structure */ 1941 - new = kvzalloc(sizeof(struct sem_undo) + sizeof(short)*nsems, 1942 - GFP_KERNEL_ACCOUNT); 1941 + new = kvzalloc(struct_size(new, semadj, nsems), GFP_KERNEL_ACCOUNT); 1943 1942 if (!new) { 1944 1943 ipc_rcu_putref(&sma->sem_perm, sem_rcu_free); 1945 1944 return ERR_PTR(-ENOMEM); ··· 1966 1967 goto success; 1967 1968 } 1968 1969 /* step 5: initialize & link new undo structure */ 1969 - new->semadj = (short *) &new[1]; 1970 1970 new->ulp = ulp; 1971 1971 new->semid = semid; 1972 1972 assert_spin_locked(&ulp->lock);
+150
kernel/Kconfig.kexec
··· 1 + # SPDX-License-Identifier: GPL-2.0-only 2 + 3 + menu "Kexec and crash features" 4 + 5 + config CRASH_CORE 6 + bool 7 + 8 + config KEXEC_CORE 9 + select CRASH_CORE 10 + bool 11 + 12 + config KEXEC_ELF 13 + bool 14 + 15 + config HAVE_IMA_KEXEC 16 + bool 17 + 18 + config KEXEC 19 + bool "Enable kexec system call" 20 + depends on ARCH_SUPPORTS_KEXEC 21 + select KEXEC_CORE 22 + help 23 + kexec is a system call that implements the ability to shutdown your 24 + current kernel, and to start another kernel. It is like a reboot 25 + but it is independent of the system firmware. And like a reboot 26 + you can start any kernel with it, not just Linux. 27 + 28 + The name comes from the similarity to the exec system call. 29 + 30 + It is an ongoing process to be certain the hardware in a machine 31 + is properly shutdown, so do not be surprised if this code does not 32 + initially work for you. As of this writing the exact hardware 33 + interface is strongly in flux, so no good recommendation can be 34 + made. 35 + 36 + config KEXEC_FILE 37 + bool "Enable kexec file based system call" 38 + depends on ARCH_SUPPORTS_KEXEC_FILE 39 + select KEXEC_CORE 40 + help 41 + This is new version of kexec system call. This system call is 42 + file based and takes file descriptors as system call argument 43 + for kernel and initramfs as opposed to list of segments as 44 + accepted by kexec system call. 45 + 46 + config KEXEC_SIG 47 + bool "Verify kernel signature during kexec_file_load() syscall" 48 + depends on ARCH_SUPPORTS_KEXEC_SIG 49 + depends on KEXEC_FILE 50 + help 51 + This option makes the kexec_file_load() syscall check for a valid 52 + signature of the kernel image. The image can still be loaded without 53 + a valid signature unless you also enable KEXEC_SIG_FORCE, though if 54 + there's a signature that we can check, then it must be valid. 55 + 56 + In addition to this option, you need to enable signature 57 + verification for the corresponding kernel image type being 58 + loaded in order for this to work. 59 + 60 + config KEXEC_SIG_FORCE 61 + bool "Require a valid signature in kexec_file_load() syscall" 62 + depends on ARCH_SUPPORTS_KEXEC_SIG_FORCE 63 + depends on KEXEC_SIG 64 + help 65 + This option makes kernel signature verification mandatory for 66 + the kexec_file_load() syscall. 67 + 68 + config KEXEC_IMAGE_VERIFY_SIG 69 + bool "Enable Image signature verification support (ARM)" 70 + default ARCH_DEFAULT_KEXEC_IMAGE_VERIFY_SIG 71 + depends on ARCH_SUPPORTS_KEXEC_IMAGE_VERIFY_SIG 72 + depends on KEXEC_SIG 73 + depends on EFI && SIGNED_PE_FILE_VERIFICATION 74 + help 75 + Enable Image signature verification support. 76 + 77 + config KEXEC_BZIMAGE_VERIFY_SIG 78 + bool "Enable bzImage signature verification support" 79 + depends on ARCH_SUPPORTS_KEXEC_BZIMAGE_VERIFY_SIG 80 + depends on KEXEC_SIG 81 + depends on SIGNED_PE_FILE_VERIFICATION 82 + select SYSTEM_TRUSTED_KEYRING 83 + help 84 + Enable bzImage signature verification support. 85 + 86 + config KEXEC_JUMP 87 + bool "kexec jump" 88 + depends on ARCH_SUPPORTS_KEXEC_JUMP 89 + depends on KEXEC && HIBERNATION 90 + help 91 + Jump between original kernel and kexeced kernel and invoke 92 + code in physical address mode via KEXEC 93 + 94 + config CRASH_DUMP 95 + bool "kernel crash dumps" 96 + depends on ARCH_SUPPORTS_CRASH_DUMP 97 + depends on ARCH_SUPPORTS_KEXEC 98 + select CRASH_CORE 99 + select KEXEC_CORE 100 + select KEXEC 101 + help 102 + Generate crash dump after being started by kexec. 103 + This should be normally only set in special crash dump kernels 104 + which are loaded in the main kernel with kexec-tools into 105 + a specially reserved region and then later executed after 106 + a crash by kdump/kexec. The crash dump kernel must be compiled 107 + to a memory address not used by the main kernel or BIOS using 108 + PHYSICAL_START, or it must be built as a relocatable image 109 + (CONFIG_RELOCATABLE=y). 110 + For more details see Documentation/admin-guide/kdump/kdump.rst 111 + 112 + For s390, this option also enables zfcpdump. 113 + See also <file:Documentation/s390/zfcpdump.rst> 114 + 115 + config CRASH_HOTPLUG 116 + bool "Update the crash elfcorehdr on system configuration changes" 117 + default y 118 + depends on CRASH_DUMP && (HOTPLUG_CPU || MEMORY_HOTPLUG) 119 + depends on ARCH_SUPPORTS_CRASH_HOTPLUG 120 + help 121 + Enable direct update to the crash elfcorehdr (which contains 122 + the list of CPUs and memory regions to be dumped upon a crash) 123 + in response to hot plug/unplug or online/offline of CPUs or 124 + memory. This is a much more advanced approach than userspace 125 + attempting that. 126 + 127 + If unsure, say Y. 128 + 129 + config CRASH_MAX_MEMORY_RANGES 130 + int "Specify the maximum number of memory regions for the elfcorehdr" 131 + default 8192 132 + depends on CRASH_HOTPLUG 133 + help 134 + For the kexec_file_load() syscall path, specify the maximum number of 135 + memory regions that the elfcorehdr buffer/segment can accommodate. 136 + These regions are obtained via walk_system_ram_res(); eg. the 137 + 'System RAM' entries in /proc/iomem. 138 + This value is combined with NR_CPUS_DEFAULT and multiplied by 139 + sizeof(Elf64_Phdr) to determine the final elfcorehdr memory buffer/ 140 + segment size. 141 + The value 8192, for example, covers a (sparsely populated) 1TiB system 142 + consisting of 128MiB memblocks, while resulting in an elfcorehdr 143 + memory buffer/segment size under 1MiB. This represents a sane choice 144 + to accommodate both baremetal and virtual machine configurations. 145 + 146 + For the kexec_load() syscall path, CRASH_MAX_MEMORY_RANGES is part of 147 + the computation behind the value provided through the 148 + /sys/kernel/crash_elfcorehdr_size attribute. 149 + 150 + endmenu
+1 -1
kernel/acct.c
··· 445 445 memset(ac, 0, sizeof(acct_t)); 446 446 447 447 ac->ac_version = ACCT_VERSION | ACCT_BYTEORDER; 448 - strlcpy(ac->ac_comm, current->comm, sizeof(ac->ac_comm)); 448 + strscpy(ac->ac_comm, current->comm, sizeof(ac->ac_comm)); 449 449 450 450 /* calculate run_time in nsec*/ 451 451 run_time = ktime_get_ns();
+1 -1
kernel/configs/tiny-base.config
··· 1 - CONFIG_EMBEDDED=y 1 + CONFIG_EXPERT=y
+391
kernel/crash_core.c
··· 10 10 #include <linux/utsname.h> 11 11 #include <linux/vmalloc.h> 12 12 #include <linux/sizes.h> 13 + #include <linux/kexec.h> 14 + #include <linux/memory.h> 15 + #include <linux/cpuhotplug.h> 13 16 14 17 #include <asm/page.h> 15 18 #include <asm/sections.h> ··· 20 17 #include <crypto/sha1.h> 21 18 22 19 #include "kallsyms_internal.h" 20 + #include "kexec_internal.h" 21 + 22 + /* Per cpu memory for storing cpu states in case of system crash. */ 23 + note_buf_t __percpu *crash_notes; 23 24 24 25 /* vmcoreinfo stuff */ 25 26 unsigned char *vmcoreinfo_data; ··· 321 314 } 322 315 early_param("crashkernel", parse_crashkernel_dummy); 323 316 317 + int crash_prepare_elf64_headers(struct crash_mem *mem, int need_kernel_map, 318 + void **addr, unsigned long *sz) 319 + { 320 + Elf64_Ehdr *ehdr; 321 + Elf64_Phdr *phdr; 322 + unsigned long nr_cpus = num_possible_cpus(), nr_phdr, elf_sz; 323 + unsigned char *buf; 324 + unsigned int cpu, i; 325 + unsigned long long notes_addr; 326 + unsigned long mstart, mend; 327 + 328 + /* extra phdr for vmcoreinfo ELF note */ 329 + nr_phdr = nr_cpus + 1; 330 + nr_phdr += mem->nr_ranges; 331 + 332 + /* 333 + * kexec-tools creates an extra PT_LOAD phdr for kernel text mapping 334 + * area (for example, ffffffff80000000 - ffffffffa0000000 on x86_64). 335 + * I think this is required by tools like gdb. So same physical 336 + * memory will be mapped in two ELF headers. One will contain kernel 337 + * text virtual addresses and other will have __va(physical) addresses. 338 + */ 339 + 340 + nr_phdr++; 341 + elf_sz = sizeof(Elf64_Ehdr) + nr_phdr * sizeof(Elf64_Phdr); 342 + elf_sz = ALIGN(elf_sz, ELF_CORE_HEADER_ALIGN); 343 + 344 + buf = vzalloc(elf_sz); 345 + if (!buf) 346 + return -ENOMEM; 347 + 348 + ehdr = (Elf64_Ehdr *)buf; 349 + phdr = (Elf64_Phdr *)(ehdr + 1); 350 + memcpy(ehdr->e_ident, ELFMAG, SELFMAG); 351 + ehdr->e_ident[EI_CLASS] = ELFCLASS64; 352 + ehdr->e_ident[EI_DATA] = ELFDATA2LSB; 353 + ehdr->e_ident[EI_VERSION] = EV_CURRENT; 354 + ehdr->e_ident[EI_OSABI] = ELF_OSABI; 355 + memset(ehdr->e_ident + EI_PAD, 0, EI_NIDENT - EI_PAD); 356 + ehdr->e_type = ET_CORE; 357 + ehdr->e_machine = ELF_ARCH; 358 + ehdr->e_version = EV_CURRENT; 359 + ehdr->e_phoff = sizeof(Elf64_Ehdr); 360 + ehdr->e_ehsize = sizeof(Elf64_Ehdr); 361 + ehdr->e_phentsize = sizeof(Elf64_Phdr); 362 + 363 + /* Prepare one phdr of type PT_NOTE for each possible CPU */ 364 + for_each_possible_cpu(cpu) { 365 + phdr->p_type = PT_NOTE; 366 + notes_addr = per_cpu_ptr_to_phys(per_cpu_ptr(crash_notes, cpu)); 367 + phdr->p_offset = phdr->p_paddr = notes_addr; 368 + phdr->p_filesz = phdr->p_memsz = sizeof(note_buf_t); 369 + (ehdr->e_phnum)++; 370 + phdr++; 371 + } 372 + 373 + /* Prepare one PT_NOTE header for vmcoreinfo */ 374 + phdr->p_type = PT_NOTE; 375 + phdr->p_offset = phdr->p_paddr = paddr_vmcoreinfo_note(); 376 + phdr->p_filesz = phdr->p_memsz = VMCOREINFO_NOTE_SIZE; 377 + (ehdr->e_phnum)++; 378 + phdr++; 379 + 380 + /* Prepare PT_LOAD type program header for kernel text region */ 381 + if (need_kernel_map) { 382 + phdr->p_type = PT_LOAD; 383 + phdr->p_flags = PF_R|PF_W|PF_X; 384 + phdr->p_vaddr = (unsigned long) _text; 385 + phdr->p_filesz = phdr->p_memsz = _end - _text; 386 + phdr->p_offset = phdr->p_paddr = __pa_symbol(_text); 387 + ehdr->e_phnum++; 388 + phdr++; 389 + } 390 + 391 + /* Go through all the ranges in mem->ranges[] and prepare phdr */ 392 + for (i = 0; i < mem->nr_ranges; i++) { 393 + mstart = mem->ranges[i].start; 394 + mend = mem->ranges[i].end; 395 + 396 + phdr->p_type = PT_LOAD; 397 + phdr->p_flags = PF_R|PF_W|PF_X; 398 + phdr->p_offset = mstart; 399 + 400 + phdr->p_paddr = mstart; 401 + phdr->p_vaddr = (unsigned long) __va(mstart); 402 + phdr->p_filesz = phdr->p_memsz = mend - mstart + 1; 403 + phdr->p_align = 0; 404 + ehdr->e_phnum++; 405 + pr_debug("Crash PT_LOAD ELF header. phdr=%p vaddr=0x%llx, paddr=0x%llx, sz=0x%llx e_phnum=%d p_offset=0x%llx\n", 406 + phdr, phdr->p_vaddr, phdr->p_paddr, phdr->p_filesz, 407 + ehdr->e_phnum, phdr->p_offset); 408 + phdr++; 409 + } 410 + 411 + *addr = buf; 412 + *sz = elf_sz; 413 + return 0; 414 + } 415 + 416 + int crash_exclude_mem_range(struct crash_mem *mem, 417 + unsigned long long mstart, unsigned long long mend) 418 + { 419 + int i, j; 420 + unsigned long long start, end, p_start, p_end; 421 + struct range temp_range = {0, 0}; 422 + 423 + for (i = 0; i < mem->nr_ranges; i++) { 424 + start = mem->ranges[i].start; 425 + end = mem->ranges[i].end; 426 + p_start = mstart; 427 + p_end = mend; 428 + 429 + if (mstart > end || mend < start) 430 + continue; 431 + 432 + /* Truncate any area outside of range */ 433 + if (mstart < start) 434 + p_start = start; 435 + if (mend > end) 436 + p_end = end; 437 + 438 + /* Found completely overlapping range */ 439 + if (p_start == start && p_end == end) { 440 + mem->ranges[i].start = 0; 441 + mem->ranges[i].end = 0; 442 + if (i < mem->nr_ranges - 1) { 443 + /* Shift rest of the ranges to left */ 444 + for (j = i; j < mem->nr_ranges - 1; j++) { 445 + mem->ranges[j].start = 446 + mem->ranges[j+1].start; 447 + mem->ranges[j].end = 448 + mem->ranges[j+1].end; 449 + } 450 + 451 + /* 452 + * Continue to check if there are another overlapping ranges 453 + * from the current position because of shifting the above 454 + * mem ranges. 455 + */ 456 + i--; 457 + mem->nr_ranges--; 458 + continue; 459 + } 460 + mem->nr_ranges--; 461 + return 0; 462 + } 463 + 464 + if (p_start > start && p_end < end) { 465 + /* Split original range */ 466 + mem->ranges[i].end = p_start - 1; 467 + temp_range.start = p_end + 1; 468 + temp_range.end = end; 469 + } else if (p_start != start) 470 + mem->ranges[i].end = p_start - 1; 471 + else 472 + mem->ranges[i].start = p_end + 1; 473 + break; 474 + } 475 + 476 + /* If a split happened, add the split to array */ 477 + if (!temp_range.end) 478 + return 0; 479 + 480 + /* Split happened */ 481 + if (i == mem->max_nr_ranges - 1) 482 + return -ENOMEM; 483 + 484 + /* Location where new range should go */ 485 + j = i + 1; 486 + if (j < mem->nr_ranges) { 487 + /* Move over all ranges one slot towards the end */ 488 + for (i = mem->nr_ranges - 1; i >= j; i--) 489 + mem->ranges[i + 1] = mem->ranges[i]; 490 + } 491 + 492 + mem->ranges[j].start = temp_range.start; 493 + mem->ranges[j].end = temp_range.end; 494 + mem->nr_ranges++; 495 + return 0; 496 + } 497 + 324 498 Elf_Word *append_elf_note(Elf_Word *buf, char *name, unsigned int type, 325 499 void *data, size_t data_len) 326 500 { ··· 701 513 } 702 514 703 515 subsys_initcall(crash_save_vmcoreinfo_init); 516 + 517 + static int __init crash_notes_memory_init(void) 518 + { 519 + /* Allocate memory for saving cpu registers. */ 520 + size_t size, align; 521 + 522 + /* 523 + * crash_notes could be allocated across 2 vmalloc pages when percpu 524 + * is vmalloc based . vmalloc doesn't guarantee 2 continuous vmalloc 525 + * pages are also on 2 continuous physical pages. In this case the 526 + * 2nd part of crash_notes in 2nd page could be lost since only the 527 + * starting address and size of crash_notes are exported through sysfs. 528 + * Here round up the size of crash_notes to the nearest power of two 529 + * and pass it to __alloc_percpu as align value. This can make sure 530 + * crash_notes is allocated inside one physical page. 531 + */ 532 + size = sizeof(note_buf_t); 533 + align = min(roundup_pow_of_two(sizeof(note_buf_t)), PAGE_SIZE); 534 + 535 + /* 536 + * Break compile if size is bigger than PAGE_SIZE since crash_notes 537 + * definitely will be in 2 pages with that. 538 + */ 539 + BUILD_BUG_ON(size > PAGE_SIZE); 540 + 541 + crash_notes = __alloc_percpu(size, align); 542 + if (!crash_notes) { 543 + pr_warn("Memory allocation for saving cpu register states failed\n"); 544 + return -ENOMEM; 545 + } 546 + return 0; 547 + } 548 + subsys_initcall(crash_notes_memory_init); 549 + 550 + #ifdef CONFIG_CRASH_HOTPLUG 551 + #undef pr_fmt 552 + #define pr_fmt(fmt) "crash hp: " fmt 553 + 554 + /* 555 + * This routine utilized when the crash_hotplug sysfs node is read. 556 + * It reflects the kernel's ability/permission to update the crash 557 + * elfcorehdr directly. 558 + */ 559 + int crash_check_update_elfcorehdr(void) 560 + { 561 + int rc = 0; 562 + 563 + /* Obtain lock while reading crash information */ 564 + if (!kexec_trylock()) { 565 + pr_info("kexec_trylock() failed, elfcorehdr may be inaccurate\n"); 566 + return 0; 567 + } 568 + if (kexec_crash_image) { 569 + if (kexec_crash_image->file_mode) 570 + rc = 1; 571 + else 572 + rc = kexec_crash_image->update_elfcorehdr; 573 + } 574 + /* Release lock now that update complete */ 575 + kexec_unlock(); 576 + 577 + return rc; 578 + } 579 + 580 + /* 581 + * To accurately reflect hot un/plug changes of cpu and memory resources 582 + * (including onling and offlining of those resources), the elfcorehdr 583 + * (which is passed to the crash kernel via the elfcorehdr= parameter) 584 + * must be updated with the new list of CPUs and memories. 585 + * 586 + * In order to make changes to elfcorehdr, two conditions are needed: 587 + * First, the segment containing the elfcorehdr must be large enough 588 + * to permit a growing number of resources; the elfcorehdr memory size 589 + * is based on NR_CPUS_DEFAULT and CRASH_MAX_MEMORY_RANGES. 590 + * Second, purgatory must explicitly exclude the elfcorehdr from the 591 + * list of segments it checks (since the elfcorehdr changes and thus 592 + * would require an update to purgatory itself to update the digest). 593 + */ 594 + static void crash_handle_hotplug_event(unsigned int hp_action, unsigned int cpu) 595 + { 596 + struct kimage *image; 597 + 598 + /* Obtain lock while changing crash information */ 599 + if (!kexec_trylock()) { 600 + pr_info("kexec_trylock() failed, elfcorehdr may be inaccurate\n"); 601 + return; 602 + } 603 + 604 + /* Check kdump is not loaded */ 605 + if (!kexec_crash_image) 606 + goto out; 607 + 608 + image = kexec_crash_image; 609 + 610 + /* Check that updating elfcorehdr is permitted */ 611 + if (!(image->file_mode || image->update_elfcorehdr)) 612 + goto out; 613 + 614 + if (hp_action == KEXEC_CRASH_HP_ADD_CPU || 615 + hp_action == KEXEC_CRASH_HP_REMOVE_CPU) 616 + pr_debug("hp_action %u, cpu %u\n", hp_action, cpu); 617 + else 618 + pr_debug("hp_action %u\n", hp_action); 619 + 620 + /* 621 + * The elfcorehdr_index is set to -1 when the struct kimage 622 + * is allocated. Find the segment containing the elfcorehdr, 623 + * if not already found. 624 + */ 625 + if (image->elfcorehdr_index < 0) { 626 + unsigned long mem; 627 + unsigned char *ptr; 628 + unsigned int n; 629 + 630 + for (n = 0; n < image->nr_segments; n++) { 631 + mem = image->segment[n].mem; 632 + ptr = kmap_local_page(pfn_to_page(mem >> PAGE_SHIFT)); 633 + if (ptr) { 634 + /* The segment containing elfcorehdr */ 635 + if (memcmp(ptr, ELFMAG, SELFMAG) == 0) 636 + image->elfcorehdr_index = (int)n; 637 + kunmap_local(ptr); 638 + } 639 + } 640 + } 641 + 642 + if (image->elfcorehdr_index < 0) { 643 + pr_err("unable to locate elfcorehdr segment"); 644 + goto out; 645 + } 646 + 647 + /* Needed in order for the segments to be updated */ 648 + arch_kexec_unprotect_crashkres(); 649 + 650 + /* Differentiate between normal load and hotplug update */ 651 + image->hp_action = hp_action; 652 + 653 + /* Now invoke arch-specific update handler */ 654 + arch_crash_handle_hotplug_event(image); 655 + 656 + /* No longer handling a hotplug event */ 657 + image->hp_action = KEXEC_CRASH_HP_NONE; 658 + image->elfcorehdr_updated = true; 659 + 660 + /* Change back to read-only */ 661 + arch_kexec_protect_crashkres(); 662 + 663 + /* Errors in the callback is not a reason to rollback state */ 664 + out: 665 + /* Release lock now that update complete */ 666 + kexec_unlock(); 667 + } 668 + 669 + static int crash_memhp_notifier(struct notifier_block *nb, unsigned long val, void *v) 670 + { 671 + switch (val) { 672 + case MEM_ONLINE: 673 + crash_handle_hotplug_event(KEXEC_CRASH_HP_ADD_MEMORY, 674 + KEXEC_CRASH_HP_INVALID_CPU); 675 + break; 676 + 677 + case MEM_OFFLINE: 678 + crash_handle_hotplug_event(KEXEC_CRASH_HP_REMOVE_MEMORY, 679 + KEXEC_CRASH_HP_INVALID_CPU); 680 + break; 681 + } 682 + return NOTIFY_OK; 683 + } 684 + 685 + static struct notifier_block crash_memhp_nb = { 686 + .notifier_call = crash_memhp_notifier, 687 + .priority = 0 688 + }; 689 + 690 + static int crash_cpuhp_online(unsigned int cpu) 691 + { 692 + crash_handle_hotplug_event(KEXEC_CRASH_HP_ADD_CPU, cpu); 693 + return 0; 694 + } 695 + 696 + static int crash_cpuhp_offline(unsigned int cpu) 697 + { 698 + crash_handle_hotplug_event(KEXEC_CRASH_HP_REMOVE_CPU, cpu); 699 + return 0; 700 + } 701 + 702 + static int __init crash_hotplug_init(void) 703 + { 704 + int result = 0; 705 + 706 + if (IS_ENABLED(CONFIG_MEMORY_HOTPLUG)) 707 + register_memory_notifier(&crash_memhp_nb); 708 + 709 + if (IS_ENABLED(CONFIG_HOTPLUG_CPU)) { 710 + result = cpuhp_setup_state_nocalls(CPUHP_BP_PREPARE_DYN, 711 + "crash/cpuhp", crash_cpuhp_online, crash_cpuhp_offline); 712 + } 713 + 714 + return result; 715 + } 716 + 717 + subsys_initcall(crash_hotplug_init); 718 + #endif
+15 -12
kernel/cred.c
··· 4 4 * Copyright (C) 2008 Red Hat, Inc. All Rights Reserved. 5 5 * Written by David Howells (dhowells@redhat.com) 6 6 */ 7 + 8 + #define pr_fmt(fmt) "CRED: " fmt 9 + 7 10 #include <linux/export.h> 8 11 #include <linux/cred.h> 9 12 #include <linux/slab.h> ··· 838 835 static void dump_invalid_creds(const struct cred *cred, const char *label, 839 836 const struct task_struct *tsk) 840 837 { 841 - printk(KERN_ERR "CRED: %s credentials: %p %s%s%s\n", 838 + pr_err("%s credentials: %p %s%s%s\n", 842 839 label, cred, 843 840 cred == &init_cred ? "[init]" : "", 844 841 cred == tsk->real_cred ? "[real]" : "", 845 842 cred == tsk->cred ? "[eff]" : ""); 846 - printk(KERN_ERR "CRED: ->magic=%x, put_addr=%p\n", 843 + pr_err("->magic=%x, put_addr=%p\n", 847 844 cred->magic, cred->put_addr); 848 - printk(KERN_ERR "CRED: ->usage=%d, subscr=%d\n", 845 + pr_err("->usage=%d, subscr=%d\n", 849 846 atomic_read(&cred->usage), 850 847 read_cred_subscribers(cred)); 851 - printk(KERN_ERR "CRED: ->*uid = { %d,%d,%d,%d }\n", 848 + pr_err("->*uid = { %d,%d,%d,%d }\n", 852 849 from_kuid_munged(&init_user_ns, cred->uid), 853 850 from_kuid_munged(&init_user_ns, cred->euid), 854 851 from_kuid_munged(&init_user_ns, cred->suid), 855 852 from_kuid_munged(&init_user_ns, cred->fsuid)); 856 - printk(KERN_ERR "CRED: ->*gid = { %d,%d,%d,%d }\n", 853 + pr_err("->*gid = { %d,%d,%d,%d }\n", 857 854 from_kgid_munged(&init_user_ns, cred->gid), 858 855 from_kgid_munged(&init_user_ns, cred->egid), 859 856 from_kgid_munged(&init_user_ns, cred->sgid), 860 857 from_kgid_munged(&init_user_ns, cred->fsgid)); 861 858 #ifdef CONFIG_SECURITY 862 - printk(KERN_ERR "CRED: ->security is %p\n", cred->security); 859 + pr_err("->security is %p\n", cred->security); 863 860 if ((unsigned long) cred->security >= PAGE_SIZE && 864 861 (((unsigned long) cred->security & 0xffffff00) != 865 862 (POISON_FREE << 24 | POISON_FREE << 16 | POISON_FREE << 8))) 866 - printk(KERN_ERR "CRED: ->security {%x, %x}\n", 863 + pr_err("->security {%x, %x}\n", 867 864 ((u32*)cred->security)[0], 868 865 ((u32*)cred->security)[1]); 869 866 #endif ··· 874 871 */ 875 872 void __noreturn __invalid_creds(const struct cred *cred, const char *file, unsigned line) 876 873 { 877 - printk(KERN_ERR "CRED: Invalid credentials\n"); 878 - printk(KERN_ERR "CRED: At %s:%u\n", file, line); 874 + pr_err("Invalid credentials\n"); 875 + pr_err("At %s:%u\n", file, line); 879 876 dump_invalid_creds(cred, "Specified", current); 880 877 BUG(); 881 878 } ··· 901 898 return; 902 899 903 900 invalid_creds: 904 - printk(KERN_ERR "CRED: Invalid process credentials\n"); 905 - printk(KERN_ERR "CRED: At %s:%u\n", file, line); 901 + pr_err("Invalid process credentials\n"); 902 + pr_err("At %s:%u\n", file, line); 906 903 907 904 dump_invalid_creds(tsk->real_cred, "Real", tsk); 908 905 if (tsk->cred != tsk->real_cred) 909 906 dump_invalid_creds(tsk->cred, "Effective", tsk); 910 907 else 911 - printk(KERN_ERR "CRED: Effective creds == Real creds\n"); 908 + pr_err("Effective creds == Real creds\n"); 912 909 BUG(); 913 910 } 914 911 EXPORT_SYMBOL(__validate_process_creds);
+9 -13
kernel/fork.c
··· 1404 1404 * This changes mm's executable file (shown as symlink /proc/[pid]/exe). 1405 1405 * 1406 1406 * Main users are mmput() and sys_execve(). Callers prevent concurrent 1407 - * invocations: in mmput() nobody alive left, in execve task is single 1408 - * threaded. 1407 + * invocations: in mmput() nobody alive left, in execve it happens before 1408 + * the new mm is made visible to anyone. 1409 1409 * 1410 1410 * Can only fail if new_exe_file != NULL. 1411 1411 */ ··· 1440 1440 /** 1441 1441 * replace_mm_exe_file - replace a reference to the mm's executable file 1442 1442 * 1443 - * This changes mm's executable file (shown as symlink /proc/[pid]/exe), 1444 - * dealing with concurrent invocation and without grabbing the mmap lock in 1445 - * write mode. 1443 + * This changes mm's executable file (shown as symlink /proc/[pid]/exe). 1446 1444 * 1447 1445 * Main user is sys_prctl(PR_SET_MM_MAP/EXE_FILE). 1448 1446 */ ··· 1470 1472 return ret; 1471 1473 } 1472 1474 1473 - /* set the new file, lockless */ 1474 1475 ret = deny_write_access(new_exe_file); 1475 1476 if (ret) 1476 1477 return -EACCES; 1477 1478 get_file(new_exe_file); 1478 1479 1479 - old_exe_file = xchg(&mm->exe_file, new_exe_file); 1480 + /* set the new file */ 1481 + mmap_write_lock(mm); 1482 + old_exe_file = rcu_dereference_raw(mm->exe_file); 1483 + rcu_assign_pointer(mm->exe_file, new_exe_file); 1484 + mmap_write_unlock(mm); 1485 + 1480 1486 if (old_exe_file) { 1481 - /* 1482 - * Don't race with dup_mmap() getting the file and disallowing 1483 - * write access while someone might open the file writable. 1484 - */ 1485 - mmap_read_lock(mm); 1486 1487 allow_write_access(old_exe_file); 1487 1488 fput(old_exe_file); 1488 - mmap_read_unlock(mm); 1489 1489 } 1490 1490 return 0; 1491 1491 }
+2
kernel/gcov/Makefile
··· 3 3 4 4 obj-y := base.o fs.o 5 5 obj-$(CONFIG_CC_IS_GCC) += gcc_base.o gcc_4_7.o 6 + CFLAGS_gcc_base.o += -Wno-missing-prototypes -Wno-missing-declarations 6 7 obj-$(CONFIG_CC_IS_CLANG) += clang.o 8 + CFLAGS_clang.o += -Wno-missing-prototypes -Wno-missing-declarations
+5
kernel/kexec.c
··· 129 129 if (flags & KEXEC_PRESERVE_CONTEXT) 130 130 image->preserve_context = 1; 131 131 132 + #ifdef CONFIG_CRASH_HOTPLUG 133 + if (flags & KEXEC_UPDATE_ELFCOREHDR) 134 + image->update_elfcorehdr = 1; 135 + #endif 136 + 132 137 ret = machine_kexec_prepare(image); 133 138 if (ret) 134 139 goto out;
+6 -37
kernel/kexec_core.c
··· 49 49 50 50 atomic_t __kexec_lock = ATOMIC_INIT(0); 51 51 52 - /* Per cpu memory for storing cpu states in case of system crash. */ 53 - note_buf_t __percpu *crash_notes; 54 - 55 52 /* Flag to indicate we are going to kexec a new kernel */ 56 53 bool kexec_in_progress = false; 57 54 ··· 273 276 274 277 /* Initialize the list of unusable pages */ 275 278 INIT_LIST_HEAD(&image->unusable_pages); 279 + 280 + #ifdef CONFIG_CRASH_HOTPLUG 281 + image->hp_action = KEXEC_CRASH_HP_NONE; 282 + image->elfcorehdr_index = -1; 283 + image->elfcorehdr_updated = false; 284 + #endif 276 285 277 286 return image; 278 287 } ··· 1220 1217 &prstatus, sizeof(prstatus)); 1221 1218 final_note(buf); 1222 1219 } 1223 - 1224 - static int __init crash_notes_memory_init(void) 1225 - { 1226 - /* Allocate memory for saving cpu registers. */ 1227 - size_t size, align; 1228 - 1229 - /* 1230 - * crash_notes could be allocated across 2 vmalloc pages when percpu 1231 - * is vmalloc based . vmalloc doesn't guarantee 2 continuous vmalloc 1232 - * pages are also on 2 continuous physical pages. In this case the 1233 - * 2nd part of crash_notes in 2nd page could be lost since only the 1234 - * starting address and size of crash_notes are exported through sysfs. 1235 - * Here round up the size of crash_notes to the nearest power of two 1236 - * and pass it to __alloc_percpu as align value. This can make sure 1237 - * crash_notes is allocated inside one physical page. 1238 - */ 1239 - size = sizeof(note_buf_t); 1240 - align = min(roundup_pow_of_two(sizeof(note_buf_t)), PAGE_SIZE); 1241 - 1242 - /* 1243 - * Break compile if size is bigger than PAGE_SIZE since crash_notes 1244 - * definitely will be in 2 pages with that. 1245 - */ 1246 - BUILD_BUG_ON(size > PAGE_SIZE); 1247 - 1248 - crash_notes = __alloc_percpu(size, align); 1249 - if (!crash_notes) { 1250 - pr_warn("Memory allocation for saving cpu register states failed\n"); 1251 - return -ENOMEM; 1252 - } 1253 - return 0; 1254 - } 1255 - subsys_initcall(crash_notes_memory_init); 1256 - 1257 1220 1258 1221 /* 1259 1222 * Move into place and start executing a preloaded standalone
+9 -184
kernel/kexec_file.c
··· 685 685 struct kexec_sha_region *sha_regions; 686 686 struct purgatory_info *pi = &image->purgatory_info; 687 687 688 - if (!IS_ENABLED(CONFIG_ARCH_HAS_KEXEC_PURGATORY)) 688 + if (!IS_ENABLED(CONFIG_ARCH_SUPPORTS_KEXEC_PURGATORY)) 689 689 return 0; 690 690 691 691 zero_buf = __va(page_to_pfn(ZERO_PAGE(0)) << PAGE_SHIFT); ··· 725 725 726 726 for (j = i = 0; i < image->nr_segments; i++) { 727 727 struct kexec_segment *ksegment; 728 + 729 + #ifdef CONFIG_CRASH_HOTPLUG 730 + /* Exclude elfcorehdr segment to allow future changes via hotplug */ 731 + if (j == image->elfcorehdr_index) 732 + continue; 733 + #endif 728 734 729 735 ksegment = &image->segment[i]; 730 736 /* ··· 796 790 return ret; 797 791 } 798 792 799 - #ifdef CONFIG_ARCH_HAS_KEXEC_PURGATORY 793 + #ifdef CONFIG_ARCH_SUPPORTS_KEXEC_PURGATORY 800 794 /* 801 795 * kexec_purgatory_setup_kbuf - prepare buffer to load purgatory. 802 796 * @pi: Purgatory to be loaded. ··· 1156 1150 1157 1151 return 0; 1158 1152 } 1159 - #endif /* CONFIG_ARCH_HAS_KEXEC_PURGATORY */ 1160 - 1161 - int crash_exclude_mem_range(struct crash_mem *mem, 1162 - unsigned long long mstart, unsigned long long mend) 1163 - { 1164 - int i, j; 1165 - unsigned long long start, end, p_start, p_end; 1166 - struct range temp_range = {0, 0}; 1167 - 1168 - for (i = 0; i < mem->nr_ranges; i++) { 1169 - start = mem->ranges[i].start; 1170 - end = mem->ranges[i].end; 1171 - p_start = mstart; 1172 - p_end = mend; 1173 - 1174 - if (mstart > end || mend < start) 1175 - continue; 1176 - 1177 - /* Truncate any area outside of range */ 1178 - if (mstart < start) 1179 - p_start = start; 1180 - if (mend > end) 1181 - p_end = end; 1182 - 1183 - /* Found completely overlapping range */ 1184 - if (p_start == start && p_end == end) { 1185 - mem->ranges[i].start = 0; 1186 - mem->ranges[i].end = 0; 1187 - if (i < mem->nr_ranges - 1) { 1188 - /* Shift rest of the ranges to left */ 1189 - for (j = i; j < mem->nr_ranges - 1; j++) { 1190 - mem->ranges[j].start = 1191 - mem->ranges[j+1].start; 1192 - mem->ranges[j].end = 1193 - mem->ranges[j+1].end; 1194 - } 1195 - 1196 - /* 1197 - * Continue to check if there are another overlapping ranges 1198 - * from the current position because of shifting the above 1199 - * mem ranges. 1200 - */ 1201 - i--; 1202 - mem->nr_ranges--; 1203 - continue; 1204 - } 1205 - mem->nr_ranges--; 1206 - return 0; 1207 - } 1208 - 1209 - if (p_start > start && p_end < end) { 1210 - /* Split original range */ 1211 - mem->ranges[i].end = p_start - 1; 1212 - temp_range.start = p_end + 1; 1213 - temp_range.end = end; 1214 - } else if (p_start != start) 1215 - mem->ranges[i].end = p_start - 1; 1216 - else 1217 - mem->ranges[i].start = p_end + 1; 1218 - break; 1219 - } 1220 - 1221 - /* If a split happened, add the split to array */ 1222 - if (!temp_range.end) 1223 - return 0; 1224 - 1225 - /* Split happened */ 1226 - if (i == mem->max_nr_ranges - 1) 1227 - return -ENOMEM; 1228 - 1229 - /* Location where new range should go */ 1230 - j = i + 1; 1231 - if (j < mem->nr_ranges) { 1232 - /* Move over all ranges one slot towards the end */ 1233 - for (i = mem->nr_ranges - 1; i >= j; i--) 1234 - mem->ranges[i + 1] = mem->ranges[i]; 1235 - } 1236 - 1237 - mem->ranges[j].start = temp_range.start; 1238 - mem->ranges[j].end = temp_range.end; 1239 - mem->nr_ranges++; 1240 - return 0; 1241 - } 1242 - 1243 - int crash_prepare_elf64_headers(struct crash_mem *mem, int need_kernel_map, 1244 - void **addr, unsigned long *sz) 1245 - { 1246 - Elf64_Ehdr *ehdr; 1247 - Elf64_Phdr *phdr; 1248 - unsigned long nr_cpus = num_possible_cpus(), nr_phdr, elf_sz; 1249 - unsigned char *buf; 1250 - unsigned int cpu, i; 1251 - unsigned long long notes_addr; 1252 - unsigned long mstart, mend; 1253 - 1254 - /* extra phdr for vmcoreinfo ELF note */ 1255 - nr_phdr = nr_cpus + 1; 1256 - nr_phdr += mem->nr_ranges; 1257 - 1258 - /* 1259 - * kexec-tools creates an extra PT_LOAD phdr for kernel text mapping 1260 - * area (for example, ffffffff80000000 - ffffffffa0000000 on x86_64). 1261 - * I think this is required by tools like gdb. So same physical 1262 - * memory will be mapped in two ELF headers. One will contain kernel 1263 - * text virtual addresses and other will have __va(physical) addresses. 1264 - */ 1265 - 1266 - nr_phdr++; 1267 - elf_sz = sizeof(Elf64_Ehdr) + nr_phdr * sizeof(Elf64_Phdr); 1268 - elf_sz = ALIGN(elf_sz, ELF_CORE_HEADER_ALIGN); 1269 - 1270 - buf = vzalloc(elf_sz); 1271 - if (!buf) 1272 - return -ENOMEM; 1273 - 1274 - ehdr = (Elf64_Ehdr *)buf; 1275 - phdr = (Elf64_Phdr *)(ehdr + 1); 1276 - memcpy(ehdr->e_ident, ELFMAG, SELFMAG); 1277 - ehdr->e_ident[EI_CLASS] = ELFCLASS64; 1278 - ehdr->e_ident[EI_DATA] = ELFDATA2LSB; 1279 - ehdr->e_ident[EI_VERSION] = EV_CURRENT; 1280 - ehdr->e_ident[EI_OSABI] = ELF_OSABI; 1281 - memset(ehdr->e_ident + EI_PAD, 0, EI_NIDENT - EI_PAD); 1282 - ehdr->e_type = ET_CORE; 1283 - ehdr->e_machine = ELF_ARCH; 1284 - ehdr->e_version = EV_CURRENT; 1285 - ehdr->e_phoff = sizeof(Elf64_Ehdr); 1286 - ehdr->e_ehsize = sizeof(Elf64_Ehdr); 1287 - ehdr->e_phentsize = sizeof(Elf64_Phdr); 1288 - 1289 - /* Prepare one phdr of type PT_NOTE for each present CPU */ 1290 - for_each_present_cpu(cpu) { 1291 - phdr->p_type = PT_NOTE; 1292 - notes_addr = per_cpu_ptr_to_phys(per_cpu_ptr(crash_notes, cpu)); 1293 - phdr->p_offset = phdr->p_paddr = notes_addr; 1294 - phdr->p_filesz = phdr->p_memsz = sizeof(note_buf_t); 1295 - (ehdr->e_phnum)++; 1296 - phdr++; 1297 - } 1298 - 1299 - /* Prepare one PT_NOTE header for vmcoreinfo */ 1300 - phdr->p_type = PT_NOTE; 1301 - phdr->p_offset = phdr->p_paddr = paddr_vmcoreinfo_note(); 1302 - phdr->p_filesz = phdr->p_memsz = VMCOREINFO_NOTE_SIZE; 1303 - (ehdr->e_phnum)++; 1304 - phdr++; 1305 - 1306 - /* Prepare PT_LOAD type program header for kernel text region */ 1307 - if (need_kernel_map) { 1308 - phdr->p_type = PT_LOAD; 1309 - phdr->p_flags = PF_R|PF_W|PF_X; 1310 - phdr->p_vaddr = (unsigned long) _text; 1311 - phdr->p_filesz = phdr->p_memsz = _end - _text; 1312 - phdr->p_offset = phdr->p_paddr = __pa_symbol(_text); 1313 - ehdr->e_phnum++; 1314 - phdr++; 1315 - } 1316 - 1317 - /* Go through all the ranges in mem->ranges[] and prepare phdr */ 1318 - for (i = 0; i < mem->nr_ranges; i++) { 1319 - mstart = mem->ranges[i].start; 1320 - mend = mem->ranges[i].end; 1321 - 1322 - phdr->p_type = PT_LOAD; 1323 - phdr->p_flags = PF_R|PF_W|PF_X; 1324 - phdr->p_offset = mstart; 1325 - 1326 - phdr->p_paddr = mstart; 1327 - phdr->p_vaddr = (unsigned long) __va(mstart); 1328 - phdr->p_filesz = phdr->p_memsz = mend - mstart + 1; 1329 - phdr->p_align = 0; 1330 - ehdr->e_phnum++; 1331 - pr_debug("Crash PT_LOAD ELF header. phdr=%p vaddr=0x%llx, paddr=0x%llx, sz=0x%llx e_phnum=%d p_offset=0x%llx\n", 1332 - phdr, phdr->p_vaddr, phdr->p_paddr, phdr->p_filesz, 1333 - ehdr->e_phnum, phdr->p_offset); 1334 - phdr++; 1335 - } 1336 - 1337 - *addr = buf; 1338 - *sz = elf_sz; 1339 - return 0; 1340 - } 1153 + #endif /* CONFIG_ARCH_SUPPORTS_KEXEC_PURGATORY */
+15
kernel/ksysfs.c
··· 165 165 } 166 166 KERNEL_ATTR_RO(vmcoreinfo); 167 167 168 + #ifdef CONFIG_CRASH_HOTPLUG 169 + static ssize_t crash_elfcorehdr_size_show(struct kobject *kobj, 170 + struct kobj_attribute *attr, char *buf) 171 + { 172 + unsigned int sz = crash_get_elfcorehdr_size(); 173 + 174 + return sysfs_emit(buf, "%u\n", sz); 175 + } 176 + KERNEL_ATTR_RO(crash_elfcorehdr_size); 177 + 178 + #endif 179 + 168 180 #endif /* CONFIG_CRASH_CORE */ 169 181 170 182 /* whether file capabilities are enabled */ ··· 267 255 #endif 268 256 #ifdef CONFIG_CRASH_CORE 269 257 &vmcoreinfo_attr.attr, 258 + #ifdef CONFIG_CRASH_HOTPLUG 259 + &crash_elfcorehdr_size_attr.attr, 260 + #endif 270 261 #endif 271 262 #ifndef CONFIG_TINY_RCU 272 263 &rcu_expedited_attr.attr,
+1 -2
kernel/kthread.c
··· 159 159 } 160 160 EXPORT_SYMBOL(kthread_should_stop); 161 161 162 - bool __kthread_should_park(struct task_struct *k) 162 + static bool __kthread_should_park(struct task_struct *k) 163 163 { 164 164 return test_bit(KTHREAD_SHOULD_PARK, &to_kthread(k)->flags); 165 165 } 166 - EXPORT_SYMBOL_GPL(__kthread_should_park); 167 166 168 167 /** 169 168 * kthread_should_park - should this kthread park now?
+14 -22
kernel/locking/lockdep.c
··· 819 819 * Is this the address of a static object: 820 820 */ 821 821 #ifdef __KERNEL__ 822 - /* 823 - * Check if an address is part of freed initmem. After initmem is freed, 824 - * memory can be allocated from it, and such allocations would then have 825 - * addresses within the range [_stext, _end]. 826 - */ 827 - #ifndef arch_is_kernel_initmem_freed 828 - static int arch_is_kernel_initmem_freed(unsigned long addr) 829 - { 830 - if (system_state < SYSTEM_FREEING_INITMEM) 831 - return 0; 832 - 833 - return init_section_contains((void *)addr, 1); 834 - } 835 - #endif 836 - 837 822 static int static_obj(const void *obj) 838 823 { 839 - unsigned long start = (unsigned long) &_stext, 840 - end = (unsigned long) &_end, 841 - addr = (unsigned long) obj; 824 + unsigned long addr = (unsigned long) obj; 842 825 843 - if (arch_is_kernel_initmem_freed(addr)) 844 - return 0; 826 + if (is_kernel_core_data(addr)) 827 + return 1; 845 828 846 829 /* 847 - * static variable? 830 + * keys are allowed in the __ro_after_init section. 848 831 */ 849 - if ((addr >= start) && (addr < end)) 832 + if (is_kernel_rodata(addr)) 833 + return 1; 834 + 835 + /* 836 + * in initdata section and used during bootup only? 837 + * NOTE: On some platforms the initdata section is 838 + * outside of the _stext ... _end range. 839 + */ 840 + if (system_state < SYSTEM_FREEING_INITMEM && 841 + init_section_contains((void *)addr, 1)) 850 842 return 1; 851 843 852 844 /*
+1 -1
kernel/relay.c
··· 375 375 */ 376 376 static struct rchan_buf *relay_open_buf(struct rchan *chan, unsigned int cpu) 377 377 { 378 - struct rchan_buf *buf = NULL; 378 + struct rchan_buf *buf; 379 379 struct dentry *dentry; 380 380 381 381 if (chan->is_global)
+12 -1
kernel/signal.c
··· 22 22 #include <linux/sched/cputime.h> 23 23 #include <linux/file.h> 24 24 #include <linux/fs.h> 25 + #include <linux/mm.h> 25 26 #include <linux/proc_fs.h> 26 27 #include <linux/tty.h> 27 28 #include <linux/binfmts.h> ··· 1261 1260 static void print_fatal_signal(int signr) 1262 1261 { 1263 1262 struct pt_regs *regs = task_pt_regs(current); 1264 - pr_info("potentially unexpected fatal signal %d.\n", signr); 1263 + struct file *exe_file; 1264 + 1265 + exe_file = get_task_exe_file(current); 1266 + if (exe_file) { 1267 + pr_info("%pD: %s: potentially unexpected fatal signal %d.\n", 1268 + exe_file, current->comm, signr); 1269 + fput(exe_file); 1270 + } else { 1271 + pr_info("%s: potentially unexpected fatal signal %d.\n", 1272 + current->comm, signr); 1273 + } 1265 1274 1266 1275 #if defined(__i386__) && !defined(__arch_um__) 1267 1276 pr_info("code at %08lx: ", regs->ip);
+3 -8
kernel/watchdog.c
··· 151 151 */ 152 152 if (is_hardlockup(cpu)) { 153 153 unsigned int this_cpu = smp_processor_id(); 154 - struct cpumask backtrace_mask; 155 - 156 - cpumask_copy(&backtrace_mask, cpu_online_mask); 157 154 158 155 /* Only print hardlockups once. */ 159 156 if (per_cpu(watchdog_hardlockup_warned, cpu)) ··· 164 167 show_regs(regs); 165 168 else 166 169 dump_stack(); 167 - cpumask_clear_cpu(cpu, &backtrace_mask); 168 170 } else { 169 - if (trigger_single_cpu_backtrace(cpu)) 170 - cpumask_clear_cpu(cpu, &backtrace_mask); 171 + trigger_single_cpu_backtrace(cpu); 171 172 } 172 173 173 174 /* ··· 174 179 */ 175 180 if (sysctl_hardlockup_all_cpu_backtrace && 176 181 !test_and_set_bit(0, &watchdog_hardlockup_all_cpu_dumped)) 177 - trigger_cpumask_backtrace(&backtrace_mask); 182 + trigger_allbutcpu_cpu_backtrace(cpu); 178 183 179 184 if (hardlockup_panic) 180 185 nmi_panic(regs, "Hard LOCKUP"); ··· 518 523 dump_stack(); 519 524 520 525 if (softlockup_all_cpu_backtrace) { 521 - trigger_allbutself_cpu_backtrace(); 526 + trigger_allbutcpu_cpu_backtrace(smp_processor_id()); 522 527 clear_bit_unlock(0, &soft_lockup_nmi_warn); 523 528 } 524 529
+1
lib/Kconfig
··· 415 415 # 416 416 config BCH 417 417 tristate 418 + select BITREVERSE 418 419 419 420 config BCH_CONST_PARAMS 420 421 bool
+2 -36
lib/bch.c
··· 71 71 #include <linux/module.h> 72 72 #include <linux/slab.h> 73 73 #include <linux/bitops.h> 74 + #include <linux/bitrev.h> 74 75 #include <asm/byteorder.h> 75 76 #include <linux/bch.h> 76 77 ··· 115 114 unsigned int c[2]; 116 115 }; 117 116 118 - static u8 swap_bits_table[] = { 119 - 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, 120 - 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0, 121 - 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8, 122 - 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8, 123 - 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4, 124 - 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4, 125 - 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec, 126 - 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc, 127 - 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2, 128 - 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2, 129 - 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea, 130 - 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa, 131 - 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6, 132 - 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6, 133 - 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee, 134 - 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe, 135 - 0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1, 136 - 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1, 137 - 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9, 138 - 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9, 139 - 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5, 140 - 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5, 141 - 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed, 142 - 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd, 143 - 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3, 144 - 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3, 145 - 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb, 146 - 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb, 147 - 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7, 148 - 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7, 149 - 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef, 150 - 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff, 151 - }; 152 - 153 117 static u8 swap_bits(struct bch_control *bch, u8 in) 154 118 { 155 119 if (!bch->swap_bits) 156 120 return in; 157 121 158 - return swap_bits_table[in]; 122 + return bitrev8(in); 159 123 } 160 124 161 125 /*
-2
lib/error-inject.c
··· 217 217 struct dentry *dir, *file; 218 218 219 219 dir = debugfs_create_dir("error_injection", NULL); 220 - if (!dir) 221 - return -ENOMEM; 222 220 223 221 file = debugfs_create_file("list", 0444, dir, NULL, &ei_fops); 224 222 if (!file) {
+1 -1
lib/kstrtox.c
··· 59 59 rv = 0; 60 60 while (max_chars--) { 61 61 unsigned int c = *s; 62 - unsigned int lc = c | 0x20; /* don't tolower() this line */ 62 + unsigned int lc = _tolower(c); 63 63 unsigned int val; 64 64 65 65 if ('0' <= c && c <= '9')
+3 -3
lib/nmi_backtrace.c
··· 34 34 * they are passed being updated as a side effect of this call. 35 35 */ 36 36 void nmi_trigger_cpumask_backtrace(const cpumask_t *mask, 37 - bool exclude_self, 37 + int exclude_cpu, 38 38 void (*raise)(cpumask_t *mask)) 39 39 { 40 40 int i, this_cpu = get_cpu(); ··· 49 49 } 50 50 51 51 cpumask_copy(to_cpumask(backtrace_mask), mask); 52 - if (exclude_self) 53 - cpumask_clear_cpu(this_cpu, to_cpumask(backtrace_mask)); 52 + if (exclude_cpu != -1) 53 + cpumask_clear_cpu(exclude_cpu, to_cpumask(backtrace_mask)); 54 54 55 55 /* 56 56 * Don't try to send an NMI to this cpu; it may work on some
-3
lib/notifier-error-inject.c
··· 83 83 notifier_err_inject_dir = 84 84 debugfs_create_dir("notifier-error-inject", NULL); 85 85 86 - if (!notifier_err_inject_dir) 87 - return -ENOMEM; 88 - 89 86 return 0; 90 87 } 91 88
+2 -8
lib/test_hmm.c
··· 368 368 for (pfn = start >> PAGE_SHIFT; pfn < (end >> PAGE_SHIFT); pfn++) { 369 369 void *entry; 370 370 struct page *page; 371 - void *tmp; 372 371 373 372 entry = xa_load(&dmirror->pt, pfn); 374 373 page = xa_untag_pointer(entry); 375 374 if (!page) 376 375 return -ENOENT; 377 376 378 - tmp = kmap(page); 379 - memcpy(ptr, tmp, PAGE_SIZE); 380 - kunmap(page); 377 + memcpy_from_page(ptr, page, 0, PAGE_SIZE); 381 378 382 379 ptr += PAGE_SIZE; 383 380 bounce->cpages++; ··· 434 437 for (pfn = start >> PAGE_SHIFT; pfn < (end >> PAGE_SHIFT); pfn++) { 435 438 void *entry; 436 439 struct page *page; 437 - void *tmp; 438 440 439 441 entry = xa_load(&dmirror->pt, pfn); 440 442 page = xa_untag_pointer(entry); 441 443 if (!page || xa_pointer_tag(entry) != DPT_XA_TAG_WRITE) 442 444 return -ENOENT; 443 445 444 - tmp = kmap(page); 445 - memcpy(tmp, ptr, PAGE_SIZE); 446 - kunmap(page); 446 + memcpy_to_page(page, 0, ptr, PAGE_SIZE); 447 447 448 448 ptr += PAGE_SIZE; 449 449 bounce->cpages++;
+1 -2
lib/test_printf.c
··· 12 12 #include <linux/random.h> 13 13 #include <linux/rtc.h> 14 14 #include <linux/slab.h> 15 + #include <linux/sprintf.h> 15 16 #include <linux/string.h> 16 17 17 18 #include <linux/bitmap.h> ··· 41 40 42 41 static char *test_buffer __initdata; 43 42 static char *alloced_buffer __initdata; 44 - 45 - extern bool no_hash_pointers; 46 43 47 44 static int __printf(4, 0) __init 48 45 do_test(int bufsize, const char *expect, int elen,
+1
lib/vsprintf.c
··· 34 34 #include <linux/dcache.h> 35 35 #include <linux/cred.h> 36 36 #include <linux/rtc.h> 37 + #include <linux/sprintf.h> 37 38 #include <linux/time.h> 38 39 #include <linux/uuid.h> 39 40 #include <linux/of.h>
+1 -2
mm/kfence/report.c
··· 13 13 #include <linux/printk.h> 14 14 #include <linux/sched/debug.h> 15 15 #include <linux/seq_file.h> 16 + #include <linux/sprintf.h> 16 17 #include <linux/stacktrace.h> 17 18 #include <linux/string.h> 18 19 #include <trace/events/error_report.h> ··· 26 25 #ifndef ARCH_FUNC_PREFIX 27 26 #define ARCH_FUNC_PREFIX "" 28 27 #endif 29 - 30 - extern bool no_hash_pointers; 31 28 32 29 /* Helper function to either print to a seq_file or to console. */ 33 30 __printf(2, 3)
+5 -5
scripts/bloat-o-meter
··· 100 100 print("Total: Before=%d, After=%d, chg %+.2f%%" % (otot, ntot, percent)) 101 101 102 102 if args.c: 103 - print_result("Function", "tT") 104 - print_result("Data", "dDbB") 103 + print_result("Function", "tTwW") 104 + print_result("Data", "dDbBvV") 105 105 print_result("RO Data", "rR") 106 106 elif args.d: 107 - print_result("Data", "dDbBrR") 107 + print_result("Data", "dDbBrRvV") 108 108 elif args.t: 109 - print_result("Function", "tT") 109 + print_result("Function", "tTwW") 110 110 else: 111 - print_result("Function", "tTdDbBrR") 111 + print_result("Function", "tTdDbBrRvVwW")
+21 -1
scripts/checkpatch.pl
··· 74 74 my $tabsize = 8; 75 75 my ${CONFIG_} = "CONFIG_"; 76 76 77 + my %maybe_linker_symbol; # for externs in c exceptions, when seen in *vmlinux.lds.h 78 + 77 79 sub help { 78 80 my ($exitcode) = @_; 79 81 ··· 3272 3270 # A Fixes:, link or signature tag line 3273 3271 $commit_log_possible_stack_dump)) { 3274 3272 WARN("COMMIT_LOG_LONG_LINE", 3275 - "Possible unwrapped commit description (prefer a maximum 75 chars per line)\n" . $herecurr); 3273 + "Prefer a maximum 75 chars per line (possible unwrapped commit description?)\n" . $herecurr); 3276 3274 $commit_log_long_line = 1; 3277 3275 } 3278 3276 ··· 6053 6051 6054 6052 # check for line continuations outside of #defines, preprocessor #, and asm 6055 6053 6054 + } elsif ($realfile =~ m@/vmlinux.lds.h$@) { 6055 + $line =~ s/(\w+)/$maybe_linker_symbol{$1}++/ge; 6056 + #print "REAL: $realfile\nln: $line\nkeys:", sort keys %maybe_linker_symbol; 6056 6057 } else { 6057 6058 if ($prevline !~ /^..*\\$/ && 6058 6059 $line !~ /^\+\s*\#.*\\$/ && # preprocessor ··· 7123 7118 WARN("FUNCTION_ARGUMENTS", 7124 7119 "arguments for function declarations should follow identifier\n" . $herecurr); 7125 7120 } 7121 + 7122 + } elsif ($realfile =~ /\.c$/ && defined $stat && 7123 + $stat =~ /^\+extern struct\s+(\w+)\s+(\w+)\[\];/) 7124 + { 7125 + my ($st_type, $st_name) = ($1, $2); 7126 + 7127 + for my $s (keys %maybe_linker_symbol) { 7128 + #print "Linker symbol? $st_name : $s\n"; 7129 + goto LIKELY_LINKER_SYMBOL 7130 + if $st_name =~ /$s/; 7131 + } 7132 + WARN("AVOID_EXTERNS", 7133 + "found a file-scoped extern type:$st_type name:$st_name in .c file\n" 7134 + . "is this a linker symbol ?\n" . $herecurr); 7135 + LIKELY_LINKER_SYMBOL: 7126 7136 7127 7137 } elsif ($realfile =~ /\.c$/ && defined $stat && 7128 7138 $stat =~ /^.\s*extern\s+/)
+55
scripts/gdb/linux/constants.py.in
··· 18 18 #include <linux/irq.h> 19 19 #include <linux/mount.h> 20 20 #include <linux/of_fdt.h> 21 + #include <linux/page_ext.h> 21 22 #include <linux/radix-tree.h> 23 + #include <linux/slab.h> 22 24 #include <linux/threads.h> 25 + #include <linux/vmalloc.h> 23 26 24 27 /* We need to stringify expanded macros so that they can be parsed */ 25 28 ··· 67 64 68 65 /* linux/module.h */ 69 66 LX_GDBPARSED(MOD_TEXT) 67 + LX_GDBPARSED(MOD_DATA) 68 + LX_GDBPARSED(MOD_RODATA) 69 + LX_GDBPARSED(MOD_RO_AFTER_INIT) 70 70 71 71 /* linux/mount.h */ 72 72 LX_VALUE(MNT_NOSUID) ··· 92 86 LX_GDBPARSED(RADIX_TREE_MAP_SHIFT) 93 87 LX_GDBPARSED(RADIX_TREE_MAP_MASK) 94 88 89 + /* linux/vmalloc.h */ 90 + LX_VALUE(VM_IOREMAP) 91 + LX_VALUE(VM_ALLOC) 92 + LX_VALUE(VM_MAP) 93 + LX_VALUE(VM_USERMAP) 94 + LX_VALUE(VM_DMA_COHERENT) 95 + 96 + /* linux/page_ext.h */ 97 + if IS_BUILTIN(CONFIG_PAGE_OWNER): 98 + LX_GDBPARSED(PAGE_EXT_OWNER) 99 + LX_GDBPARSED(PAGE_EXT_OWNER_ALLOCATED) 100 + 101 + /* linux/slab.h */ 102 + LX_GDBPARSED(SLAB_RED_ZONE) 103 + LX_GDBPARSED(SLAB_POISON) 104 + LX_GDBPARSED(SLAB_KMALLOC) 105 + LX_GDBPARSED(SLAB_HWCACHE_ALIGN) 106 + LX_GDBPARSED(SLAB_CACHE_DMA) 107 + LX_GDBPARSED(SLAB_CACHE_DMA32) 108 + LX_GDBPARSED(SLAB_STORE_USER) 109 + LX_GDBPARSED(SLAB_PANIC) 110 + 95 111 /* Kernel Configs */ 96 112 LX_CONFIG(CONFIG_GENERIC_CLOCKEVENTS) 97 113 LX_CONFIG(CONFIG_GENERIC_CLOCKEVENTS_BROADCAST) ··· 130 102 LX_CONFIG(CONFIG_X86_MCE) 131 103 LX_CONFIG(CONFIG_X86_IO_APIC) 132 104 LX_CONFIG(CONFIG_HAVE_KVM) 105 + LX_CONFIG(CONFIG_NUMA) 106 + LX_CONFIG(CONFIG_ARM64) 107 + LX_CONFIG(CONFIG_ARM64_4K_PAGES) 108 + LX_CONFIG(CONFIG_ARM64_16K_PAGES) 109 + LX_CONFIG(CONFIG_ARM64_64K_PAGES) 110 + if IS_BUILTIN(CONFIG_ARM64): 111 + LX_VALUE(CONFIG_ARM64_PA_BITS) 112 + LX_VALUE(CONFIG_ARM64_VA_BITS) 113 + LX_VALUE(CONFIG_ARM64_PAGE_SHIFT) 114 + LX_VALUE(CONFIG_ARCH_FORCE_MAX_ORDER) 115 + LX_CONFIG(CONFIG_SPARSEMEM) 116 + LX_CONFIG(CONFIG_SPARSEMEM_EXTREME) 117 + LX_CONFIG(CONFIG_SPARSEMEM_VMEMMAP) 118 + LX_CONFIG(CONFIG_KASAN) 119 + LX_CONFIG(CONFIG_KASAN_GENERIC) 120 + LX_CONFIG(CONFIG_KASAN_SW_TAGS) 121 + LX_CONFIG(CONFIG_KASAN_HW_TAGS) 122 + if IS_BUILTIN(CONFIG_KASAN_GENERIC) or IS_BUILTIN(CONFIG_KASAN_SW_TAGS): 123 + LX_VALUE(CONFIG_KASAN_SHADOW_OFFSET) 124 + LX_CONFIG(CONFIG_VMAP_STACK) 125 + if IS_BUILTIN(CONFIG_NUMA): 126 + LX_VALUE(CONFIG_NODES_SHIFT) 127 + LX_CONFIG(CONFIG_DEBUG_VIRTUAL) 128 + LX_CONFIG(CONFIG_STACKDEPOT) 129 + LX_CONFIG(CONFIG_PAGE_OWNER) 130 + LX_CONFIG(CONFIG_SLUB_DEBUG) 131 + LX_CONFIG(CONFIG_SLAB_FREELIST_HARDENED)
+370 -194
scripts/gdb/linux/mm.py
··· 1 - # SPDX-License-Identifier: GPL-2.0-only 1 + # SPDX-License-Identifier: GPL-2.0 2 2 # 3 - # gdb helper commands and functions for Linux kernel debugging 4 - # 5 - # routines to introspect page table 3 + # Copyright (c) 2023 MediaTek Inc. 6 4 # 7 5 # Authors: 8 - # Dmitrii Bundin <dmitrii.bundin.a@gmail.com> 6 + # Kuan-Ying Lee <Kuan-Ying.Lee@mediatek.com> 9 7 # 10 8 11 9 import gdb 10 + import math 11 + from linux import utils, constants 12 12 13 - from linux import utils 13 + def DIV_ROUND_UP(n,d): 14 + return ((n) + (d) - 1) // (d) 14 15 15 - PHYSICAL_ADDRESS_MASK = gdb.parse_and_eval('0xfffffffffffff') 16 - 17 - 18 - def page_mask(level=1): 19 - # 4KB 20 - if level == 1: 21 - return gdb.parse_and_eval('(u64) ~0xfff') 22 - # 2MB 23 - elif level == 2: 24 - return gdb.parse_and_eval('(u64) ~0x1fffff') 25 - # 1GB 26 - elif level == 3: 27 - return gdb.parse_and_eval('(u64) ~0x3fffffff') 16 + def test_bit(nr, addr): 17 + if addr.dereference() & (0x1 << nr): 18 + return True 28 19 else: 29 - raise Exception(f'Unknown page level: {level}') 20 + return False 30 21 22 + class page_ops(): 23 + ops = None 24 + def __init__(self): 25 + if not constants.LX_CONFIG_SPARSEMEM_VMEMMAP: 26 + raise gdb.GdbError('Only support CONFIG_SPARSEMEM_VMEMMAP now') 27 + if constants.LX_CONFIG_ARM64 and utils.is_target_arch('aarch64'): 28 + self.ops = aarch64_page_ops() 29 + else: 30 + raise gdb.GdbError('Only support aarch64 now') 31 31 32 - #page_offset_base in case CONFIG_DYNAMIC_MEMORY_LAYOUT is disabled 33 - POB_NO_DYNAMIC_MEM_LAYOUT = '0xffff888000000000' 34 - def _page_offset_base(): 35 - pob_symbol = gdb.lookup_global_symbol('page_offset_base') 36 - pob = pob_symbol.name if pob_symbol else POB_NO_DYNAMIC_MEM_LAYOUT 37 - return gdb.parse_and_eval(pob) 32 + class aarch64_page_ops(): 33 + def __init__(self): 34 + self.SUBSECTION_SHIFT = 21 35 + self.SEBSECTION_SIZE = 1 << self.SUBSECTION_SHIFT 36 + self.MODULES_VSIZE = 128 * 1024 * 1024 38 37 38 + if constants.LX_CONFIG_ARM64_64K_PAGES: 39 + self.SECTION_SIZE_BITS = 29 40 + else: 41 + self.SECTION_SIZE_BITS = 27 42 + self.MAX_PHYSMEM_BITS = constants.LX_CONFIG_ARM64_VA_BITS 39 43 40 - def is_bit_defined_tupled(data, offset): 41 - return offset, bool(data >> offset & 1) 44 + self.PAGE_SHIFT = constants.LX_CONFIG_ARM64_PAGE_SHIFT 45 + self.PAGE_SIZE = 1 << self.PAGE_SHIFT 46 + self.PAGE_MASK = (~(self.PAGE_SIZE - 1)) & ((1 << 64) - 1) 42 47 43 - def content_tupled(data, bit_start, bit_end): 44 - return (bit_start, bit_end), data >> bit_start & ((1 << (1 + bit_end - bit_start)) - 1) 48 + self.VA_BITS = constants.LX_CONFIG_ARM64_VA_BITS 49 + if self.VA_BITS > 48: 50 + self.VA_BITS_MIN = 48 51 + self.vabits_actual = gdb.parse_and_eval('vabits_actual') 52 + else: 53 + self.VA_BITS_MIN = self.VA_BITS 54 + self.vabits_actual = self.VA_BITS 55 + self.kimage_voffset = gdb.parse_and_eval('kimage_voffset') & ((1 << 64) - 1) 45 56 46 - def entry_va(level, phys_addr, translating_va): 47 - def start_bit(level): 48 - if level == 5: 49 - return 48 50 - elif level == 4: 51 - return 39 52 - elif level == 3: 53 - return 30 54 - elif level == 2: 55 - return 21 56 - elif level == 1: 57 - return 12 57 + self.SECTIONS_SHIFT = self.MAX_PHYSMEM_BITS - self.SECTION_SIZE_BITS 58 + 59 + if str(constants.LX_CONFIG_ARCH_FORCE_MAX_ORDER).isdigit(): 60 + self.MAX_ORDER = constants.LX_CONFIG_ARCH_FORCE_MAX_ORDER 61 + else: 62 + self.MAX_ORDER = 11 63 + 64 + self.MAX_ORDER_NR_PAGES = 1 << (self.MAX_ORDER - 1) 65 + self.PFN_SECTION_SHIFT = self.SECTION_SIZE_BITS - self.PAGE_SHIFT 66 + self.NR_MEM_SECTIONS = 1 << self.SECTIONS_SHIFT 67 + self.PAGES_PER_SECTION = 1 << self.PFN_SECTION_SHIFT 68 + self.PAGE_SECTION_MASK = (~(self.PAGES_PER_SECTION - 1)) & ((1 << 64) - 1) 69 + 70 + if constants.LX_CONFIG_SPARSEMEM_EXTREME: 71 + self.SECTIONS_PER_ROOT = self.PAGE_SIZE // gdb.lookup_type("struct mem_section").sizeof 72 + else: 73 + self.SECTIONS_PER_ROOT = 1 74 + 75 + self.NR_SECTION_ROOTS = DIV_ROUND_UP(self.NR_MEM_SECTIONS, self.SECTIONS_PER_ROOT) 76 + self.SECTION_ROOT_MASK = self.SECTIONS_PER_ROOT - 1 77 + self.SUBSECTION_SHIFT = 21 78 + self.SEBSECTION_SIZE = 1 << self.SUBSECTION_SHIFT 79 + self.PFN_SUBSECTION_SHIFT = self.SUBSECTION_SHIFT - self.PAGE_SHIFT 80 + self.PAGES_PER_SUBSECTION = 1 << self.PFN_SUBSECTION_SHIFT 81 + 82 + self.SECTION_HAS_MEM_MAP = 1 << int(gdb.parse_and_eval('SECTION_HAS_MEM_MAP_BIT')) 83 + self.SECTION_IS_EARLY = 1 << int(gdb.parse_and_eval('SECTION_IS_EARLY_BIT')) 84 + 85 + self.struct_page_size = utils.get_page_type().sizeof 86 + self.STRUCT_PAGE_MAX_SHIFT = (int)(math.log(self.struct_page_size, 2)) 87 + 88 + self.PAGE_OFFSET = self._PAGE_OFFSET(self.VA_BITS) 89 + self.MODULES_VADDR = self._PAGE_END(self.VA_BITS_MIN) 90 + self.MODULES_END = self.MODULES_VADDR + self.MODULES_VSIZE 91 + 92 + self.VMEMMAP_SHIFT = (self.PAGE_SHIFT - self.STRUCT_PAGE_MAX_SHIFT) 93 + self.VMEMMAP_SIZE = ((self._PAGE_END(self.VA_BITS_MIN) - self.PAGE_OFFSET) >> self.VMEMMAP_SHIFT) 94 + self.VMEMMAP_START = (-(1 << (self.VA_BITS - self.VMEMMAP_SHIFT))) & 0xffffffffffffffff 95 + self.VMEMMAP_END = self.VMEMMAP_START + self.VMEMMAP_SIZE 96 + 97 + self.VMALLOC_START = self.MODULES_END 98 + self.VMALLOC_END = self.VMEMMAP_START - 256 * 1024 * 1024 99 + 100 + self.memstart_addr = gdb.parse_and_eval("memstart_addr") 101 + self.PHYS_OFFSET = self.memstart_addr 102 + self.vmemmap = gdb.Value(self.VMEMMAP_START).cast(utils.get_page_type().pointer()) - (self.memstart_addr >> self.PAGE_SHIFT) 103 + 104 + self.KERNEL_START = gdb.parse_and_eval("_text") 105 + self.KERNEL_END = gdb.parse_and_eval("_end") 106 + 107 + if constants.LX_CONFIG_KASAN_GENERIC or constants.LX_CONFIG_KASAN_SW_TAGS: 108 + if constants.LX_CONFIG_KASAN_GENERIC: 109 + self.KASAN_SHADOW_SCALE_SHIFT = 3 58 110 else: 59 - raise Exception(f'Unknown level {level}') 60 - 61 - entry_offset = ((translating_va >> start_bit(level)) & 511) * 8 62 - entry_va = _page_offset_base() + phys_addr + entry_offset 63 - return entry_va 64 - 65 - class Cr3(): 66 - def __init__(self, cr3, page_levels): 67 - self.cr3 = cr3 68 - self.page_levels = page_levels 69 - self.page_level_write_through = is_bit_defined_tupled(cr3, 3) 70 - self.page_level_cache_disabled = is_bit_defined_tupled(cr3, 4) 71 - self.next_entry_physical_address = cr3 & PHYSICAL_ADDRESS_MASK & page_mask() 72 - 73 - def next_entry(self, va): 74 - next_level = self.page_levels 75 - return PageHierarchyEntry(entry_va(next_level, self.next_entry_physical_address, va), next_level) 76 - 77 - def mk_string(self): 78 - return f"""\ 79 - cr3: 80 - {'cr3 binary data': <30} {hex(self.cr3)} 81 - {'next entry physical address': <30} {hex(self.next_entry_physical_address)} 82 - --- 83 - {'bit' : <4} {self.page_level_write_through[0]: <10} {'page level write through': <30} {self.page_level_write_through[1]} 84 - {'bit' : <4} {self.page_level_cache_disabled[0]: <10} {'page level cache disabled': <30} {self.page_level_cache_disabled[1]} 85 - """ 86 - 87 - 88 - class PageHierarchyEntry(): 89 - def __init__(self, address, level): 90 - data = int.from_bytes( 91 - memoryview(gdb.selected_inferior().read_memory(address, 8)), 92 - "little" 93 - ) 94 - if level == 1: 95 - self.is_page = True 96 - self.entry_present = is_bit_defined_tupled(data, 0) 97 - self.read_write = is_bit_defined_tupled(data, 1) 98 - self.user_access_allowed = is_bit_defined_tupled(data, 2) 99 - self.page_level_write_through = is_bit_defined_tupled(data, 3) 100 - self.page_level_cache_disabled = is_bit_defined_tupled(data, 4) 101 - self.entry_was_accessed = is_bit_defined_tupled(data, 5) 102 - self.dirty = is_bit_defined_tupled(data, 6) 103 - self.pat = is_bit_defined_tupled(data, 7) 104 - self.global_translation = is_bit_defined_tupled(data, 8) 105 - self.page_physical_address = data & PHYSICAL_ADDRESS_MASK & page_mask(level) 106 - self.next_entry_physical_address = None 107 - self.hlat_restart_with_ordinary = is_bit_defined_tupled(data, 11) 108 - self.protection_key = content_tupled(data, 59, 62) 109 - self.executed_disable = is_bit_defined_tupled(data, 63) 111 + self.KASAN_SHADOW_SCALE_SHIFT = 4 112 + self.KASAN_SHADOW_OFFSET = constants.LX_CONFIG_KASAN_SHADOW_OFFSET 113 + self.KASAN_SHADOW_END = (1 << (64 - self.KASAN_SHADOW_SCALE_SHIFT)) + self.KASAN_SHADOW_OFFSET 114 + self.PAGE_END = self.KASAN_SHADOW_END - (1 << (self.vabits_actual - self.KASAN_SHADOW_SCALE_SHIFT)) 110 115 else: 111 - page_size = is_bit_defined_tupled(data, 7) 112 - page_size_bit = page_size[1] 113 - self.is_page = page_size_bit 114 - self.entry_present = is_bit_defined_tupled(data, 0) 115 - self.read_write = is_bit_defined_tupled(data, 1) 116 - self.user_access_allowed = is_bit_defined_tupled(data, 2) 117 - self.page_level_write_through = is_bit_defined_tupled(data, 3) 118 - self.page_level_cache_disabled = is_bit_defined_tupled(data, 4) 119 - self.entry_was_accessed = is_bit_defined_tupled(data, 5) 120 - self.page_size = page_size 121 - self.dirty = is_bit_defined_tupled( 122 - data, 6) if page_size_bit else None 123 - self.global_translation = is_bit_defined_tupled( 124 - data, 8) if page_size_bit else None 125 - self.pat = is_bit_defined_tupled( 126 - data, 12) if page_size_bit else None 127 - self.page_physical_address = data & PHYSICAL_ADDRESS_MASK & page_mask(level) if page_size_bit else None 128 - self.next_entry_physical_address = None if page_size_bit else data & PHYSICAL_ADDRESS_MASK & page_mask() 129 - self.hlat_restart_with_ordinary = is_bit_defined_tupled(data, 11) 130 - self.protection_key = content_tupled(data, 59, 62) if page_size_bit else None 131 - self.executed_disable = is_bit_defined_tupled(data, 63) 132 - self.address = address 133 - self.page_entry_binary_data = data 134 - self.page_hierarchy_level = level 116 + self.PAGE_END = self._PAGE_END(self.VA_BITS_MIN) 135 117 136 - def next_entry(self, va): 137 - if self.is_page or not self.entry_present[1]: 138 - return None 139 - 140 - next_level = self.page_hierarchy_level - 1 141 - return PageHierarchyEntry(entry_va(next_level, self.next_entry_physical_address, va), next_level) 142 - 143 - 144 - def mk_string(self): 145 - if not self.entry_present[1]: 146 - return f"""\ 147 - level {self.page_hierarchy_level}: 148 - {'entry address': <30} {hex(self.address)} 149 - {'page entry binary data': <30} {hex(self.page_entry_binary_data)} 150 - --- 151 - PAGE ENTRY IS NOT PRESENT! 152 - """ 153 - elif self.is_page: 154 - def page_size_line(ps_bit, ps, level): 155 - return "" if level == 1 else f"{'bit': <3} {ps_bit: <5} {'page size': <30} {ps}" 156 - 157 - return f"""\ 158 - level {self.page_hierarchy_level}: 159 - {'entry address': <30} {hex(self.address)} 160 - {'page entry binary data': <30} {hex(self.page_entry_binary_data)} 161 - {'page size': <30} {'1GB' if self.page_hierarchy_level == 3 else '2MB' if self.page_hierarchy_level == 2 else '4KB' if self.page_hierarchy_level == 1 else 'Unknown page size for level:' + self.page_hierarchy_level} 162 - {'page physical address': <30} {hex(self.page_physical_address)} 163 - --- 164 - {'bit': <4} {self.entry_present[0]: <10} {'entry present': <30} {self.entry_present[1]} 165 - {'bit': <4} {self.read_write[0]: <10} {'read/write access allowed': <30} {self.read_write[1]} 166 - {'bit': <4} {self.user_access_allowed[0]: <10} {'user access allowed': <30} {self.user_access_allowed[1]} 167 - {'bit': <4} {self.page_level_write_through[0]: <10} {'page level write through': <30} {self.page_level_write_through[1]} 168 - {'bit': <4} {self.page_level_cache_disabled[0]: <10} {'page level cache disabled': <30} {self.page_level_cache_disabled[1]} 169 - {'bit': <4} {self.entry_was_accessed[0]: <10} {'entry has been accessed': <30} {self.entry_was_accessed[1]} 170 - {"" if self.page_hierarchy_level == 1 else f"{'bit': <4} {self.page_size[0]: <10} {'page size': <30} {self.page_size[1]}"} 171 - {'bit': <4} {self.dirty[0]: <10} {'page dirty': <30} {self.dirty[1]} 172 - {'bit': <4} {self.global_translation[0]: <10} {'global translation': <30} {self.global_translation[1]} 173 - {'bit': <4} {self.hlat_restart_with_ordinary[0]: <10} {'restart to ordinary': <30} {self.hlat_restart_with_ordinary[1]} 174 - {'bit': <4} {self.pat[0]: <10} {'pat': <30} {self.pat[1]} 175 - {'bits': <4} {str(self.protection_key[0]): <10} {'protection key': <30} {self.protection_key[1]} 176 - {'bit': <4} {self.executed_disable[0]: <10} {'execute disable': <30} {self.executed_disable[1]} 177 - """ 118 + if constants.LX_CONFIG_NUMA and constants.LX_CONFIG_NODES_SHIFT: 119 + self.NODE_SHIFT = constants.LX_CONFIG_NODES_SHIFT 178 120 else: 179 - return f"""\ 180 - level {self.page_hierarchy_level}: 181 - {'entry address': <30} {hex(self.address)} 182 - {'page entry binary data': <30} {hex(self.page_entry_binary_data)} 183 - {'next entry physical address': <30} {hex(self.next_entry_physical_address)} 184 - --- 185 - {'bit': <4} {self.entry_present[0]: <10} {'entry present': <30} {self.entry_present[1]} 186 - {'bit': <4} {self.read_write[0]: <10} {'read/write access allowed': <30} {self.read_write[1]} 187 - {'bit': <4} {self.user_access_allowed[0]: <10} {'user access allowed': <30} {self.user_access_allowed[1]} 188 - {'bit': <4} {self.page_level_write_through[0]: <10} {'page level write through': <30} {self.page_level_write_through[1]} 189 - {'bit': <4} {self.page_level_cache_disabled[0]: <10} {'page level cache disabled': <30} {self.page_level_cache_disabled[1]} 190 - {'bit': <4} {self.entry_was_accessed[0]: <10} {'entry has been accessed': <30} {self.entry_was_accessed[1]} 191 - {'bit': <4} {self.page_size[0]: <10} {'page size': <30} {self.page_size[1]} 192 - {'bit': <4} {self.hlat_restart_with_ordinary[0]: <10} {'restart to ordinary': <30} {self.hlat_restart_with_ordinary[1]} 193 - {'bit': <4} {self.executed_disable[0]: <10} {'execute disable': <30} {self.executed_disable[1]} 194 - """ 121 + self.NODE_SHIFT = 0 195 122 123 + self.MAX_NUMNODES = 1 << self.NODE_SHIFT 196 124 197 - class TranslateVM(gdb.Command): 198 - """Prints the entire paging structure used to translate a given virtual address. 125 + def SECTION_NR_TO_ROOT(self, sec): 126 + return sec // self.SECTIONS_PER_ROOT 199 127 200 - Having an address space of the currently executed process translates the virtual address 201 - and prints detailed information of all paging structure levels used for the transaltion. 202 - Currently supported arch: x86""" 128 + def __nr_to_section(self, nr): 129 + root = self.SECTION_NR_TO_ROOT(nr) 130 + mem_section = gdb.parse_and_eval("mem_section") 131 + return mem_section[root][nr & self.SECTION_ROOT_MASK] 132 + 133 + def pfn_to_section_nr(self, pfn): 134 + return pfn >> self.PFN_SECTION_SHIFT 135 + 136 + def section_nr_to_pfn(self, sec): 137 + return sec << self.PFN_SECTION_SHIFT 138 + 139 + def __pfn_to_section(self, pfn): 140 + return self.__nr_to_section(self.pfn_to_section_nr(pfn)) 141 + 142 + def pfn_to_section(self, pfn): 143 + return self.__pfn_to_section(pfn) 144 + 145 + def subsection_map_index(self, pfn): 146 + return (pfn & ~(self.PAGE_SECTION_MASK)) // self.PAGES_PER_SUBSECTION 147 + 148 + def pfn_section_valid(self, ms, pfn): 149 + if constants.LX_CONFIG_SPARSEMEM_VMEMMAP: 150 + idx = self.subsection_map_index(pfn) 151 + return test_bit(idx, ms['usage']['subsection_map']) 152 + else: 153 + return True 154 + 155 + def valid_section(self, mem_section): 156 + if mem_section != None and (mem_section['section_mem_map'] & self.SECTION_HAS_MEM_MAP): 157 + return True 158 + return False 159 + 160 + def early_section(self, mem_section): 161 + if mem_section != None and (mem_section['section_mem_map'] & self.SECTION_IS_EARLY): 162 + return True 163 + return False 164 + 165 + def pfn_valid(self, pfn): 166 + ms = None 167 + if self.PHYS_PFN(self.PFN_PHYS(pfn)) != pfn: 168 + return False 169 + if self.pfn_to_section_nr(pfn) >= self.NR_MEM_SECTIONS: 170 + return False 171 + ms = self.__pfn_to_section(pfn) 172 + 173 + if not self.valid_section(ms): 174 + return False 175 + return self.early_section(ms) or self.pfn_section_valid(ms, pfn) 176 + 177 + def _PAGE_OFFSET(self, va): 178 + return (-(1 << (va))) & 0xffffffffffffffff 179 + 180 + def _PAGE_END(self, va): 181 + return (-(1 << (va - 1))) & 0xffffffffffffffff 182 + 183 + def kasan_reset_tag(self, addr): 184 + if constants.LX_CONFIG_KASAN_SW_TAGS or constants.LX_CONFIG_KASAN_HW_TAGS: 185 + return int(addr) | (0xff << 56) 186 + else: 187 + return addr 188 + 189 + def __is_lm_address(self, addr): 190 + if (addr - self.PAGE_OFFSET) < (self.PAGE_END - self.PAGE_OFFSET): 191 + return True 192 + else: 193 + return False 194 + def __lm_to_phys(self, addr): 195 + return addr - self.PAGE_OFFSET + self.PHYS_OFFSET 196 + 197 + def __kimg_to_phys(self, addr): 198 + return addr - self.kimage_voffset 199 + 200 + def __virt_to_phys_nodebug(self, va): 201 + untagged_va = self.kasan_reset_tag(va) 202 + if self.__is_lm_address(untagged_va): 203 + return self.__lm_to_phys(untagged_va) 204 + else: 205 + return self.__kimg_to_phys(untagged_va) 206 + 207 + def __virt_to_phys(self, va): 208 + if constants.LX_CONFIG_DEBUG_VIRTUAL: 209 + if not self.__is_lm_address(self.kasan_reset_tag(va)): 210 + raise gdb.GdbError("Warning: virt_to_phys used for non-linear address: 0x%lx\n" % va) 211 + return self.__virt_to_phys_nodebug(va) 212 + 213 + def virt_to_phys(self, va): 214 + return self.__virt_to_phys(va) 215 + 216 + def PFN_PHYS(self, pfn): 217 + return pfn << self.PAGE_SHIFT 218 + 219 + def PHYS_PFN(self, phys): 220 + return phys >> self.PAGE_SHIFT 221 + 222 + def __phys_to_virt(self, pa): 223 + return (pa - self.PHYS_OFFSET) | self.PAGE_OFFSET 224 + 225 + def __phys_to_pfn(self, pa): 226 + return self.PHYS_PFN(pa) 227 + 228 + def __pfn_to_phys(self, pfn): 229 + return self.PFN_PHYS(pfn) 230 + 231 + def __pa_symbol_nodebug(self, x): 232 + return self.__kimg_to_phys(x) 233 + 234 + def __phys_addr_symbol(self, x): 235 + if constants.LX_CONFIG_DEBUG_VIRTUAL: 236 + if x < self.KERNEL_START or x > self.KERNEL_END: 237 + raise gdb.GdbError("0x%x exceed kernel range" % x) 238 + return self.__pa_symbol_nodebug(x) 239 + 240 + def __pa_symbol(self, x): 241 + return self.__phys_addr_symbol(x) 242 + 243 + def __va(self, pa): 244 + return self.__phys_to_virt(pa) 245 + 246 + def pfn_to_kaddr(self, pfn): 247 + return self.__va(pfn << self.PAGE_SHIFT) 248 + 249 + def virt_to_pfn(self, va): 250 + return self.__phys_to_pfn(self.__virt_to_phys(va)) 251 + 252 + def sym_to_pfn(self, x): 253 + return self.__phys_to_pfn(self.__pa_symbol(x)) 254 + 255 + def page_to_pfn(self, page): 256 + return int(page.cast(utils.get_page_type().pointer()) - self.vmemmap.cast(utils.get_page_type().pointer())) 257 + 258 + def page_to_phys(self, page): 259 + return self.__pfn_to_phys(self.page_to_pfn(page)) 260 + 261 + def pfn_to_page(self, pfn): 262 + return (self.vmemmap + pfn).cast(utils.get_page_type().pointer()) 263 + 264 + def page_to_virt(self, page): 265 + if constants.LX_CONFIG_DEBUG_VIRTUAL: 266 + return self.__va(self.page_to_phys(page)) 267 + else: 268 + __idx = int((page.cast(gdb.lookup_type("unsigned long")) - self.VMEMMAP_START).cast(utils.get_ulong_type())) // self.struct_page_size 269 + return self.PAGE_OFFSET + (__idx * self.PAGE_SIZE) 270 + 271 + def virt_to_page(self, va): 272 + if constants.LX_CONFIG_DEBUG_VIRTUAL: 273 + return self.pfn_to_page(self.virt_to_pfn(va)) 274 + else: 275 + __idx = int(self.kasan_reset_tag(va) - self.PAGE_OFFSET) // self.PAGE_SIZE 276 + addr = self.VMEMMAP_START + (__idx * self.struct_page_size) 277 + return gdb.Value(addr).cast(utils.get_page_type().pointer()) 278 + 279 + def page_address(self, page): 280 + return self.page_to_virt(page) 281 + 282 + def folio_address(self, folio): 283 + return self.page_address(folio['page'].address) 284 + 285 + class LxPFN2Page(gdb.Command): 286 + """PFN to struct page""" 203 287 204 288 def __init__(self): 205 - super(TranslateVM, self).__init__('translate-vm', gdb.COMMAND_USER) 289 + super(LxPFN2Page, self).__init__("lx-pfn_to_page", gdb.COMMAND_USER) 206 290 207 291 def invoke(self, arg, from_tty): 208 - if utils.is_target_arch("x86"): 209 - vm_address = gdb.parse_and_eval(f'{arg}') 210 - cr3_data = gdb.parse_and_eval('$cr3') 211 - cr4 = gdb.parse_and_eval('$cr4') 212 - page_levels = 5 if cr4 & (1 << 12) else 4 213 - page_entry = Cr3(cr3_data, page_levels) 214 - while page_entry: 215 - gdb.write(page_entry.mk_string()) 216 - page_entry = page_entry.next_entry(vm_address) 217 - else: 218 - gdb.GdbError("Virtual address translation is not" 219 - "supported for this arch") 292 + argv = gdb.string_to_argv(arg) 293 + pfn = int(argv[0]) 294 + page = page_ops().ops.pfn_to_page(pfn) 295 + gdb.write("pfn_to_page(0x%x) = 0x%x\n" % (pfn, page)) 220 296 297 + LxPFN2Page() 221 298 222 - TranslateVM() 299 + class LxPage2PFN(gdb.Command): 300 + """struct page to PFN""" 301 + 302 + def __init__(self): 303 + super(LxPage2PFN, self).__init__("lx-page_to_pfn", gdb.COMMAND_USER) 304 + 305 + def invoke(self, arg, from_tty): 306 + argv = gdb.string_to_argv(arg) 307 + struct_page_addr = int(argv[0], 16) 308 + page = gdb.Value(struct_page_addr).cast(utils.get_page_type().pointer()) 309 + pfn = page_ops().ops.page_to_pfn(page) 310 + gdb.write("page_to_pfn(0x%x) = 0x%x\n" % (page, pfn)) 311 + 312 + LxPage2PFN() 313 + 314 + class LxPageAddress(gdb.Command): 315 + """struct page to linear mapping address""" 316 + 317 + def __init__(self): 318 + super(LxPageAddress, self).__init__("lx-page_address", gdb.COMMAND_USER) 319 + 320 + def invoke(self, arg, from_tty): 321 + argv = gdb.string_to_argv(arg) 322 + struct_page_addr = int(argv[0], 16) 323 + page = gdb.Value(struct_page_addr).cast(utils.get_page_type().pointer()) 324 + addr = page_ops().ops.page_address(page) 325 + gdb.write("page_address(0x%x) = 0x%x\n" % (page, addr)) 326 + 327 + LxPageAddress() 328 + 329 + class LxPage2Phys(gdb.Command): 330 + """struct page to physical address""" 331 + 332 + def __init__(self): 333 + super(LxPage2Phys, self).__init__("lx-page_to_phys", gdb.COMMAND_USER) 334 + 335 + def invoke(self, arg, from_tty): 336 + argv = gdb.string_to_argv(arg) 337 + struct_page_addr = int(argv[0], 16) 338 + page = gdb.Value(struct_page_addr).cast(utils.get_page_type().pointer()) 339 + phys_addr = page_ops().ops.page_to_phys(page) 340 + gdb.write("page_to_phys(0x%x) = 0x%x\n" % (page, phys_addr)) 341 + 342 + LxPage2Phys() 343 + 344 + class LxVirt2Phys(gdb.Command): 345 + """virtual address to physical address""" 346 + 347 + def __init__(self): 348 + super(LxVirt2Phys, self).__init__("lx-virt_to_phys", gdb.COMMAND_USER) 349 + 350 + def invoke(self, arg, from_tty): 351 + argv = gdb.string_to_argv(arg) 352 + linear_addr = int(argv[0], 16) 353 + phys_addr = page_ops().ops.virt_to_phys(linear_addr) 354 + gdb.write("virt_to_phys(0x%x) = 0x%x\n" % (linear_addr, phys_addr)) 355 + 356 + LxVirt2Phys() 357 + 358 + class LxVirt2Page(gdb.Command): 359 + """virtual address to struct page""" 360 + 361 + def __init__(self): 362 + super(LxVirt2Page, self).__init__("lx-virt_to_page", gdb.COMMAND_USER) 363 + 364 + def invoke(self, arg, from_tty): 365 + argv = gdb.string_to_argv(arg) 366 + linear_addr = int(argv[0], 16) 367 + page = page_ops().ops.virt_to_page(linear_addr) 368 + gdb.write("virt_to_page(0x%x) = 0x%x\n" % (linear_addr, page)) 369 + 370 + LxVirt2Page() 371 + 372 + class LxSym2PFN(gdb.Command): 373 + """symbol address to PFN""" 374 + 375 + def __init__(self): 376 + super(LxSym2PFN, self).__init__("lx-sym_to_pfn", gdb.COMMAND_USER) 377 + 378 + def invoke(self, arg, from_tty): 379 + argv = gdb.string_to_argv(arg) 380 + sym_addr = int(argv[0], 16) 381 + pfn = page_ops().ops.sym_to_pfn(sym_addr) 382 + gdb.write("sym_to_pfn(0x%x) = %d\n" % (sym_addr, pfn)) 383 + 384 + LxSym2PFN() 385 + 386 + class LxPFN2Kaddr(gdb.Command): 387 + """PFN to kernel address""" 388 + 389 + def __init__(self): 390 + super(LxPFN2Kaddr, self).__init__("lx-pfn_to_kaddr", gdb.COMMAND_USER) 391 + 392 + def invoke(self, arg, from_tty): 393 + argv = gdb.string_to_argv(arg) 394 + pfn = int(argv[0]) 395 + kaddr = page_ops().ops.pfn_to_kaddr(pfn) 396 + gdb.write("pfn_to_kaddr(%d) = 0x%x\n" % (pfn, kaddr)) 397 + 398 + LxPFN2Kaddr()
+40 -4
scripts/gdb/linux/modules.py
··· 73 73 " " if utils.get_long_type().sizeof == 8 else "")) 74 74 75 75 for module in module_list(): 76 - layout = module['mem'][constants.LX_MOD_TEXT] 76 + text = module['mem'][constants.LX_MOD_TEXT] 77 + text_addr = str(text['base']).split()[0] 78 + total_size = 0 79 + 80 + for i in range(constants.LX_MOD_TEXT, constants.LX_MOD_RO_AFTER_INIT + 1): 81 + total_size += module['mem'][i]['size'] 82 + 77 83 gdb.write("{address} {name:<19} {size:>8} {ref}".format( 78 - address=str(layout['base']).split()[0], 84 + address=text_addr, 79 85 name=module['name'].string(), 80 - size=str(layout['size']), 86 + size=str(total_size), 81 87 ref=str(module['refcnt']['counter'] - 1))) 82 88 83 89 t = self._module_use_type.get_type().pointer() ··· 97 91 98 92 gdb.write("\n") 99 93 100 - 101 94 LxLsmod() 95 + 96 + def help(): 97 + t = """Usage: lx-getmod-by-textaddr [Heximal Address] 98 + Example: lx-getmod-by-textaddr 0xffff800002d305ac\n""" 99 + gdb.write("Unrecognized command\n") 100 + raise gdb.GdbError(t) 101 + 102 + class LxFindTextAddrinMod(gdb.Command): 103 + '''Look up loaded kernel module by text address.''' 104 + 105 + def __init__(self): 106 + super(LxFindTextAddrinMod, self).__init__('lx-getmod-by-textaddr', gdb.COMMAND_SUPPORT) 107 + 108 + def invoke(self, arg, from_tty): 109 + args = gdb.string_to_argv(arg) 110 + 111 + if len(args) != 1: 112 + help() 113 + 114 + addr = gdb.Value(int(args[0], 16)).cast(utils.get_ulong_type()) 115 + for mod in module_list(): 116 + mod_text_start = mod['mem'][constants.LX_MOD_TEXT]['base'] 117 + mod_text_end = mod_text_start + mod['mem'][constants.LX_MOD_TEXT]['size'].cast(utils.get_ulong_type()) 118 + 119 + if addr >= mod_text_start and addr < mod_text_end: 120 + s = "0x%x" % addr + " is in " + mod['name'].string() + ".ko\n" 121 + gdb.write(s) 122 + return 123 + gdb.write("0x%x is not in any module text section\n" % addr) 124 + 125 + LxFindTextAddrinMod()
+190
scripts/gdb/linux/page_owner.py
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + # 3 + # Copyright (c) 2023 MediaTek Inc. 4 + # 5 + # Authors: 6 + # Kuan-Ying Lee <Kuan-Ying.Lee@mediatek.com> 7 + # 8 + 9 + import gdb 10 + from linux import utils, stackdepot, constants, mm 11 + 12 + if constants.LX_CONFIG_PAGE_OWNER: 13 + page_ext_t = utils.CachedType('struct page_ext') 14 + page_owner_t = utils.CachedType('struct page_owner') 15 + 16 + PAGE_OWNER_STACK_DEPTH = 16 17 + PAGE_EXT_OWNER = constants.LX_PAGE_EXT_OWNER 18 + PAGE_EXT_INVALID = 0x1 19 + PAGE_EXT_OWNER_ALLOCATED = constants.LX_PAGE_EXT_OWNER_ALLOCATED 20 + 21 + def help(): 22 + t = """Usage: lx-dump-page-owner [Option] 23 + Option: 24 + --pfn [Decimal pfn] 25 + Example: 26 + lx-dump-page-owner --pfn 655360\n""" 27 + gdb.write("Unrecognized command\n") 28 + raise gdb.GdbError(t) 29 + 30 + class DumpPageOwner(gdb.Command): 31 + """Dump page owner""" 32 + 33 + min_pfn = None 34 + max_pfn = None 35 + p_ops = None 36 + migrate_reason_names = None 37 + 38 + def __init__(self): 39 + super(DumpPageOwner, self).__init__("lx-dump-page-owner", gdb.COMMAND_SUPPORT) 40 + 41 + def invoke(self, args, from_tty): 42 + if not constants.LX_CONFIG_PAGE_OWNER: 43 + raise gdb.GdbError('CONFIG_PAGE_OWNER does not enable') 44 + 45 + page_owner_inited = gdb.parse_and_eval('page_owner_inited') 46 + if page_owner_inited['key']['enabled']['counter'] != 0x1: 47 + raise gdb.GdbError('page_owner_inited is not enabled') 48 + 49 + self.p_ops = mm.page_ops().ops 50 + self.get_page_owner_info() 51 + argv = gdb.string_to_argv(args) 52 + if len(argv) == 0: 53 + self.read_page_owner() 54 + elif len(argv) == 2: 55 + if argv[0] == "--pfn": 56 + pfn = int(argv[1]) 57 + self.read_page_owner_by_addr(self.p_ops.pfn_to_page(pfn)) 58 + else: 59 + help() 60 + else: 61 + help() 62 + 63 + def get_page_owner_info(self): 64 + self.min_pfn = int(gdb.parse_and_eval("min_low_pfn")) 65 + self.max_pfn = int(gdb.parse_and_eval("max_pfn")) 66 + self.page_ext_size = int(gdb.parse_and_eval("page_ext_size")) 67 + self.migrate_reason_names = gdb.parse_and_eval('migrate_reason_names') 68 + 69 + def page_ext_invalid(self, page_ext): 70 + if page_ext == gdb.Value(0): 71 + return True 72 + if page_ext.cast(utils.get_ulong_type()) & PAGE_EXT_INVALID == PAGE_EXT_INVALID: 73 + return True 74 + return False 75 + 76 + def get_entry(self, base, index): 77 + return (base.cast(utils.get_ulong_type()) + self.page_ext_size * index).cast(page_ext_t.get_type().pointer()) 78 + 79 + def lookup_page_ext(self, page): 80 + pfn = self.p_ops.page_to_pfn(page) 81 + section = self.p_ops.pfn_to_section(pfn) 82 + page_ext = section["page_ext"] 83 + if self.page_ext_invalid(page_ext): 84 + return gdb.Value(0) 85 + return self.get_entry(page_ext, pfn) 86 + 87 + def page_ext_get(self, page): 88 + page_ext = self.lookup_page_ext(page) 89 + if page_ext != gdb.Value(0): 90 + return page_ext 91 + else: 92 + return gdb.Value(0) 93 + 94 + def get_page_owner(self, page_ext): 95 + addr = page_ext.cast(utils.get_ulong_type()) + gdb.parse_and_eval("page_owner_ops")["offset"].cast(utils.get_ulong_type()) 96 + return addr.cast(page_owner_t.get_type().pointer()) 97 + 98 + def read_page_owner_by_addr(self, struct_page_addr): 99 + page = gdb.Value(struct_page_addr).cast(utils.get_page_type().pointer()) 100 + pfn = self.p_ops.page_to_pfn(page) 101 + 102 + if pfn < self.min_pfn or pfn > self.max_pfn or (not self.p_ops.pfn_valid(pfn)): 103 + gdb.write("pfn is invalid\n") 104 + return 105 + 106 + page = self.p_ops.pfn_to_page(pfn) 107 + page_ext = self.page_ext_get(page) 108 + 109 + if page_ext == gdb.Value(0): 110 + gdb.write("page_ext is null\n") 111 + return 112 + 113 + if not (page_ext['flags'] & (1 << PAGE_EXT_OWNER)): 114 + gdb.write("page_owner flag is invalid\n") 115 + raise gdb.GdbError('page_owner info is not present (never set?)\n') 116 + 117 + if mm.test_bit(PAGE_EXT_OWNER_ALLOCATED, page_ext['flags'].address): 118 + gdb.write('page_owner tracks the page as allocated\n') 119 + else: 120 + gdb.write('page_owner tracks the page as freed\n') 121 + 122 + if not (page_ext['flags'] & (1 << PAGE_EXT_OWNER_ALLOCATED)): 123 + gdb.write("page_owner is not allocated\n") 124 + 125 + try: 126 + page_owner = self.get_page_owner(page_ext) 127 + gdb.write("Page last allocated via order %d, gfp_mask: 0x%x, pid: %d, tgid: %d (%s), ts %u ns, free_ts %u ns\n" %\ 128 + (page_owner["order"], page_owner["gfp_mask"],\ 129 + page_owner["pid"], page_owner["tgid"], page_owner["comm"],\ 130 + page_owner["ts_nsec"], page_owner["free_ts_nsec"])) 131 + gdb.write("PFN: %d, Flags: 0x%x\n" % (pfn, page['flags'])) 132 + if page_owner["handle"] == 0: 133 + gdb.write('page_owner allocation stack trace missing\n') 134 + else: 135 + stackdepot.stack_depot_print(page_owner["handle"]) 136 + 137 + if page_owner["free_handle"] == 0: 138 + gdb.write('page_owner free stack trace missing\n') 139 + else: 140 + gdb.write('page last free stack trace:\n') 141 + stackdepot.stack_depot_print(page_owner["free_handle"]) 142 + if page_owner['last_migrate_reason'] != -1: 143 + gdb.write('page has been migrated, last migrate reason: %s\n' % self.migrate_reason_names[page_owner['last_migrate_reason']]) 144 + except: 145 + gdb.write("\n") 146 + 147 + def read_page_owner(self): 148 + pfn = self.min_pfn 149 + 150 + # Find a valid PFN or the start of a MAX_ORDER_NR_PAGES area 151 + while ((not self.p_ops.pfn_valid(pfn)) and (pfn & (self.p_ops.MAX_ORDER_NR_PAGES - 1))) != 0: 152 + pfn += 1 153 + 154 + while pfn < self.max_pfn: 155 + # 156 + # If the new page is in a new MAX_ORDER_NR_PAGES area, 157 + # validate the area as existing, skip it if not 158 + # 159 + if ((pfn & (self.p_ops.MAX_ORDER_NR_PAGES - 1)) == 0) and (not self.p_ops.pfn_valid(pfn)): 160 + pfn += (self.p_ops.MAX_ORDER_NR_PAGES - 1) 161 + continue; 162 + 163 + page = self.p_ops.pfn_to_page(pfn) 164 + page_ext = self.page_ext_get(page) 165 + if page_ext == gdb.Value(0): 166 + pfn += 1 167 + continue 168 + 169 + if not (page_ext['flags'] & (1 << PAGE_EXT_OWNER)): 170 + pfn += 1 171 + continue 172 + if not (page_ext['flags'] & (1 << PAGE_EXT_OWNER_ALLOCATED)): 173 + pfn += 1 174 + continue 175 + 176 + try: 177 + page_owner = self.get_page_owner(page_ext) 178 + gdb.write("Page allocated via order %d, gfp_mask: 0x%x, pid: %d, tgid: %d (%s), ts %u ns, free_ts %u ns\n" %\ 179 + (page_owner["order"], page_owner["gfp_mask"],\ 180 + page_owner["pid"], page_owner["tgid"], page_owner["comm"],\ 181 + page_owner["ts_nsec"], page_owner["free_ts_nsec"])) 182 + gdb.write("PFN: %d, Flags: 0x%x\n" % (pfn, page['flags'])) 183 + stackdepot.stack_depot_print(page_owner["handle"]) 184 + pfn += (1 << page_owner["order"]) 185 + continue 186 + except: 187 + gdb.write("\n") 188 + pfn += 1 189 + 190 + DumpPageOwner()
+222
scripts/gdb/linux/pgtable.py
··· 1 + # SPDX-License-Identifier: GPL-2.0-only 2 + # 3 + # gdb helper commands and functions for Linux kernel debugging 4 + # 5 + # routines to introspect page table 6 + # 7 + # Authors: 8 + # Dmitrii Bundin <dmitrii.bundin.a@gmail.com> 9 + # 10 + 11 + import gdb 12 + 13 + from linux import utils 14 + 15 + PHYSICAL_ADDRESS_MASK = gdb.parse_and_eval('0xfffffffffffff') 16 + 17 + 18 + def page_mask(level=1): 19 + # 4KB 20 + if level == 1: 21 + return gdb.parse_and_eval('(u64) ~0xfff') 22 + # 2MB 23 + elif level == 2: 24 + return gdb.parse_and_eval('(u64) ~0x1fffff') 25 + # 1GB 26 + elif level == 3: 27 + return gdb.parse_and_eval('(u64) ~0x3fffffff') 28 + else: 29 + raise Exception(f'Unknown page level: {level}') 30 + 31 + 32 + #page_offset_base in case CONFIG_DYNAMIC_MEMORY_LAYOUT is disabled 33 + POB_NO_DYNAMIC_MEM_LAYOUT = '0xffff888000000000' 34 + def _page_offset_base(): 35 + pob_symbol = gdb.lookup_global_symbol('page_offset_base') 36 + pob = pob_symbol.name if pob_symbol else POB_NO_DYNAMIC_MEM_LAYOUT 37 + return gdb.parse_and_eval(pob) 38 + 39 + 40 + def is_bit_defined_tupled(data, offset): 41 + return offset, bool(data >> offset & 1) 42 + 43 + def content_tupled(data, bit_start, bit_end): 44 + return (bit_start, bit_end), data >> bit_start & ((1 << (1 + bit_end - bit_start)) - 1) 45 + 46 + def entry_va(level, phys_addr, translating_va): 47 + def start_bit(level): 48 + if level == 5: 49 + return 48 50 + elif level == 4: 51 + return 39 52 + elif level == 3: 53 + return 30 54 + elif level == 2: 55 + return 21 56 + elif level == 1: 57 + return 12 58 + else: 59 + raise Exception(f'Unknown level {level}') 60 + 61 + entry_offset = ((translating_va >> start_bit(level)) & 511) * 8 62 + entry_va = _page_offset_base() + phys_addr + entry_offset 63 + return entry_va 64 + 65 + class Cr3(): 66 + def __init__(self, cr3, page_levels): 67 + self.cr3 = cr3 68 + self.page_levels = page_levels 69 + self.page_level_write_through = is_bit_defined_tupled(cr3, 3) 70 + self.page_level_cache_disabled = is_bit_defined_tupled(cr3, 4) 71 + self.next_entry_physical_address = cr3 & PHYSICAL_ADDRESS_MASK & page_mask() 72 + 73 + def next_entry(self, va): 74 + next_level = self.page_levels 75 + return PageHierarchyEntry(entry_va(next_level, self.next_entry_physical_address, va), next_level) 76 + 77 + def mk_string(self): 78 + return f"""\ 79 + cr3: 80 + {'cr3 binary data': <30} {hex(self.cr3)} 81 + {'next entry physical address': <30} {hex(self.next_entry_physical_address)} 82 + --- 83 + {'bit' : <4} {self.page_level_write_through[0]: <10} {'page level write through': <30} {self.page_level_write_through[1]} 84 + {'bit' : <4} {self.page_level_cache_disabled[0]: <10} {'page level cache disabled': <30} {self.page_level_cache_disabled[1]} 85 + """ 86 + 87 + 88 + class PageHierarchyEntry(): 89 + def __init__(self, address, level): 90 + data = int.from_bytes( 91 + memoryview(gdb.selected_inferior().read_memory(address, 8)), 92 + "little" 93 + ) 94 + if level == 1: 95 + self.is_page = True 96 + self.entry_present = is_bit_defined_tupled(data, 0) 97 + self.read_write = is_bit_defined_tupled(data, 1) 98 + self.user_access_allowed = is_bit_defined_tupled(data, 2) 99 + self.page_level_write_through = is_bit_defined_tupled(data, 3) 100 + self.page_level_cache_disabled = is_bit_defined_tupled(data, 4) 101 + self.entry_was_accessed = is_bit_defined_tupled(data, 5) 102 + self.dirty = is_bit_defined_tupled(data, 6) 103 + self.pat = is_bit_defined_tupled(data, 7) 104 + self.global_translation = is_bit_defined_tupled(data, 8) 105 + self.page_physical_address = data & PHYSICAL_ADDRESS_MASK & page_mask(level) 106 + self.next_entry_physical_address = None 107 + self.hlat_restart_with_ordinary = is_bit_defined_tupled(data, 11) 108 + self.protection_key = content_tupled(data, 59, 62) 109 + self.executed_disable = is_bit_defined_tupled(data, 63) 110 + else: 111 + page_size = is_bit_defined_tupled(data, 7) 112 + page_size_bit = page_size[1] 113 + self.is_page = page_size_bit 114 + self.entry_present = is_bit_defined_tupled(data, 0) 115 + self.read_write = is_bit_defined_tupled(data, 1) 116 + self.user_access_allowed = is_bit_defined_tupled(data, 2) 117 + self.page_level_write_through = is_bit_defined_tupled(data, 3) 118 + self.page_level_cache_disabled = is_bit_defined_tupled(data, 4) 119 + self.entry_was_accessed = is_bit_defined_tupled(data, 5) 120 + self.page_size = page_size 121 + self.dirty = is_bit_defined_tupled( 122 + data, 6) if page_size_bit else None 123 + self.global_translation = is_bit_defined_tupled( 124 + data, 8) if page_size_bit else None 125 + self.pat = is_bit_defined_tupled( 126 + data, 12) if page_size_bit else None 127 + self.page_physical_address = data & PHYSICAL_ADDRESS_MASK & page_mask(level) if page_size_bit else None 128 + self.next_entry_physical_address = None if page_size_bit else data & PHYSICAL_ADDRESS_MASK & page_mask() 129 + self.hlat_restart_with_ordinary = is_bit_defined_tupled(data, 11) 130 + self.protection_key = content_tupled(data, 59, 62) if page_size_bit else None 131 + self.executed_disable = is_bit_defined_tupled(data, 63) 132 + self.address = address 133 + self.page_entry_binary_data = data 134 + self.page_hierarchy_level = level 135 + 136 + def next_entry(self, va): 137 + if self.is_page or not self.entry_present[1]: 138 + return None 139 + 140 + next_level = self.page_hierarchy_level - 1 141 + return PageHierarchyEntry(entry_va(next_level, self.next_entry_physical_address, va), next_level) 142 + 143 + 144 + def mk_string(self): 145 + if not self.entry_present[1]: 146 + return f"""\ 147 + level {self.page_hierarchy_level}: 148 + {'entry address': <30} {hex(self.address)} 149 + {'page entry binary data': <30} {hex(self.page_entry_binary_data)} 150 + --- 151 + PAGE ENTRY IS NOT PRESENT! 152 + """ 153 + elif self.is_page: 154 + def page_size_line(ps_bit, ps, level): 155 + return "" if level == 1 else f"{'bit': <3} {ps_bit: <5} {'page size': <30} {ps}" 156 + 157 + return f"""\ 158 + level {self.page_hierarchy_level}: 159 + {'entry address': <30} {hex(self.address)} 160 + {'page entry binary data': <30} {hex(self.page_entry_binary_data)} 161 + {'page size': <30} {'1GB' if self.page_hierarchy_level == 3 else '2MB' if self.page_hierarchy_level == 2 else '4KB' if self.page_hierarchy_level == 1 else 'Unknown page size for level:' + self.page_hierarchy_level} 162 + {'page physical address': <30} {hex(self.page_physical_address)} 163 + --- 164 + {'bit': <4} {self.entry_present[0]: <10} {'entry present': <30} {self.entry_present[1]} 165 + {'bit': <4} {self.read_write[0]: <10} {'read/write access allowed': <30} {self.read_write[1]} 166 + {'bit': <4} {self.user_access_allowed[0]: <10} {'user access allowed': <30} {self.user_access_allowed[1]} 167 + {'bit': <4} {self.page_level_write_through[0]: <10} {'page level write through': <30} {self.page_level_write_through[1]} 168 + {'bit': <4} {self.page_level_cache_disabled[0]: <10} {'page level cache disabled': <30} {self.page_level_cache_disabled[1]} 169 + {'bit': <4} {self.entry_was_accessed[0]: <10} {'entry has been accessed': <30} {self.entry_was_accessed[1]} 170 + {"" if self.page_hierarchy_level == 1 else f"{'bit': <4} {self.page_size[0]: <10} {'page size': <30} {self.page_size[1]}"} 171 + {'bit': <4} {self.dirty[0]: <10} {'page dirty': <30} {self.dirty[1]} 172 + {'bit': <4} {self.global_translation[0]: <10} {'global translation': <30} {self.global_translation[1]} 173 + {'bit': <4} {self.hlat_restart_with_ordinary[0]: <10} {'restart to ordinary': <30} {self.hlat_restart_with_ordinary[1]} 174 + {'bit': <4} {self.pat[0]: <10} {'pat': <30} {self.pat[1]} 175 + {'bits': <4} {str(self.protection_key[0]): <10} {'protection key': <30} {self.protection_key[1]} 176 + {'bit': <4} {self.executed_disable[0]: <10} {'execute disable': <30} {self.executed_disable[1]} 177 + """ 178 + else: 179 + return f"""\ 180 + level {self.page_hierarchy_level}: 181 + {'entry address': <30} {hex(self.address)} 182 + {'page entry binary data': <30} {hex(self.page_entry_binary_data)} 183 + {'next entry physical address': <30} {hex(self.next_entry_physical_address)} 184 + --- 185 + {'bit': <4} {self.entry_present[0]: <10} {'entry present': <30} {self.entry_present[1]} 186 + {'bit': <4} {self.read_write[0]: <10} {'read/write access allowed': <30} {self.read_write[1]} 187 + {'bit': <4} {self.user_access_allowed[0]: <10} {'user access allowed': <30} {self.user_access_allowed[1]} 188 + {'bit': <4} {self.page_level_write_through[0]: <10} {'page level write through': <30} {self.page_level_write_through[1]} 189 + {'bit': <4} {self.page_level_cache_disabled[0]: <10} {'page level cache disabled': <30} {self.page_level_cache_disabled[1]} 190 + {'bit': <4} {self.entry_was_accessed[0]: <10} {'entry has been accessed': <30} {self.entry_was_accessed[1]} 191 + {'bit': <4} {self.page_size[0]: <10} {'page size': <30} {self.page_size[1]} 192 + {'bit': <4} {self.hlat_restart_with_ordinary[0]: <10} {'restart to ordinary': <30} {self.hlat_restart_with_ordinary[1]} 193 + {'bit': <4} {self.executed_disable[0]: <10} {'execute disable': <30} {self.executed_disable[1]} 194 + """ 195 + 196 + 197 + class TranslateVM(gdb.Command): 198 + """Prints the entire paging structure used to translate a given virtual address. 199 + 200 + Having an address space of the currently executed process translates the virtual address 201 + and prints detailed information of all paging structure levels used for the transaltion. 202 + Currently supported arch: x86""" 203 + 204 + def __init__(self): 205 + super(TranslateVM, self).__init__('translate-vm', gdb.COMMAND_USER) 206 + 207 + def invoke(self, arg, from_tty): 208 + if utils.is_target_arch("x86"): 209 + vm_address = gdb.parse_and_eval(f'{arg}') 210 + cr3_data = gdb.parse_and_eval('$cr3') 211 + cr4 = gdb.parse_and_eval('$cr4') 212 + page_levels = 5 if cr4 & (1 << 12) else 4 213 + page_entry = Cr3(cr3_data, page_levels) 214 + while page_entry: 215 + gdb.write(page_entry.mk_string()) 216 + page_entry = page_entry.next_entry(vm_address) 217 + else: 218 + gdb.GdbError("Virtual address translation is not" 219 + "supported for this arch") 220 + 221 + 222 + TranslateVM()
+326
scripts/gdb/linux/slab.py
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + # 3 + # Copyright (c) 2023 MediaTek Inc. 4 + # 5 + # Authors: 6 + # Kuan-Ying Lee <Kuan-Ying.Lee@mediatek.com> 7 + # 8 + 9 + import gdb 10 + import re 11 + import traceback 12 + from linux import lists, utils, stackdepot, constants, mm 13 + 14 + SLAB_RED_ZONE = constants.LX_SLAB_RED_ZONE 15 + SLAB_POISON = constants.LX_SLAB_POISON 16 + SLAB_KMALLOC = constants.LX_SLAB_KMALLOC 17 + SLAB_HWCACHE_ALIGN = constants.LX_SLAB_HWCACHE_ALIGN 18 + SLAB_CACHE_DMA = constants.LX_SLAB_CACHE_DMA 19 + SLAB_CACHE_DMA32 = constants.LX_SLAB_CACHE_DMA32 20 + SLAB_STORE_USER = constants.LX_SLAB_STORE_USER 21 + SLAB_PANIC = constants.LX_SLAB_PANIC 22 + 23 + OO_SHIFT = 16 24 + OO_MASK = (1 << OO_SHIFT) - 1 25 + 26 + if constants.LX_CONFIG_SLUB_DEBUG: 27 + slab_type = utils.CachedType("struct slab") 28 + slab_ptr_type = slab_type.get_type().pointer() 29 + kmem_cache_type = utils.CachedType("struct kmem_cache") 30 + kmem_cache_ptr_type = kmem_cache_type.get_type().pointer() 31 + freeptr_t = utils.CachedType("freeptr_t") 32 + freeptr_t_ptr = freeptr_t.get_type().pointer() 33 + 34 + track_type = gdb.lookup_type('struct track') 35 + track_alloc = int(gdb.parse_and_eval('TRACK_ALLOC')) 36 + track_free = int(gdb.parse_and_eval('TRACK_FREE')) 37 + 38 + def slab_folio(slab): 39 + return slab.cast(gdb.lookup_type("struct folio").pointer()) 40 + 41 + def slab_address(slab): 42 + p_ops = mm.page_ops().ops 43 + folio = slab_folio(slab) 44 + return p_ops.folio_address(folio) 45 + 46 + def for_each_object(cache, addr, slab_objects): 47 + p = addr 48 + if cache['flags'] & SLAB_RED_ZONE: 49 + p += int(cache['red_left_pad']) 50 + while p < addr + (slab_objects * cache['size']): 51 + yield p 52 + p = p + int(cache['size']) 53 + 54 + def get_info_end(cache): 55 + if (cache['offset'] >= cache['inuse']): 56 + return cache['inuse'] + gdb.lookup_type("void").pointer().sizeof 57 + else: 58 + return cache['inuse'] 59 + 60 + def get_orig_size(cache, obj): 61 + if cache['flags'] & SLAB_STORE_USER and cache['flags'] & SLAB_KMALLOC: 62 + p = mm.page_ops().ops.kasan_reset_tag(obj) 63 + p += get_info_end(cache) 64 + p += gdb.lookup_type('struct track').sizeof * 2 65 + p = p.cast(utils.get_uint_type().pointer()) 66 + return p.dereference() 67 + else: 68 + return cache['object_size'] 69 + 70 + def get_track(cache, object_pointer, alloc): 71 + p = object_pointer + get_info_end(cache) 72 + p += (alloc * track_type.sizeof) 73 + return p 74 + 75 + def oo_objects(x): 76 + return int(x['x']) & OO_MASK 77 + 78 + def oo_order(x): 79 + return int(x['x']) >> OO_SHIFT 80 + 81 + def reciprocal_divide(a, R): 82 + t = (a * int(R['m'])) >> 32 83 + return (t + ((a - t) >> int(R['sh1']))) >> int(R['sh2']) 84 + 85 + def __obj_to_index(cache, addr, obj): 86 + return reciprocal_divide(int(mm.page_ops().ops.kasan_reset_tag(obj)) - addr, cache['reciprocal_size']) 87 + 88 + def swab64(x): 89 + result = (((x & 0x00000000000000ff) << 56) | \ 90 + ((x & 0x000000000000ff00) << 40) | \ 91 + ((x & 0x0000000000ff0000) << 24) | \ 92 + ((x & 0x00000000ff000000) << 8) | \ 93 + ((x & 0x000000ff00000000) >> 8) | \ 94 + ((x & 0x0000ff0000000000) >> 24) | \ 95 + ((x & 0x00ff000000000000) >> 40) | \ 96 + ((x & 0xff00000000000000) >> 56)) 97 + return result 98 + 99 + def freelist_ptr_decode(cache, ptr, ptr_addr): 100 + if constants.LX_CONFIG_SLAB_FREELIST_HARDENED: 101 + return ptr['v'] ^ cache['random'] ^ swab64(int(ptr_addr)) 102 + else: 103 + return ptr['v'] 104 + 105 + def get_freepointer(cache, obj): 106 + obj = mm.page_ops().ops.kasan_reset_tag(obj) 107 + ptr_addr = obj + cache['offset'] 108 + p = ptr_addr.cast(freeptr_t_ptr).dereference() 109 + return freelist_ptr_decode(cache, p, ptr_addr) 110 + 111 + def loc_exist(loc_track, addr, handle, waste): 112 + for loc in loc_track: 113 + if loc['addr'] == addr and loc['handle'] == handle and loc['waste'] == waste: 114 + return loc 115 + return None 116 + 117 + def add_location(loc_track, cache, track, orig_size): 118 + jiffies = gdb.parse_and_eval("jiffies_64") 119 + age = jiffies - track['when'] 120 + handle = 0 121 + waste = cache['object_size'] - int(orig_size) 122 + pid = int(track['pid']) 123 + cpuid = int(track['cpu']) 124 + addr = track['addr'] 125 + if constants.LX_CONFIG_STACKDEPOT: 126 + handle = track['handle'] 127 + 128 + loc = loc_exist(loc_track, addr, handle, waste) 129 + if loc: 130 + loc['count'] += 1 131 + if track['when']: 132 + loc['sum_time'] += age 133 + loc['min_time'] = min(loc['min_time'], age) 134 + loc['max_time'] = max(loc['max_time'], age) 135 + loc['min_pid'] = min(loc['min_pid'], pid) 136 + loc['max_pid'] = max(loc['max_pid'], pid) 137 + loc['cpus'].add(cpuid) 138 + else: 139 + loc_track.append({ 140 + 'count' : 1, 141 + 'addr' : addr, 142 + 'sum_time' : age, 143 + 'min_time' : age, 144 + 'max_time' : age, 145 + 'min_pid' : pid, 146 + 'max_pid' : pid, 147 + 'handle' : handle, 148 + 'waste' : waste, 149 + 'cpus' : {cpuid} 150 + } 151 + ) 152 + 153 + def slabtrace(alloc, cache_name): 154 + 155 + def __fill_map(obj_map, cache, slab): 156 + p = slab['freelist'] 157 + addr = slab_address(slab) 158 + while p != gdb.Value(0): 159 + index = __obj_to_index(cache, addr, p) 160 + obj_map[index] = True # free objects 161 + p = get_freepointer(cache, p) 162 + 163 + # process every slab page on the slab_list (partial and full list) 164 + def process_slab(loc_track, slab_list, alloc, cache): 165 + for slab in lists.list_for_each_entry(slab_list, slab_ptr_type, "slab_list"): 166 + obj_map[:] = [False] * oo_objects(cache['oo']) 167 + __fill_map(obj_map, cache, slab) 168 + addr = slab_address(slab) 169 + for object_pointer in for_each_object(cache, addr, slab['objects']): 170 + if obj_map[__obj_to_index(cache, addr, object_pointer)] == True: 171 + continue 172 + p = get_track(cache, object_pointer, alloc) 173 + track = gdb.Value(p).cast(track_type.pointer()) 174 + if alloc == track_alloc: 175 + size = get_orig_size(cache, object_pointer) 176 + else: 177 + size = cache['object_size'] 178 + add_location(loc_track, cache, track, size) 179 + continue 180 + 181 + slab_caches = gdb.parse_and_eval("slab_caches") 182 + if mm.page_ops().ops.MAX_NUMNODES > 1: 183 + nr_node_ids = int(gdb.parse_and_eval("nr_node_ids")) 184 + else: 185 + nr_node_ids = 1 186 + 187 + target_cache = None 188 + loc_track = [] 189 + 190 + for cache in lists.list_for_each_entry(slab_caches, kmem_cache_ptr_type, 'list'): 191 + if cache['name'].string() == cache_name: 192 + target_cache = cache 193 + break 194 + 195 + obj_map = [False] * oo_objects(target_cache['oo']) 196 + 197 + if target_cache['flags'] & SLAB_STORE_USER: 198 + for i in range(0, nr_node_ids): 199 + cache_node = target_cache['node'][i] 200 + if cache_node['nr_slabs']['counter'] == 0: 201 + continue 202 + process_slab(loc_track, cache_node['partial'], alloc, target_cache) 203 + process_slab(loc_track, cache_node['full'], alloc, target_cache) 204 + else: 205 + raise gdb.GdbError("SLAB_STORE_USER is not set in %s" % target_cache['name'].string()) 206 + 207 + for loc in sorted(loc_track, key=lambda x:x['count'], reverse=True): 208 + if loc['addr']: 209 + addr = loc['addr'].cast(utils.get_ulong_type().pointer()) 210 + gdb.write("%d %s" % (loc['count'], str(addr).split(' ')[-1])) 211 + else: 212 + gdb.write("%d <not-available>" % loc['count']) 213 + 214 + if loc['waste']: 215 + gdb.write(" waste=%d/%d" % (loc['count'] * loc['waste'], loc['waste'])) 216 + 217 + if loc['sum_time'] != loc['min_time']: 218 + gdb.write(" age=%d/%d/%d" % (loc['min_time'], loc['sum_time']/loc['count'], loc['max_time'])) 219 + else: 220 + gdb.write(" age=%d" % loc['min_time']) 221 + 222 + if loc['min_pid'] != loc['max_pid']: 223 + gdb.write(" pid=%d-%d" % (loc['min_pid'], loc['max_pid'])) 224 + else: 225 + gdb.write(" pid=%d" % loc['min_pid']) 226 + 227 + if constants.LX_NR_CPUS > 1: 228 + nr_cpu = gdb.parse_and_eval('__num_online_cpus')['counter'] 229 + if nr_cpu > 1: 230 + gdb.write(" cpus=") 231 + for i in loc['cpus']: 232 + gdb.write("%d," % i) 233 + gdb.write("\n") 234 + if constants.LX_CONFIG_STACKDEPOT: 235 + if loc['handle']: 236 + stackdepot.stack_depot_print(loc['handle']) 237 + gdb.write("\n") 238 + 239 + def help(): 240 + t = """Usage: lx-slabtrace --cache_name [cache_name] [Options] 241 + Options: 242 + --alloc 243 + print information of allocation trace of the allocated objects 244 + --free 245 + print information of freeing trace of the allocated objects 246 + Example: 247 + lx-slabtrace --cache_name kmalloc-1k --alloc 248 + lx-slabtrace --cache_name kmalloc-1k --free\n""" 249 + gdb.write("Unrecognized command\n") 250 + raise gdb.GdbError(t) 251 + 252 + class LxSlabTrace(gdb.Command): 253 + """Show specific cache slabtrace""" 254 + 255 + def __init__(self): 256 + super(LxSlabTrace, self).__init__("lx-slabtrace", gdb.COMMAND_DATA) 257 + 258 + def invoke(self, arg, from_tty): 259 + if not constants.LX_CONFIG_SLUB_DEBUG: 260 + raise gdb.GdbError("CONFIG_SLUB_DEBUG is not enabled") 261 + 262 + argv = gdb.string_to_argv(arg) 263 + alloc = track_alloc # default show alloc_traces 264 + 265 + if len(argv) == 3: 266 + if argv[2] == '--alloc': 267 + alloc = track_alloc 268 + elif argv[2] == '--free': 269 + alloc = track_free 270 + else: 271 + help() 272 + if len(argv) >= 2 and argv[0] == '--cache_name': 273 + slabtrace(alloc, argv[1]) 274 + else: 275 + help() 276 + LxSlabTrace() 277 + 278 + def slabinfo(): 279 + nr_node_ids = None 280 + 281 + if not constants.LX_CONFIG_SLUB_DEBUG: 282 + raise gdb.GdbError("CONFIG_SLUB_DEBUG is not enabled") 283 + 284 + def count_free(slab): 285 + total_free = 0 286 + for slab in lists.list_for_each_entry(slab, slab_ptr_type, 'slab_list'): 287 + total_free += int(slab['objects'] - slab['inuse']) 288 + return total_free 289 + 290 + gdb.write("{:^18} | {:^20} | {:^12} | {:^12} | {:^8} | {:^11} | {:^13}\n".format('Pointer', 'name', 'active_objs', 'num_objs', 'objsize', 'objperslab', 'pagesperslab')) 291 + gdb.write("{:-^18} | {:-^20} | {:-^12} | {:-^12} | {:-^8} | {:-^11} | {:-^13}\n".format('', '', '', '', '', '', '')) 292 + 293 + slab_caches = gdb.parse_and_eval("slab_caches") 294 + if mm.page_ops().ops.MAX_NUMNODES > 1: 295 + nr_node_ids = int(gdb.parse_and_eval("nr_node_ids")) 296 + else: 297 + nr_node_ids = 1 298 + 299 + for cache in lists.list_for_each_entry(slab_caches, kmem_cache_ptr_type, 'list'): 300 + nr_objs = 0 301 + nr_free = 0 302 + nr_slabs = 0 303 + for i in range(0, nr_node_ids): 304 + cache_node = cache['node'][i] 305 + try: 306 + nr_slabs += cache_node['nr_slabs']['counter'] 307 + nr_objs = int(cache_node['total_objects']['counter']) 308 + nr_free = count_free(cache_node['partial']) 309 + except: 310 + raise gdb.GdbError(traceback.format_exc()) 311 + active_objs = nr_objs - nr_free 312 + num_objs = nr_objs 313 + active_slabs = nr_slabs 314 + objects_per_slab = oo_objects(cache['oo']) 315 + cache_order = oo_order(cache['oo']) 316 + gdb.write("{:18s} | {:20.19s} | {:12} | {:12} | {:8} | {:11} | {:13}\n".format(hex(cache), cache['name'].string(), str(active_objs), str(num_objs), str(cache['size']), str(objects_per_slab), str(1 << cache_order))) 317 + 318 + class LxSlabInfo(gdb.Command): 319 + """Show slabinfo""" 320 + 321 + def __init__(self): 322 + super(LxSlabInfo, self).__init__("lx-slabinfo", gdb.COMMAND_DATA) 323 + 324 + def invoke(self, arg, from_tty): 325 + slabinfo() 326 + LxSlabInfo()
+55
scripts/gdb/linux/stackdepot.py
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + # 3 + # Copyright (c) 2023 MediaTek Inc. 4 + # 5 + # Authors: 6 + # Kuan-Ying Lee <Kuan-Ying.Lee@mediatek.com> 7 + # 8 + 9 + import gdb 10 + from linux import utils, constants 11 + 12 + if constants.LX_CONFIG_STACKDEPOT: 13 + stack_record_type = utils.CachedType('struct stack_record') 14 + DEPOT_STACK_ALIGN = 4 15 + 16 + def stack_depot_fetch(handle): 17 + global DEPOT_STACK_ALIGN 18 + global stack_record_type 19 + 20 + stack_depot_disabled = gdb.parse_and_eval('stack_depot_disabled') 21 + 22 + if stack_depot_disabled: 23 + raise gdb.GdbError("stack_depot_disabled\n") 24 + 25 + handle_parts_t = gdb.lookup_type("union handle_parts") 26 + parts = handle.cast(handle_parts_t) 27 + offset = parts['offset'] << DEPOT_STACK_ALIGN 28 + pool_index_cached = gdb.parse_and_eval('pool_index') 29 + 30 + if parts['pool_index'] > pool_index_cached: 31 + gdb.write("pool index %d out of bounds (%d) for stack id 0x%08x\n" % (parts['pool_index'], pool_index_cached, handle)) 32 + return gdb.Value(0), 0 33 + 34 + stack_pools = gdb.parse_and_eval('stack_pools') 35 + 36 + try: 37 + pool = stack_pools[parts['pool_index']] 38 + stack = (pool + gdb.Value(offset).cast(utils.get_size_t_type())).cast(stack_record_type.get_type().pointer()) 39 + size = int(stack['size'].cast(utils.get_ulong_type())) 40 + return stack['entries'], size 41 + except Exception as e: 42 + gdb.write("%s\n" % e) 43 + return gdb.Value(0), 0 44 + 45 + def stack_depot_print(handle): 46 + if not constants.LX_CONFIG_STACKDEPOT: 47 + raise gdb.GdbError("CONFIG_STACKDEPOT is not enabled") 48 + 49 + entries, nr_entries = stack_depot_fetch(handle) 50 + if nr_entries > 0: 51 + for i in range(0, nr_entries): 52 + try: 53 + gdb.execute("x /i 0x%x" % (int(entries[i]))) 54 + except Exception as e: 55 + gdb.write("%s\n" % e)
+31 -9
scripts/gdb/linux/symbols.py
··· 89 89 return name 90 90 return None 91 91 92 - def _section_arguments(self, module): 92 + def _section_arguments(self, module, module_addr): 93 93 try: 94 94 sect_attrs = module['sect_attrs'].dereference() 95 95 except gdb.error: 96 - return "" 96 + return str(module_addr) 97 + 97 98 attrs = sect_attrs['attrs'] 98 99 section_name_to_address = { 99 100 attrs[n]['battr']['attr']['name'].string(): attrs[n]['address'] 100 101 for n in range(int(sect_attrs['nsections']))} 102 + 103 + textaddr = section_name_to_address.get(".text", module_addr) 101 104 args = [] 102 105 for section_name in [".data", ".data..read_mostly", ".rodata", ".bss", 103 - ".text", ".text.hot", ".text.unlikely"]: 106 + ".text.hot", ".text.unlikely"]: 104 107 address = section_name_to_address.get(section_name) 105 108 if address: 106 109 args.append(" -s {name} {addr}".format( 107 110 name=section_name, addr=str(address))) 108 - return "".join(args) 111 + return "{textaddr} {sections}".format( 112 + textaddr=textaddr, sections="".join(args)) 109 113 110 - def load_module_symbols(self, module): 114 + def load_module_symbols(self, module, module_file=None): 111 115 module_name = module['name'].string() 112 116 module_addr = str(module['mem'][constants.LX_MOD_TEXT]['base']).split()[0] 113 117 114 - module_file = self._get_module_file(module_name) 118 + if not module_file: 119 + module_file = self._get_module_file(module_name) 115 120 if not module_file and not self.module_files_updated: 116 121 self._update_module_files() 117 122 module_file = self._get_module_file(module_name) ··· 130 125 module_addr = hex(int(module_addr, 0) + plt_offset + plt_size) 131 126 gdb.write("loading @{addr}: {filename}\n".format( 132 127 addr=module_addr, filename=module_file)) 133 - cmdline = "add-symbol-file {filename} {addr}{sections}".format( 128 + cmdline = "add-symbol-file {filename} {sections}".format( 134 129 filename=module_file, 135 - addr=module_addr, 136 - sections=self._section_arguments(module)) 130 + sections=self._section_arguments(module, module_addr)) 137 131 gdb.execute(cmdline, to_string=True) 138 132 if module_name not in self.loaded_modules: 139 133 self.loaded_modules.append(module_name) 140 134 else: 141 135 gdb.write("no module object found for '{0}'\n".format(module_name)) 136 + 137 + def load_ko_symbols(self, mod_path): 138 + self.loaded_modules = [] 139 + module_list = modules.module_list() 140 + 141 + for module in module_list: 142 + module_name = module['name'].string() 143 + module_pattern = ".*/{0}\.ko(?:.debug)?$".format( 144 + module_name.replace("_", r"[_\-]")) 145 + if re.match(module_pattern, mod_path) and os.path.exists(mod_path): 146 + self.load_module_symbols(module, mod_path) 147 + return 148 + raise gdb.GdbError("%s is not a valid .ko\n" % mod_path) 142 149 143 150 def load_all_symbols(self): 144 151 gdb.write("loading vmlinux\n") ··· 189 172 # enforce update 190 173 self.module_files = [] 191 174 self.module_files_updated = False 175 + 176 + argv = gdb.string_to_argv(arg) 177 + if len(argv) == 1: 178 + self.load_ko_symbols(argv[0]) 179 + return 192 180 193 181 self.load_all_symbols() 194 182
+20
scripts/gdb/linux/utils.py
··· 35 35 36 36 37 37 long_type = CachedType("long") 38 + ulong_type = CachedType("unsigned long") 39 + uint_type = CachedType("unsigned int") 38 40 atomic_long_type = CachedType("atomic_long_t") 41 + size_t_type = CachedType("size_t") 42 + struct_page_type = CachedType("struct page") 43 + 44 + def get_uint_type(): 45 + global uint_type 46 + return uint_type.get_type() 47 + 48 + def get_page_type(): 49 + global struct_page_type 50 + return struct_page_type.get_type() 39 51 40 52 def get_long_type(): 41 53 global long_type 42 54 return long_type.get_type() 55 + 56 + def get_ulong_type(): 57 + global ulong_type 58 + return ulong_type.get_type() 59 + 60 + def get_size_t_type(): 61 + global size_t_type 62 + return size_t_type.get_type() 43 63 44 64 def offset_of(typeobj, field): 45 65 element = gdb.Value(0).cast(typeobj)
+56
scripts/gdb/linux/vmalloc.py
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + # 3 + # Copyright (c) 2023 MediaTek Inc. 4 + # 5 + # Authors: 6 + # Kuan-Ying Lee <Kuan-Ying.Lee@mediatek.com> 7 + # 8 + 9 + import gdb 10 + import re 11 + from linux import lists, utils, stackdepot, constants, mm 12 + 13 + vmap_area_type = utils.CachedType('struct vmap_area') 14 + vmap_area_ptr_type = vmap_area_type.get_type().pointer() 15 + 16 + def is_vmalloc_addr(x): 17 + pg_ops = mm.page_ops().ops 18 + addr = pg_ops.kasan_reset_tag(x) 19 + return addr >= pg_ops.VMALLOC_START and addr < pg_ops.VMALLOC_END 20 + 21 + class LxVmallocInfo(gdb.Command): 22 + """Show vmallocinfo""" 23 + 24 + def __init__(self): 25 + super(LxVmallocInfo, self).__init__("lx-vmallocinfo", gdb.COMMAND_DATA) 26 + 27 + def invoke(self, arg, from_tty): 28 + vmap_area_list = gdb.parse_and_eval('vmap_area_list') 29 + for vmap_area in lists.list_for_each_entry(vmap_area_list, vmap_area_ptr_type, "list"): 30 + if not vmap_area['vm']: 31 + gdb.write("0x%x-0x%x %10d vm_map_ram\n" % (vmap_area['va_start'], vmap_area['va_end'], 32 + vmap_area['va_end'] - vmap_area['va_start'])) 33 + continue 34 + v = vmap_area['vm'] 35 + gdb.write("0x%x-0x%x %10d" % (v['addr'], v['addr'] + v['size'], v['size'])) 36 + if v['caller']: 37 + gdb.write(" %s" % str(v['caller']).split(' ')[-1]) 38 + if v['nr_pages']: 39 + gdb.write(" pages=%d" % v['nr_pages']) 40 + if v['phys_addr']: 41 + gdb.write(" phys=0x%x" % v['phys_addr']) 42 + if v['flags'] & constants.LX_VM_IOREMAP: 43 + gdb.write(" ioremap") 44 + if v['flags'] & constants.LX_VM_ALLOC: 45 + gdb.write(" vmalloc") 46 + if v['flags'] & constants.LX_VM_MAP: 47 + gdb.write(" vmap") 48 + if v['flags'] & constants.LX_VM_USERMAP: 49 + gdb.write(" user") 50 + if v['flags'] & constants.LX_VM_DMA_COHERENT: 51 + gdb.write(" dma-coherent") 52 + if is_vmalloc_addr(v['pages']): 53 + gdb.write(" vpages") 54 + gdb.write("\n") 55 + 56 + LxVmallocInfo()
+6 -1
scripts/gdb/vmlinux-gdb.py
··· 41 41 import linux.genpd 42 42 import linux.device 43 43 import linux.vfs 44 - import linux.mm 44 + import linux.pgtable 45 45 import linux.radixtree 46 46 import linux.interrupts 47 + import linux.mm 48 + import linux.stackdepot 49 + import linux.page_owner 50 + import linux.slab 51 + import linux.vmalloc
-1
scripts/headers_install.sh
··· 76 76 arch/arm/include/uapi/asm/ptrace.h:CONFIG_CPU_ENDIAN_BE8 77 77 arch/hexagon/include/uapi/asm/ptrace.h:CONFIG_HEXAGON_ARCH_VERSION 78 78 arch/hexagon/include/uapi/asm/user.h:CONFIG_HEXAGON_ARCH_VERSION 79 - arch/ia64/include/uapi/asm/cmpxchg.h:CONFIG_IA64_DEBUG_CMPXCHG 80 79 arch/m68k/include/uapi/asm/ptrace.h:CONFIG_COLDFIRE 81 80 arch/nios2/include/uapi/asm/swab.h:CONFIG_NIOS2_CI_SWAB_NO 82 81 arch/nios2/include/uapi/asm/swab.h:CONFIG_NIOS2_CI_SWAB_SUPPORT
+23
tools/testing/selftests/proc/proc-empty-vm.c
··· 1 + #if defined __amd64__ || defined __i386__ 1 2 /* 2 3 * Copyright (c) 2022 Alexey Dobriyan <adobriyan@gmail.com> 3 4 * ··· 37 36 #include <sys/types.h> 38 37 #include <sys/wait.h> 39 38 #include <unistd.h> 39 + 40 + #ifdef __amd64__ 41 + #define TEST_VSYSCALL 42 + #endif 40 43 41 44 /* 42 45 * 0: vsyscall VMA doesn't exist vsyscall=none ··· 124 119 _exit(EXIT_FAILURE); 125 120 } 126 121 122 + #ifdef TEST_VSYSCALL 127 123 static void sigaction_SIGSEGV_vsyscall(int _, siginfo_t *__, void *___) 128 124 { 129 125 _exit(g_vsyscall); ··· 176 170 exit(1); 177 171 } 178 172 } 173 + #endif 179 174 180 175 static int test_proc_pid_maps(pid_t pid) 181 176 { ··· 306 299 { 307 300 int rv = EXIT_SUCCESS; 308 301 302 + #ifdef TEST_VSYSCALL 309 303 vsyscall(); 304 + #endif 310 305 311 306 switch (g_vsyscall) { 312 307 case 0: ··· 355 346 356 347 #ifdef __amd64__ 357 348 munmap(NULL, ((size_t)1 << 47) - 4096); 349 + #elif defined __i386__ 350 + { 351 + size_t len; 352 + 353 + for (len = -4096;; len -= 4096) { 354 + munmap(NULL, len); 355 + } 356 + } 358 357 #else 359 358 #error "implement 'unmap everything'" 360 359 #endif ··· 403 386 404 387 return rv; 405 388 } 389 + #else 390 + int main(void) 391 + { 392 + return 4; 393 + } 394 + #endif
-1
tools/testing/selftests/wireguard/qemu/kernel.config
··· 41 41 CONFIG_BUG=y 42 42 CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE=y 43 43 CONFIG_JUMP_LABEL=y 44 - CONFIG_EMBEDDED=n 45 44 CONFIG_BASE_FULL=y 46 45 CONFIG_FUTEX=y 47 46 CONFIG_SHMEM=y