hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/release-management/issues/ID3TGE -------------------------------- Add a new interface dump_pagetable for debug, user can use it to dump the pagetables of vaddr. Signed-off-by: Liu Mingrui <liumingrui@huawei.com> --- drivers/zcopy/zcopy.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/zcopy/zcopy.c b/drivers/zcopy/zcopy.c index f36b6e252224..5c801e88fc58 100644 --- a/drivers/zcopy/zcopy.c +++ b/drivers/zcopy/zcopy.c @@ -35,6 +35,7 @@ enum pgt_entry { enum { IO_ATTACH = 1, + IO_DUMP = 3, IO_MAX }; @@ -46,6 +47,11 @@ struct zcopy_ioctl_pswap { unsigned long size; }; +struct zcopy_ioctl_dump { + unsigned long size; + unsigned long addr; +}; + struct zcopy_cdev { struct cdev chrdev; dev_t dev; @@ -60,6 +66,7 @@ static int (*__zcopy_pte_alloc)(struct mm_struct *, pmd_t *); static int (*__zcopy_pmd_alloc)(struct mm_struct *, pud_t *, unsigned long); static int (*__zcopy_pud_alloc)(struct mm_struct *, p4d_t *, unsigned long); static unsigned long (*kallsyms_lookup_name_funcp)(const char *); +static void (*dump_pagetable)(unsigned long addr); static struct kretprobe __kretprobe; @@ -547,6 +554,19 @@ static long zcopy_ioctl(struct file *file, unsigned int type, unsigned long ptr) ctx.src_pid, ctx.size); break; } + case IO_DUMP: + { + struct zcopy_ioctl_dump param; + + if (copy_from_user((void *)¶m, (void *)ptr, + sizeof(struct zcopy_ioctl_dump))) { + pr_err("copy from user for dump failed\n"); + ret = -EFAULT; + break; + } + dump_pagetable(param.addr); + break; + } default: break; } @@ -603,6 +623,11 @@ static int register_unexport_func(void) = (int (*)(struct mm_struct *, p4d_t *, unsigned long)) __kallsyms_lookup_name("__pud_alloc"); ret = REGISTER_CHECK(__zcopy_pud_alloc, "__pud_alloc"); + if (ret) + goto out; + + dump_pagetable = (void (*)(unsigned long))__kallsyms_lookup_name("show_pte"); + ret = REGISTER_CHECK(dump_pagetable, "show_pte"); out: return ret; -- 2.33.0