mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-27 12:57:53 +00:00
8f6f76a6a2
there's little I can say which isn't in the individual changelogs. The lengthier patch series are - "kdump: use generic functions to simplify crashkernel reservation in arch", from Baoquan He. This is mainly cleanups and consolidation of the "crashkernel=" kernel parameter handling. - After much discussion, David Laight's "minmax: Relax type checks in min() and max()" is here. Hopefully reduces some typecasting and the use of min_t() and max_t(). - A group of patches from Oleg Nesterov which clean up and slightly fix our handling of reads from /proc/PID/task/... and which remove task_struct.therad_group. -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQTTMBEPP41GrTpTJgfdBJ7gKXxAjgUCZUQP9wAKCRDdBJ7gKXxA jmOAAQDh8sxagQYocoVsSm28ICqXFeaY9Co1jzBIDdNesAvYVwD/c2DHRqJHEiS4 63BNcG3+hM9nwGJHb5lyh5m79nBMRg0= =On4u -----END PGP SIGNATURE----- Merge tag 'mm-nonmm-stable-2023-11-02-14-08' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Pull non-MM updates from Andrew Morton: "As usual, lots of singleton and doubleton patches all over the tree and there's little I can say which isn't in the individual changelogs. The lengthier patch series are - 'kdump: use generic functions to simplify crashkernel reservation in arch', from Baoquan He. This is mainly cleanups and consolidation of the 'crashkernel=' kernel parameter handling - After much discussion, David Laight's 'minmax: Relax type checks in min() and max()' is here. Hopefully reduces some typecasting and the use of min_t() and max_t() - A group of patches from Oleg Nesterov which clean up and slightly fix our handling of reads from /proc/PID/task/... and which remove task_struct.thread_group" * tag 'mm-nonmm-stable-2023-11-02-14-08' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm: (64 commits) scripts/gdb/vmalloc: disable on no-MMU scripts/gdb: fix usage of MOD_TEXT not defined when CONFIG_MODULES=n .mailmap: add address mapping for Tomeu Vizoso mailmap: update email address for Claudiu Beznea tools/testing/selftests/mm/run_vmtests.sh: lower the ptrace permissions .mailmap: map Benjamin Poirier's address scripts/gdb: add lx_current support for riscv ocfs2: fix a spelling typo in comment proc: test ProtectionKey in proc-empty-vm test proc: fix proc-empty-vm test with vsyscall fs/proc/base.c: remove unneeded semicolon do_io_accounting: use sig->stats_lock do_io_accounting: use __for_each_thread() ocfs2: replace BUG_ON() at ocfs2_num_free_extents() with ocfs2_error() ocfs2: fix a typo in a comment scripts/show_delta: add __main__ judgement before main code treewide: mark stuff as __ro_after_init fs: ocfs2: check status values proc: test /proc/${pid}/statm compiler.h: move __is_constexpr() to compiler.h ...
153 lines
5.1 KiB
C
153 lines
5.1 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef LINUX_CRASH_CORE_H
|
|
#define LINUX_CRASH_CORE_H
|
|
|
|
#include <linux/linkage.h>
|
|
#include <linux/elfcore.h>
|
|
#include <linux/elf.h>
|
|
#ifdef CONFIG_ARCH_HAS_GENERIC_CRASHKERNEL_RESERVATION
|
|
#include <asm/crash_core.h>
|
|
#endif
|
|
|
|
/* Location of a reserved region to hold the crash kernel.
|
|
*/
|
|
extern struct resource crashk_res;
|
|
extern struct resource crashk_low_res;
|
|
|
|
#define CRASH_CORE_NOTE_NAME "CORE"
|
|
#define CRASH_CORE_NOTE_HEAD_BYTES ALIGN(sizeof(struct elf_note), 4)
|
|
#define CRASH_CORE_NOTE_NAME_BYTES ALIGN(sizeof(CRASH_CORE_NOTE_NAME), 4)
|
|
#define CRASH_CORE_NOTE_DESC_BYTES ALIGN(sizeof(struct elf_prstatus), 4)
|
|
|
|
/*
|
|
* The per-cpu notes area is a list of notes terminated by a "NULL"
|
|
* note header. For kdump, the code in vmcore.c runs in the context
|
|
* of the second kernel to combine them into one note.
|
|
*/
|
|
#define CRASH_CORE_NOTE_BYTES ((CRASH_CORE_NOTE_HEAD_BYTES * 2) + \
|
|
CRASH_CORE_NOTE_NAME_BYTES + \
|
|
CRASH_CORE_NOTE_DESC_BYTES)
|
|
|
|
#define VMCOREINFO_BYTES PAGE_SIZE
|
|
#define VMCOREINFO_NOTE_NAME "VMCOREINFO"
|
|
#define VMCOREINFO_NOTE_NAME_BYTES ALIGN(sizeof(VMCOREINFO_NOTE_NAME), 4)
|
|
#define VMCOREINFO_NOTE_SIZE ((CRASH_CORE_NOTE_HEAD_BYTES * 2) + \
|
|
VMCOREINFO_NOTE_NAME_BYTES + \
|
|
VMCOREINFO_BYTES)
|
|
|
|
typedef u32 note_buf_t[CRASH_CORE_NOTE_BYTES/4];
|
|
/* Per cpu memory for storing cpu states in case of system crash. */
|
|
extern note_buf_t __percpu *crash_notes;
|
|
|
|
void crash_update_vmcoreinfo_safecopy(void *ptr);
|
|
void crash_save_vmcoreinfo(void);
|
|
void arch_crash_save_vmcoreinfo(void);
|
|
__printf(1, 2)
|
|
void vmcoreinfo_append_str(const char *fmt, ...);
|
|
phys_addr_t paddr_vmcoreinfo_note(void);
|
|
|
|
#define VMCOREINFO_OSRELEASE(value) \
|
|
vmcoreinfo_append_str("OSRELEASE=%s\n", value)
|
|
#define VMCOREINFO_BUILD_ID() \
|
|
({ \
|
|
static_assert(sizeof(vmlinux_build_id) == 20); \
|
|
vmcoreinfo_append_str("BUILD-ID=%20phN\n", vmlinux_build_id); \
|
|
})
|
|
|
|
#define VMCOREINFO_PAGESIZE(value) \
|
|
vmcoreinfo_append_str("PAGESIZE=%ld\n", value)
|
|
#define VMCOREINFO_SYMBOL(name) \
|
|
vmcoreinfo_append_str("SYMBOL(%s)=%lx\n", #name, (unsigned long)&name)
|
|
#define VMCOREINFO_SYMBOL_ARRAY(name) \
|
|
vmcoreinfo_append_str("SYMBOL(%s)=%lx\n", #name, (unsigned long)name)
|
|
#define VMCOREINFO_SIZE(name) \
|
|
vmcoreinfo_append_str("SIZE(%s)=%lu\n", #name, \
|
|
(unsigned long)sizeof(name))
|
|
#define VMCOREINFO_STRUCT_SIZE(name) \
|
|
vmcoreinfo_append_str("SIZE(%s)=%lu\n", #name, \
|
|
(unsigned long)sizeof(struct name))
|
|
#define VMCOREINFO_OFFSET(name, field) \
|
|
vmcoreinfo_append_str("OFFSET(%s.%s)=%lu\n", #name, #field, \
|
|
(unsigned long)offsetof(struct name, field))
|
|
#define VMCOREINFO_TYPE_OFFSET(name, field) \
|
|
vmcoreinfo_append_str("OFFSET(%s.%s)=%lu\n", #name, #field, \
|
|
(unsigned long)offsetof(name, field))
|
|
#define VMCOREINFO_LENGTH(name, value) \
|
|
vmcoreinfo_append_str("LENGTH(%s)=%lu\n", #name, (unsigned long)value)
|
|
#define VMCOREINFO_NUMBER(name) \
|
|
vmcoreinfo_append_str("NUMBER(%s)=%ld\n", #name, (long)name)
|
|
#define VMCOREINFO_CONFIG(name) \
|
|
vmcoreinfo_append_str("CONFIG_%s=y\n", #name)
|
|
|
|
extern unsigned char *vmcoreinfo_data;
|
|
extern size_t vmcoreinfo_size;
|
|
extern u32 *vmcoreinfo_note;
|
|
|
|
Elf_Word *append_elf_note(Elf_Word *buf, char *name, unsigned int type,
|
|
void *data, size_t data_len);
|
|
void final_note(Elf_Word *buf);
|
|
|
|
#ifdef CONFIG_ARCH_HAS_GENERIC_CRASHKERNEL_RESERVATION
|
|
#ifndef DEFAULT_CRASH_KERNEL_LOW_SIZE
|
|
#define DEFAULT_CRASH_KERNEL_LOW_SIZE (128UL << 20)
|
|
#endif
|
|
#endif
|
|
|
|
int __init parse_crashkernel(char *cmdline, unsigned long long system_ram,
|
|
unsigned long long *crash_size, unsigned long long *crash_base,
|
|
unsigned long long *low_size, bool *high);
|
|
|
|
#ifdef CONFIG_ARCH_HAS_GENERIC_CRASHKERNEL_RESERVATION
|
|
#ifndef DEFAULT_CRASH_KERNEL_LOW_SIZE
|
|
#define DEFAULT_CRASH_KERNEL_LOW_SIZE (128UL << 20)
|
|
#endif
|
|
#ifndef CRASH_ALIGN
|
|
#define CRASH_ALIGN SZ_2M
|
|
#endif
|
|
#ifndef CRASH_ADDR_LOW_MAX
|
|
#define CRASH_ADDR_LOW_MAX SZ_4G
|
|
#endif
|
|
#ifndef CRASH_ADDR_HIGH_MAX
|
|
#define CRASH_ADDR_HIGH_MAX memblock_end_of_DRAM()
|
|
#endif
|
|
|
|
void __init reserve_crashkernel_generic(char *cmdline,
|
|
unsigned long long crash_size,
|
|
unsigned long long crash_base,
|
|
unsigned long long crash_low_size,
|
|
bool high);
|
|
#else
|
|
static inline void __init reserve_crashkernel_generic(char *cmdline,
|
|
unsigned long long crash_size,
|
|
unsigned long long crash_base,
|
|
unsigned long long crash_low_size,
|
|
bool high)
|
|
{}
|
|
#endif
|
|
|
|
/* Alignment required for elf header segment */
|
|
#define ELF_CORE_HEADER_ALIGN 4096
|
|
|
|
struct crash_mem {
|
|
unsigned int max_nr_ranges;
|
|
unsigned int nr_ranges;
|
|
struct range ranges[] __counted_by(max_nr_ranges);
|
|
};
|
|
|
|
extern int crash_exclude_mem_range(struct crash_mem *mem,
|
|
unsigned long long mstart,
|
|
unsigned long long mend);
|
|
extern int crash_prepare_elf64_headers(struct crash_mem *mem, int need_kernel_map,
|
|
void **addr, unsigned long *sz);
|
|
|
|
struct kimage;
|
|
struct kexec_segment;
|
|
|
|
#define KEXEC_CRASH_HP_NONE 0
|
|
#define KEXEC_CRASH_HP_ADD_CPU 1
|
|
#define KEXEC_CRASH_HP_REMOVE_CPU 2
|
|
#define KEXEC_CRASH_HP_ADD_MEMORY 3
|
|
#define KEXEC_CRASH_HP_REMOVE_MEMORY 4
|
|
#define KEXEC_CRASH_HP_INVALID_CPU -1U
|
|
|
|
#endif /* LINUX_CRASH_CORE_H */
|