Kernel
Threads by month
- ----- 2025 -----
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- 44 participants
- 17149 discussions
hulk inclusion
category: bugfix
bugzilla: NA
CVE: NA
The specifier of __init added to hrd_flashProbe() isn't appropriate.
It can cause following building warning:
WARNING: drivers/mtd/hisilicon/sfc/hi-sfc.o(.text.unlikely+0x38c): Section mismatch in reference from the \
function flash_map_init() to the function .init.text:hrd_flashProbe()
The function flash_map_init() references
the function __init hrd_flashProbe().
This is often because flash_map_init lacks a __init
annotation or the annotation of hrd_flashProbe is wrong.
Fixes: 25d711e7ffb7 ("drivers: add sfc driver to hulk")
Signed-off-by: Zhengyuan Liu <liuzhengyuan(a)tj.kylinos.cn>
---
drivers/mtd/hisilicon/sfc/hrd_sfc_driver.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/mtd/hisilicon/sfc/hrd_sfc_driver.c b/drivers/mtd/hisilicon/sfc/hrd_sfc_driver.c
index 23254e325a85..69fb1b306f0d 100644
--- a/drivers/mtd/hisilicon/sfc/hrd_sfc_driver.c
+++ b/drivers/mtd/hisilicon/sfc/hrd_sfc_driver.c
@@ -87,8 +87,8 @@ static int _hrd_flashProbe(const char **mtdDrv, struct map_info *map,
return HRD_ERR;
}
-static int __init hrd_flashProbe(const char **mtdDrv, struct map_info *map,
- struct resource *sfc_regres, struct mtd_info **mtd)
+static int hrd_flashProbe(const char **mtdDrv, struct map_info *map,
+ struct resource *sfc_regres, struct mtd_info **mtd)
{
int ret;
--
2.20.1
3
2

04 Jan '21
From: Zhengyuan Liu <liuzhengyuan(a)tj.kylinos.cn>
hulk inclusion
category: bugfix
bugzilla: NA
CVE: NA
MAP_PA32BIT was defined in uapi/asm-generic/mman.h, that was not
automatically included by mm/mmap.c when building on platforms such as
mips, and result in following compiling error:
mm/mmap.c: In function ‘do_mmap’:
mm/mmap.c:1450:14: error: ‘MAP_PA32BIT’ undeclared (first use in this function); did you mean ‘MAP_32BIT’?
if (flags & MAP_PA32BIT)
^~~~~~~~~~~
MAP_32BIT
mm/mmap.c:1450:14: note: each undeclared identifier is reported only once for each function it appears in
make[1]: *** [scripts/Makefile.build:303: mm/mmap.o] Error 1
Fixes: e138253f2b82 ("svm: add support for allocing memory which is within 4G physical address in svm_mmap")
Signed-off-by: Zhengyuan Liu <liuzhengyuan(a)tj.kylinos.cn>
Signed-off-by: Bixuan Cui <cuibixuan(a)huawei.com>
---
arch/alpha/include/uapi/asm/mman.h | 1 +
arch/mips/include/uapi/asm/mman.h | 1 +
arch/parisc/include/uapi/asm/mman.h | 1 +
arch/powerpc/include/uapi/asm/mman.h | 1 +
arch/sparc/include/uapi/asm/mman.h | 1 +
arch/xtensa/include/uapi/asm/mman.h | 1 +
6 files changed, 6 insertions(+)
diff --git a/arch/alpha/include/uapi/asm/mman.h b/arch/alpha/include/uapi/asm/mman.h
index f9d4e6b6d4bd..b3acfc00c8ec 100644
--- a/arch/alpha/include/uapi/asm/mman.h
+++ b/arch/alpha/include/uapi/asm/mman.h
@@ -33,6 +33,7 @@
#define MAP_STACK 0x80000 /* give out an address that is best suited for process/thread stacks */
#define MAP_HUGETLB 0x100000 /* create a huge page mapping */
#define MAP_FIXED_NOREPLACE 0x200000/* MAP_FIXED which doesn't unmap underlying mapping */
+#define MAP_PA32BIT 0x400000 /* physical address is within 4G */
#define MS_ASYNC 1 /* sync memory asynchronously */
#define MS_SYNC 2 /* synchronous memory sync */
diff --git a/arch/mips/include/uapi/asm/mman.h b/arch/mips/include/uapi/asm/mman.h
index 3035ca499cd8..72a00c746e78 100644
--- a/arch/mips/include/uapi/asm/mman.h
+++ b/arch/mips/include/uapi/asm/mman.h
@@ -51,6 +51,7 @@
#define MAP_STACK 0x40000 /* give out an address that is best suited for process/thread stacks */
#define MAP_HUGETLB 0x80000 /* create a huge page mapping */
#define MAP_FIXED_NOREPLACE 0x100000 /* MAP_FIXED which doesn't unmap underlying mapping */
+#define MAP_PA32BIT 0x400000 /* physical address is within 4G */
/*
* Flags for msync
diff --git a/arch/parisc/include/uapi/asm/mman.h b/arch/parisc/include/uapi/asm/mman.h
index 870fbf8c7088..9e989d649e85 100644
--- a/arch/parisc/include/uapi/asm/mman.h
+++ b/arch/parisc/include/uapi/asm/mman.h
@@ -27,6 +27,7 @@
#define MAP_STACK 0x40000 /* give out an address that is best suited for process/thread stacks */
#define MAP_HUGETLB 0x80000 /* create a huge page mapping */
#define MAP_FIXED_NOREPLACE 0x100000 /* MAP_FIXED which doesn't unmap underlying mapping */
+#define MAP_PA32BIT 0x400000 /* physical address is within 4G */
#define MS_SYNC 1 /* synchronous memory sync */
#define MS_ASYNC 2 /* sync memory asynchronously */
diff --git a/arch/powerpc/include/uapi/asm/mman.h b/arch/powerpc/include/uapi/asm/mman.h
index 65065ce32814..95f884ada96f 100644
--- a/arch/powerpc/include/uapi/asm/mman.h
+++ b/arch/powerpc/include/uapi/asm/mman.h
@@ -29,6 +29,7 @@
#define MAP_NONBLOCK 0x10000 /* do not block on IO */
#define MAP_STACK 0x20000 /* give out an address that is best suited for process/thread stacks */
#define MAP_HUGETLB 0x40000 /* create a huge page mapping */
+#define MAP_PA32BIT 0x400000 /* physical address is within 4G */
/* Override any generic PKEY permission defines */
#define PKEY_DISABLE_EXECUTE 0x4
diff --git a/arch/sparc/include/uapi/asm/mman.h b/arch/sparc/include/uapi/asm/mman.h
index f6f99ec65bb3..0d1881b8f30d 100644
--- a/arch/sparc/include/uapi/asm/mman.h
+++ b/arch/sparc/include/uapi/asm/mman.h
@@ -26,6 +26,7 @@
#define MAP_NONBLOCK 0x10000 /* do not block on IO */
#define MAP_STACK 0x20000 /* give out an address that is best suited for process/thread stacks */
#define MAP_HUGETLB 0x40000 /* create a huge page mapping */
+#define MAP_PA32BIT 0x400000 /* physical address is within 4G */
#endif /* _UAPI__SPARC_MMAN_H__ */
diff --git a/arch/xtensa/include/uapi/asm/mman.h b/arch/xtensa/include/uapi/asm/mman.h
index 58f29a9d895d..f584a590bb00 100644
--- a/arch/xtensa/include/uapi/asm/mman.h
+++ b/arch/xtensa/include/uapi/asm/mman.h
@@ -58,6 +58,7 @@
#define MAP_STACK 0x40000 /* give out an address that is best suited for process/thread stacks */
#define MAP_HUGETLB 0x80000 /* create a huge page mapping */
#define MAP_FIXED_NOREPLACE 0x100000 /* MAP_FIXED which doesn't unmap underlying mapping */
+#define MAP_PA32BIT 0x400000 /* physical address is within 4G */
#ifdef CONFIG_MMAP_ALLOW_UNINITIALIZED
# define MAP_UNINITIALIZED 0x4000000 /* For anonymous mmap, memory could be
* uninitialized */
--
2.17.1
3
2

[PATCH kernel-4.19 01/12] memcg/ascend: Check sysctl oom config for memcg oom
by Yang Yingliang 04 Jan '21
by Yang Yingliang 04 Jan '21
04 Jan '21
From: Zhou Guanghui <zhouguanghui1(a)huawei.com>
ascend inclusion
category: feature
bugzilla: NA
CVE: NA
--------------------------------------------------
If memcg oom_kill_disable is false(enable oom killer), and sysctl
enable_oom_killer is also false(disable oom killer), the memory
allocated for this memcg will exceed the limit. This means that
the memcg cannot limit the memory usage.
Therefore, ensure that sysctl enable_oom_killer is not false.
Otherwise, wait for memory resources.
Signed-off-by: Zhou Guanghui <zhouguanghui1(a)huawei.com>
Reviewed-by: Ding Tianhong <dingtianhong(a)huawei.com>
Signed-off-by: Yang Yingliang <yangyingliang(a)huawei.com>
---
mm/memcontrol.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 6ad8fafcdf87..aa8f6f75eea1 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1942,7 +1942,11 @@ bool mem_cgroup_oom_synchronize(bool handle)
if (locked)
mem_cgroup_oom_notify(memcg);
- if (locked && !memcg->oom_kill_disable) {
+ if (locked &&
+#ifdef CONFIG_ASCEND_OOM
+ sysctl_enable_oom_killer != 0 &&
+#endif
+ !memcg->oom_kill_disable) {
mem_cgroup_unmark_under_oom(memcg);
finish_wait(&memcg_oom_waitq, &owait.wait);
mem_cgroup_out_of_memory(memcg, current->memcg_oom_gfp_mask,
--
2.25.1
1
11
本次MPAM特性合入59个补丁,主要包括:
1)MPAM 对外sysfs功能增强;
2)适配后续社区版本,适配兼容MPAM协议;
3)代码框架整体重构,拓展对SMMU io的支持;
4)支持鲲鹏930全套MPAM能力;
James Morse (10):
arm64/mpam: Add mpam driver discovery phase and kbuild boiler plate
cacheinfo: Provide a helper to find a cacheinfo leaf
arm64/mpam: Probe supported partid/pmg ranges from devices
arm64/mpam: Supplement MPAM MSC register layout definitions
arm64/mpam: Probe the features resctrl supports
arm64/mpam: Reset controls when CPUs come online
arm64/mpam: Summarize feature support during mpam_enable()
arm64/mpam: resctrl: Re-synchronise resctrl's view of online CPUs
drivers: base: cacheinfo: Add helper to search cacheinfo by of_node
arm64/mpam: Enabling registering and logging error interrupts
Wang ShaoBo (49):
arm64/mpam: Preparing for MPAM refactoring
arm64/mpam: Add helper for getting mpam sysprops
arm64/mpam: Allocate mpam component configuration arrays
arm64/mpam: Pick MPAM resources and events for resctrl_res exported
arm64/mpam: Init resctrl resources' info from resctrl_res selected
arm64/mpam: resctrl: Handle cpuhp and resctrl_dom allocation
arm64/mpam: Implement helpers for handling configuration and
monitoring
arm64/mpam: Migrate old MSCs' discovery process to new branch
arm64/mpam: Add helper for getting MSCs' configuration
arm64/mpam: Probe partid,pmg and feature capabilities' ranges from
classes
arm64/mpam: resctrl: Rebuild configuration and monitoring pipeline
arm64/mpam: resctrl: Append schemata CDP definitions
arm64/mpam: resctrl: Supplement cdpl2,cdpl3 for mount options
arm64/mpam: resctrl: Add helpers for init and destroy schemata list
arm64/mpam: resctrl: Use resctrl_group_init_alloc() to init schema
list
arm64/mpam: resctrl: Write and read schemata by schema_list
arm64/mpam: Support cdp in mpam_sched_in()
arm64/mpam: resctrl: Update resources reset process
arm64/mpam: resctrl: Update closid alloc and free process with bitmap
arm64/mpam: resctrl: Move ctrlmon sysfile write/read function to
mpam_ctrlmon.c
arm64/mpam: Support cdp on allocating monitors
arm64/mpam: resctrl: Support cdp on monitoring data
arm64/mpam: Clean up header files and rearrange declarations
arm64/mpam: resctrl: Remove ctrlmon sysfile
arm64/mpam: resctrl: Remove unnecessary CONFIG_ARM64
arm64/mpam: Implement intpartid narrowing process
arm64/mpam: Using software-defined id for rdtgroup instead of 32-bit
integer
arm64/mpam: resctrl: collect child mon group's monitor data
arm64/mpam: resctrl: Support cpus' monitoring for mon group
arm64/mpam: resctrl: Support priority and hardlimit(Memory bandwidth)
configuration
arm64/mpam: Store intpri and dspri for mpam device reset
arm64/mpam: Squash default priority from mpam device to class
arm64/mpam: Restore extend ctrls' max width for checking schemata
input
arm64/mpam: Re-plan intpartid narrowing process
arm64/mpam: Add hook-events id for ctrl features
arm64/mpam: Integrate monitor data for Memory Bandwidth if cdp enabled
arm64/mpam: Fix MPAM_ESR intPARTID_range error
arm64/mpam: Separate internal and downstream priority event
arm64/mpam: Remap reqpartid,pmg to rmid and intpartid to closid
arm64/mpam: Add wait queue for monitor alloc and free
arm64/mpam: Add resctrl_ctrl_feature structure to manage ctrl features
arm64/mpam: resctrl: Export resource's properties to info directory
arm64/mpam: Split header files into suitable location
arm64/mpam: resctrl: Add rmid file in resctrl sysfs
arm64/mpam: Filter schema control type with ctrl features
arm64/mpam: Simplify mpamid cdp mapping process
arm64/mpam: Set per-cpu's closid to none zero for cdp
ACPI/MPAM: Use acpi_map_pxm_to_node() to get node id for memory node
arm64/mpam: Supplement additional useful ctrl features for mount
options
arch/arm64/include/asm/mpam.h | 324 +---
arch/arm64/include/asm/mpam_resource.h | 129 --
arch/arm64/include/asm/mpam_sched.h | 8 -
arch/arm64/include/asm/resctrl.h | 489 +++++-
arch/arm64/kernel/Makefile | 2 +-
arch/arm64/kernel/mpam.c | 1494 ----------------
arch/arm64/kernel/mpam/Makefile | 3 +
arch/arm64/kernel/mpam/mpam_ctrlmon.c | 957 ++++++++++
arch/arm64/kernel/mpam/mpam_device.c | 1706 ++++++++++++++++++
arch/arm64/kernel/mpam/mpam_device.h | 140 ++
arch/arm64/kernel/mpam/mpam_internal.h | 345 ++++
arch/arm64/kernel/mpam/mpam_mon.c | 331 ++++
arch/arm64/kernel/mpam/mpam_resctrl.c | 2221 ++++++++++++++++++++++++
arch/arm64/kernel/mpam/mpam_resource.h | 228 +++
arch/arm64/kernel/mpam/mpam_setup.c | 597 +++++++
arch/arm64/kernel/mpam_ctrlmon.c | 619 -------
arch/arm64/kernel/mpam_mon.c | 121 --
drivers/acpi/arm64/mpam.c | 87 +-
drivers/base/cacheinfo.c | 38 +
fs/resctrlfs.c | 410 +++--
include/linux/arm_mpam.h | 118 ++
include/linux/cacheinfo.h | 36 +
include/linux/resctrlfs.h | 30 -
23 files changed, 7473 insertions(+), 2960 deletions(-)
delete mode 100644 arch/arm64/include/asm/mpam_resource.h
delete mode 100644 arch/arm64/kernel/mpam.c
create mode 100644 arch/arm64/kernel/mpam/Makefile
create mode 100644 arch/arm64/kernel/mpam/mpam_ctrlmon.c
create mode 100644 arch/arm64/kernel/mpam/mpam_device.c
create mode 100644 arch/arm64/kernel/mpam/mpam_device.h
create mode 100644 arch/arm64/kernel/mpam/mpam_internal.h
create mode 100644 arch/arm64/kernel/mpam/mpam_mon.c
create mode 100644 arch/arm64/kernel/mpam/mpam_resctrl.c
create mode 100644 arch/arm64/kernel/mpam/mpam_resource.h
create mode 100644 arch/arm64/kernel/mpam/mpam_setup.c
delete mode 100644 arch/arm64/kernel/mpam_ctrlmon.c
delete mode 100644 arch/arm64/kernel/mpam_mon.c
create mode 100644 include/linux/arm_mpam.h
--
2.25.1
1
59

