The patch titled Subject: vmcore: convert read_from_oldmem() to take an iov_iter has been added to the -mm tree. Its filename is vmcore-convert-read_from_oldmem-to-take-an-iov_iter.patch This patch should soon appear at https://ozlabs.org/~akpm/mmots/broken-out/vmcore-convert-read_from_oldmem-to-take-an-iov_iter.patch and later at https://ozlabs.org/~akpm/mmotm/broken-out/vmcore-convert-read_from_oldmem-to-take-an-iov_iter.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: "Matthew Wilcox (Oracle)" <willy@xxxxxxxxxxxxx> Subject: vmcore: convert read_from_oldmem() to take an iov_iter Remove the read_from_oldmem() wrapper introduced earlier and convert all the remaining callers to pass an iov_iter. Link: https://lkml.kernel.org/r/20220408090636.560886-4-bhe@xxxxxxxxxx Signed-off-by: Matthew Wilcox (Oracle) <willy@xxxxxxxxxxxxx> Signed-off-by: Baoquan He <bhe@xxxxxxxxxx> Reviewed-by: Christoph Hellwig <hch@xxxxxx> Cc: Tiezhu Yang <yangtiezhu@xxxxxxxxxxx> Cc: Amit Daniel Kachhap <amit.kachhap@xxxxxxx> Cc: Al Viro <viro@xxxxxxxxxxxxxxxxxx> Cc: Matthew Wilcox <willy@xxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- arch/x86/kernel/crash_dump_64.c | 7 ++++- fs/proc/vmcore.c | 40 +++++++++++------------------- include/linux/crash_dump.h | 10 +++---- 3 files changed, 25 insertions(+), 32 deletions(-) --- a/arch/x86/kernel/crash_dump_64.c~vmcore-convert-read_from_oldmem-to-take-an-iov_iter +++ a/arch/x86/kernel/crash_dump_64.c @@ -54,6 +54,11 @@ ssize_t copy_oldmem_page_encrypted(struc ssize_t elfcorehdr_read(char *buf, size_t count, u64 *ppos) { - return read_from_oldmem(buf, count, ppos, 0, + struct kvec kvec = { .iov_base = buf, .iov_len = count }; + struct iov_iter iter; + + iov_iter_kvec(&iter, READ, &kvec, 1, count); + + return read_from_oldmem(&iter, count, ppos, cc_platform_has(CC_ATTR_GUEST_MEM_ENCRYPT)); } --- a/fs/proc/vmcore.c~vmcore-convert-read_from_oldmem-to-take-an-iov_iter +++ a/fs/proc/vmcore.c @@ -129,7 +129,7 @@ static int open_vmcore(struct inode *ino } /* Reads a page from the oldmem device from given offset. */ -static ssize_t read_from_oldmem_iter(struct iov_iter *iter, size_t count, +ssize_t read_from_oldmem(struct iov_iter *iter, size_t count, u64 *ppos, bool encrypted) { unsigned long pfn, offset; @@ -178,27 +178,6 @@ static ssize_t read_from_oldmem_iter(str return read; } -ssize_t read_from_oldmem(char *buf, size_t count, - u64 *ppos, int userbuf, - bool encrypted) -{ - struct iov_iter iter; - struct iovec iov; - struct kvec kvec; - - if (userbuf) { - iov.iov_base = (__force void __user *)buf; - iov.iov_len = count; - iov_iter_init(&iter, READ, &iov, 1, count); - } else { - kvec.iov_base = buf; - kvec.iov_len = count; - iov_iter_kvec(&iter, READ, &kvec, 1, count); - } - - return read_from_oldmem_iter(&iter, count, ppos, encrypted); -} - /* * Architectures may override this function to allocate ELF header in 2nd kernel */ @@ -218,7 +197,12 @@ void __weak elfcorehdr_free(unsigned lon */ ssize_t __weak elfcorehdr_read(char *buf, size_t count, u64 *ppos) { - return read_from_oldmem(buf, count, ppos, 0, false); + struct kvec kvec = { .iov_base = buf, .iov_len = count }; + struct iov_iter iter; + + iov_iter_kvec(&iter, READ, &kvec, 1, count); + + return read_from_oldmem(&iter, count, ppos, false); } /* @@ -226,7 +210,13 @@ ssize_t __weak elfcorehdr_read(char *buf */ ssize_t __weak elfcorehdr_read_notes(char *buf, size_t count, u64 *ppos) { - return read_from_oldmem(buf, count, ppos, 0, cc_platform_has(CC_ATTR_MEM_ENCRYPT)); + struct kvec kvec = { .iov_base = buf, .iov_len = count }; + struct iov_iter iter; + + iov_iter_kvec(&iter, READ, &kvec, 1, count); + + return read_from_oldmem(&iter, count, ppos, + cc_platform_has(CC_ATTR_MEM_ENCRYPT)); } /* @@ -402,7 +392,7 @@ static ssize_t __read_vmcore(struct iov_ m->offset + m->size - *fpos, iov_iter_count(iter)); start = m->paddr + *fpos - m->offset; - tmp = read_from_oldmem_iter(iter, tsz, &start, + tmp = read_from_oldmem(iter, tsz, &start, cc_platform_has(CC_ATTR_MEM_ENCRYPT)); if (tmp < 0) return tmp; --- a/include/linux/crash_dump.h~vmcore-convert-read_from_oldmem-to-take-an-iov_iter +++ a/include/linux/crash_dump.h @@ -134,13 +134,11 @@ static inline int vmcore_add_device_dump #endif /* CONFIG_PROC_VMCORE_DEVICE_DUMP */ #ifdef CONFIG_PROC_VMCORE -ssize_t read_from_oldmem(char *buf, size_t count, - u64 *ppos, int userbuf, - bool encrypted); +ssize_t read_from_oldmem(struct iov_iter *iter, size_t count, + u64 *ppos, bool encrypted); #else -static inline ssize_t read_from_oldmem(char *buf, size_t count, - u64 *ppos, int userbuf, - bool encrypted) +static inline ssize_t read_from_oldmem(struct iov_iter *iter, size_t count, + u64 *ppos, bool encrypted) { return -EOPNOTSUPP; } _ Patches currently in -mm which might be from willy@xxxxxxxxxxxxx are vmcore-convert-copy_oldmem_page-to-take-an-iov_iter.patch vmcore-convert-__read_vmcore-to-use-an-iov_iter.patch vmcore-convert-read_from_oldmem-to-take-an-iov_iter.patch