mirror of
https://github.com/torvalds/linux.git
synced 2026-04-19 07:13:56 -04:00
Pull non-MM updates from Andrew Morton:
- "panic: sys_info: Refactor and fix a potential issue" (Andy Shevchenko)
fixes a build issue and does some cleanup in ib/sys_info.c
- "Implement mul_u64_u64_div_u64_roundup()" (David Laight)
enhances the 64-bit math code on behalf of a PWM driver and beefs up
the test module for these library functions
- "scripts/gdb/symbols: make BPF debug info available to GDB" (Ilya Leoshkevich)
makes BPF symbol names, sizes, and line numbers available to the GDB
debugger
- "Enable hung_task and lockup cases to dump system info on demand" (Feng Tang)
adds a sysctl which can be used to cause additional info dumping when
the hung-task and lockup detectors fire
- "lib/base64: add generic encoder/decoder, migrate users" (Kuan-Wei Chiu)
adds a general base64 encoder/decoder to lib/ and migrates several
users away from their private implementations
- "rbree: inline rb_first() and rb_last()" (Eric Dumazet)
makes TCP a little faster
- "liveupdate: Rework KHO for in-kernel users" (Pasha Tatashin)
reworks the KEXEC Handover interfaces in preparation for Live Update
Orchestrator (LUO), and possibly for other future clients
- "kho: simplify state machine and enable dynamic updates" (Pasha Tatashin)
increases the flexibility of KEXEC Handover. Also preparation for LUO
- "Live Update Orchestrator" (Pasha Tatashin)
is a major new feature targeted at cloud environments. Quoting the
cover letter:
This series introduces the Live Update Orchestrator, a kernel
subsystem designed to facilitate live kernel updates using a
kexec-based reboot. This capability is critical for cloud
environments, allowing hypervisors to be updated with minimal
downtime for running virtual machines. LUO achieves this by
preserving the state of selected resources, such as memory,
devices and their dependencies, across the kernel transition.
As a key feature, this series includes support for preserving
memfd file descriptors, which allows critical in-memory data, such
as guest RAM or any other large memory region, to be maintained in
RAM across the kexec reboot.
Mike Rappaport merits a mention here, for his extensive review and
testing work.
- "kexec: reorganize kexec and kdump sysfs" (Sourabh Jain)
moves the kexec and kdump sysfs entries from /sys/kernel/ to
/sys/kernel/kexec/ and adds back-compatibility symlinks which can
hopefully be removed one day
- "kho: fixes for vmalloc restoration" (Mike Rapoport)
fixes a BUG which was being hit during KHO restoration of vmalloc()
regions
* tag 'mm-nonmm-stable-2025-12-06-11-14' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm: (139 commits)
calibrate: update header inclusion
Reinstate "resource: avoid unnecessary lookups in find_next_iomem_res()"
vmcoreinfo: track and log recoverable hardware errors
kho: fix restoring of contiguous ranges of order-0 pages
kho: kho_restore_vmalloc: fix initialization of pages array
MAINTAINERS: TPM DEVICE DRIVER: update the W-tag
init: replace simple_strtoul with kstrtoul to improve lpj_setup
KHO: fix boot failure due to kmemleak access to non-PRESENT pages
Documentation/ABI: new kexec and kdump sysfs interface
Documentation/ABI: mark old kexec sysfs deprecated
kexec: move sysfs entries to /sys/kernel/kexec
test_kho: always print restore status
kho: free chunks using free_page() instead of kfree()
selftests/liveupdate: add kexec test for multiple and empty sessions
selftests/liveupdate: add simple kexec-based selftest for LUO
selftests/liveupdate: add userspace API selftests
docs: add documentation for memfd preservation via LUO
mm: memfd_luo: allow preserving memfd
liveupdate: luo_file: add private argument to store runtime state
mm: shmem: export some functions to internal.h
...
159 lines
5.1 KiB
C
159 lines
5.1 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#include <stdint.h>
|
|
#include <stdbool.h>
|
|
#include <sys/mman.h>
|
|
#include <err.h>
|
|
#include <stdarg.h>
|
|
#include <strings.h> /* ffsl() */
|
|
#include <unistd.h> /* _SC_PAGESIZE */
|
|
#include "kselftest.h"
|
|
#include <linux/fs.h>
|
|
|
|
#define BIT_ULL(nr) (1ULL << (nr))
|
|
#define PM_SOFT_DIRTY BIT_ULL(55)
|
|
#define PM_MMAP_EXCLUSIVE BIT_ULL(56)
|
|
#define PM_UFFD_WP BIT_ULL(57)
|
|
#define PM_GUARD_REGION BIT_ULL(58)
|
|
#define PM_FILE BIT_ULL(61)
|
|
#define PM_SWAP BIT_ULL(62)
|
|
#define PM_PRESENT BIT_ULL(63)
|
|
|
|
#define KPF_COMPOUND_HEAD BIT_ULL(15)
|
|
#define KPF_COMPOUND_TAIL BIT_ULL(16)
|
|
#define KPF_THP BIT_ULL(22)
|
|
/*
|
|
* Ignore the checkpatch warning, we must read from x but don't want to do
|
|
* anything with it in order to trigger a read page fault. We therefore must use
|
|
* volatile to stop the compiler from optimising this away.
|
|
*/
|
|
#define FORCE_READ(x) (*(const volatile typeof(x) *)&(x))
|
|
|
|
extern unsigned int __page_size;
|
|
extern unsigned int __page_shift;
|
|
|
|
/*
|
|
* Represents an open fd and PROCMAP_QUERY state for binary (via ioctl)
|
|
* /proc/$pid/[s]maps lookup.
|
|
*/
|
|
struct procmap_fd {
|
|
int fd;
|
|
struct procmap_query query;
|
|
};
|
|
|
|
static inline unsigned int psize(void)
|
|
{
|
|
if (!__page_size)
|
|
__page_size = sysconf(_SC_PAGESIZE);
|
|
return __page_size;
|
|
}
|
|
|
|
static inline unsigned int pshift(void)
|
|
{
|
|
if (!__page_shift)
|
|
__page_shift = (ffsl(psize()) - 1);
|
|
return __page_shift;
|
|
}
|
|
|
|
bool detect_huge_zeropage(void);
|
|
|
|
/*
|
|
* Plan 9 FS has bugs (at least on QEMU) where certain operations fail with
|
|
* ENOENT on unlinked files. See
|
|
* https://gitlab.com/qemu-project/qemu/-/issues/103 for some info about such
|
|
* bugs. There are rumours of NFS implementations with similar bugs.
|
|
*
|
|
* Ideally, tests should just detect filesystems known to have such issues and
|
|
* bail early. But 9pfs has the additional "feature" that it causes fstatfs to
|
|
* pass through the f_type field from the host filesystem. To avoid having to
|
|
* scrape /proc/mounts or some other hackery, tests can call this function when
|
|
* it seems such a bug might have been encountered.
|
|
*/
|
|
static inline void skip_test_dodgy_fs(const char *op_name)
|
|
{
|
|
ksft_test_result_skip("%s failed with ENOENT. Filesystem might be buggy (9pfs?)\n", op_name);
|
|
}
|
|
|
|
uint64_t pagemap_get_entry(int fd, char *start);
|
|
bool pagemap_is_softdirty(int fd, char *start);
|
|
bool pagemap_is_swapped(int fd, char *start);
|
|
bool pagemap_is_populated(int fd, char *start);
|
|
unsigned long pagemap_get_pfn(int fd, char *start);
|
|
void clear_softdirty(void);
|
|
bool check_for_pattern(FILE *fp, const char *pattern, char *buf, size_t len);
|
|
uint64_t read_pmd_pagesize(void);
|
|
unsigned long rss_anon(void);
|
|
bool check_huge_anon(void *addr, int nr_hpages, uint64_t hpage_size);
|
|
bool check_huge_file(void *addr, int nr_hpages, uint64_t hpage_size);
|
|
bool check_huge_shmem(void *addr, int nr_hpages, uint64_t hpage_size);
|
|
int64_t allocate_transhuge(void *ptr, int pagemap_fd);
|
|
unsigned long default_huge_page_size(void);
|
|
int detect_hugetlb_page_sizes(size_t sizes[], int max);
|
|
int pageflags_get(unsigned long pfn, int kpageflags_fd, uint64_t *flags);
|
|
|
|
int uffd_register(int uffd, void *addr, uint64_t len,
|
|
bool miss, bool wp, bool minor);
|
|
int uffd_unregister(int uffd, void *addr, uint64_t len);
|
|
int uffd_register_with_ioctls(int uffd, void *addr, uint64_t len,
|
|
bool miss, bool wp, bool minor, uint64_t *ioctls);
|
|
unsigned long get_free_hugepages(void);
|
|
bool check_vmflag_io(void *addr);
|
|
bool check_vmflag_pfnmap(void *addr);
|
|
bool check_vmflag_guard(void *addr);
|
|
int open_procmap(pid_t pid, struct procmap_fd *procmap_out);
|
|
int query_procmap(struct procmap_fd *procmap);
|
|
bool find_vma_procmap(struct procmap_fd *procmap, void *address);
|
|
int close_procmap(struct procmap_fd *procmap);
|
|
int write_sysfs(const char *file_path, unsigned long val);
|
|
int read_sysfs(const char *file_path, unsigned long *val);
|
|
bool softdirty_supported(void);
|
|
|
|
static inline int open_self_procmap(struct procmap_fd *procmap_out)
|
|
{
|
|
pid_t pid = getpid();
|
|
|
|
return open_procmap(pid, procmap_out);
|
|
}
|
|
|
|
/* These helpers need to be inline to match the kselftest.h idiom. */
|
|
static char test_name[1024];
|
|
|
|
static inline void log_test_start(const char *name, ...)
|
|
{
|
|
va_list args;
|
|
va_start(args, name);
|
|
|
|
vsnprintf(test_name, sizeof(test_name), name, args);
|
|
ksft_print_msg("[RUN] %s\n", test_name);
|
|
|
|
va_end(args);
|
|
}
|
|
|
|
static inline void log_test_result(int result)
|
|
{
|
|
ksft_test_result_report(result, "%s\n", test_name);
|
|
}
|
|
|
|
static inline int sz2ord(size_t size, size_t pagesize)
|
|
{
|
|
return __builtin_ctzll(size / pagesize);
|
|
}
|
|
|
|
void *sys_mremap(void *old_address, unsigned long old_size,
|
|
unsigned long new_size, int flags, void *new_address);
|
|
|
|
long ksm_get_self_zero_pages(void);
|
|
long ksm_get_self_merging_pages(void);
|
|
long ksm_get_full_scans(void);
|
|
int ksm_use_zero_pages(void);
|
|
int ksm_start(void);
|
|
int ksm_stop(void);
|
|
|
|
/*
|
|
* On ppc64 this will only work with radix 2M hugepage size
|
|
*/
|
|
#define HPAGE_SHIFT 21
|
|
#define HPAGE_SIZE (1 << HPAGE_SHIFT)
|
|
|
|
#define PAGEMAP_PRESENT(ent) (((ent) & (1ull << 63)) != 0)
|
|
#define PAGEMAP_PFN(ent) ((ent) & ((1ull << 55) - 1))
|