04 Jan '21
From: Yan Zhao <yan.y.zhao(a)intel.com>
mainline inclusion
from mainline-v5.6-rc7
commit c0560f51cf77472f4ed113539b0a02ca6cda7961
category: Common features
bugzilla: 46841
CVE: NA
-------------------------------------------------
external user calls vfio_group_get_external_user_from_dev() with a device
pointer to get the VFIO group associated with this device.
The VFIO group is checked to be vialbe and have IOMMU set. Then
container user counter is increased and VFIO group reference is hold
to prevent the VFIO group from disposal before external user exits.
when the external user finishes using of the VFIO group, it calls
vfio_group_put_external_user() to dereference the VFIO group and the
container user counter.
Suggested-by: Alex Williamson <alex.williamson(a)redhat.com>
Signed-off-by: Yan Zhao <yan.y.zhao(a)intel.com>
Signed-off-by: Alex Williamson <alex.williamson(a)redhat.com>
Signed-off-by: Xiaoyang Xu <xuxiaoyang2(a)huawei.com>
Reviewed-by: Xiangyou Xie <xiexiangyou(a)huawei.com>
Signed-off-by: Yang Yingliang <yangyingliang(a)huawei.com>
---
drivers/vfio/vfio.c | 38 ++++++++++++++++++++++++++++++++++++++
include/linux/vfio.h | 2 ++
2 files changed, 40 insertions(+)
diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c
index 7a386fb30bf1..34a293318a39 100644
--- a/drivers/vfio/vfio.c
+++ b/drivers/vfio/vfio.c
@@ -1759,6 +1759,44 @@ struct vfio_group *vfio_group_get_external_user(struct file *filep)
}
EXPORT_SYMBOL_GPL(vfio_group_get_external_user);
+/**
+ * External user API, exported by symbols to be linked dynamically.
+ * The external user passes in a device pointer
+ * to verify that:
+ * - A VFIO group is assiciated with the device;
+ * - IOMMU is set for the group.
+ * If both checks passed, vfio_group_get_external_user_from_dev()
+ * increments the container user counter to prevent the VFIO group
+ * from disposal before external user exits and returns the pointer
+ * to the VFIO group.
+ *
+ * When the external user finishes using the VFIO group, it calls
+ * vfio_group_put_external_user() to release the VFIO group and
+ * decrement the container user counter.
+ *
+ * @dev [in] : device
+ * Return error PTR or pointer to VFIO group.
+ */
+
+struct vfio_group *vfio_group_get_external_user_from_dev(struct device *dev)
+{
+ struct vfio_group *group;
+ int ret;
+
+ group = vfio_group_get_from_dev(dev);
+ if (!group)
+ return ERR_PTR(-ENODEV);
+
+ ret = vfio_group_add_container_user(group);
+ if (ret) {
+ vfio_group_put(group);
+ return ERR_PTR(ret);
+ }
+
+ return group;
+}
+EXPORT_SYMBOL_GPL(vfio_group_get_external_user_from_dev);
+
void vfio_group_put_external_user(struct vfio_group *group)
{
vfio_group_try_dissolve_container(group);
diff --git a/include/linux/vfio.h b/include/linux/vfio.h
index 66741ab087c1..a1e8943b7be3 100644
--- a/include/linux/vfio.h
+++ b/include/linux/vfio.h
@@ -97,6 +97,8 @@ extern void vfio_unregister_iommu_driver(
*/
extern struct vfio_group *vfio_group_get_external_user(struct file *filep);
extern void vfio_group_put_external_user(struct vfio_group *group);
+extern struct vfio_group *vfio_group_get_external_user_from_dev(struct device
+ *dev);
extern bool vfio_external_group_match_file(struct vfio_group *group,
struct file *filep);
extern int vfio_external_user_iommu_id(struct vfio_group *group);
--
2.25.1
1
9
Alan Stern (1):
media: gspca: Fix memory leak in probe
Alexander Sverdlin (1):
serial: 8250_omap: Avoid FIFO corruption caused by MDR1 access
Alexandre Belloni (1):
ARM: dts: at91: at91sam9rl: fix ADC triggers
Alexey Kardashevskiy (1):
serial_core: Check for port state when tty is in error state
Amadej Kastelic (1):
ALSA: usb-audio: Add VID to support native DSD reproduction on FiiO
devices
Anant Thazhemadam (1):
Bluetooth: hci_h5: fix memory leak in h5_close
Andy Lutomirski (1):
x86/membarrier: Get rid of a dubious optimization
Andy Shevchenko (2):
pinctrl: merrifield: Set default bias in case no particular value
given
pinctrl: baytrail: Avoid clearing debounce value when turning it off
Anmol Karn (1):
Bluetooth: Fix null pointer dereference in hci_event_packet()
Ansuel Smith (1):
PCI: qcom: Add missing reset for ipq806x
Anton Ivanov (3):
um: Monitor error events in IRQ controller
um: tty: Fix handling of close in tty lines
um: chan_xterm: Fix fd leak
Antti Palosaari (1):
media: msi2500: assign SPI bus number dynamically
Ard Biesheuvel (2):
ARM: p2v: fix handling of LPAE translation in BE mode
crypto: ecdh - avoid unaligned accesses in ecdh_set_secret()
Arnd Bergmann (7):
kbuild: avoid static_assert for genksyms
scsi: megaraid_sas: Check user-provided offsets
RDMa/mthca: Work around -Wenum-conversion warning
seq_buf: Avoid type mismatch for seq_buf_init
watchdog: coh901327: add COMMON_CLK dependency
Input: cyapa_gen6 - fix out-of-bounds stack access
platform/x86: mlx-platform: remove an unused variable
Artem Lapkin (1):
arm64: dts: meson: fix spi-max-frequency on Khadas VIM2
Arvind Sankar (3):
x86/mm/mem_encrypt: Fix definition of PMD_FLAGS_DEC_WP
compiler.h: fix barrier_data() on clang
x86/mm/ident_map: Check for errors from ident_pud_init()
Athira Rajeev (1):
powerpc/perf: Exclude kernel samples while counting events in user
space.
Baruch Siach (1):
gpio: mvebu: fix potential user-after-free on probe
Bean Huo (1):
mmc: block: Fixup condition for CMD13 polling for RPMB requests
Bharat Gooty (1):
PCI: iproc: Fix out-of-bound array accesses
Bjorn Andersson (1):
slimbus: qcom-ngd-ctrl: Avoid sending power requests without QMI
Bjorn Helgaas (1):
PCI: Bounds-check command-line resource alignment requests
Björn Töpel (1):
ixgbe: avoid premature Rx buffer reuse
Bob Pearson (1):
RDMA/rxe: Compute PSN windows correctly
Bongsu Jeon (1):
nfc: s3fwrn5: Release the nfc firmware
Borislav Petkov (1):
EDAC/amd64: Fix PCI component registration
Bui Quang Minh (1):
USB: dummy-hcd: Fix uninitialized array use in init()
Calum Mackay (1):
lockd: don't use interval-based rebinding over TCP
Can Guo (1):
scsi: ufs: Make sure clk scaling happens only when HBA is runtime
ACTIVE
Carlos Garnacho (1):
platform/x86: intel-vbtn: Allow switch events on Acer Switch Alpha 12
Cezary Rojewski (1):
ASoC: pcm: DRAIN support reactivation
Chen-Yu Tsai (2):
arm64: dts: rockchip: Set dr_mode to "host" for OTG on rk3328-roc-cc
arm64: dts: rockchip: Fix UART pull-ups on rk3328
Cheng Lin (1):
nfs_common: need lock during iterate through the list
Chris Chiu (4):
Input: i8042 - add Acer laptops to the i8042 reset list
ALSA: hda/realtek - Enable headset mic of ASUS X430UN with ALC256
ALSA: hda/realtek - Enable headset mic of ASUS Q524UQK with ALC255
ALSA: hda/realtek: Apply jack fixup for Quanta NL3
Chris Packham (1):
ARM: dts: Remove non-existent i2c1 from 98dx3236
Christophe JAILLET (5):
ath10k: Fix an error handling path
ath10k: Release some resources in an error handling path
net: bcmgenet: Fix a resource leak in an error handling path in the
probe functin
net: allwinner: Fix some resources leak in the error handling path of
the probe and in the remove function
clk: s2mps11: Fix a resource leak in error handling paths in the probe
function
Christophe Leroy (4):
crypto: talitos - Endianess in current_desc_hdr()
crypto: talitos - Fix return type of current_desc_hdr()
powerpc/feature: Fix CPU_FTRS_ALWAYS by removing CPU_FTRS_GENERIC_32
powerpc/xmon: Change printk() to pr_cont()
Chuhong Yuan (1):
ASoC: jz4740-i2s: add missed checks for clk_get()
Chunguang Xu (1):
ext4: fix a memory leak of ext4_free_data
Chunyan Zhang (1):
gpio: eic-sprd: break loop when getting NULL device resource
Claudiu Beznea (1):
ARM: dts: at91: sama5d2: map securam as device
Coiby Xu (1):
pinctrl: amd: remove debounce filter setting in IRQ type setting
Colin Ian King (3):
crypto: inside-secure - Fix sizeof() mismatch
media: tm6000: Fix sizeof() mismatches
PCI: Fix overflow in command-line resource alignment requests
Connor McAdams (1):
ALSA: hda/ca0132 - Change Input Source enum strings.
Cristian Birsan (2):
ARM: dts: at91: sama5d4_xplained: add pincontrol for USB Host
ARM: dts: at91: sama5d3_xplained: add pincontrol for USB Host
Dae R. Jeong (1):
md: fix a warning caused by a race between concurrent md_ioctl()s
Dan Carpenter (6):
scsi: be2iscsi: Revert "Fix a theoretical leak in
beiscsi_create_eqs()"
soc: renesas: rmobile-sysc: Fix some leaks in
rmobile_init_pm_domains()
media: max2175: fix max2175_set_csm_mode() error code
media: saa7146: fix array overflow in vidioc_s_audio()
ASoC: wm_adsp: remove "ctl" from list on error in
wm_adsp_create_control()
qlcnic: Fix error code in probe
Dan Williams (1):
libnvdimm/namespace: Fix reaping of invalidated block-window-namespace
labels
Daniel Scally (1):
Revert "ACPI / resources: Use AE_CTRL_TERMINATE to terminate resources
walks"
Daniel T. Lee (1):
samples: bpf: Fix lwt_len_hist reusing previous BPF map
David Hildenbrand (2):
powerpc/powernv/memtrace: Don't leak kernel memory to user space
powerpc/powernv/memtrace: Fix crashing the kernel when enabling
concurrently
David Jander (1):
Input: ads7846 - fix race that causes missing releases
David Woodhouse (1):
x86/apic: Fix x2apic enablement without interrupt remapping
Deepak R Varma (1):
drm/tegra: replace idr_init() by idr_init_base()
Dmitry Baryshkov (1):
drm/msm/dsi_pll_10nm: restore VCO rate during restore_state
Dmitry Osipenko (1):
clk: tegra: Fix duplicated SE clock entry
Dmitry Torokhov (3):
Input: cm109 - do not stomp on control URB
Input: ads7846 - fix unaligned access on 7845
Input: cros_ec_keyb - send 'scancodes' in addition to key events
Dongdong Wang (1):
lwt: Disable BH too in run_lwt_bpf()
Douglas Anderson (1):
soc: qcom: geni: More properly switch to DMA mode
Dwaipayan Ray (1):
checkpatch: fix unescaped left brace
Eric Biggers (1):
crypto: af_alg - avoid undefined behavior accessing salg_name
Eric Dumazet (2):
mac80211: mesh: fix mesh_pathtbl_init() error path
tcp: select sane initial rcvq_space.space for big MSS
Evan Green (1):
soc: qcom: smp2p: Safely acquire spinlock without IRQs
Fabio Estevam (1):
usb: chipidea: ci_hdrc_imx: Pass DISABLE_DEVICE_STREAMING flag to
imx6ul
Fangrui Song (2):
x86/lib: Change .weak to SYM_FUNC_START_WEAK for
arch/x86/lib/mem*_64.S
arm64: Change .weak to SYM_FUNC_START_WEAK_PI for
arch/arm64/lib/mem*.S
Fugang Duan (2):
net: stmmac: free tx skb buffer in stmmac_resume()
net: stmmac: delete the eee_ctrl_timer after napi disabled
Geert Uytterhoeven (1):
clk: renesas: r9a06g032: Drop __packed for portability
Greg Kroah-Hartman (1):
Linux 4.19.164
Guenter Roeck (1):
watchdog: sirfsoc: Add missing dependency on HAS_IOMEM
H. Nikolaus Schaller (1):
ARM: dts: pandaboard: fix pinmux for gpio user button of Pandaboard ES
Hans de Goede (3):
platform/x86: thinkpad_acpi: Do not report SW_TABLET_MODE on Yoga 11e
platform/x86: thinkpad_acpi: Add BAT1 is primary battery quirk for
Thinkpad Yoga 11e 4th gen
power: supply: axp288_charger: Fix HP Pavilion x2 10 DMI matching
Hao Si (1):
soc: fsl: dpio: Get the cpumask through cpumask_of(cpu)
Hui Wang (1):
ACPI: PNP: compare the string length in the matching_id()
Ian Abbott (1):
staging: comedi: mf6x4: Fix AI end-of-conversion detection
Icenowy Zheng (1):
ARM: dts: sun8i: v3s: fix GIC node memory range
Jack Pham (1):
usb: gadget: f_fs: Re-use SS descriptors for SuperSpeedPlus
Jack Xu (1):
crypto: qat - fix status check in qat_hal_put_rel_rd_xfer()
James Morse (1):
x86/resctrl: Remove unused struct mbm_state::chunks_bw
James Smart (2):
scsi: lpfc: Fix invalid sleeping context in lpfc_sli4_nvmet_alloc()
scsi: lpfc: Re-fix use after free in lpfc_rq_buf_free()
Jan Kara (2):
quota: Sanity-check quota file headers on load
ext4: fix deadlock with fs freezing and EA inodes
Jason Gunthorpe (1):
vfio-pci: Use io_remap_pfn_range() for PCI IO memory
Jernej Skrabec (1):
clk: sunxi-ng: Make sure divider tables have sentinel
Jerome Brunet (1):
ASoC: meson: fix COMPILE_TEST error
Jing Xiangfeng (3):
staging: gasket: interrupt: fix the missed eventfd_ctx_put() in
gasket_interrupt.c
HSI: omap_ssi: Don't jump to free ID in ssi_add_controller()
memstick: r592: Fix error return in r592_probe()
Joel Stanley (1):
ARM: dts: aspeed: s2600wf: Fix VGA memory region location
Johan Hovold (9):
USB: serial: option: add interface-number sanity check to flag
handling
USB: serial: mos7720: fix parallel-port state restore
USB: serial: digi_acceleport: fix write-wakeup deadlocks
USB: serial: keyspan_pda: fix dropped unthrottle interrupts
USB: serial: keyspan_pda: fix write deadlock
USB: serial: keyspan_pda: fix stalled writes
USB: serial: keyspan_pda: fix write-wakeup use-after-free
USB: serial: keyspan_pda: fix tx-unthrottle use-after-free
USB: serial: keyspan_pda: fix write unthrottling
Johannes Berg (2):
iwlwifi: pcie: limit memory read spin time
mac80211: don't set set TDLS STA bandwidth wider than possible
Johannes Thumshirn (1):
block: factor out requeue handling from dispatch code
Jonathan Cameron (4):
iio:light:rpr0521: Fix timestamp alignment and prevent data leak.
iio:light:st_uvis25: Fix timestamp alignment and prevent data leak.
iio:pressure:mpl3115: Force alignment of buffer
iio:imu:bmi160: Fix too large a buffer.
Jordan Niethe (1):
powerpc/64: Set up a kernel stack for secondaries before cpu_restore()
Jubin Zhong (1):
PCI: Fix pci_slot_release() NULL pointer dereference
Julian Sax (1):
HID: i2c-hid: add Vero K147 to descriptor override
Kamal Heib (2):
RDMA/bnxt_re: Set queue pair state when being queried
RDMA/cxgb4: Validate the number of CQEs
Keita Suzuki (1):
media: siano: fix memory leak of debugfs members in smsdvb_hotplug
Keqian Zhu (1):
clocksource/drivers/arm_arch_timer: Correct fault programming of
CNTKCTL_EL1.EVNTI
Krzysztof Kozlowski (4):
ARM: dts: exynos: fix roles of USB 3.0 ports on Odroid XU
ARM: dts: exynos: fix USB 3.0 VBUS control and over-current pins on
Exynos5410
ARM: dts: exynos: fix USB 3.0 pins supply being turned off on Odroid
XU
drm/tve200: Fix handling of platform_get_irq() error
Leo Yan (2):
perf cs-etm: Change tuple from traceID-CPU# to traceID-metadata
perf cs-etm: Move definition of 'traceid_list' global variable from
header file
Leon Romanovsky (2):
RDMA/cm: Fix an attempt to use non-valid pointer when cleaning
timewait
net/mlx5: Properly convey driver version to firmware
Li Jun (1):
xhci: Give USB2 ports time to enter U3 in bus suspend
Lingling Xu (2):
watchdog: sprd: remove watchdog disable from resume fail path
watchdog: sprd: check busy bit before new loading rather than after
that
Lokesh Vutla (1):
pwm: lp3943: Dynamically allocate PWM chip base
Luc Van Oostenryck (1):
xsk: Fix xsk_poll()'s return type
Luis Henriques (1):
ceph: fix race in concurrent __ceph_remove_cap invocations
Lukas Wunner (8):
spi: bcm2835aux: Fix use-after-free on unbind
media: netup_unidvb: Don't leak SPI master in probe error path
spi: spi-sh: Fix use-after-free on unbind
spi: davinci: Fix use-after-free on unbind
spi: pic32: Don't leak DMA channels in probe error path
spi: rb4xx: Don't leak SPI master in probe error path
spi: sc18is602: Don't leak SPI master in probe error path
spi: st-ssc4: Fix unbalanced pm_runtime_disable() in probe error path
Manivannan Sadhasivam (1):
watchdog: qcom: Avoid context switch in restart handler
Mao Jinlong (1):
coresight: tmc-etr: Check if page is valid before dma_map_page()
Marc Zyngier (3):
genirq/irqdomain: Don't try to free an interrupt that has no mapping
irqchip/alpine-msi: Fix freeing of interrupts on allocation error path
KVM: arm64: Introduce handling of AArch32 TTBCR2 traps
Marek Szyprowski (1):
extcon: max77693: Fix modalias string
Mark Rutland (1):
arm64: syscall: exit userspace before unmasking exceptions
Markus Reichl (1):
arm64: dts: rockchip: Assign a fixed index to mmc devices on rk3399
boards.
Martin Blumenstingl (1):
net: stmmac: dwmac-meson8b: fix mask definition of the m250_sel mux
Martin Wilck (1):
scsi: core: Fix VPD LUN ID designator priorities
Masahiro Yamada (1):
kconfig: fix return value of do_error_if()
Masami Hiramatsu (1):
x86/kprobes: Restore BTF if the single-stepping is cancelled
Mathieu Desnoyers (1):
powerpc: Fix incorrect stw{, ux, u, x} instructions in __set_pte_at
Max Verevkin (1):
platform/x86: intel-vbtn: Support for tablet mode on HP Pavilion 13
x360 PC
Michael Ellerman (1):
powerpc: Drop -me200 addition to build flags
Miquel Raynal (1):
mtd: spinand: Fix OOB read
Moshe Shemesh (2):
net/mlx4_en: Avoid scheduling restart task if it is already running
net/mlx4_en: Handle TX error CQE
Nathan Chancellor (2):
spi: bcm2835aux: Restore err assignment in bcm2835aux_spi_probe
crypto: crypto4xx - Replace bitwise OR with logical OR in
crypto4xx_build_pd
Nathan Lynch (2):
powerpc/pseries/hibernation: drop pseries_suspend_begin() from suspend
ops
powerpc/pseries/hibernation: remove redundant cacheinfo update
Neal Cardwell (1):
tcp: fix cwnd-limited bug for TSO deferral where we send nothing
Necip Fazil Yildiran (1):
MIPS: BCM47XX: fix kconfig dependency bug for BCM47XX_BCMA
NeilBrown (1):
NFS: switch nfsiod to be an UNBOUND workqueue.
Nicholas Piggin (1):
kernel/cpu: add arch override for clear_tasks_mm_cpumask() mm handling
Nick Desaulniers (1):
Kbuild: do not emit debug info for assembly with LLVM_IAS=1
Nicolas Boichat (1):
soc: mediatek: Check if power domains can be powered on at boot time
Nicolas Ferre (1):
ARM: dts: at91: sama5d2: fix CAN message ram offset and size
Nicolin Chen (1):
soc/tegra: fuse: Fix index bug in get_process_id
Nuno Sá (1):
iio: buffer: Fix demux update
Oleksandr Andrushchenko (1):
drm/xen-front: Fix misused IS_ERR_OR_NULL checks
Oleksij Rempel (1):
Input: ads7846 - fix integer overflow on Rt calculation
Olga Kornievskaia (1):
NFSv4.2: condition READDIR's mask for security label based on LSM
state
Oliver Neukum (2):
USB: add RESET_RESUME quirk for Snapscan 1212
USB: UAS: introduce a quirk to set no_write_same
Pali Rohár (5):
cpufreq: highbank: Add missing MODULE_DEVICE_TABLE
cpufreq: mediatek: Add missing MODULE_DEVICE_TABLE
cpufreq: st: Add missing MODULE_DEVICE_TABLE
cpufreq: loongson1: Add missing MODULE_ALIAS
cpufreq: scpi: Add missing MODULE_ALIAS
Paul Kocialkowski (1):
ARM: sunxi: Add machine match for the Allwinner V3 SoC
Paul Moore (1):
selinux: fix inode_doinit_with_dentry() LABEL_INVALID error handling
Paweł Chmiel (2):
arm64: dts: exynos: Include common syscon restart/poweroff for Exynos7
arm64: dts: exynos: Correct psci compatible used on Exynos7
Peilin Ye (1):
Bluetooth: Fix slab-out-of-bounds read in
hci_le_direct_adv_report_evt()
Peng Liu (1):
sched/deadline: Fix sched_dl_global_validate()
Philipp Rudo (1):
s390/kexec_file: fix diag308 subcode when loading crash kernel
Praveenkumar I (1):
mtd: rawnand: qcom: Fix DMA sync on FLASH_STATUS register read
Qinglang Miao (11):
drm/tegra: sor: Disable clocks on error in tegra_sor_init()
spi: bcm63xx-hsspi: fix missing clk_disable_unprepare() on error in
bcm63xx_hsspi_resume
media: solo6x10: fix missing snd_card_free in error handling case
memstick: fix a double-free bug in memstick_check
cw1200: fix missing destroy_workqueue() on error in cw1200_init_common
mips: cdmm: fix use-after-free in mips_cdmm_bus_discover
platform/x86: dell-smbios-base: Fix error return code in
dell_smbios_init
dm ioctl: fix error return code in target_message
scsi: qedi: Fix missing destroy_workqueue() on error in __qedi_probe
spi: mt7621: fix missing clk_disable_unprepare() on error in
mt7621_spi_probe
iio: adc: rockchip_saradc: fix missing clk_disable_unprepare() on
error in rockchip_saradc_resume
Rafael J. Wysocki (1):
PM: ACPI: PCI: Drop acpi_pm_set_bridge_wakeup()
Rakesh Pillai (1):
ath10k: Fix the parsing error in service available event
Randy Dunlap (1):
scsi: bnx2i: Requires MMU
Richard Weinberger (1):
ubifs: wbuf: Don't leak kernel memory to flash
Roberto Sassu (1):
ima: Don't modify file descriptor mode on the fly
Sakari Ailus (5):
media: ipu3-cio2: Remove traces of returned buffers
media: ipu3-cio2: Return actual subdev format
media: ipu3-cio2: Serialise access to pad format
media: ipu3-cio2: Validate mbus format in setting subdev format
media: ipu3-cio2: Make the field on subdev format V4L2_FIELD_NONE
Sami Tolvanen (1):
arm64: lse: fix LSE atomics with LLVM's integrated assembler
Sara Sharon (2):
iwlwifi: mvm: fix kernel panic in case of assert during CSA
cfg80211: initialize rekey_data
Sean Young (1):
media: sunxi-cir: ensure IR is handled when it is continuous
Sebastian Andrzej Siewior (1):
orinoco: Move context allocation after processing the skb
Serge Hallyn (1):
fix namespaced fscaps when !CONFIG_SECURITY
Sergej Bauer (1):
lan743x: fix for potential NULL pointer dereference with bare card
Simon Beginn (1):
Input: goodix - add upside-down quirk for Teclast X98 Pro tablet
Sreekanth Reddy (1):
scsi: mpt3sas: Increase IOCInit request timeout to 30s
Stefan Haberland (4):
s390/dasd: fix hanging device offline processing
s390/dasd: prevent inconsistent LCU device data
s390/dasd: fix list corruption of pavgroup group list
s390/dasd: fix list corruption of lcu list
Steve French (2):
SMB3: avoid confusing warning message on mount to Azure
SMB3.1.1: do not log warning message if server doesn't populate salt
Steven Rostedt (VMware) (1):
ktest.pl: If size of log is too big to email, email error message
Subash Abhinov Kasiviswanathan (1):
netfilter: x_tables: Switch synchronization to RCU
Sven Eckelmann (3):
vxlan: Add needed_headroom for lower device
vxlan: Copy needed_tailroom from lowerdev
mtd: parser: cmdline: Fix parsing of part-names with colons
Sven Schnelle (1):
s390/smp: perform initial CPU reset also for SMT siblings
Takashi Iwai (7):
ALSA: usb-audio: Fix potential out-of-bounds shift
ALSA: usb-audio: Fix control 'access overflow' errors from chmap
ALSA: pcm: oss: Fix potential out-of-bounds shift
ALSA: hda: Fix regressions on clear and reconfig sysfs
ALSA: pcm: oss: Fix a few more UBSAN fixes
ALSA: hda/realtek: Add quirk for MSI-GP73
ALSA: usb-audio: Disable sample read check if firmware doesn't give
back
Terry Zhou (1):
clk: mvebu: a3700: fix the XTAL MODE pin to MPP1_9
Thomas Gleixner (4):
x86/apic/vector: Fix ordering in vector assignment
USB: sisusbvga: Make console support depend on BROKEN
dm table: Remove BUG_ON(in_interrupt())
sched: Reenable interrupts in do_sched_yield()
Tianyue Ren (1):
selinux: fix error initialization in inode_doinit_with_dentry()
Timo Witte (1):
platform/x86: acer-wmi: add automatic keyboard background light toggle
key as KEY_LIGHTS_TOGGLE
Toke Høiland-Jørgensen (1):
selftests/bpf/test_offload.py: Reset ethtool features after failed
setting
Tom Rix (1):
drm/gma500: fix double free of gma_connector
Trond Myklebust (1):
SUNRPC: xprt_load_transport() needs to support the netid "rdma6"
Tsuchiya Yuto (1):
mwifiex: fix mwifiex_shutdown_sw() causing sw reset failure
Tyrel Datwyler (1):
powerpc/rtas: Fix typo of ibm,open-errinjct in RTAS filter
Uwe Kleine-König (2):
spi: fix resource leak for drivers without .remove callback
pwm: zx: Add missing cleanup in error path
Vadim Pasternak (3):
platform/x86: mlx-platform: Remove PSU EEPROM from default platform
configuration
platform/x86: mlx-platform: Remove PSU EEPROM from MSN274x platform
configuration
platform/x86: mlx-platform: Fix item counter assignment for MSN2700,
MSN24xx systems
Vincent Stehlé (2):
powerpc/ps3: use dma_mapping_error()
net: korina: fix return value
Vincenzo Frascino (1):
arm64: lse: Fix LSE atomics with LLVM
Vineet Gupta (1):
ARC: stack unwinding: don't assume non-current task is sleeping
Wang Wensheng (1):
watchdog: Fix potential dereferencing of null pointer
Will McVicker (2):
USB: gadget: f_midi: setup SuperSpeed Plus descriptors
USB: gadget: f_rndis: fix bitrate for SuperSpeed and above
Xiaochen Shen (1):
x86/resctrl: Fix incorrect local bandwidth when mba_sc is enabled
Xin Xiong (1):
drm: fix drm_dp_mst_port refcount leaks in drm_dp_mst_allocate_vcpi
Yang Yingliang (4):
video: fbdev: atmel_lcdfb: fix return error code in
atmel_lcdfb_of_init()
drm/omap: dmm_tiler: fix return error code in omap_dmm_probe()
usb/max3421: fix return error code in max3421_probe()
speakup: fix uninitialized flush_lock
Yangtao Li (1):
pinctrl: sunxi: Always call chained_irq_{enter, exit} in
sunxi_pinctrl_irq_handler
Yu Kuai (3):
media: mtk-vcodec: add missing put_device() call in
mtk_vcodec_release_dec_pm()
clocksource/drivers/cadence_ttc: Fix memory leak in
ttc_setup_clockevent()
pinctrl: falcon: add missing put_device() call in
pinctrl_falcon_probe()
Zhang Changzhong (3):
net: bridge: vlan: fix error return code in __vlan_add()
scsi: fnic: Fix error return code in fnic_probe()
bus: fsl-mc: fix error return code in fsl_mc_object_allocate()
Zhang Qilong (20):
can: softing: softing_netdev_open(): fix error handling
spi: img-spfi: fix reference leak in img_spfi_resume
spi: spi-ti-qspi: fix reference leak in ti_qspi_setup
spi: tegra20-slink: fix reference leak in slink ops of tegra20
spi: tegra20-sflash: fix reference leak in tegra_sflash_resume
spi: tegra114: fix reference leak in tegra spi ops
ASoC: wm8998: Fix PM disable depth imbalance on error
ASoC: arizona: Fix a wrong free in wm8997_probe
staging: greybus: codecs: Fix reference counter leak in error handling
spi: mxs: fix reference leak in mxs_spi_probe
crypto: omap-aes - Fix PM disable depth imbalance in omap_aes_probe
soc: ti: knav_qmss: fix reference leak in knav_queue_probe
soc: ti: Fix reference imbalance in knav_dma_probe
Input: omap4-keypad - fix runtime PM error handling
power: supply: bq24190_charger: fix reference leak
scsi: pm80xx: Fix error return in pm8001_pci_probe()
usb: ehci-omap: Fix PM disable depth umbalance in ehci_hcd_omap_probe
usb: oxu210hp-hcd: Fix memory leak in oxu_create
libnvdimm/label: Return -ENXIO for no slot in __blk_label_update
clk: ti: Fix memleak in ti_fapll_synth_setup
Zhao Heming (2):
md/cluster: block reshape with remote resync job
md/cluster: fix deadlock when node is doing resync job
Zhe Li (1):
jffs2: Fix GC exit abnormally
Zheng Zengkai (1):
perf record: Fix memory leak when using '--user-regs=?' to list
registers
Zhihao Cheng (2):
drivers: soc: ti: knav_qmss_queue: Fix error return code in
knav_queue_probe
dmaengine: mv_xor_v2: Fix error return code in mv_xor_v2_probe()
Zwane Mwaikambo (1):
drm/dp_aux_dev: check aux_dev before use in
drm_dp_aux_dev_get_by_minor()
kazuo ito (1):
nfsd: Fix message level for normal termination
taehyun.cho (1):
USB: gadget: f_acm: add support for SuperSpeed Plus
.../admin-guide/kernel-parameters.txt | 1 +
Makefile | 5 +-
arch/arc/kernel/stacktrace.c | 23 ++--
arch/arm/boot/dts/armada-xp-98dx3236.dtsi | 5 -
.../arm/boot/dts/aspeed-bmc-intel-s2600wf.dts | 4 +-
arch/arm/boot/dts/at91-sama5d3_xplained.dts | 7 +
arch/arm/boot/dts/at91-sama5d4_xplained.dts | 7 +
arch/arm/boot/dts/at91sam9rl.dtsi | 19 +--
arch/arm/boot/dts/exynos5410-odroidxu.dts | 6 +-
arch/arm/boot/dts/exynos5410-pinctrl.dtsi | 28 ++++
arch/arm/boot/dts/exynos5410.dtsi | 4 +
arch/arm/boot/dts/omap4-panda-es.dts | 2 +-
arch/arm/boot/dts/sama5d2.dtsi | 7 +-
arch/arm/boot/dts/sun8i-v3s.dtsi | 2 +-
arch/arm/kernel/head.S | 6 +-
arch/arm/mach-shmobile/pm-rmobile.c | 1 +
arch/arm/mach-sunxi/sunxi.c | 1 +
.../dts/amlogic/meson-gxm-khadas-vim2.dts | 2 +-
arch/arm64/boot/dts/exynos/exynos7.dtsi | 12 +-
.../arm64/boot/dts/rockchip/rk3328-roc-cc.dts | 1 +
arch/arm64/boot/dts/rockchip/rk3328.dtsi | 16 +--
arch/arm64/boot/dts/rockchip/rk3399.dtsi | 3 +
arch/arm64/include/asm/atomic_lse.h | 76 ++++++++---
arch/arm64/include/asm/kvm_host.h | 1 +
arch/arm64/include/asm/lse.h | 6 +-
arch/arm64/kernel/syscall.c | 2 +-
arch/arm64/kvm/sys_regs.c | 1 +
arch/arm64/lib/memcpy.S | 3 +-
arch/arm64/lib/memmove.S | 3 +-
arch/arm64/lib/memset.S | 3 +-
arch/mips/bcm47xx/Kconfig | 1 +
arch/powerpc/Makefile | 1 -
arch/powerpc/include/asm/book3s/32/pgtable.h | 4 +-
arch/powerpc/include/asm/cputable.h | 5 -
arch/powerpc/include/asm/nohash/pgtable.h | 4 +-
arch/powerpc/kernel/head_64.S | 8 +-
arch/powerpc/kernel/rtas.c | 2 +-
arch/powerpc/kernel/setup-common.c | 4 +-
arch/powerpc/perf/core-book3s.c | 10 ++
arch/powerpc/platforms/powernv/memtrace.c | 44 +++++-
arch/powerpc/platforms/pseries/suspend.c | 4 -
arch/powerpc/xmon/nonstdio.c | 2 +-
arch/s390/kernel/smp.c | 18 +--
arch/s390/purgatory/head.S | 9 +-
arch/um/drivers/chan_user.c | 4 +-
arch/um/drivers/xterm.c | 5 +
arch/um/os-Linux/irq.c | 2 +-
arch/x86/include/asm/apic.h | 1 +
arch/x86/include/asm/pgtable_types.h | 1 +
arch/x86/include/asm/sync_core.h | 9 +-
arch/x86/kernel/apic/apic.c | 14 +-
arch/x86/kernel/apic/vector.c | 24 ++--
arch/x86/kernel/apic/x2apic_phys.c | 9 ++
arch/x86/kernel/cpu/intel_rdt.h | 2 -
arch/x86/kernel/cpu/intel_rdt_monitor.c | 7 +-
arch/x86/kernel/kprobes/core.c | 5 +
arch/x86/lib/memcpy_64.S | 6 +-
arch/x86/lib/memmove_64.S | 4 +-
arch/x86/lib/memset_64.S | 6 +-
arch/x86/mm/ident_map.c | 12 +-
arch/x86/mm/mem_encrypt_identity.c | 4 +-
arch/x86/mm/tlb.c | 10 +-
block/blk-mq.c | 29 ++--
crypto/af_alg.c | 10 +-
crypto/ecdh.c | 9 +-
drivers/acpi/acpi_pnp.c | 3 +
drivers/acpi/device_pm.c | 41 ++----
drivers/acpi/resource.c | 2 +-
drivers/bluetooth/hci_h5.c | 3 +
drivers/bus/fsl-mc/fsl-mc-allocator.c | 4 +-
drivers/bus/mips_cdmm.c | 4 +-
drivers/clk/clk-s2mps11.c | 1 +
drivers/clk/mvebu/armada-37xx-xtal.c | 4 +-
drivers/clk/renesas/r9a06g032-clocks.c | 2 +-
drivers/clk/sunxi-ng/ccu-sun50i-a64.c | 1 +
drivers/clk/sunxi-ng/ccu-sun8i-h3.c | 1 +
drivers/clk/tegra/clk-id.h | 1 +
drivers/clk/tegra/clk-tegra-periph.c | 2 +-
drivers/clk/ti/fapll.c | 11 +-
drivers/clocksource/arm_arch_timer.c | 23 +++-
drivers/clocksource/cadence_ttc_timer.c | 18 +--
drivers/cpufreq/highbank-cpufreq.c | 7 +
drivers/cpufreq/loongson1-cpufreq.c | 1 +
drivers/cpufreq/mediatek-cpufreq.c | 1 +
drivers/cpufreq/scpi-cpufreq.c | 1 +
drivers/cpufreq/sti-cpufreq.c | 7 +
drivers/crypto/amcc/crypto4xx_core.c | 2 +-
drivers/crypto/inside-secure/safexcel.c | 2 +-
drivers/crypto/omap-aes.c | 3 +-
drivers/crypto/qat/qat_common/qat_hal.c | 2 +-
drivers/crypto/talitos.c | 10 +-
drivers/dma/mv_xor_v2.c | 4 +-
drivers/edac/amd64_edac.c | 26 ++--
drivers/extcon/extcon-max77693.c | 2 +-
drivers/gpio/gpio-eic-sprd.c | 2 +-
drivers/gpio/gpio-mvebu.c | 16 ++-
drivers/gpu/drm/drm_dp_aux_dev.c | 2 +-
drivers/gpu/drm/drm_dp_mst_topology.c | 7 +-
drivers/gpu/drm/gma500/cdv_intel_dp.c | 2 +-
drivers/gpu/drm/msm/dsi/pll/dsi_pll_10nm.c | 8 ++
drivers/gpu/drm/omapdrm/omap_dmm_tiler.c | 1 +
drivers/gpu/drm/tegra/drm.c | 2 +-
drivers/gpu/drm/tegra/sor.c | 10 +-
drivers/gpu/drm/tve200/tve200_drv.c | 4 +-
drivers/gpu/drm/xen/xen_drm_front.c | 2 +-
drivers/gpu/drm/xen/xen_drm_front_gem.c | 8 +-
drivers/gpu/drm/xen/xen_drm_front_kms.c | 2 +-
drivers/hid/i2c-hid/i2c-hid-dmi-quirks.c | 8 ++
drivers/hsi/controllers/omap_ssi_core.c | 2 +-
.../hwtracing/coresight/coresight-tmc-etr.c | 2 +
drivers/iio/adc/rockchip_saradc.c | 2 +-
drivers/iio/imu/bmi160/bmi160_core.c | 4 +-
drivers/iio/industrialio-buffer.c | 6 +-
drivers/iio/light/rpr0521.c | 17 ++-
drivers/iio/light/st_uvis25.h | 5 +
drivers/iio/light/st_uvis25_core.c | 8 +-
drivers/iio/pressure/mpl3115.c | 9 +-
drivers/infiniband/core/cm.c | 2 +
drivers/infiniband/hw/bnxt_re/ib_verbs.c | 1 +
drivers/infiniband/hw/cxgb4/cq.c | 3 +
drivers/infiniband/hw/mthca/mthca_cq.c | 2 +-
drivers/infiniband/hw/mthca/mthca_dev.h | 1 -
drivers/infiniband/sw/rxe/rxe_req.c | 3 +-
drivers/input/keyboard/cros_ec_keyb.c | 1 +
drivers/input/keyboard/omap4-keypad.c | 89 ++++++++-----
drivers/input/misc/cm109.c | 7 +-
drivers/input/mouse/cyapa_gen6.c | 2 +-
drivers/input/serio/i8042-x86ia64io.h | 42 ++++++
drivers/input/touchscreen/ads7846.c | 52 +++++---
drivers/input/touchscreen/goodix.c | 12 ++
drivers/irqchip/irq-alpine-msi.c | 3 +-
drivers/md/dm-ioctl.c | 1 +
drivers/md/dm-table.c | 6 -
drivers/md/md-cluster.c | 67 ++++++----
drivers/md/md.c | 21 ++-
drivers/media/common/siano/smsdvb-main.c | 5 +-
drivers/media/i2c/max2175.c | 2 +-
drivers/media/pci/intel/ipu3/ipu3-cio2.c | 62 +++++----
drivers/media/pci/intel/ipu3/ipu3-cio2.h | 1 +
.../media/pci/netup_unidvb/netup_unidvb_spi.c | 5 +-
drivers/media/pci/saa7146/mxb.c | 19 +--
drivers/media/pci/solo6x10/solo6x10-g723.c | 2 +-
.../platform/mtk-vcodec/mtk_vcodec_dec_pm.c | 1 +
drivers/media/rc/sunxi-cir.c | 2 +
drivers/media/usb/gspca/gspca.c | 1 +
drivers/media/usb/msi2500/msi2500.c | 2 +-
drivers/media/usb/tm6000/tm6000-video.c | 5 +-
drivers/memstick/core/memstick.c | 1 -
drivers/memstick/host/r592.c | 12 +-
drivers/mmc/core/block.c | 2 +-
drivers/mtd/cmdlinepart.c | 14 +-
drivers/mtd/nand/raw/qcom_nandc.c | 2 +
drivers/mtd/nand/spi/core.c | 4 +
drivers/net/can/softing/softing_main.c | 9 +-
drivers/net/ethernet/allwinner/sun4i-emac.c | 7 +-
.../net/ethernet/broadcom/genet/bcmgenet.c | 4 +-
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 24 +++-
drivers/net/ethernet/korina.c | 2 +-
.../net/ethernet/mellanox/mlx4/en_netdev.c | 21 ++-
drivers/net/ethernet/mellanox/mlx4/en_tx.c | 40 +++++-
drivers/net/ethernet/mellanox/mlx4/mlx4_en.h | 12 +-
.../net/ethernet/mellanox/mlx5/core/main.c | 6 +-
.../net/ethernet/microchip/lan743x_ethtool.c | 9 +-
.../net/ethernet/qlogic/qlcnic/qlcnic_main.c | 1 +
.../ethernet/stmicro/stmmac/dwmac-meson8b.c | 6 +-
.../net/ethernet/stmicro/stmmac/stmmac_main.c | 27 +++-
drivers/net/vxlan.c | 3 +
drivers/net/wireless/ath/ath10k/usb.c | 7 +-
drivers/net/wireless/ath/ath10k/wmi-tlv.c | 4 +-
drivers/net/wireless/ath/ath10k/wmi.c | 9 +-
drivers/net/wireless/ath/ath10k/wmi.h | 1 +
.../net/wireless/intel/iwlwifi/mvm/mac80211.c | 2 +-
.../net/wireless/intel/iwlwifi/pcie/trans.c | 36 +++--
.../wireless/intersil/orinoco/orinoco_usb.c | 14 +-
drivers/net/wireless/marvell/mwifiex/main.c | 2 +
drivers/net/wireless/st/cw1200/main.c | 2 +
drivers/nfc/s3fwrn5/firmware.c | 4 +-
drivers/nvdimm/label.c | 13 +-
drivers/pci/controller/dwc/pcie-qcom.c | 12 ++
drivers/pci/controller/pcie-iproc.c | 10 +-
drivers/pci/pci-acpi.c | 4 +-
drivers/pci/pci.c | 14 +-
drivers/pci/slot.c | 6 +-
drivers/pinctrl/intel/pinctrl-baytrail.c | 8 +-
drivers/pinctrl/intel/pinctrl-merrifield.c | 8 ++
drivers/pinctrl/pinctrl-amd.c | 7 -
drivers/pinctrl/pinctrl-falcon.c | 14 +-
drivers/pinctrl/sunxi/pinctrl-sunxi.c | 6 +-
drivers/platform/x86/acer-wmi.c | 1 +
drivers/platform/x86/dell-smbios-base.c | 1 +
drivers/platform/x86/intel-vbtn.c | 12 ++
drivers/platform/x86/mlx-platform.c | 27 +---
drivers/platform/x86/thinkpad_acpi.c | 10 +-
drivers/power/supply/axp288_charger.c | 28 ++--
drivers/power/supply/bq24190_charger.c | 20 ++-
drivers/ps3/ps3stor_lib.c | 2 +-
drivers/pwm/pwm-lp3943.c | 1 +
drivers/pwm/pwm-zx.c | 1 +
drivers/s390/block/dasd_alias.c | 22 ++-
drivers/scsi/be2iscsi/be_main.c | 4 +-
drivers/scsi/bnx2i/Kconfig | 1 +
drivers/scsi/fnic/fnic_main.c | 1 +
drivers/scsi/lpfc/lpfc_mem.c | 6 +-
drivers/scsi/lpfc/lpfc_sli.c | 10 +-
drivers/scsi/megaraid/megaraid_sas_base.c | 16 ++-
drivers/scsi/mpt3sas/mpt3sas_base.c | 2 +-
drivers/scsi/pm8001/pm8001_init.c | 3 +-
drivers/scsi/qedi/qedi_main.c | 4 +-
drivers/scsi/scsi_lib.c | 126 ++++++++++++------
drivers/scsi/ufs/ufshcd.c | 7 +
drivers/slimbus/qcom-ngd-ctrl.c | 6 +
drivers/soc/fsl/dpio/dpio-driver.c | 5 +-
drivers/soc/mediatek/mtk-scpsys.c | 5 +-
drivers/soc/qcom/qcom-geni-se.c | 17 ++-
drivers/soc/qcom/smp2p.c | 5 +-
drivers/soc/tegra/fuse/speedo-tegra210.c | 2 +-
drivers/soc/ti/knav_dma.c | 13 +-
drivers/soc/ti/knav_qmss_queue.c | 4 +-
drivers/spi/spi-bcm2835aux.c | 17 +--
drivers/spi/spi-bcm63xx-hsspi.c | 4 +-
drivers/spi/spi-davinci.c | 2 +-
drivers/spi/spi-img-spfi.c | 4 +-
drivers/spi/spi-mxs.c | 1 +
drivers/spi/spi-pic32.c | 1 +
drivers/spi/spi-rb4xx.c | 2 +-
drivers/spi/spi-sc18is602.c | 13 +-
drivers/spi/spi-sh.c | 13 +-
drivers/spi/spi-st-ssc4.c | 5 +-
drivers/spi/spi-tegra114.c | 2 +
drivers/spi/spi-tegra20-sflash.c | 1 +
drivers/spi/spi-tegra20-slink.c | 2 +
drivers/spi/spi-ti-qspi.c | 1 +
drivers/spi/spi.c | 19 +--
drivers/staging/comedi/drivers/mf6x4.c | 3 +-
drivers/staging/gasket/gasket_interrupt.c | 15 ++-
drivers/staging/greybus/audio_codec.c | 2 +
drivers/staging/mt7621-spi/spi-mt7621.c | 2 +
drivers/staging/speakup/speakup_dectlk.c | 2 +-
drivers/tty/serial/8250/8250_omap.c | 5 -
drivers/tty/serial/serial_core.c | 4 +
drivers/usb/chipidea/ci_hdrc_imx.c | 3 +-
drivers/usb/core/quirks.c | 3 +
drivers/usb/gadget/function/f_acm.c | 2 +-
drivers/usb/gadget/function/f_fs.c | 5 +-
drivers/usb/gadget/function/f_midi.c | 6 +
drivers/usb/gadget/function/f_rndis.c | 4 +-
drivers/usb/gadget/udc/dummy_hcd.c | 2 +-
drivers/usb/host/ehci-omap.c | 1 +
drivers/usb/host/max3421-hcd.c | 3 +-
drivers/usb/host/oxu210hp-hcd.c | 4 +-
drivers/usb/host/xhci-hub.c | 4 +
drivers/usb/misc/sisusbvga/Kconfig | 2 +-
drivers/usb/serial/digi_acceleport.c | 45 ++-----
drivers/usb/serial/keyspan_pda.c | 63 +++++----
drivers/usb/serial/mos7720.c | 2 +
drivers/usb/serial/option.c | 23 +++-
drivers/usb/storage/uas.c | 3 +
drivers/usb/storage/unusual_uas.h | 7 +-
drivers/usb/storage/usb.c | 3 +
drivers/vfio/pci/vfio_pci.c | 4 +-
drivers/video/fbdev/atmel_lcdfb.c | 2 +-
drivers/watchdog/Kconfig | 3 +-
drivers/watchdog/qcom-wdt.c | 2 +-
drivers/watchdog/sprd_wdt.c | 34 +++--
drivers/watchdog/watchdog_core.c | 22 +--
fs/ceph/caps.c | 11 +-
fs/cifs/smb2ops.c | 3 +-
fs/cifs/smb2pdu.c | 7 +-
fs/cifs/smb2pdu.h | 14 +-
fs/ext4/inode.c | 19 ++-
fs/ext4/mballoc.c | 1 +
fs/jffs2/readinode.c | 16 +++
fs/lockd/host.c | 20 +--
fs/nfs/inode.c | 2 +-
fs/nfs/nfs4proc.c | 10 +-
fs/nfs_common/grace.c | 6 +-
fs/nfsd/nfssvc.c | 3 +-
fs/quota/quota_v2.c | 19 +++
fs/ubifs/io.c | 13 +-
include/acpi/acpi_bus.h | 5 -
include/linux/build_bug.h | 5 +
include/linux/compiler-clang.h | 1 -
include/linux/compiler-gcc.h | 19 ---
include/linux/compiler.h | 18 ++-
include/linux/netfilter/x_tables.h | 5 +-
include/linux/security.h | 2 +-
include/linux/seq_buf.h | 2 +-
include/linux/sunrpc/xprt.h | 1 +
include/linux/trace_seq.h | 4 +-
include/linux/usb_usual.h | 2 +
include/uapi/linux/if_alg.h | 16 +++
kernel/cpu.c | 6 +-
kernel/irq/irqdomain.c | 11 +-
kernel/sched/core.c | 6 +-
kernel/sched/deadline.c | 5 +-
kernel/sched/sched.h | 42 +++---
net/bluetooth/hci_event.c | 17 ++-
net/bridge/br_vlan.c | 4 +-
net/core/lwt_bpf.c | 8 +-
net/ipv4/netfilter/arp_tables.c | 14 +-
net/ipv4/netfilter/ip_tables.c | 14 +-
net/ipv4/tcp_input.c | 3 +-
net/ipv4/tcp_output.c | 9 +-
net/ipv6/netfilter/ip6_tables.c | 14 +-
net/mac80211/mesh_pathtbl.c | 4 +-
net/mac80211/vht.c | 14 +-
net/netfilter/x_tables.c | 49 +++----
net/sunrpc/xprt.c | 65 ++++++---
net/sunrpc/xprtrdma/module.c | 1 +
net/sunrpc/xprtrdma/transport.c | 1 +
net/sunrpc/xprtsock.c | 4 +
net/wireless/nl80211.c | 2 +-
net/xdp/xsk.c | 8 +-
samples/bpf/lwt_len_hist.sh | 2 +
samples/bpf/test_lwt_bpf.sh | 0
scripts/checkpatch.pl | 2 +-
scripts/kconfig/preprocess.c | 2 +-
security/integrity/ima/ima_crypto.c | 20 +--
security/selinux/hooks.c | 16 ++-
sound/core/oss/pcm_oss.c | 28 ++--
sound/pci/hda/hda_codec.c | 2 +-
sound/pci/hda/hda_sysfs.c | 2 +-
sound/pci/hda/patch_ca0132.c | 2 +-
sound/pci/hda/patch_realtek.c | 4 +
sound/soc/codecs/wm8997.c | 2 +
sound/soc/codecs/wm8998.c | 4 +-
sound/soc/codecs/wm_adsp.c | 5 +-
sound/soc/jz4740/jz4740-i2s.c | 4 +
sound/soc/meson/Kconfig | 2 +-
sound/soc/soc-pcm.c | 2 +
sound/usb/clock.c | 6 +
sound/usb/format.c | 2 +
sound/usb/quirks.c | 1 +
sound/usb/stream.c | 6 +-
.../perf/util/cs-etm-decoder/cs-etm-decoder.c | 8 +-
tools/perf/util/cs-etm.c | 29 +++-
tools/perf/util/cs-etm.h | 10 +-
tools/perf/util/parse-regs-options.c | 2 +-
tools/testing/ktest/ktest.pl | 7 +-
tools/testing/selftests/bpf/test_offload.py | 1 +
340 files changed, 2021 insertions(+), 1084 deletions(-)
mode change 100644 => 100755 samples/bpf/lwt_len_hist.sh
mode change 100644 => 100755 samples/bpf/test_lwt_bpf.sh
--
2.25.1
1
337

[PATCH v2 1/1 openEuler-1.0-LTS] fork: add pid recover method for checkpoint and recover
by hejingxian 31 Dec '20
by hejingxian 31 Dec '20
31 Dec '20
From: hejingxian <hejingxian(a)huawei.com>
Date: Thu, 31 Dec 2020 20:18:56 +0800
Subject: [PATCH v2 1/1 openEuler-1.0-LTS] fork: add pid recover method for checkpoint and recover
We record the pid of dump task in the reserved memory, and reserve the pids before
init task start. In the recover process, set the fork_pid of the recovery task before
call fork(). And then the fork_pid will be used to alloc pid.
/proc/sys/kernel/ns_last_pid can also be used to fork child task with assigned pid.
However, when there exist many tasks need to recover at the same time, we will fail to
recover pids by using /proc/sys/kernel/ns_last_pid.
Signed-off-by: Jingxian He <hejingxian(a)huawei.com>
---
drivers/char/pin_memory.c | 24 +++++++++++++++++++++-
include/linux/pin_mem.h | 6 ++++++
include/linux/sched.h | 9 +++++++++
init/init_task.c | 3 +++
kernel/pid.c | 33 ++++++++++++++++++++++++++++++
mm/Kconfig | 7 +++++++
mm/pin_mem.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++
7 files changed, 132 insertions(+), 1 deletion(-)
diff --git a/drivers/char/pin_memory.c b/drivers/char/pin_memory.c
index a0464e1..2c65de7 100644
--- a/drivers/char/pin_memory.c
+++ b/drivers/char/pin_memory.c
@@ -36,9 +36,12 @@ struct pin_mem_area_set {
#define _SET_PIN_MEM_AREA 1
#define _CLEAR_PIN_MEM_AREA 2
#define _REMAP_PIN_MEM_AREA 3
+#define _SET_FORK_PID 4
+
#define SET_PIN_MEM_AREA _IOW(PIN_MEM_MAGIC, _SET_PIN_MEM_AREA, struct pin_mem_area_set)
#define CLEAR_PIN_MEM_AREA _IOW(PIN_MEM_MAGIC, _CLEAR_PIN_MEM_AREA, int)
#define REMAP_PIN_MEM_AREA _IOW(PIN_MEM_MAGIC, _REMAP_PIN_MEM_AREA, int)
+#define SET_FORK_PID _IOW(PIN_MEM_MAGIC, _SET_FORK_PID, int)
static int set_pin_mem(struct pin_mem_area_set *pmas)
{
@@ -136,13 +139,29 @@ static int pin_mem_remap(unsigned long arg)
return -EFAULT;
}
+static int set_fork_pid(unsigned long arg)
+{
+ int pid;
+ struct page_map_info * pmi = NULL;
+ void __user *buf = (void __user *)arg;
+
+ if (!access_ok(buf, sizeof(int)))
+ goto fault;
+ if (copy_from_user(&pid, buf, sizeof(int)))
+ goto fault;
+ current->fork_pid = pid;
+ return 0;
+fault:
+ return -EFAULT;
+}
+
static long pin_memory_ioctl(struct file *file, unsigned cmd, unsigned long arg)
{
long ret = 0;
if (_IOC_TYPE(cmd) != PIN_MEM_MAGIC)
return -EINVAL;
- if (_IOC_NR(cmd) > _REMAP_PIN_MEM_AREA)
+ if (_IOC_NR(cmd) > _SET_FORK_PID)
return -EINVAL;
switch (cmd) {
@@ -155,6 +174,9 @@ static long pin_memory_ioctl(struct file *file, unsigned cmd, unsigned long arg)
case REMAP_PIN_MEM_AREA:
ret = pin_mem_remap(arg);
break;
+ case SET_FORK_PID:
+ ret = set_fork_pid(arg);
+ break;
default:
return -EINVAL;
}
diff --git a/include/linux/pin_mem.h b/include/linux/pin_mem.h
index 997ddb8..f47dab4 100644
--- a/include/linux/pin_mem.h
+++ b/include/linux/pin_mem.h
@@ -58,5 +58,11 @@ extern vm_fault_t do_anon_huge_page_remap(struct vm_area_struct *vma, unsigned l
#endif
extern void init_reserve_page_map(unsigned long map_addr, unsigned long map_size);
+#ifdef CONFIG_PID_RECOVER
+extern bool is_need_reserve_pids(void);
+extern void reserve_pids(struct idr *idr, int pid_max);
+extern void free_reserved_pid(struct idr *idr, int pid);
+#endif
+
#endif /* CONFIG_PIN_MEMORY */
#endif /* _LINUX_PIN_MEMORY_H */
diff --git a/include/linux/sched.h b/include/linux/sched.h
index ced2d7f..3d23e46 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1220,7 +1220,16 @@ struct task_struct {
KABI_RESERVE(1)
KABI_RESERVE(2)
#endif
+#ifdef CONFIG_PID_RECOVER
+#ifndef __GENKSYMS__
+ int fork_pid;
+ int reserve;
+#else
KABI_RESERVE(3)
+#endif
+#else
+ KABI_RESERVE(3)
+#endif
KABI_RESERVE(4)
KABI_RESERVE(5)
KABI_RESERVE(6)
diff --git a/init/init_task.c b/init/init_task.c
index 5aebe3b..0334ad8 100644
--- a/init/init_task.c
+++ b/init/init_task.c
@@ -179,6 +179,9 @@ struct task_struct init_task
#ifdef CONFIG_SECURITY
.security = NULL,
#endif
+#ifdef CONFIG_PID_RECOVER
+ .fork_pid = 0,
+#endif
};
EXPORT_SYMBOL(init_task);
diff --git a/kernel/pid.c b/kernel/pid.c
index bfdcd16..5d02591 100644
--- a/kernel/pid.c
+++ b/kernel/pid.c
@@ -41,6 +41,9 @@
#include <linux/sched/task.h>
#include <linux/idr.h>
#include <linux/kmemleak.h>
+#ifdef CONFIG_PID_RECOVER
+#include <linux/pin_mem.h>
+#endif
struct pid init_struct_pid = {
.count = ATOMIC_INIT(1),
@@ -185,6 +188,31 @@ struct pid *alloc_pid(struct pid_namespace *ns)
if (idr_get_cursor(&tmp->idr) > RESERVED_PIDS)
pid_min = RESERVED_PIDS;
+#ifdef CONFIG_PID_RECOVER
+ if (!current->fork_pid) {
+ /*
+ * Store a null pointer so find_pid_ns does not find
+ * a partially initialized PID (see below).
+ */
+ nr = idr_alloc_cyclic(&tmp->idr, NULL, pid_min,
+ tmp->pid_max,
+ GFP_ATOMIC);
+ } else {
+ /* Try to use fork_pid to alloc pid, and change to use the default way after fail. */
+ test_pid_reserved_and_free(&tmp->idr, current->fork_pid);
+ pid_min = current->fork_pid;
+ current->fork_pid = 0;
+ nr = idr_alloc(&tmp->idr, NULL, pid_min,
+ tmp->pid_max,
+ GFP_ATOMIC);
+ pr_debug("Alloc pid by fork_pid ret: %d.", nr);
+ if (nr < 0)
+ nr = idr_alloc_cyclic(&tmp->idr, NULL, pid_min,
+ tmp->pid_max,
+ GFP_ATOMIC);
+ }
+#else
+
/*
* Store a null pointer so find_pid_ns does not find
* a partially initialized PID (see below).
@@ -192,6 +220,7 @@ struct pid *alloc_pid(struct pid_namespace *ns)
nr = idr_alloc_cyclic(&tmp->idr, NULL, pid_min,
tmp->pid_max,
GFP_ATOMIC);
+#endif
spin_unlock_irq(&pidmap_lock);
idr_preload_end();
@@ -500,6 +529,10 @@ void __init pid_idr_init(void)
init_pid_ns.pid_cachep = KMEM_CACHE(pid,
SLAB_HWCACHE_ALIGN | SLAB_PANIC | SLAB_ACCOUNT);
+#ifdef CONFIG_PID_RECOVER
+ if (is_need_reserve_pids())
+ reserve_pids(&init_pid_ns.idr, pid_max);
+#endif
hdr = register_sysctl_paths(pid_kern_path, pid_ctl_table);
kmemleak_not_leak(hdr);
diff --git a/mm/Kconfig b/mm/Kconfig
index 31fa670..9ac20da 100644
--- a/mm/Kconfig
+++ b/mm/Kconfig
@@ -794,4 +794,11 @@ config PIN_MEMORY
help
Say y here to enable the pin memory feature for checkpoint
and restore.
+
+config PID_RECOVER
+ bool "Support for pid recover"
+ depends on PIN_MEMORY
+ help
+ Say y here to enable the pid recover feature for checkpoint
+ and restore.
endmenu
diff --git a/mm/pin_mem.c b/mm/pin_mem.c
index 89af938..2f77e86 100644
--- a/mm/pin_mem.c
+++ b/mm/pin_mem.c
@@ -688,4 +688,55 @@ vm_fault_t reserve_kernel_space_mem(unsigned long start_addr, unsigned int pages
}
EXPORT_SYMBOL_GPL(reserve_kernel_space_mem);
+#ifdef CONFIG_PID_RECOVER
+struct idr *reserve_idr;
+
+/* test if there exist pin memory tasks */
+bool is_need_reserve_pids(void)
+{
+ return (pin_pid_num > 0);
+}
+
+void free_reserved_pid(struct idr *idr, int pid)
+{
+ unsigned int index;
+ struct page_map_info *pmi;
+
+ if (!max_pin_pid_num || idr != reserve_idr)
+ return;
+
+ for (index = 0; index < pin_pid_num; index++) {
+ pmi = &(user_space_reserve_start[index]);
+ if (pmi->pid == pid && pmi->pid_reserved) {
+ idr_remove(idr, pid);
+ return;
+ }
+ }
+}
+
+/* reserve pids for check point tasks which pinned memory */
+void reserve_pids(struct idr *idr, int pid_max)
+{
+ int alloc_pid;
+ unsigned int index;
+ struct page_map_info *pmi;
+
+ if (!max_pin_pid_num)
+ return;
+ reserve_idr = idr;
+ for (index = 0; index < pin_pid_num; index++) {
+ pmi = &(user_space_reserve_start[index]);
+ pmi->pid_reserved = true;
+ alloc_pid = idr_alloc(idr, NULL, pmi->pid, pid_max, GFP_ATOMIC);
+ if (alloc_pid != pmi->pid) {
+ if (alloc_pid > 0)
+ idr_remove(idr, alloc_pid);
+ pr_warn("Reserve pid (%d) fail, real pid is %d.\n", alloc_pid, pmi->pid);
+ pmi->pid_reserved = false;
+ continue;
+ }
+ }
+ return;
+}
+#endif /* CONFIG_PID_RECOVER */
#endif /* CONFIG_PIN_MEMORY */
--
1.8.3.1
1
0

[PATCH v1 1/1 openEuler-1.0-LTS] fork: add pid recover method for checkpoint and recover
by hejingxian 31 Dec '20
by hejingxian 31 Dec '20
31 Dec '20
From: hejingxian <hejingxian(a)huawei.com>
Date: Thu, 10 Dec 2020 20:35:00 +0800
Subject: [PATCH v1 1/1 openEuler-1.0-LTS] fork: add pid recover method for checkpoint and recover
We record the pid of dump task in the reserved memory, and reserve the pids before
init task start. In the recover process, set the fork_pid of the recovery task before
call fork(). And then the fork_pid will be used to alloc pid.
/proc/sys/kernel/ns_last_pid can also be used to fork child task with assigned pid.
However, when there exist many tasks need to recover at the same time, we will fail to
recover pids by using /proc/sys/kernel/ns_last_pid.
Signed-off-by: Jingxian He <hejingxian(a)huawei.com>
---
drivers/char/pin_memory.c | 24 +++++++++++++++++++++-
include/linux/pin_mem.h | 6 ++++++
include/linux/sched.h | 4 ++++
init/init_task.c | 3 +++
kernel/pid.c | 27 ++++++++++++++++++++++++-
mm/Kconfig | 7 +++++++
mm/pin_mem.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++
7 files changed, 120 insertions(+), 2 deletions(-)
diff --git a/drivers/char/pin_memory.c b/drivers/char/pin_memory.c
index a0464e1..2c65de7 100644
--- a/drivers/char/pin_memory.c
+++ b/drivers/char/pin_memory.c
@@ -36,9 +36,12 @@ struct pin_mem_area_set {
#define _SET_PIN_MEM_AREA 1
#define _CLEAR_PIN_MEM_AREA 2
#define _REMAP_PIN_MEM_AREA 3
+#define _SET_FORK_PID 4
+
#define SET_PIN_MEM_AREA _IOW(PIN_MEM_MAGIC, _SET_PIN_MEM_AREA, struct pin_mem_area_set)
#define CLEAR_PIN_MEM_AREA _IOW(PIN_MEM_MAGIC, _CLEAR_PIN_MEM_AREA, int)
#define REMAP_PIN_MEM_AREA _IOW(PIN_MEM_MAGIC, _REMAP_PIN_MEM_AREA, int)
+#define SET_FORK_PID _IOW(PIN_MEM_MAGIC, _SET_FORK_PID, int)
static int set_pin_mem(struct pin_mem_area_set *pmas)
{
@@ -136,13 +139,29 @@ static int pin_mem_remap(unsigned long arg)
return -EFAULT;
}
+static int set_fork_pid(unsigned long arg)
+{
+ int pid;
+ struct page_map_info * pmi = NULL;
+ void __user *buf = (void __user *)arg;
+
+ if (!access_ok(buf, sizeof(int)))
+ goto fault;
+ if (copy_from_user(&pid, buf, sizeof(int)))
+ goto fault;
+ current->fork_pid = pid;
+ return 0;
+fault:
+ return -EFAULT;
+}
+
static long pin_memory_ioctl(struct file *file, unsigned cmd, unsigned long arg)
{
long ret = 0;
if (_IOC_TYPE(cmd) != PIN_MEM_MAGIC)
return -EINVAL;
- if (_IOC_NR(cmd) > _REMAP_PIN_MEM_AREA)
+ if (_IOC_NR(cmd) > _SET_FORK_PID)
return -EINVAL;
switch (cmd) {
@@ -155,6 +174,9 @@ static long pin_memory_ioctl(struct file *file, unsigned cmd, unsigned long arg)
case REMAP_PIN_MEM_AREA:
ret = pin_mem_remap(arg);
break;
+ case SET_FORK_PID:
+ ret = set_fork_pid(arg);
+ break;
default:
return -EINVAL;
}
diff --git a/include/linux/pin_mem.h b/include/linux/pin_mem.h
index 0ca44ac..4162043 100644
--- a/include/linux/pin_mem.h
+++ b/include/linux/pin_mem.h
@@ -58,5 +58,11 @@ extern vm_fault_t do_anon_huge_page_remap(struct vm_area_struct *vma, unsigned l
#endif
extern void init_reserve_page_map(unsigned long map_addr, unsigned long map_size);
+#ifdef CONFIG_PID_RECOVER
+extern bool is_need_reserve_pids(void);
+extern void reserve_pids(struct idr *idr, int pid_max);
+extern void free_reserved_pid(struct idr *idr, int pid);
+#endif
+
#endif /* CONFIG_PIN_MEMORY */
#endif /* _LINUX_PIN_MEMORY_H */
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 716ad1d..f6b1560 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1281,6 +1281,10 @@ struct task_struct {
unsigned long prev_lowest_stack;
#endif
+#ifdef CONFIG_PID_RECOVER
+ int fork_pid;
+#endif
+
/*
* New fields for task_struct should be added above here, so that
* they are included in the randomized portion of task_struct.
diff --git a/init/init_task.c b/init/init_task.c
index 9e5cbe5..40cd98f 100644
--- a/init/init_task.c
+++ b/init/init_task.c
@@ -181,6 +181,9 @@ struct task_struct init_task
#ifdef CONFIG_SECURITY
.security = NULL,
#endif
+#ifdef CONFIG_PID_RECOVER
+ .fork_pid = 0,
+#endif
};
EXPORT_SYMBOL(init_task);
diff --git a/kernel/pid.c b/kernel/pid.c
index 2278e24..dc93f7a 100644
--- a/kernel/pid.c
+++ b/kernel/pid.c
@@ -42,6 +42,9 @@
#include <linux/sched/signal.h>
#include <linux/sched/task.h>
#include <linux/idr.h>
+#ifdef CONFIG_PID_RECOVER
+#include <linux/pin_mem.h>
+#endif
struct pid init_struct_pid = {
.count = REFCOUNT_INIT(1),
@@ -208,8 +211,26 @@ struct pid *alloc_pid(struct pid_namespace *ns, pid_t *set_tid,
idr_preload(GFP_KERNEL);
spin_lock_irq(&pidmap_lock);
-
+#ifdef CONFIG_PID_RECOVER
+ if (current->fork_pid) {
+ int pid_min;
+ /* Try to free the reserved fork_pid, and then use it to alloc pid. */
+ free_reserved_pid(&tmp->idr, current->fork_pid);
+ pid_min = current->fork_pid;
+ current->fork_pid = 0;
+ nr = idr_alloc(&tmp->idr, NULL, pid_min,
+ pid_min + 1,
+ GFP_ATOMIC);
+ /*
+ * If ENOSPC is returned it means that the PID is
+ * alreay in use. Return EEXIST in that case.
+ */
+ if (nr == -ENOSPC)
+ nr = -EEXIST;
+ } else if (tid) {
+#else
if (tid) {
+#endif
nr = idr_alloc(&tmp->idr, NULL, tid,
tid + 1, GFP_ATOMIC);
/*
@@ -577,4 +598,8 @@ void __init pid_idr_init(void)
init_pid_ns.pid_cachep = KMEM_CACHE(pid,
SLAB_HWCACHE_ALIGN | SLAB_PANIC | SLAB_ACCOUNT);
+#ifdef CONFIG_PID_RECOVER
+ if (is_need_reserve_pids())
+ reserve_pids(&init_pid_ns.idr, pid_max);
+#endif
}
diff --git a/mm/Kconfig b/mm/Kconfig
index c2dd088..847e8e4 100644
--- a/mm/Kconfig
+++ b/mm/Kconfig
@@ -745,4 +745,11 @@ config PIN_MEMORY
help
Say y here to enable the pin memory feature for checkpoint
and restore.
+
+config PID_RECOVER
+ bool "Support for pid recover"
+ depends on PIN_MEMORY
+ help
+ Say y here to enable the pid recover feature for checkpoint
+ and restore.
endmenu
diff --git a/mm/pin_mem.c b/mm/pin_mem.c
index ca3f23a..9426874 100644
--- a/mm/pin_mem.c
+++ b/mm/pin_mem.c
@@ -688,4 +688,55 @@ vm_fault_t reserve_kernel_space_mem(unsigned long start_addr, unsigned int pages
}
EXPORT_SYMBOL_GPL(reserve_kernel_space_mem);
+#ifdef CONFIG_PID_RECOVER
+struct idr *reserve_idr;
+
+/* test if there exist pin memory tasks */
+bool is_need_reserve_pids(void)
+{
+ return (pin_pid_num > 0);
+}
+
+void free_reserved_pid(struct idr *idr, int pid)
+{
+ unsigned int index;
+ struct page_map_info *pmi;
+
+ if (!max_pin_pid_num || idr != reserve_idr)
+ return;
+
+ for (index = 0; index < pin_pid_num; index++) {
+ pmi = &(user_space_reserve_start[index]);
+ if (pmi->pid == pid && pmi->pid_reserved) {
+ idr_remove(idr, pid);
+ return;
+ }
+ }
+}
+
+/* reserve pids for check point tasks which pinned memory */
+void reserve_pids(struct idr *idr, int pid_max)
+{
+ int alloc_pid;
+ unsigned int index;
+ struct page_map_info *pmi;
+
+ if (!max_pin_pid_num)
+ return;
+ reserve_idr = idr;
+ for (index = 0; index < pin_pid_num; index++) {
+ pmi = &(user_space_reserve_start[index]);
+ pmi->pid_reserved = true;
+ alloc_pid = idr_alloc(idr, NULL, pmi->pid, pid_max, GFP_ATOMIC);
+ if (alloc_pid != pmi->pid) {
+ if (alloc_pid > 0)
+ idr_remove(idr, alloc_pid);
+ pr_warn("Reserve pid (%d) fail, real pid is %d.\n", alloc_pid, pmi->pid);
+ pmi->pid_reserved = false;
+ continue;
+ }
+ }
+ return;
+}
+#endif /* CONFIG_PID_RECOVER */
#endif /* CONFIG_PIN_MEMORY */
--
1.8.3.1
2
1

[PATCH v1 0/1 openEuler-1.0-LTS] mm: add pin memory method for checkpoint add restore
by hejingxian 31 Dec '20
by hejingxian 31 Dec '20
31 Dec '20
From: hejingxian <hejingxian(a)huawei.com>
Date: Thu, 10 Dec 2020 20:31:15 +0800
Subject: [PATCH v1 0/1 openEuler-1.0-LTS] mm: add pin memory method for checkpoint add restore
We can use the checkpoint and restore in userspace(criu) method to dump and restore tasks
when updating the kernel. Currently, criu needs dump all memory data of tasks to files.
When the memory size is very large(larger than 1G), the cost time of the dumping data
will be very long(more than 1 min).
We can pin the memory data of tasks and collect the corresponding physical pages mapping info
in checkpoint process, and remap the physical pages to restore tasks after kernel is updated.
The pin memory area info is saved in the reserve memblock named nvwa_res_first, which can keep
usable in the kernel update process.
The pin memory driver provides the following ioctl command for criu:
1) SET_PIN_MEM_AREA: set pin memory area, which can be remap to the restore task.
2) CLEAR_PIN_MEM_AREA: clear the pin memory area info, which enable user reset the pin data.
3) REMAP_PIN_MEM_AREA: remap the pages of the pin memory to the restore task.
Signed-off-by: Jingxian He <hejingxian(a)huawei.com>
---
arch/arm64/kernel/setup.c | 7 +
arch/arm64/mm/init.c | 62 +++-
drivers/char/Kconfig | 7 +
drivers/char/Makefile | 1 +
drivers/char/pin_memory.c | 198 +++++++++++++
include/linux/crash_core.h | 5 +
include/linux/pin_mem.h | 62 ++++
kernel/crash_core.c | 11 +
mm/Kconfig | 6 +
mm/Makefile | 1 +
mm/huge_memory.c | 61 ++++
mm/memory.c | 68 +++++
mm/pin_mem.c | 691 +++++++++++++++++++++++++++++++++++++++++++++
13 files changed, 1179 insertions(+), 1 deletion(-)
create mode 100644 drivers/char/pin_memory.c
create mode 100644 include/linux/pin_mem.h
create mode 100644 mm/pin_mem.c
diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
index 56f6645..40751ed 100644
--- a/arch/arm64/kernel/setup.c
+++ b/arch/arm64/kernel/setup.c
@@ -50,6 +50,9 @@
#include <asm/efi.h>
#include <asm/xen/hypervisor.h>
#include <asm/mmu_context.h>
+#ifdef CONFIG_PIN_MEMORY
+#include <linux/pin_memory.h>
+#endif
static int num_standard_resources;
static struct resource *standard_resources;
@@ -243,6 +246,10 @@ static void __init request_standard_resources(void)
crashk_res.end <= res->end)
request_resource(res, &crashk_res);
#endif
+#ifdef CONFIG_PIN_MEMORY
+ if (pin_memory_resource.end)
+ insert_resource(&iomem_resource, &pin_memory_resource);
+#endif
}
}
diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
index b65dffd..dee3192 100644
--- a/arch/arm64/mm/init.c
+++ b/arch/arm64/mm/init.c
@@ -41,7 +41,9 @@
#include <linux/sizes.h>
#include <asm/tlb.h>
#include <asm/alternative.h>
-
+#ifdef CONFIG_PIN_MEMORY
+#include <linux/pin_memory.h>
+#endif
#define ARM64_ZONE_DMA_BITS 30
/*
@@ -68,6 +70,16 @@
phys_addr_t arm64_dma_phys_limit __ro_after_init;
static phys_addr_t arm64_dma32_phys_limit __ro_after_init;
+#ifdef CONFIG_PIN_MEMORY
+struct resource pin_memory_resource = {
+ .name = "Pin memory maps",
+ .start = 0,
+ .end = 0,
+ .flags = IORESOURCE_MEM,
+ .desc = IORES_DESC_PIN_MEM_MAPS
+};
+#endif
+
#ifdef CONFIG_KEXEC_CORE
/*
* reserve_crashkernel() - reserves memory for crash kernel
@@ -129,6 +141,47 @@ static void __init reserve_crashkernel(void)
}
#endif /* CONFIG_KEXEC_CORE */
+#ifdef CONFIG_PIN_MEMORY
+static void __init reserve_pin_memory_res(void)
+{
+ unsigned long long mem_start, mem_len;
+ int ret;
+
+ ret = parse_pin_memory(boot_command_line, memblock_phys_mem_size(),
+ &mem_len, &mem_start);
+ if (ret || !mem_len)
+ return;
+
+ mem_len = PAGE_ALIGN(mem_len);
+
+ if (!memblock_is_region_memory(mem_start, mem_len)) {
+ pr_warn("cannot reserve for pin memory: region is not memory!\n");
+ return;
+ }
+
+ if (memblock_is_region_reserved(mem_start, mem_len)) {
+ pr_warn("cannot reserve for pin memory: region overlaps reserved memory!\n");
+ return;
+ }
+
+ if (!IS_ALIGNED(mem_start, SZ_2M)) {
+ pr_warn("cannot reserve for pin memory: base address is not 2MB aligned\n");
+ return;
+ }
+
+ memblock_reserve(mem_start, mem_len);
+ pr_debug("pin memory resource reserved: 0x%016llx - 0x%016llx (%lld MB)\n",
+ mem_start, mem_start + mem_len, mem_len >> 20);
+
+ pin_memory_resource.start = mem_start;
+ pin_memory_resource.end = mem_start + mem_len - 1;
+}
+#else
+static void __init reserve_pin_memory_res(void)
+{
+}
+#endif /* CONFIG_PIN_MEMORY */
+
#ifdef CONFIG_CRASH_DUMP
static int __init early_init_dt_scan_elfcorehdr(unsigned long node,
const char *uname, int depth, void *data)
@@ -452,6 +505,8 @@ void __init arm64_memblock_init(void)
reserve_crashkernel();
+ reserve_pin_memory_res();
+
reserve_elfcorehdr();
high_memory = __va(memblock_end_of_DRAM() - 1) + 1;
@@ -573,6 +628,11 @@ void __init mem_init(void)
/* this will put all unused low memory onto the freelists */
memblock_free_all();
+#ifdef CONFIG_PIN_MEMORY
+ /* pre alloc the pages for pin memory */
+ init_reserve_page_map((unsigned long)pin_memory_resource.start,
+ (unsigned long)(pin_memory_resource.end - pin_memory_resource.start));
+#endif
mem_init_print_info(NULL);
/*
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
index 26956c0..73af2f0 100644
--- a/drivers/char/Kconfig
+++ b/drivers/char/Kconfig
@@ -560,3 +560,10 @@ config RANDOM_TRUST_BOOTLOADER
booloader is trustworthy so it will be added to the kernel's entropy
pool. Otherwise, say N here so it will be regarded as device input that
only mixes the entropy pool.
+
+config PIN_MEMORY_DEV
+ bool "/dev/pinmem character device"
+ depends PIN_MEMORY
+ default n
+ help
+ pin memory driver
diff --git a/drivers/char/Makefile b/drivers/char/Makefile
index 7c5ea6f..1941642 100644
--- a/drivers/char/Makefile
+++ b/drivers/char/Makefile
@@ -52,3 +52,4 @@ js-rtc-y = rtc.o
obj-$(CONFIG_XILLYBUS) += xillybus/
obj-$(CONFIG_POWERNV_OP_PANEL) += powernv-op-panel.o
obj-$(CONFIG_ADI) += adi.o
+obj-$(CONFIG_PIN_MEMORY_DEV) += pin_memory.o
diff --git a/drivers/char/pin_memory.c b/drivers/char/pin_memory.c
new file mode 100644
index 00000000..a0464e1
--- /dev/null
+++ b/drivers/char/pin_memory.c
@@ -0,0 +1,198 @@
+/*
+ * Copyright @ Huawei Technologies Co., Ltd. 2020-2020. ALL rights reserved.
+ * Description: Euler pin memory driver
+ */
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/kprobes.h>
+#include <linux/spinlock.h>
+#include <linux/workqueue.h>
+#include <linux/sched.h>
+#include <linux/mm.h>
+#include <linux/init.h>
+#include <linux/miscdevice.h>
+#include <linux/fs.h>
+#include <linux/mm_types.h>
+#include <asm/processor.h>
+#include <uapi/asm-generic/ioctl.h>
+#include <uapi/asm-generic/mman-common.h>
+#include <uapi/asm/setup.h>
+#include <linux/pin_mem.h>
+#include <linux/sched/mm.h>
+
+#define MAX_PIN_MEM_AREA_NUM 16
+struct _pin_mem_area {
+ unsigned long virt_start;
+ unsigned long virt_end;
+};
+
+struct pin_mem_area_set {
+ unsigned int pid;
+ unsigned int area_num;
+ struct _pin_mem_area mem_area[MAX_PIN_MEM_AREA_NUM];
+};
+
+#define PIN_MEM_MAGIC 0x59
+#define _SET_PIN_MEM_AREA 1
+#define _CLEAR_PIN_MEM_AREA 2
+#define _REMAP_PIN_MEM_AREA 3
+#define SET_PIN_MEM_AREA _IOW(PIN_MEM_MAGIC, _SET_PIN_MEM_AREA, struct pin_mem_area_set)
+#define CLEAR_PIN_MEM_AREA _IOW(PIN_MEM_MAGIC, _CLEAR_PIN_MEM_AREA, int)
+#define REMAP_PIN_MEM_AREA _IOW(PIN_MEM_MAGIC, _REMAP_PIN_MEM_AREA, int)
+
+static int set_pin_mem(struct pin_mem_area_set *pmas)
+{
+ int i;
+ int ret = 0;
+ struct _pin_mem_area *pma;
+ struct mm_struct *mm;
+ struct task_struct *task;
+ struct pid *pid_s;
+
+ pid_s = find_get_pid(pmas->pid);
+ if (!pid_s) {
+ pr_warn("Get pid struct fail:%d.\n", pmas->pid);
+ goto fail;
+ }
+ rcu_read_lock();
+ task = pid_task(pid_s, PIDTYPE_PID);
+ if (!task) {
+ pr_warn("Get task struct fail:%d.\n", pmas->pid);
+ goto fail;
+ }
+ mm = get_task_mm(task);
+ for (i = 0; i < pmas->area_num; i++) {
+ pma = &(pmas->mem_area[i]);
+ ret = pin_mem_area(task, mm, pma->virt_start, pma->virt_end);
+ if (ret) {
+ mmput(mm);
+ goto fail;
+ }
+ }
+ mmput(mm);
+ rcu_read_unlock();
+ return ret;
+
+fail:
+ rcu_read_unlock();
+ return -EFAULT;
+}
+
+static int set_pin_mem_area(unsigned long arg)
+{
+ struct pin_mem_area_set pmas;
+ void __user *buf = (void __user *)arg;
+
+ if (!access_ok(buf, sizeof(pmas)))
+ return -EFAULT;
+ if (copy_from_user(&pmas, buf, sizeof(pmas)))
+ return -EINVAL;
+ if (pmas.area_num > MAX_PIN_MEM_AREA_NUM) {
+ pr_warn("Input area_num is too large.\n");
+ return -EINVAL;
+ }
+
+ return set_pin_mem(&pmas);
+}
+
+static int pin_mem_remap(unsigned long arg)
+{
+ int pid;
+ struct task_struct *task;
+ struct mm_struct *mm;
+ vm_fault_t ret;
+ void __user *buf = (void __user *)arg;
+ struct pid *pid_s;
+
+ if (!access_ok(buf, sizeof(int)))
+ return -EINVAL;
+ if (copy_from_user(&pid, buf, sizeof(int)))
+ return -EINVAL;
+
+ pid_s = find_get_pid(pid);
+ if (!pid_s) {
+ pr_warn("Get pid struct fail:%d.\n", pid);
+ return -EINVAL;
+ }
+ rcu_read_lock();
+ task = pid_task(pid_s, PIDTYPE_PID);
+ if (!task) {
+ pr_warn("Get task struct fail:%d.\n", pid);
+ goto fault;
+ }
+ mm = get_task_mm(task);
+ ret = do_mem_remap(pid, mm);
+ if (ret) {
+ pr_warn("Handle pin memory remap fail.\n");
+ mmput(mm);
+ goto fault;
+ }
+ mmput(mm);
+ rcu_read_unlock();
+ return 0;
+
+fault:
+ rcu_read_unlock();
+ return -EFAULT;
+}
+
+static long pin_memory_ioctl(struct file *file, unsigned cmd, unsigned long arg)
+{
+ long ret = 0;
+
+ if (_IOC_TYPE(cmd) != PIN_MEM_MAGIC)
+ return -EINVAL;
+ if (_IOC_NR(cmd) > _REMAP_PIN_MEM_AREA)
+ return -EINVAL;
+
+ switch (cmd) {
+ case SET_PIN_MEM_AREA:
+ ret = set_pin_mem_area(arg);
+ break;
+ case CLEAR_PIN_MEM_AREA:
+ clear_pin_memory_record();
+ break;
+ case REMAP_PIN_MEM_AREA:
+ ret = pin_mem_remap(arg);
+ break;
+ default:
+ return -EINVAL;
+ }
+ return ret;
+}
+
+static const struct file_operations pin_memory_fops = {
+ .owner = THIS_MODULE,
+ .unlocked_ioctl = pin_memory_ioctl,
+ .compat_ioctl = pin_memory_ioctl,
+};
+
+static struct miscdevice pin_memory_miscdev = {
+ .minor = MISC_DYNAMIC_MINOR,
+ .name = "pinmem",
+ .fops = &pin_memory_fops,
+};
+
+static int pin_memory_init(void)
+{
+ int err = misc_register(&pin_memory_miscdev);
+ if (!err) {
+ pr_info("pin_memory init\n");
+ } else {
+ pr_warn("pin_memory init failed!\n");
+ }
+ return err;
+}
+
+static void pin_memory_exit(void)
+{
+ misc_deregister(&pin_memory_miscdev);
+ pr_info("pin_memory ko exists!\n");
+}
+
+module_init(pin_memory_init);
+module_exit(pin_memory_exit);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Euler");
+MODULE_DESCRIPTION("pin memory");
diff --git a/include/linux/crash_core.h b/include/linux/crash_core.h
index 525510a..5baf40d 100644
--- a/include/linux/crash_core.h
+++ b/include/linux/crash_core.h
@@ -75,4 +75,9 @@ int parse_crashkernel_high(char *cmdline, unsigned long long system_ram,
int parse_crashkernel_low(char *cmdline, unsigned long long system_ram,
unsigned long long *crash_size, unsigned long long *crash_base);
+#ifdef CONFIG_PIN_MEMORY
+int __init parse_pin_memory(char *cmdline, unsigned long long system_ram,
+ unsigned long long *pin_size, unsigned long long *pin_base);
+#endif
+
#endif /* LINUX_CRASH_CORE_H */
diff --git a/include/linux/pin_mem.h b/include/linux/pin_mem.h
new file mode 100644
index 00000000..0ca44ac
--- /dev/null
+++ b/include/linux/pin_mem.h
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved.
+ * Provide the pin memory method for check point and restore task.
+ */
+#ifndef _LINUX_PIN_MEMORY_H
+#define _LINUX_PIN_MEMORY_H
+
+#ifdef CONFIG_PIN_MEMORY
+#include <linux/errno.h>
+#include <linux/kabi.h>
+#include <linux/mm_types.h>
+#include <linux/err.h>
+#ifdef CONFIG_ARM64
+#include <linux/ioport.h>
+#endif
+
+#define PAGE_BUDDY_MAPCOUNT_VALUE (~PG_buddy)
+
+#define COLLECT_PAGES_FINISH 0
+#define COLLECT_PAGES_NEED_CONTINUE 1
+#define COLLECT_PAGES_FAIL -1
+
+#define COMPOUND_PAD_MASK 0xffffffff
+#define COMPOUND_PAD_START 0x88
+#define COMPOUND_PAD_DELTA 0x40
+#define LIST_POISON4 0xdead000000000400
+
+#define next_pme(pme) ((unsigned long *)(pme + 1) + pme->nr_pages)
+
+struct page_map_entry {
+ unsigned long virt_addr;
+ unsigned int nr_pages;
+ unsigned int is_huge_page;
+ unsigned long phy_addr_array[0];
+};
+
+struct page_map_info {
+ int pid;
+ int pid_reserved;
+ unsigned int entry_num;
+ struct page_map_entry *pme;
+};
+
+extern struct page_map_info *get_page_map_info(int pid);
+extern struct page_map_info *create_page_map_info(int pid);
+extern vm_fault_t do_mem_remap(int pid, struct mm_struct *mm);
+extern vm_fault_t do_anon_page_remap(struct vm_area_struct *vma, unsigned long address,
+ pmd_t *pmd, struct page *page);
+extern void clear_pin_memory_record(void);
+extern int pin_mem_area(struct task_struct *task, struct mm_struct *mm,
+ unsigned long start_addr, unsigned long end_addr);
+extern vm_fault_t do_anon_huge_page_remap(struct vm_area_struct *vma, unsigned long address,
+ pmd_t *pmd, struct page *page);
+
+/* reserve space for pin memory*/
+#ifdef CONFIG_ARM64
+extern struct resource pin_memory_resource;
+#endif
+extern void init_reserve_page_map(unsigned long map_addr, unsigned long map_size);
+
+#endif /* CONFIG_PIN_MEMORY */
+#endif /* _LINUX_PIN_MEMORY_H */
diff --git a/kernel/crash_core.c b/kernel/crash_core.c
index 9f1557b..7512696 100644
--- a/kernel/crash_core.c
+++ b/kernel/crash_core.c
@@ -292,6 +292,17 @@ int __init parse_crashkernel_low(char *cmdline,
"crashkernel=", suffix_tbl[SUFFIX_LOW]);
}
+#ifdef CONFIG_PIN_MEMORY
+int __init parse_pin_memory(char *cmdline,
+ unsigned long long system_ram,
+ unsigned long long *pin_size,
+ unsigned long long *pin_base)
+{
+ return __parse_crashkernel(cmdline, system_ram, pin_size, pin_base,
+ "pinmemory=", NULL);
+}
+#endif
+
Elf_Word *append_elf_note(Elf_Word *buf, char *name, unsigned int type,
void *data, size_t data_len)
{
diff --git a/mm/Kconfig b/mm/Kconfig
index ab80933..c2dd088 100644
--- a/mm/Kconfig
+++ b/mm/Kconfig
@@ -739,4 +739,10 @@ config ARCH_HAS_HUGEPD
config MAPPING_DIRTY_HELPERS
bool
+config PIN_MEMORY
+ bool "Support for pin memory"
+ depends on CHECKPOINT_RESTORE
+ help
+ Say y here to enable the pin memory feature for checkpoint
+ and restore.
endmenu
diff --git a/mm/Makefile b/mm/Makefile
index 1937cc2..7e1984e 100644
--- a/mm/Makefile
+++ b/mm/Makefile
@@ -108,3 +108,4 @@ obj-$(CONFIG_ZONE_DEVICE) += memremap.o
obj-$(CONFIG_HMM_MIRROR) += hmm.o
obj-$(CONFIG_MEMFD_CREATE) += memfd.o
obj-$(CONFIG_MAPPING_DIRTY_HELPERS) += mapping_dirty_helpers.o
+obj-$(CONFIG_PIN_MEMORY) += pin_mem.o
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index a880932..93dc582 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -3083,4 +3083,65 @@ void remove_migration_pmd(struct page_vma_mapped_walk *pvmw, struct page *new)
mlock_vma_page(new);
update_mmu_cache_pmd(vma, address, pvmw->pmd);
}
+
+#ifdef CONFIG_PIN_MEMORY
+vm_fault_t do_anon_huge_page_remap(struct vm_area_struct *vma, unsigned long address,
+ pmd_t *pmd, struct page *page)
+{
+ gfp_t gfp;
+ pgtable_t pgtable;
+ spinlock_t *ptl;
+ pmd_t entry;
+ vm_fault_t ret = 0;
+ struct mem_cgroup *memcg;
+
+ if (unlikely(anon_vma_prepare(vma)))
+ return VM_FAULT_OOM;
+ if (unlikely(khugepaged_enter(vma, vma->vm_flags)))
+ return VM_FAULT_OOM;
+ gfp = alloc_hugepage_direct_gfpmask(vma);
+ prep_transhuge_page(page);
+ if (mem_cgroup_try_charge_delay(page, vma->vm_mm, gfp, &memcg, true)) {
+ put_page(page);
+ count_vm_event(THP_FAULT_FALLBACK);
+ return VM_FAULT_FALLBACK;
+ }
+ pgtable = pte_alloc_one(vma->vm_mm, address);
+ if (unlikely(!pgtable)) {
+ ret = VM_FAULT_OOM;
+ goto release;
+ }
+ __SetPageUptodate(page);
+ ptl = pmd_lock(vma->vm_mm, pmd);
+ if (unlikely(!pmd_none(*pmd))) {
+ goto unlock_release;
+ } else {
+ ret = check_stable_address_space(vma->vm_mm);
+ if (ret)
+ goto unlock_release;
+ entry = mk_huge_pmd(page, vma->vm_page_prot);
+ entry = maybe_pmd_mkwrite(pmd_mkdirty(entry), vma);
+ page_add_new_anon_rmap(page, vma, address, true);
+ mem_cgroup_commit_charge(page, memcg, false, true);
+ lru_cache_add_active_or_unevictable(page, vma);
+ pgtable_trans_huge_deposit(vma->vm_mm, pmd, pgtable);
+ set_pmd_at(vma->vm_mm, address, pmd, entry);
+ add_mm_counter(vma->vm_mm, MM_ANONPAGES, HPAGE_PMD_NR);
+ mm_inc_nr_ptes(vma->vm_mm);
+ spin_unlock(ptl);
+ count_vm_event(THP_FAULT_ALLOC);
+ }
+
+ return 0;
+unlock_release:
+ spin_unlock(ptl);
+release:
+ if (pgtable)
+ pte_free(vma->vm_mm, pgtable);
+ mem_cgroup_cancel_charge(page, memcg, true);
+ put_page(page);
+ return ret;
+}
+#endif
+
#endif
diff --git a/mm/memory.c b/mm/memory.c
index 45442d9..dd416fd 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -4799,4 +4799,72 @@ void ptlock_free(struct page *page)
{
kmem_cache_free(page_ptl_cachep, page->ptl);
}
+
+#ifdef CONFIG_PIN_MEMORY
+vm_fault_t do_anon_page_remap(struct vm_area_struct *vma, unsigned long address,
+ pmd_t *pmd, struct page *page)
+{
+ struct mem_cgroup *memcg;
+ pte_t entry;
+ spinlock_t *ptl;
+ pte_t *pte;
+ vm_fault_t ret = 0;
+
+ if (pte_alloc(vma->vm_mm, pmd, address))
+ return VM_FAULT_OOM;
+
+ /* See the comment in pte_alloc_one_map() */
+ if (unlikely(pmd_trans_unstable(pmd)))
+ return 0;
+
+ /* Allocate our own private page. */
+ if (unlikely(anon_vma_prepare(vma)))
+ goto oom;
+
+ if (mem_cgroup_try_charge_delay(page, vma->vm_mm, GFP_KERNEL, &memcg,
+ false))
+ goto oom_free_page;
+
+ /*
+ * The memory barrier inside __SetPageUptodate makes sure that
+ * preceeding stores to the page contents become visible before
+ * the set_pte_at() write.
+ */
+ __SetPageUptodate(page);
+
+ entry = mk_pte(page, vma->vm_page_prot);
+ if (vma->vm_flags & VM_WRITE)
+ entry = pte_mkwrite(pte_mkdirty(entry));
+ pte = pte_offset_map_lock(vma->vm_mm, pmd, address,
+ &ptl);
+ if (!pte_none(*pte)) {
+ ret = VM_FAULT_FALLBACK;
+ goto release;
+ }
+
+ ret = check_stable_address_space(vma->vm_mm);
+ if (ret)
+ goto release;
+ inc_mm_counter_fast(vma->vm_mm, MM_ANONPAGES);
+ page_add_new_anon_rmap(page, vma, address, false);
+ mem_cgroup_commit_charge(page, memcg, false, false);
+ lru_cache_add_active_or_unevictable(page, vma);
+
+ set_pte_at(vma->vm_mm, address, pte, entry);
+ /* No need to invalidate - it was non-present before */
+ update_mmu_cache(vma, address, pte);
+unlock:
+ pte_unmap_unlock(pte, ptl);
+ return ret;
+release:
+ mem_cgroup_cancel_charge(page, memcg, false);
+ put_page(page);
+ goto unlock;
+oom_free_page:
+ put_page(page);
+oom:
+ return VM_FAULT_OOM;
+}
+#endif
+
#endif
diff --git a/mm/pin_mem.c b/mm/pin_mem.c
new file mode 100644
index 00000000..ca3f23a
--- /dev/null
+++ b/mm/pin_mem.c
@@ -0,0 +1,691 @@
+/*
+ * Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved.
+ * Provide the pin memory method for check point and restore task.
+ */
+#ifdef CONFIG_PIN_MEMORY
+#include <linux/fs.h>
+#include <linux/init.h>
+#include <linux/proc_fs.h>
+#include <linux/seq_file.h>
+#include <linux/slab.h>
+#include <linux/time.h>
+#include <linux/sched/cputime.h>
+#include <linux/tick.h>
+#include <asm/uaccess.h>
+#include <linux/mm.h>
+#include <linux/pin_mem.h>
+#include <linux/idr.h>
+#include <linux/page-isolation.h>
+#include <linux/sched/mm.h>
+#include <linux/ctype.h>
+
+#define MAX_PIN_PID_NUM 128
+static DEFINE_SPINLOCK(page_map_entry_lock);
+
+unsigned int pin_pid_num;
+static unsigned int *pin_pid_num_addr;
+static unsigned long __page_map_entry_start;
+static unsigned long page_map_entry_end;
+static struct page_map_info *user_space_reserve_start;
+static struct page_map_entry *page_map_entry_start;
+unsigned int max_pin_pid_num __read_mostly;
+
+static int __init setup_max_pin_pid_num(char *str)
+{
+ int ret = 1;
+
+ if (!str)
+ goto out;
+
+ ret = kstrtouint(str, 10, &max_pin_pid_num);
+out:
+ if (ret) {
+ pr_warn("Unable to parse max pin pid num.\n");
+ } else {
+ if (max_pin_pid_num > MAX_PIN_PID_NUM) {
+ max_pin_pid_num = 0;
+ pr_warn("Input max_pin_pid_num is too large.\n");
+ }
+ }
+ return ret;
+}
+early_param("max_pin_pid_num", setup_max_pin_pid_num);
+
+struct page_map_info *create_page_map_info(int pid)
+{
+ struct page_map_info *new;
+
+ if (!user_space_reserve_start)
+ return NULL;
+
+ if (pin_pid_num >= max_pin_pid_num) {
+ pr_warn("Pin pid num too large than max_pin_pid_num, fail create: %d!", pid);
+ return NULL;
+ }
+ new = (struct page_map_info *)(user_space_reserve_start + pin_pid_num);
+ new->pid = pid;
+ new->pme = NULL;
+ new->entry_num = 0;
+ new->pid_reserved = false;
+ (*pin_pid_num_addr)++;
+ pin_pid_num++;
+ return new;
+}
+EXPORT_SYMBOL_GPL(create_page_map_info);
+
+struct page_map_info *get_page_map_info(int pid)
+{
+ int i;
+
+ if (!user_space_reserve_start)
+ return NULL;
+
+ for (i = 0; i < pin_pid_num; i++) {
+ if (user_space_reserve_start[i].pid == pid) {
+ return &(user_space_reserve_start[i]);
+ }
+ }
+ return NULL;
+}
+EXPORT_SYMBOL_GPL(get_page_map_info);
+
+static struct page *find_head_page(struct page *page)
+{
+ struct page *p = page;
+
+ while (!PageBuddy(p)) {
+ if (PageLRU(p))
+ return NULL;
+ p--;
+ }
+ return p;
+}
+
+static void spilt_page_area_left(struct zone *zone, struct free_area *area, struct page *page,
+ unsigned long size, int order)
+{
+ unsigned long cur_size = 1 << order;
+ unsigned long total_size = 0;
+ struct page *tmp;
+ unsigned long tmp_size = size;
+
+ while (size && cur_size > size) {
+ cur_size >>= 1;
+ order--;
+ area--;
+ if (cur_size <= size) {
+ list_add(&page[total_size].lru, &area->free_list[MIGRATE_MOVABLE]);
+ atomic_set(&(page[total_size]._mapcount), PAGE_BUDDY_MAPCOUNT_VALUE);
+ set_page_private(&page[total_size], order);
+ set_pageblock_migratetype(&page[total_size], MIGRATE_MOVABLE);
+ area->nr_free++;
+ total_size += cur_size;
+ size -= cur_size;
+ }
+ }
+}
+
+static void spilt_page_area_right(struct zone *zone, struct free_area *area, struct page *page,
+ unsigned long size, int order)
+{
+ unsigned long cur_size = 1 << order;
+ struct page *right_page, *head_page;
+ unsigned long tmp_size = size;
+
+ right_page = page + size;
+ while (size && cur_size > size) {
+ cur_size >>= 1;
+ order--;
+ area--;
+ if (cur_size <= size) {
+ head_page = right_page - cur_size;
+ list_add(&head_page->lru, &area->free_list[MIGRATE_MOVABLE]);
+ atomic_set(&(head_page->_mapcount), PAGE_BUDDY_MAPCOUNT_VALUE);
+ set_page_private(head_page, order);
+ set_pageblock_migratetype(head_page, MIGRATE_MOVABLE);
+ area->nr_free++;
+ size -= cur_size;
+ right_page = head_page;
+ }
+ }
+}
+
+void reserve_page_from_buddy(unsigned long nr_pages, struct page *page)
+{
+ unsigned int current_order;
+ struct page *page_end;
+ struct free_area *area;
+ struct zone *zone;
+ struct page *head_page;
+
+ head_page = find_head_page(page);
+ if (!head_page) {
+ pr_warn("Find page head fail.");
+ return;
+ }
+ current_order = head_page->private;
+ page_end = head_page + (1 << current_order);
+ zone = page_zone(head_page);
+ area = &(zone->free_area[current_order]);
+ list_del(&head_page->lru);
+ atomic_set(&head_page->_mapcount, -1);
+ set_page_private(head_page, 0);
+ area->nr_free--;
+ if (head_page != page)
+ spilt_page_area_left(zone, area, head_page,
+ (unsigned long)(page - head_page), current_order);
+ page = page + nr_pages;
+ if (page < page_end) {
+ spilt_page_area_right(zone, area, page,
+ (unsigned long)(page_end - page), current_order);
+ } else if (page > page_end) {
+ pr_warn("Find page end smaller than page.");
+ }
+}
+
+static inline void reserve_user_normal_pages(struct page *page)
+{
+ if (!atomic_read(&page->_refcount)) {
+ atomic_inc(&page->_refcount);
+ reserve_page_from_buddy(1, page);
+ } else {
+ pr_warn("Page %pK refcount %d large than zero, no need reserve.\n",
+ page, page->_refcount.counter);
+ }
+}
+
+static void init_huge_pmd_pages(struct page *head_page)
+{
+ int i = 0;
+ struct page *page = head_page;
+ unsigned long *temp;
+ unsigned long compound_pad = COMPOUND_PAD_START;
+
+ __set_bit(PG_head, &page->flags);
+ __set_bit(PG_active, &page->flags);
+ atomic_set(&page->_refcount, 1);
+ page++;
+ i++;
+ page->compound_head = (unsigned long)head_page + 1;
+ page->_compound_pad_2 = (unsigned long)head_page & COMPOUND_PAD_MASK;
+ temp = (unsigned long *)(&(page->_compound_pad_2));
+ temp[1] = LIST_POISON4;
+ page->compound_dtor = HUGETLB_PAGE_DTOR + 1;
+ page->compound_order = HPAGE_PMD_ORDER;
+ page++;
+ i++;
+ page->compound_head = (unsigned long)head_page + 1;
+ page->_compound_pad_2 = (unsigned long)head_page + compound_pad;
+ i++;
+ INIT_LIST_HEAD(&(page->deferred_list));
+ for (; i < HPAGE_PMD_NR; i++) {
+ page = head_page + i;
+ page->compound_head = (unsigned long)head_page + 1;
+ compound_pad += COMPOUND_PAD_DELTA;
+ page->_compound_pad_2 = (unsigned long)head_page + compound_pad;
+ temp = (unsigned long *)(&(page->_compound_pad_2));
+ temp[1] = LIST_POISON4;
+ }
+}
+
+static void reserve_user_huge_pmd_pages(struct page *page)
+{
+ struct page *head_page;
+
+ if (!atomic_read(&page->_refcount)) {
+ atomic_inc(&page->_refcount);
+ head_page = find_head_page(page);
+ reserve_page_from_buddy((1 << HPAGE_PMD_ORDER), page);
+ init_huge_pmd_pages(page);
+ } else {
+ pr_warn("Page %pK refcount %d large than zero, no need reserve.\n",
+ page, page->_refcount.counter);
+ }
+}
+
+static void reserve_user_space_map_pages(void)
+{
+ struct page_map_info *pmi;
+ struct page_map_entry *pme;
+ unsigned int i, j, index;
+ struct page *page;
+ unsigned long flags;
+ unsigned long page_size;
+ int err = 0;
+ unsigned long phy_addr;
+
+ if (!user_space_reserve_start)
+ return;
+ spin_lock_irqsave(&page_map_entry_lock, flags);
+ for (index = 0; index < pin_pid_num; index++) {
+ pmi = &(user_space_reserve_start[index]);
+ pme = pmi->pme;
+
+ for (i = 0; i < pmi->entry_num; i++) {
+ err = 0;
+ for (j = 0; j < pme->nr_pages; j++) {
+ phy_addr = pme->phy_addr_array[j];
+ if (!phy_addr)
+ continue;
+ page = phys_to_page(phy_addr);
+ if (atomic_read(&page->_refcount)) {
+ pme->phy_addr_array[j] = 0;
+ page_size = pme->is_huge_page ? HPAGE_PMD_SIZE : PAGE_SIZE;
+ continue;
+ }
+ if (!pme->is_huge_page) {
+ reserve_user_normal_pages(page);
+ } else {
+ reserve_user_huge_pmd_pages(page);
+ }
+ }
+ pme = (struct page_map_entry *)next_pme(pme);
+ if (err)
+ err_phy_num++;
+ }
+ page_size = pme->is_huge_page ? HPAGE_PMD_SIZE : PAGE_SIZE;
+ }
+ spin_unlock(&page_map_entry_lock);
+}
+
+
+/* The whole page map entry collect process must be Sequentially.
+ The user_space_reserve_start points to the first page map info for
+ the first dump task. And the page_map_entry_start points to
+ the first page map entry of the first dump vma. */
+static void init_page_map_info(unsigned int *map_addr)
+{
+ unsigned long map_len = pin_memory_resource.end - pin_memory_resource.start;
+
+ if (user_space_reserve_start || !max_pin_pid_num)
+ return;
+ pin_pid_num = *map_addr;
+ pin_pid_num_addr = map_addr;
+ user_space_reserve_start =
+ (struct kup_page_map_info *)(map_addr + 1);
+ page_map_entry_start =
+ (struct page_map_entry *)(user_space_reserve_start + max_pin_pid_num);
+ page_map_entry_end = (unsigned long)map_addr + map_len;
+ if (pin_pid_num > 0)
+ reserve_user_space_map_pages();
+}
+
+int collect_pmd_huge_pages(struct task_struct *task,
+ unsigned long start_addr, unsigned long end_addr, struct page_map_entry *pme)
+{
+ long res;
+ int index = 0;
+ unsigned long start = start_addr;
+ struct page *temp_page;
+
+ while (start < end_addr) {
+ temp_page = NULL;
+ res = get_user_pages_remote(task, task->mm, start, 1,
+ FOLL_TOUCH|FOLL_GET, &temp_page, NULL, NULL);
+ if (!res) {
+ pr_warn("Get huge page for addr(%lx) fail.", start);
+ return COLLECT_PAGES_FAIL;
+ }
+ if (PageHead(temp_page)) {
+ start += HPAGE_PMD_SIZE;
+ pme->phy_addr_array[index] = page_to_phys(temp_page);
+ index++;
+ } else {
+ pme->nr_pages = index;
+ atomic_dec(&((temp_page)->_refcount));
+ return COLLECT_PAGES_NEED_CONTINUE;
+ }
+ }
+ pme->nr_pages = index;
+ return COLLECT_PAGES_FINISH;
+}
+
+int collect_normal_pages(struct task_struct *task,
+ unsigned long start_addr, unsigned long end_addr, struct page_map_entry *pme)
+{
+ int res;
+ unsigned long next;
+ unsigned long i, nr_pages;
+ struct page *tmp_page;
+ unsigned long *phy_addr_array = pme->phy_addr_array;
+ struct page **page_array = (struct page **)pme->phy_addr_array;
+
+ next = (start_addr & HPAGE_PMD_MASK) + HPAGE_PMD_SIZE;
+ next = (next > end_addr) ? end_addr : next;
+ pme->nr_pages = 0;
+ while (start_addr < next) {
+ nr_pages = (next - start_addr) / PAGE_SIZE;
+ res = get_user_pages_remote(task, task->mm, start_addr, 1,
+ FOLL_TOUCH|FOLL_GET, &tmp_page, NULL, NULL);
+ if (!res) {
+ pr_warn("Get user pages of %lx fail.\n", start_addr);
+ return COLLECT_PAGES_FAIL;
+ }
+ if (PageHead(tmp_page)) {
+ atomic_dec(&(tmp_page->_refcount));
+ return COLLECT_PAGES_NEED_CONTINUE;
+ }
+ atomic_dec(&(tmp_page->_refcount));
+ if (PageTail(tmp_page)) {
+ start_addr = next;
+ pme->virt_addr = start_addr;
+ next = (next + HPAGE_PMD_SIZE) > end_addr ? end_addr : (next + HPAGE_PMD_SIZE);
+ continue;
+ }
+ res = get_user_pages_remote(task, task->mm, start_addr, nr_pages,
+ FOLL_TOUCH|FOLL_GET, page_array, NULL, NULL);
+ if (!res) {
+ pr_warn("Get user pages of %lx fail.\n", start_addr);
+ return COLLECT_PAGES_FAIL;
+ }
+ for (i = 0; i < nr_pages; i++) {
+ phy_addr_array[i] = page_to_phys(page_array[i]);
+ }
+ pme->nr_pages += nr_pages;
+ page_array += nr_pages;
+ phy_addr_array += nr_pages;
+ start_addr = next;
+ next = (next + HPAGE_PMD_SIZE) > end_addr ? end_addr : (next + HPAGE_PMD_SIZE);
+ }
+ return COLLECT_PAGES_FINISH;
+}
+
+/* Users make sure that the pin memory belongs to anonymous vma. */
+int pin_mem_area(struct task_struct *task, struct mm_struct *mm,
+ unsigned long start_addr, unsigned long end_addr)
+{
+ int pid, ret;
+ int is_huge_page = false;
+ unsigned int page_size;
+ unsigned long nr_pages, flags;
+ struct page_map_entry *pme;
+ struct page_map_info *pmi;
+ struct vm_area_struct *vma;
+ unsigned long i;
+ struct page *tmp_page;
+
+ if (!page_map_entry_start
+ || !task || !mm
+ || start_addr >= end_addr)
+ return -EFAULT;
+
+ pid = task->pid;
+ spin_lock_irqsave(&page_map_entry_lock, flags);
+ nr_pages = ((end_addr - start_addr) / PAGE_SIZE);
+ if ((unsigned long)page_map_entry_start + nr_pages * sizeof(struct page *)
+ >= page_map_entry_end) {
+ pr_warn("Page map entry use up!\n");
+ ret = -EFAULT;
+ goto finish;
+ }
+ vma = find_extend_vma(mm, start_addr);
+ if (!vma) {
+ pr_warn("Find no match vma!\n");
+ ret = -EFAULT;
+ goto finish;
+ }
+ if (start_addr == (start_addr & HPAGE_PMD_MASK) &&
+ transparent_hugepage_enabled(vma)) {
+ page_size = HPAGE_PMD_SIZE;
+ is_huge_page = true;
+ } else {
+ page_size = PAGE_SIZE;
+ }
+ pme = page_map_entry_start;
+ pme->virt_addr = start_addr;
+ pme->is_huge_page = is_huge_page;
+ memset(pme->phy_addr_array, 0, nr_pages * sizeof(unsigned long));
+ down_write(&mm->mmap_sem);
+ if (!is_huge_page) {
+ ret = collect_normal_pages(task, start_addr, end_addr, pme);
+ if (!pme->nr_pages) {
+ if (ret == COLLECT_PAGES_FINISH) {
+ ret = 0;
+ up_write(&mm->mmap_sem);
+ goto finish;
+ }
+ pme->is_huge_page = true;
+ page_size = HPAGE_PMD_SIZE;
+ ret = collect_pmd_huge_pages(task, pme->virt_addr, end_addr, pme);
+ }
+ } else {
+ ret = collect_pmd_huge_pages(task, start_addr, end_addr, pme);
+ if (!pme->nr_pages) {
+ if (ret == COLLECT_PAGES_FINISH) {
+ ret = 0;
+ up_write(&mm->mmap_sem);
+ goto finish;
+ }
+ pme->is_huge_page = false;
+ page_size = PAGE_SIZE;
+ ret = collect_normal_pages(task, pme->virt_addr, end_addr, pme);
+ }
+ }
+ up_write(&mm->mmap_sem);
+ if (ret == COLLECT_PAGES_FAIL) {
+ ret = -EFAULT;
+ goto finish;
+ }
+
+ /* check for zero pages */
+ for (i = 0; i < pme->nr_pages; i++) {
+ tmp_page = phys_to_page(pme->phy_addr_array[i]);
+ if (!pme->is_huge_page) {
+ if (page_to_pfn(tmp_page) == my_zero_pfn(pme->virt_addr + i * PAGE_SIZE))
+ pme->phy_addr_array[i] = 0;
+ } else if (is_huge_zero_page(tmp_page))
+ pme->phy_addr_array[i] = 0;
+ }
+
+ page_map_entry_start = (struct page_map_entry *)(next_pme(pme));
+ pmi = get_page_map_info(pid);
+ if (!pmi)
+ pmi = create_page_map_info(pid);
+ if (!pmi) {
+ pr_warn("Create page map info fail for pid: %d!\n", pid);
+ ret = -EFAULT;
+ goto finish;
+ }
+ if (!pmi->pme)
+ pmi->pme = pme;
+ pmi->entry_num++;
+ spin_unlock_irqrestore(&page_map_entry_lock, flags);
+ if (ret == COLLECT_PAGES_NEED_CONTINUE) {
+ ret = pin_mem_area(task, mm, pme->virt_addr + pme->nr_pages * page_size, end_addr);
+ }
+ return ret;
+finish:
+ spin_unlock_irqrestore(&page_map_entry_lock, flags);
+ return ret;
+}
+EXPORT_SYMBOL_GPL(pin_mem_area);
+
+vm_fault_t remap_normal_pages(struct mm_struct *mm, struct vm_area_struct *vma,
+ struct page_map_entry *pme)
+{
+ int ret;
+ unsigned int j;
+ pgd_t *pgd;
+ p4d_t *p4d;
+ pmd_t *pmd;
+ pud_t *pud;
+ struct page *page;
+ unsigned long address;
+ unsigned long phy_addr;
+
+ for (j = 0; j < pme->nr_pages; j++) {
+ address = pme->virt_addr + j * PAGE_SIZE;
+ phy_addr = pme->phy_addr_array[j];
+ if (!phy_addr)
+ continue;
+ page = phys_to_page(phy_addr);
+ if (page->flags & (1 << PG_reserved))
+ page->flags -= (1 << PG_reserved);
+ if (page_to_pfn(page) == my_zero_pfn(address)) {
+ pme->phy_addr_array[j] = 0;
+ continue;
+ }
+ page->mapping = NULL;
+ pgd = pgd_offset(mm, address);
+ p4d = p4d_alloc(mm, pgd, address);
+ if (!p4d)
+ return VM_FAULT_OOM;
+ pud = pud_alloc(mm, p4d, address);
+ if (!pud)
+ return VM_FAULT_OOM;
+ pmd = pmd_alloc(mm, pud, address);
+ if (!pmd)
+ return VM_FAULT_OOM;
+ ret = do_anon_page_remap(vma, address, pmd, page);
+ if (ret == VM_FAULT_OOM)
+ return ret;
+ }
+ return 0;
+}
+
+vm_fault_t remap_huge_pmd_pages(struct mm_struct *mm, struct vm_area_struct *vma,
+ struct page_map_entry *pme)
+{
+ int ret;
+ unsigned int j;
+ pgd_t *pgd;
+ p4d_t *p4d;
+ pmd_t *pmd;
+ pud_t *pud;
+ struct page *page;
+ unsigned long address;
+ unsigned long phy_addr;
+
+ for (j = 0; j < pme->nr_pages; j++) {
+ address = pme->virt_addr + j * HPAGE_PMD_SIZE;
+ phy_addr = pme->phy_addr_array[j];
+ if (!phy_addr)
+ continue;
+ page = phys_to_page(phy_addr);
+ if (page->flags & (1 << PG_reserved))
+ page->flags -= (1 << PG_reserved);
+ if (is_huge_zero_page(page)) {
+ pme->phy_addr_array[j] = 0;
+ continue;
+ }
+ pgd = pgd_offset(mm, address);
+ p4d = p4d_alloc(mm, pgd, address);
+ if (!p4d)
+ return VM_FAULT_OOM;
+ pud = pud_alloc(mm, p4d, address);
+ if (!pud)
+ return VM_FAULT_OOM;
+ pmd = pmd_alloc(mm, pud, address);
+ if (!pmd)
+ return VM_FAULT_OOM;
+ ret = do_anon_huge_page_remap(vma, address, pmd, page);
+ if (ret == VM_FAULT_OOM)
+ return ret;
+ }
+ return 0;
+}
+
+vm_fault_t do_mem_remap(int pid, struct mm_struct *mm)
+{
+ unsigned int i = 0;
+ vm_fault_t ret = 0;
+ struct vm_area_struct *vma;
+ struct page_map_info *pmi;
+ struct page_map_entry *pme;
+
+ pmi = get_page_map_info(pid);
+ if (!pmi)
+ return -EFAULT;
+ down_write(&mm->mmap_sem);
+ pme = pmi->pme;
+ vma = mm->mmap;
+ while ((i < pmi->entry_num) && (vma != NULL)) {
+ if (pme->virt_addr >= vma->vm_start && pme->virt_addr < vma->vm_end) {
+ i++;
+ if (!vma_is_anonymous(vma)) {
+ pme = (struct page_map_entry *)(next_pme(pme));
+ continue;
+ }
+ if (!pme->is_huge_page) {
+ ret = remap_normal_pages(mm, vma, pme);
+ if (ret < 0)
+ goto out;
+ } else {
+ ret = remap_huge_pmd_pages(mm, vma, pme);
+ if (ret < 0)
+ goto out;
+ }
+ pme = (struct page_map_entry *)(next_pme(pme));
+ } else {
+ vma = vma->vm_next;
+ }
+ }
+out:
+ up_write(&mm->mmap_sem);
+ return ret;
+}
+EXPORT_SYMBOL_GPL(do_mem_remap);
+
+#if defined(CONFIG_ARM64)
+void init_reserve_page_map(unsigned long map_addr, unsigned long map_size)
+{
+ void *addr;
+
+ if (!map_addr || !map_size)
+ return;
+ addr = phys_to_virt(map_addr);
+ init_page_map_info((unsigned int *)addr);
+}
+#else
+void init_reserve_page_map(unsigned long map_addr, unsigned long map_size)
+{
+}
+#endif
+
+/* Clear all pin memory record. */
+void clear_pin_memory_record(void)
+{
+ if (pin_pid_num_addr) {
+ *pin_pid_num_addr = 0;
+ pin_pid_num = 0;
+ page_map_entry_start = (struct page_map_entry *)__page_map_entry_start;
+ }
+ if (kernel_space_reserve_start && kernel_pin_space_size > 0) {
+ *(unsigned long *)kernel_space_reserve_start = 0;
+ }
+}
+EXPORT_SYMBOL_GPL(clear_pin_memory_record);
+
+vm_fault_t reserve_kernel_space_mem(unsigned long start_addr, unsigned int pages)
+{
+ unsigned long i;
+ unsigned long entry_num;
+ struct page_map_entry *pme, *pme_start;
+
+
+ entry_num = *(unsigned long *)kernel_space_reserve_start;
+ pme_start = (struct page_map_entry *)(kernel_space_reserve_start + sizeof(entry_num));
+ pme = pme_start;
+ spin_lock(&page_map_entry_lock);
+ for (i = 0; i < entry_num; i++) {
+ if (start_addr == pme->virt_addr) {
+ spin_unlock(&page_map_entry_lock);
+ return 0;
+ }
+ pme = pme + 1;
+ }
+ if ((unsigned long)(pme_start + entry_num) >= kernel_space_reserve_end) {
+ spin_unlock(&page_map_entry_lock);
+ return VM_FAULT_OOM;
+ }
+ pme = pme_start + entry_num;
+ pme->virt_addr = start_addr;
+ pme->nr_pages = pages;
+ pme->is_huge_page = false;
+ *(unsigned long *)kernel_space_reserve_start = entry_num + 1;
+ spin_unlock(&page_map_entry_lock);
+ return 0;
+}
+EXPORT_SYMBOL_GPL(reserve_kernel_space_mem);
+
+#endif /* CONFIG_PIN_MEMORY */
--
1.8.3.1
1
0
hulk inclusion
category: bugfix
bugzilla: NA
CVE: NA
MAP_PA32BIT was defined in uapi/asm-generic/mman.h, that was not
automatically included by mm/mmap.c when building on mips platform, and
result in following compiling error:
mm/mmap.c: In function ‘do_mmap’:
mm/mmap.c:1450:14: error: ‘MAP_PA32BIT’ undeclared (first use in this function); did you mean ‘MAP_32BIT’?
if (flags & MAP_PA32BIT)
^~~~~~~~~~~
MAP_32BIT
mm/mmap.c:1450:14: note: each undeclared identifier is reported only once for each function it appears in
make[1]: *** [scripts/Makefile.build:303: mm/mmap.o] Error 1
Fixes: e138253f2b82 ("svm: add support for allocing memory which is within 4G physical address in svm_mmap")
Signed-off-by: Zhengyuan Liu <liuzhengyuan(a)tj.kylinos.cn>
---
arch/mips/include/uapi/asm/mman.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/mips/include/uapi/asm/mman.h b/arch/mips/include/uapi/asm/mman.h
index 3035ca499cd8..0247a3c705af 100644
--- a/arch/mips/include/uapi/asm/mman.h
+++ b/arch/mips/include/uapi/asm/mman.h
@@ -51,6 +51,7 @@
#define MAP_STACK 0x40000 /* give out an address that is best suited for process/thread stacks */
#define MAP_HUGETLB 0x80000 /* create a huge page mapping */
#define MAP_FIXED_NOREPLACE 0x100000 /* MAP_FIXED which doesn't unmap underlying mapping */
+#define MAP_PA32BIT 0x400000
/*
* Flags for msync
--
2.17.1
4
4