2022-05-31 18:04:11 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-08-06 15:19:32 +08:00
|
|
|
|
2022-07-20 18:51:24 +08:00
|
|
|
|
2022-08-06 15:19:33 +08:00
|
|
|
|
2023-11-21 13:44:15 +00:00
|
|
|
|
2023-06-29 20:58:43 +08:00
|
|
|
|
2022-05-31 18:04:11 +08:00
|
|
|
|
|
|
|
|
|
kasan: introduce ARCH_DEFER_KASAN and unify static key across modes
Patch series "kasan: unify kasan_enabled() and remove arch-specific
implementations", v6.
This patch series addresses the fragmentation in KASAN initialization
across architectures by introducing a unified approach that eliminates
duplicate static keys and arch-specific kasan_arch_is_ready()
implementations.
The core issue is that different architectures have inconsistent approaches
to KASAN readiness tracking:
- PowerPC, LoongArch, and UML arch, each implement own kasan_arch_is_ready()
- Only HW_TAGS mode had a unified static key (kasan_flag_enabled)
- Generic and SW_TAGS modes relied on arch-specific solutions
or always-on behavior
This patch (of 2):
Introduce CONFIG_ARCH_DEFER_KASAN to identify architectures [1] that need
to defer KASAN initialization until shadow memory is properly set up, and
unify the static key infrastructure across all KASAN modes.
[1] PowerPC, UML, LoongArch selects ARCH_DEFER_KASAN.
The core issue is that different architectures haveinconsistent approaches
to KASAN readiness tracking:
- PowerPC, LoongArch, and UML arch, each implement own
kasan_arch_is_ready()
- Only HW_TAGS mode had a unified static key (kasan_flag_enabled)
- Generic and SW_TAGS modes relied on arch-specific solutions or always-on
behavior
This patch addresses the fragmentation in KASAN initialization across
architectures by introducing a unified approach that eliminates duplicate
static keys and arch-specific kasan_arch_is_ready() implementations.
Let's replace kasan_arch_is_ready() with existing kasan_enabled() check,
which examines the static key being enabled if arch selects
ARCH_DEFER_KASAN or has HW_TAGS mode support. For other arch,
kasan_enabled() checks the enablement during compile time.
Now KASAN users can use a single kasan_enabled() check everywhere.
Link: https://lkml.kernel.org/r/20250810125746.1105476-1-snovitoll@gmail.com
Link: https://lkml.kernel.org/r/20250810125746.1105476-2-snovitoll@gmail.com
Closes: https://bugzilla.kernel.org/show_bug.cgi?id=217049
Signed-off-by: Sabyrzhan Tasbolatov <snovitoll@gmail.com>
Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Reviewed-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com> #powerpc
Cc: Alexander Gordeev <agordeev@linux.ibm.com>
Cc: Alexander Potapenko <glider@google.com>
Cc: Alexandre Ghiti <alex@ghiti.fr>
Cc: Alexandre Ghiti <alexghiti@rivosinc.com>
Cc: Andrey Konovalov <andreyknvl@gmail.com>
Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com>
Cc: Baoquan He <bhe@redhat.com>
Cc: David Gow <davidgow@google.com>
Cc: Dmitriy Vyukov <dvyukov@google.com>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Huacai Chen <chenhuacai@loongson.cn>
Cc: Marco Elver <elver@google.com>
Cc: Qing Zhang <zhangqing@loongson.cn>
Cc: Sabyrzhan Tasbolatov <snovitoll@gmail.com>
Cc: Vincenzo Frascino <vincenzo.frascino@arm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2025-08-10 17:57:45 +05:00
|
|
|
|
2023-09-06 22:54:16 +08:00
|
|
|
|
2022-05-31 18:04:11 +08:00
|
|
|
|
2026-07-06 04:42:08 -07:00
|
|
|
|
2022-05-31 18:04:11 +08:00
|
|
|
|
2023-06-14 01:39:28 +02:00
|
|
|
|
2024-03-19 15:50:27 +08:00
|
|
|
|
2024-07-20 22:40:59 +08:00
|
|
|
|
2024-05-14 12:24:18 +08:00
|
|
|
|
2023-05-01 17:19:52 +08:00
|
|
|
|
2023-09-06 22:53:55 +08:00
|
|
|
|
2026-04-22 15:44:26 +08:00
|
|
|
|
2022-09-28 11:21:54 -07:00
|
|
|
|
2023-07-28 10:30:42 +08:00
|
|
|
|
2024-11-22 15:47:53 +08:00
|
|
|
|
2026-04-22 15:44:26 +08:00
|
|
|
|
2024-09-24 15:32:20 +08:00
|
|
|
|
2024-09-24 15:32:20 +08:00
|
|
|
|
2022-05-31 18:04:11 +08:00
|
|
|
|
2025-03-30 16:31:08 +08:00
|
|
|
|
2025-02-04 13:05:42 +01:00
|
|
|
|
2022-05-31 18:04:11 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-09-02 22:33:42 +08:00
|
|
|
|
2022-05-31 18:04:11 +08:00
|
|
|
|
|
|
|
|
|
2022-08-06 16:10:04 +08:00
|
|
|
|
2022-05-31 18:04:11 +08:00
|
|
|
|
|
|
|
|
|
2026-04-22 15:44:26 +08:00
|
|
|
|
2024-05-14 12:24:18 +08:00
|
|
|
|
2023-06-29 20:58:43 +08:00
|
|
|
|
|
|
|
|
|
2025-05-30 21:45:42 +08:00
|
|
|
|
mm: decouple protnone helpers from CONFIG_NUMA_BALANCING
Patch series "userfaultfd: working set tracking for VM guest memory", v10.
This series adds userfaultfd support for tracking the working set of VM
guest memory, so a VMM can identify hot pages and reclaim cold ones to
tiered or remote storage.
This patch (of 15):
pte_protnone() and pmd_protnone() detect present-but-inaccessible page
table entries. This capability is useful beyond NUMA balancing -- for
example, userfaultfd working set tracking uses protnone PTEs to track page
access without unmapping pages.
Introduce CONFIG_ARCH_HAS_PTE_PROTNONE to decouple the protnone PTE
infrastructure from CONFIG_NUMA_BALANCING. The six architectures that
support protnone PTEs (x86_64, arm64, powerpc, s390, riscv, loongarch) now
select this option, and CONFIG_NUMA_BALANCING depends on it.
No functional change -- the same set of architectures continues to have
working protnone support, but the infrastructure is now available
independently of NUMA balancing.
Link: https://lore.kernel.org/20260708111417.173443-1-kirill@shutemov.name
Link: https://lore.kernel.org/20260708111417.173443-2-kirill@shutemov.name
Signed-off-by: Kiryl Shutsemau (Meta) <kas@kernel.org>
Assisted-by: Claude:claude-opus-4-6
Acked-by: SeongJae Park <sj@kernel.org>
Acked-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: David Hildenbrand <david@kernel.org>
Cc: James Houghton <jthoughton@google.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Liam Howlett <liam@infradead.org>
Cc: Lorenzo Stoakes <ljs@kernel.org>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Peter Xu <peterx@redhat.com>
Cc: Sean Christopherson <seanjc@google.com>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Vlastimil Babka <vbabka@kernel.org>
Cc: Zi Yan <ziy@nvidia.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2026-07-08 12:14:02 +01:00
|
|
|
|
2026-04-22 15:44:26 +08:00
|
|
|
|
2025-10-02 22:39:19 +08:00
|
|
|
|
2024-11-22 15:47:53 +08:00
|
|
|
|
2025-08-26 11:08:57 +02:00
|
|
|
|
|
|
|
|
|
2022-05-31 18:04:11 +08:00
|
|
|
|
|
|
|
|
|
2025-04-24 20:15:22 +08:00
|
|
|
|
2022-05-31 18:04:11 +08:00
|
|
|
|
2022-10-12 16:36:14 +08:00
|
|
|
|
2026-04-22 15:44:26 +08:00
|
|
|
|
2022-05-31 18:04:11 +08:00
|
|
|
|
2022-08-24 17:31:10 +02:00
|
|
|
|
2026-04-22 15:44:26 +08:00
|
|
|
|
2022-05-31 18:04:11 +08:00
|
|
|
|
2024-05-14 12:24:18 +08:00
|
|
|
|
2022-05-31 18:04:11 +08:00
|
|
|
|
|
|
|
|
|
2022-12-10 22:40:15 +08:00
|
|
|
|
2024-12-19 20:48:46 +08:00
|
|
|
|
2022-08-06 15:19:32 +08:00
|
|
|
|
2026-04-22 15:44:26 +08:00
|
|
|
|
2022-05-31 18:04:11 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-11-21 13:45:17 +00:00
|
|
|
|
2024-09-24 15:31:51 +08:00
|
|
|
|
2022-05-31 18:04:11 +08:00
|
|
|
|
2026-04-22 15:44:26 +08:00
|
|
|
|
2022-10-12 16:36:14 +08:00
|
|
|
|
2024-08-23 18:43:37 +08:00
|
|
|
|
2022-05-31 18:04:11 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-10-12 16:36:14 +08:00
|
|
|
|
2022-05-31 18:04:11 +08:00
|
|
|
|
|
|
|
|
|
2022-05-31 18:04:12 +08:00
|
|
|
|
2022-05-31 18:04:11 +08:00
|
|
|
|
2023-03-23 17:33:52 +01:00
|
|
|
|
2026-04-22 15:44:26 +08:00
|
|
|
|
2022-05-31 18:04:11 +08:00
|
|
|
|
2026-05-06 13:52:02 -04:00
|
|
|
|
2023-06-29 20:58:44 +08:00
|
|
|
|
|
|
|
|
|
2026-04-22 15:44:26 +08:00
|
|
|
|
|
|
|
|
|
2023-09-06 22:53:55 +08:00
|
|
|
|
2025-07-17 16:25:06 -07:00
|
|
|
|
2022-05-31 18:04:11 +08:00
|
|
|
|
2024-07-20 22:40:58 +08:00
|
|
|
|
2024-02-06 12:32:05 +08:00
|
|
|
|
2022-05-31 18:04:11 +08:00
|
|
|
|
|
|
|
|
|
2026-04-22 15:44:26 +08:00
|
|
|
|
|
|
|
|
|
2022-05-31 18:04:11 +08:00
|
|
|
|
2026-02-10 19:31:12 +08:00
|
|
|
|
2026-02-10 19:31:06 +08:00
|
|
|
|
2022-06-08 16:40:24 +02:00
|
|
|
|
2022-12-10 22:40:15 +08:00
|
|
|
|
2023-06-29 20:58:44 +08:00
|
|
|
|
2022-05-31 18:04:11 +08:00
|
|
|
|
|
|
|
|
|
2022-12-10 22:40:15 +08:00
|
|
|
|
2022-12-10 22:40:16 +08:00
|
|
|
|
2024-12-26 14:12:31 +09:00
|
|
|
|
2023-05-01 17:19:53 +08:00
|
|
|
|
2022-12-10 22:40:15 +08:00
|
|
|
|
2026-04-22 15:44:26 +08:00
|
|
|
|
2023-02-25 15:52:56 +08:00
|
|
|
|
2022-05-31 18:04:11 +08:00
|
|
|
|
2025-09-08 23:32:36 +02:00
|
|
|
|
2024-04-02 14:55:15 +02:00
|
|
|
|
2024-12-26 14:13:34 +09:00
|
|
|
|
2023-02-25 15:52:57 +08:00
|
|
|
|
2023-05-01 17:19:52 +08:00
|
|
|
|
2024-12-26 14:11:55 +09:00
|
|
|
|
2022-12-10 22:40:15 +08:00
|
|
|
|
|
|
|
|
|
2023-09-06 22:53:55 +08:00
|
|
|
|
2022-05-31 18:04:11 +08:00
|
|
|
|
2023-02-25 15:52:57 +08:00
|
|
|
|
2022-05-31 18:04:11 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-02-25 15:52:57 +08:00
|
|
|
|
2023-02-25 15:52:57 +08:00
|
|
|
|
2023-02-25 15:52:57 +08:00
|
|
|
|
2024-03-11 22:23:47 +08:00
|
|
|
|
2022-05-31 18:04:11 +08:00
|
|
|
|
|
|
|
|
|
2026-04-22 15:44:26 +08:00
|
|
|
|
2022-08-06 15:19:33 +08:00
|
|
|
|
2026-04-22 15:44:26 +08:00
|
|
|
|
2022-10-12 16:36:14 +08:00
|
|
|
|
|
|
|
|
|
2024-11-22 15:47:53 +08:00
|
|
|
|
2023-11-08 14:12:01 +08:00
|
|
|
|
2022-05-31 18:04:11 +08:00
|
|
|
|
2024-03-11 22:23:47 +08:00
|
|
|
|
2023-06-29 20:58:44 +08:00
|
|
|
|
2022-05-31 18:04:11 +08:00
|
|
|
|
2024-01-17 12:43:00 +08:00
|
|
|
|
2023-05-01 17:19:53 +08:00
|
|
|
|
|
|
|
|
|
2022-05-31 18:04:12 +08:00
|
|
|
|
2024-03-11 22:23:47 +08:00
|
|
|
|
2022-12-10 22:40:15 +08:00
|
|
|
|
2022-05-31 18:04:11 +08:00
|
|
|
|
|
|
|
|
|
2025-03-30 16:30:20 +08:00
|
|
|
|
2026-02-10 19:31:13 +08:00
|
|
|
|
2022-05-31 18:04:11 +08:00
|
|
|
|
|
|
|
|
|
mm/fault: convert remaining simple cases to lock_mm_and_find_vma()
This does the simple pattern conversion of alpha, arc, csky, hexagon,
loongarch, nios2, sh, sparc32, and xtensa to the lock_mm_and_find_vma()
helper. They all have the regular fault handling pattern without odd
special cases.
The remaining architectures all have something that keeps us from a
straightforward conversion: ia64 and parisc have stacks that can grow
both up as well as down (and ia64 has special address region checks).
And m68k, microblaze, openrisc, sparc64, and um end up having extra
rules about only expanding the stack down a limited amount below the
user space stack pointer. That is something that x86 used to do too
(long long ago), and it probably could just be skipped, but it still
makes the conversion less than trivial.
Note that this conversion was done manually and with the exception of
alpha without any build testing, because I have a fairly limited cross-
building environment. The cases are all simple, and I went through the
changes several times, but...
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2023-06-24 10:55:38 -07:00
|
|
|
|
2022-08-06 15:19:32 +08:00
|
|
|
|
2026-01-27 20:12:56 +08:00
|
|
|
|
2022-05-31 18:04:11 +08:00
|
|
|
|
2022-05-31 18:04:12 +08:00
|
|
|
|
|
|
|
|
|
2025-05-30 21:45:43 +08:00
|
|
|
|
2022-12-10 22:40:05 +08:00
|
|
|
|
|
|
|
|
|
2022-08-06 15:19:33 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-08-25 19:34:59 +08:00
|
|
|
|
2022-05-31 18:04:11 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-12-10 22:39:59 +08:00
|
|
|
|
|
|
|
|
|
2022-05-31 18:04:11 +08:00
|
|
|
|
2026-04-22 15:44:26 +08:00
|
|
|
|
LoongArch: Add THREAD_INFO_IN_TASK implementation
Like other architectures such as x86, arm64, riscv, powerpc and s390,
select THREAD_INFO_IN_TASK for LoongArch to move thread_info off the
stack into task_struct. This follows modern kernel standards and also
makes the system more secure.
With this patch, thread_info is included in task_struct at an offset
of 0 instead of being placed at the bottom of the kernel stack. Thus,
the $tp register points to both thread_info and task_struct.
To support this, introduce a per-CPU variable cpu_tasks to store the
pointer to the current task_struct. This decouples the recovery of the
$tp register from the stack pointer during exception entry.
Then initialize cpu_tasks for the primary and secondary CPUs during
arch-specific setup and SMP boot paths. To eliminate the dangerous
windows during the early initialization where the cpu_tasks remains
uninitialized, set_current() is invoked as early as possible in both
setup_arch() and start_secondary(). This ensures the $tp recovery
barrier is armed in case any early boot exceptions or kernel panics
occur.
Modify SAVE_SOME and handle_syscall to restore the $tp register from
cpu_tasks, and also use the la_abs absolute addressing for cpu_tasks
access in assembly to bypass the relocation limits within exception
handling sections. By advancing the preservation of u0 in SAVE_SOME,
we reuse the PERCPU_BASE_KS value in u0 for the cpu_tasks calculation,
effectively eliminating a duplicate csrrd instruction execution on SMP
platforms.
Update <asm/switch_to.h> and <kernel/switch.S> to fully support the
CONFIG_THREAD_INFO_IN_TASK feature.
Remove the obsolete next_ti argument from __switch_to(), which shifts
the remaining arguments ahead in the calling convention (sched_ra from
a3 to a2, and sched_cfa from a4 to a3). Under the new configuration,
__switch_to() now directly derives the thread pointer ($tp) from the
next task_struct pointer in a1.
To preserve the optimal and clean "move tp, a1" path for 64-bit kernels,
the thread pointer ($tp) is assigned directly from a1 in the core path.
For 32-bit kernels, where a1 carries a 2000-byte structural pointer bias
at entry, an explicit adjustment "PTR_ADDI tp, tp, -TASK_STRUCT_OFFSET"
is introduced at the function exit.
In the context of __switch_to(), local interrupts are disabled, and the
kernel is in a critical switching phase where handling any synchronous
exception is practically impossible and prohibited.
If any synchronous exception or watchpoint does trigger in this narrow
window, it constitutes a fatal double fault and the kernel is expected
to die/panic immediately anyway. Therefore, the temporary biased value
in $tp is safe and acceptable here.
Additionally, evaluate the stack lookup as a single load instruction
"LONG_LPTR t0, a1, (TASK_STACK - TASK_STRUCT_OFFSET)", this perfectly
satisfies both 32-bit and 64-bit kernels. Using the "next" pointer in
a1 as the base register, rather than $tp, effectively unchains the data
dependency (RAW hazard) from the preceding move instruction, maximizing
the instruction-level parallelism and superscalar execution efficiency
while naturally adapting the structural shift.
With CONFIG_THREAD_INFO_IN_TASK enabled, the kernel stack life cycle is
decoupled from task_struct and can be freed concurrently.
Currently, show_stacktrace() reads raw stack data via __get_addr() and
subsequently calls show_backtrace() to unwind the frame, without holding
any reference to the target task's stack. If show_stacktrace() is called
on a concurrently exiting task, it could attempt to read from a freed or
reallocated kernel stack. This introduces a severe use-after-free (UAF)
read risk or kernel panics.
Wrap the entire stack inspection process inside show_stacktrace() with
a try_get_task_stack() and put_task_stack() pair. This ensures the task
stack remains pinned safely during both the raw stack data dump loop and
the subsequent stack unwinding phase.
Also, ensure that the task pointer is initialized to "current" early if
it is NULL, so that try_get_task_stack() always operates on a valid task
reference.
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
2026-06-25 13:03:47 +08:00
|
|
|
|
2022-05-31 18:04:11 +08:00
|
|
|
|
2022-05-31 18:04:12 +08:00
|
|
|
|
2022-08-06 16:10:05 +08:00
|
|
|
|
2024-09-01 14:13:11 +08:00
|
|
|
|
2026-04-22 15:44:26 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-05-04 09:00:00 +08:00
|
|
|
|
2022-05-31 18:04:11 +08:00
|
|
|
|
|
|
|
|
|
2026-04-22 15:44:26 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-05-31 18:04:11 +08:00
|
|
|
|
|
|
|
|
|
2026-04-22 15:44:26 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-05-31 18:04:11 +08:00
|
|
|
|
2022-10-12 16:36:19 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-05-31 18:04:11 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-08-06 16:10:04 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-05-31 18:04:11 +08:00
|
|
|
|
|
|
|
|
|
2022-10-12 16:36:08 +08:00
|
|
|
|
2022-05-31 18:04:11 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-10-12 16:36:14 +08:00
|
|
|
|
2025-01-25 18:51:33 +08:00
|
|
|
|
2022-10-12 16:36:14 +08:00
|
|
|
|
2022-05-31 18:04:11 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-10-12 16:36:08 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-06-29 20:58:43 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LoongArch: Only allow OBJTOOL & ORC unwinder if toolchain supports -mthin-add-sub
GAS <= 2.41 does not support generating R_LARCH_{32,64}_PCREL for
"label - ." and it generates R_LARCH_{ADD,SUB}{32,64} pairs instead.
Objtool cannot handle R_LARCH_{ADD,SUB}{32,64} pair in __jump_table
(static key implementation) and etc. so it will produce some warnings.
This is causing the kernel CI systems to complain everywhere.
For GAS we can check if -mthin-add-sub option is available to know if
R_LARCH_{32,64}_PCREL are supported.
For Clang, we require Clang >= 18 and Clang >= 17 already supports
R_LARCH_{32,64}_PCREL. But unfortunately Clang has some other issues,
so we disable objtool for Clang at present.
Note that __jump_table here is not generated by the compiler, so
-fno-jump-table is completely irrelevant for this issue.
Fixes: cb8a2ef0848c ("LoongArch: Add ORC stack unwinder support")
Closes: https://lore.kernel.org/loongarch/Zl5m1ZlVmGKitAof@yujie-X299/
Closes: https://lore.kernel.org/loongarch/ZlY1gDDPi_mNrwJ1@slm.duckdns.org/
Closes: https://lore.kernel.org/loongarch/1717478006.038663-1-hengqi@linux.alibaba.com/
Link: https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=816029e06768
Link: https://github.com/llvm/llvm-project/commit/42cb3c6346fc
Signed-off-by: Xi Ruoyao <xry111@xry111.site>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
2024-06-21 10:18:40 +08:00
|
|
|
|
LoongArch: Set AS_HAS_THIN_ADD_SUB as y if AS_IS_LLVM
When building kernel with "make CC=clang defconfig", LLVM Assembler is
used due to LLVM_IAS=0 is not specified, then AS_HAS_THIN_ADD_SUB is not
set, thus objtool can not be built after enable it for Clang.
config AS_HAS_THIN_ADD_SUB is to check whether -mthin-add-sub option is
available to know R_LARCH_{32,64}_PCREL are supported for GNU Assembler,
there is no such an option for LLVM Assembler. The minimal version of
Clang is 18 for building LoongArch kernel, and Clang >= 17 has already
supported R_LARCH_{32,64}_PCREL, that is to say, there is no need to
depend on AS_HAS_THIN_ADD_SUB for Clang, so just set AS_HAS_THIN_ADD_SUB
as y if AS_IS_LLVM.
Fixes: 120dd4118e58 ("LoongArch: Only allow OBJTOOL & ORC unwinder if toolchain supports -mthin-add-sub")
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
2024-09-17 22:23:09 +08:00
|
|
|
|
LoongArch: Only allow OBJTOOL & ORC unwinder if toolchain supports -mthin-add-sub
GAS <= 2.41 does not support generating R_LARCH_{32,64}_PCREL for
"label - ." and it generates R_LARCH_{ADD,SUB}{32,64} pairs instead.
Objtool cannot handle R_LARCH_{ADD,SUB}{32,64} pair in __jump_table
(static key implementation) and etc. so it will produce some warnings.
This is causing the kernel CI systems to complain everywhere.
For GAS we can check if -mthin-add-sub option is available to know if
R_LARCH_{32,64}_PCREL are supported.
For Clang, we require Clang >= 18 and Clang >= 17 already supports
R_LARCH_{32,64}_PCREL. But unfortunately Clang has some other issues,
so we disable objtool for Clang at present.
Note that __jump_table here is not generated by the compiler, so
-fno-jump-table is completely irrelevant for this issue.
Fixes: cb8a2ef0848c ("LoongArch: Add ORC stack unwinder support")
Closes: https://lore.kernel.org/loongarch/Zl5m1ZlVmGKitAof@yujie-X299/
Closes: https://lore.kernel.org/loongarch/ZlY1gDDPi_mNrwJ1@slm.duckdns.org/
Closes: https://lore.kernel.org/loongarch/1717478006.038663-1-hengqi@linux.alibaba.com/
Link: https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=816029e06768
Link: https://github.com/llvm/llvm-project/commit/42cb3c6346fc
Signed-off-by: Xi Ruoyao <xry111@xry111.site>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
2024-06-21 10:18:40 +08:00
|
|
|
|
2023-06-29 20:58:43 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-09-06 22:53:55 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-10-02 10:01:29 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-03-16 10:36:00 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-12-17 09:09:03 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-09-18 19:43:42 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-05-31 18:04:11 +08:00
|
|
|
|
|
|
|
|
|
2026-04-22 15:44:54 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-05-31 18:04:11 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-04-22 15:44:26 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-05-31 18:04:11 +08:00
|
|
|
|
|
|
|
|
|
2026-04-22 15:44:26 +08:00
|
|
|
|
2024-02-23 23:18:37 +01:00
|
|
|
|
2022-05-31 18:04:11 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-04-22 15:44:26 +08:00
|
|
|
|
2024-02-23 23:18:37 +01:00
|
|
|
|
2022-05-31 18:04:11 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-02-23 23:18:37 +01:00
|
|
|
|
2022-05-31 18:04:11 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-04-22 15:44:26 +08:00
|
|
|
|
2024-02-23 23:18:37 +01:00
|
|
|
|
2022-05-31 18:04:11 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-02-23 23:18:37 +01:00
|
|
|
|
2022-05-31 18:04:11 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-04-22 15:44:26 +08:00
|
|
|
|
2024-02-23 23:18:37 +01:00
|
|
|
|
2022-05-31 18:04:11 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-03-30 16:31:09 +08:00
|
|
|
|
|
|
|
|
|
2022-05-31 18:04:11 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-01-17 12:43:00 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-01-25 18:51:33 +08:00
|
|
|
|
2024-01-17 12:43:00 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-05-31 18:04:11 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
efi/loongarch: Add efistub booting support
This patch adds efistub booting support, which is the standard UEFI boot
protocol for LoongArch to use.
We use generic efistub, which means we can pass boot information (i.e.,
system table, memory map, kernel command line, initrd) via a light FDT
and drop a lot of non-standard code.
We use a flat mapping to map the efi runtime in the kernel's address
space. In efi, VA = PA; in kernel, VA = PA + PAGE_OFFSET. As a result,
flat mapping is not identity mapping, SetVirtualAddressMap() is still
needed for the efi runtime.
Tested-by: Xi Ruoyao <xry111@xry111.site>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
[ardb: change fpic to fpie as suggested by Xi Ruoyao]
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
2022-08-19 18:20:37 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-05-31 18:04:12 +08:00
|
|
|
|
|
|
|
|
|
2026-04-22 15:44:26 +08:00
|
|
|
|
2022-05-31 18:04:12 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-05-30 21:45:43 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-05-31 18:04:12 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-05-31 18:04:12 +08:00
|
|
|
|
|
|
|
|
|
LoongArch: Fix the !CONFIG_SMP build
1, We assume arch/loongarch/include/asm/smp.h be included in include/
linux/smp.h is valid and the reverse inclusion isn't. So remove the
<linux/smp.h> in arch/loongarch/include/asm/smp.h.
2, arch/loongarch/include/asm/smp.h is only needed when CONFIG_SMP,
and setup.c include it only because it need plat_smp_setup(). So,
reorganize setup.c & smp.h, and then remove <asm/smp.h> in setup.c.
3, Fix cacheinfo.c and percpu.h build error by adding the missing header
files when !CONFIG_SMP.
4, Fix acpi.c build error by adding CONFIG_SMP guards.
5, Move irq_stat definition from smp.c to irq.c and fix its declaration.
6, Select CONFIG_SMP for CONFIG_NUMA, similar as other architectures do.
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
2022-06-05 16:19:53 +08:00
|
|
|
|
2026-04-22 15:44:26 +08:00
|
|
|
|
2022-05-31 18:04:12 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-08-15 10:39:59 -04:00
|
|
|
|
2022-05-31 18:04:11 +08:00
|
|
|
|
2023-03-15 14:31:33 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-05-31 18:04:11 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-10-12 16:36:14 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-04-18 19:38:58 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-02-25 15:52:56 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-09-18 19:43:42 +08:00
|
|
|
|
|
|
|
|
|
2023-02-25 15:52:56 +08:00
|
|
|
|
|
|
|
|
|
2025-09-18 19:43:42 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-02-25 15:52:56 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-12-06 10:40:32 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-06-29 20:58:43 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-04-22 15:44:26 +08:00
|
|
|
|
2023-06-29 20:58:43 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-04-22 15:44:26 +08:00
|
|
|
|
2023-06-29 20:58:43 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-09-06 22:53:55 +08:00
|
|
|
|
|
|
|
|
|
2026-04-22 15:44:26 +08:00
|
|
|
|
2023-09-06 22:53:55 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-06-29 20:58:43 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-07-12 12:15:37 -04:00
|
|
|
|
|
|
|
|
|
2022-10-12 16:36:19 +08:00
|
|
|
|
2025-10-02 22:39:07 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LoongArch: Add ELF binary support for kexec_file
This patch creates kexec_elf_ops to load ELF binary file for
kexec_file_load() syscall.
However, for `kbuf->memsz` and `kbuf->buf_min`, special handling is
required, and the generic `kexec_elf_load()` cannot be used directly.
$ readelf -l vmlinux
...
Type Offset VirtAddr PhysAddr
FileSiz MemSiz Flags Align
LOAD 0x0000000000010000 0x9000000000200000 0x9000000000200000
0x0000000002747a00 0x000000000287a0d8 RWE 0x10000
NOTE 0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000000000 0x0000000000000000 R 0x8
phdr->p_paddr should have been a physical address, but it is a virtual
address on the current LoongArch. This will cause kexec_file to fail
when loading the kernel and need to be converted to a physical address.
From the above MemSiz, it can be seen that 0x287a0d8 isn't page aligned.
Although kexec_add_buffer() will perform PAGE_SIZE alignment on kbuf->
memsz, there is still a stampeding in the loaded kernel space and initrd
space. The initrd resolution failed when starting the second kernel.
It can be known from the link script vmlinux.lds.S that,
BSS_SECTION(0, SZ_64K, 8)
. = ALIGN(PECOFF_SEGMENT_ALIGN);
It needs to be aligned according to SZ_64K, so that after alignment, its
size is consistent with _kernel_asize.
The basic usage (vmlinux):
1) Load second kernel image:
# kexec -s -l vmlinux --initrd=initrd.img --reuse-cmdline
2) Startup second kernel:
# kexec -e
Signed-off-by: Youling Tang <tangyouling@kylinos.cn>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
2025-10-02 22:39:08 +08:00
|
|
|
|
2025-10-02 22:39:07 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-07-12 12:15:37 -04:00
|
|
|
|
2026-04-22 15:44:26 +08:00
|
|
|
|
2024-09-17 12:37:20 -04:00
|
|
|
|
|
|
|
|
|
2026-04-22 15:44:26 +08:00
|
|
|
|
2022-10-12 16:36:19 +08:00
|
|
|
|
2023-07-12 12:15:37 -04:00
|
|
|
|
2026-04-22 15:44:26 +08:00
|
|
|
|
2023-07-12 12:15:37 -04:00
|
|
|
|
2023-02-25 15:52:56 +08:00
|
|
|
|
LoongArch: Add kdump support
This patch adds support for kdump. In kdump case the normal kernel will
reserve a region for the crash kernel and jump there on panic.
Arch-specific functions are added to allow for implementing a crash dump
file interface, /proc/vmcore, which can be viewed as a ELF file.
A user-space tool, such as kexec-tools, is responsible for allocating a
separate region for the core's ELF header within the crash kdump kernel
memory and filling it in when executing kexec_load().
Then, its location will be advertised to the crash dump kernel via a
command line argument "elfcorehdr=", and the crash dump kernel will
preserve this region for later use with arch_reserve_vmcore() at boot
time.
At the same time, the crash kdump kernel is also limited within the
"crashkernel" area via a command line argument "mem=", so as not to
destroy the original kernel dump data.
In the crash dump kernel environment, /proc/vmcore is used to access the
primary kernel's memory with copy_oldmem_page().
I tested kdump on LoongArch machines (Loongson-3A5000) and it works as
expected (suggested crashkernel parameter is "crashkernel=512M@2560M"),
you may test it by triggering a crash through /proc/sysrq-trigger:
$ sudo kexec -p /boot/vmlinux-kdump --reuse-cmdline --append="nr_cpus=1"
# echo c > /proc/sysrq-trigger
Signed-off-by: Youling Tang <tangyouling@loongson.cn>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
2022-10-12 16:36:19 +08:00
|
|
|
|
LoongArch: Use generic interface to support crashkernel=X,[high,low]
LoongArch already supports two crashkernel regions in kexec-tools, so we
can directly use the common interface to support crashkernel=X,[high,low]
after commit 0ab97169aa0517079b ("crash_core: add generic function to do
reservation").
With the help of newly changed function parse_crashkernel() and generic
reserve_crashkernel_generic(), crashkernel reservation can be simplified
by steps:
1) Add a new header file <asm/crash_core.h>, then define CRASH_ALIGN,
CRASH_ADDR_LOW_MAX and CRASH_ADDR_HIGH_MAX and in <asm/crash_core.h>;
2) Add arch_reserve_crashkernel() to call parse_crashkernel() and
reserve_crashkernel_generic();
3) Add ARCH_HAS_GENERIC_CRASHKERNEL_RESERVATION Kconfig in
arch/loongarch/Kconfig.
One can reserve the crash kernel from high memory above DMA zone range
by explicitly passing "crashkernel=X,high"; or reserve a memory range
below 4G with "crashkernel=X,low". Besides, there are few rules need to
take notice:
1) "crashkernel=X,[high,low]" will be ignored if "crashkernel=size" is
specified.
2) "crashkernel=X,low" is valid only when "crashkernel=X,high" is passed
and there is enough memory to be allocated under 4G.
3) When allocating crashkernel above 4G and no "crashkernel=X,low" is
specified, a 128M low memory will be allocated automatically for
swiotlb bounce buffer.
See Documentation/admin-guide/kernel-parameters.txt for more information.
Following test cases have been performed as expected:
1) crashkernel=256M //low=256M
2) crashkernel=1G //low=1G
3) crashkernel=4G //high=4G, low=128M(default)
4) crashkernel=4G crashkernel=256M,high //high=4G, low=128M(default), high is ignored
5) crashkernel=4G crashkernel=256M,low //high=4G, low=128M(default), low is ignored
6) crashkernel=4G,high //high=4G, low=128M(default)
7) crashkernel=256M,low //low=0M, invalid
8) crashkernel=4G,high crashkernel=256M,low //high=4G, low=256M
9) crashkernel=4G,high crashkernel=4G,low //high=0M, low=0M, invalid
10) crashkernel=512M@2560M //low=512M
11) crashkernel=1G,high crashkernel=0M,low //high=1G, low=0M
Recommended usage in general:
1) In the case of small memory: crashkernel=512M
2) In the case of large memory: crashkernel=1024M,high crashkernel=128M,low
Signed-off-by: Youling Tang <tangyouling@kylinos.cn>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
2024-01-17 12:43:08 +08:00
|
|
|
|
2024-04-24 12:36:07 +08:00
|
|
|
|
LoongArch: Use generic interface to support crashkernel=X,[high,low]
LoongArch already supports two crashkernel regions in kexec-tools, so we
can directly use the common interface to support crashkernel=X,[high,low]
after commit 0ab97169aa0517079b ("crash_core: add generic function to do
reservation").
With the help of newly changed function parse_crashkernel() and generic
reserve_crashkernel_generic(), crashkernel reservation can be simplified
by steps:
1) Add a new header file <asm/crash_core.h>, then define CRASH_ALIGN,
CRASH_ADDR_LOW_MAX and CRASH_ADDR_HIGH_MAX and in <asm/crash_core.h>;
2) Add arch_reserve_crashkernel() to call parse_crashkernel() and
reserve_crashkernel_generic();
3) Add ARCH_HAS_GENERIC_CRASHKERNEL_RESERVATION Kconfig in
arch/loongarch/Kconfig.
One can reserve the crash kernel from high memory above DMA zone range
by explicitly passing "crashkernel=X,high"; or reserve a memory range
below 4G with "crashkernel=X,low". Besides, there are few rules need to
take notice:
1) "crashkernel=X,[high,low]" will be ignored if "crashkernel=size" is
specified.
2) "crashkernel=X,low" is valid only when "crashkernel=X,high" is passed
and there is enough memory to be allocated under 4G.
3) When allocating crashkernel above 4G and no "crashkernel=X,low" is
specified, a 128M low memory will be allocated automatically for
swiotlb bounce buffer.
See Documentation/admin-guide/kernel-parameters.txt for more information.
Following test cases have been performed as expected:
1) crashkernel=256M //low=256M
2) crashkernel=1G //low=1G
3) crashkernel=4G //high=4G, low=128M(default)
4) crashkernel=4G crashkernel=256M,high //high=4G, low=128M(default), high is ignored
5) crashkernel=4G crashkernel=256M,low //high=4G, low=128M(default), low is ignored
6) crashkernel=4G,high //high=4G, low=128M(default)
7) crashkernel=256M,low //low=0M, invalid
8) crashkernel=4G,high crashkernel=256M,low //high=4G, low=256M
9) crashkernel=4G,high crashkernel=4G,low //high=0M, low=0M, invalid
10) crashkernel=512M@2560M //low=512M
11) crashkernel=1G,high crashkernel=0M,low //high=1G, low=0M
Recommended usage in general:
1) In the case of small memory: crashkernel=512M
2) In the case of large memory: crashkernel=1024M,high crashkernel=128M,low
Signed-off-by: Youling Tang <tangyouling@kylinos.cn>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
2024-01-17 12:43:08 +08:00
|
|
|
|
2023-02-25 15:52:56 +08:00
|
|
|
|
|
|
|
|
|
2026-04-22 15:44:26 +08:00
|
|
|
|
2024-07-20 22:41:07 +08:00
|
|
|
|
2023-02-25 15:52:56 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-02-25 15:52:56 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-03-11 22:23:47 +08:00
|
|
|
|
|
|
|
|
|
2024-05-06 22:00:47 +08:00
|
|
|
|
|
|
|
|
|
2026-04-22 15:44:26 +08:00
|
|
|
|
2026-01-05 12:05:08 +01:00
|
|
|
|
2024-05-06 22:00:47 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-07-09 16:25:51 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-05-31 18:04:11 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-05-31 18:04:12 +08:00
|
|
|
|
2022-05-31 18:04:11 +08:00
|
|
|
|
|
|
|
|
|
2026-04-22 15:44:26 +08:00
|
|
|
|
2022-10-27 20:52:51 +08:00
|
|
|
|
2022-05-31 18:04:11 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-06-27 09:00:26 +03:00
|
|
|
|
2022-05-31 18:04:11 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-04-22 15:44:26 +08:00
|
|
|
|
|
|
|
|
|
2022-05-31 18:04:11 +08:00
|
|
|
|
|
|
|
|
|
2026-04-22 15:44:26 +08:00
|
|
|
|
|
|
|
|
|
2022-05-31 18:04:11 +08:00
|
|
|
|
2023-06-29 20:58:44 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-09-06 22:54:16 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-05-31 18:04:11 +08:00
|
|
|
|
|
|
|
|
|
2022-12-10 22:40:15 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-12-10 22:40:15 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-12-10 22:40:15 +08:00
|
|
|
|
2022-05-31 18:04:11 +08:00
|
|
|
|
2024-07-20 22:41:06 +08:00
|
|
|
|
2022-05-31 18:04:11 +08:00
|
|
|
|
|
|
|
|
|
2023-10-02 10:01:29 +08:00
|
|
|
|
|
|
|
|
|