
From: ZhangPeng <zhangpeng362@huawei.com> hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I8KESX CVE: NA -------------------------------- The uffd_msg.reserved3 field is used to transfer the CPU information of the PF. Signed-off-by: ZhangPeng <zhangpeng362@huawei.com> --- fs/userfaultfd.c | 3 +++ include/linux/userswap.h | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c index 207467a46e7a..4db4a6b8a4a3 100644 --- a/fs/userfaultfd.c +++ b/fs/userfaultfd.c @@ -269,6 +269,9 @@ static inline struct uffd_msg userfault_msg(unsigned long address, msg.arg.pagefault.flags |= UFFD_PAGEFAULT_FLAG_MINOR; if (features & UFFD_FEATURE_THREAD_ID) msg.arg.pagefault.feat.ptid = task_pid_vnr(current); +#ifdef CONFIG_USERSWAP + uswap_get_cpu_id(reason, &msg); +#endif return msg; } diff --git a/include/linux/userswap.h b/include/linux/userswap.h index 10a7111e9129..cecdef09c66f 100644 --- a/include/linux/userswap.h +++ b/include/linux/userswap.h @@ -50,5 +50,11 @@ static inline bool uswap_check_copy(struct vm_area_struct *vma, return true; } +static inline void uswap_get_cpu_id(unsigned long reason, struct uffd_msg *msg) +{ + if (reason & VM_USWAP) + msg->reserved3 = smp_processor_id(); +} + #endif /* CONFIG_USERSWAP */ #endif /* _LINUX_USERSWAP_H */ -- 2.25.1