From: Alexander Gordeev <agordeev@linux.ibm.com>
To: Matthew Wilcox <willy@infradead.org>,
Alexander Egorenkov <egorenar@linux.ibm.com>,
Heiko Carstens <hca@linux.ibm.com>
Cc: Baoquan He <bhe@redhat.com>, Christoph Hellwig <hch@lst.de>,
Vasily Gorbik <gor@linux.ibm.com>,
Al Viro <viro@zeniv.linux.org.uk>,
linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org
Subject: [PATCH v4 2/4] s390/crash: move copy_to_user_real() to crash_dump.c
Date: Tue, 19 Jul 2022 07:16:34 +0200 [thread overview]
Message-ID: <e8de968d40202d87caa09aef12e9c67ec23a1c1a.1658206891.git.agordeev@linux.ibm.com> (raw)
In-Reply-To: <cover.1658206891.git.agordeev@linux.ibm.com>
Function copy_to_user_real() does not really belong to maccess.c.
It is only used for copying oldmem to user space, so let's move
it to the friends.
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
---
arch/s390/include/asm/uaccess.h | 1 -
arch/s390/kernel/crash_dump.c | 26 ++++++++++++++++++++++++++
arch/s390/mm/maccess.c | 26 --------------------------
3 files changed, 26 insertions(+), 27 deletions(-)
diff --git a/arch/s390/include/asm/uaccess.h b/arch/s390/include/asm/uaccess.h
index f4511e21d646..2a067315fe59 100644
--- a/arch/s390/include/asm/uaccess.h
+++ b/arch/s390/include/asm/uaccess.h
@@ -285,7 +285,6 @@ static inline unsigned long __must_check clear_user(void __user *to, unsigned lo
return __clear_user(to, n);
}
-int copy_to_user_real(void __user *dest, unsigned long src, unsigned long count);
void *s390_kernel_write(void *dst, const void *src, size_t size);
int __noreturn __put_kernel_bad(void);
diff --git a/arch/s390/kernel/crash_dump.c b/arch/s390/kernel/crash_dump.c
index 0efee5c49b1e..8d7332d4444c 100644
--- a/arch/s390/kernel/crash_dump.c
+++ b/arch/s390/kernel/crash_dump.c
@@ -173,6 +173,32 @@ int copy_oldmem_kernel(void *dst, unsigned long src, size_t count)
return 0;
}
+/*
+ * Copy memory from kernel (real) to user (virtual)
+ */
+static int copy_to_user_real(void __user *dest, unsigned long src, unsigned long count)
+{
+ int offs = 0, size, rc;
+ char *buf;
+
+ buf = (char *)__get_free_page(GFP_KERNEL);
+ if (!buf)
+ return -ENOMEM;
+ rc = -EFAULT;
+ while (offs < count) {
+ size = min(PAGE_SIZE, count - offs);
+ if (memcpy_real(buf, src + offs, size))
+ goto out;
+ if (copy_to_user(dest + offs, buf, size))
+ goto out;
+ offs += size;
+ }
+ rc = 0;
+out:
+ free_page((unsigned long)buf);
+ return rc;
+}
+
/*
* Copy memory of the old, dumped system to a user space virtual address
*/
diff --git a/arch/s390/mm/maccess.c b/arch/s390/mm/maccess.c
index 421efa46946b..d6d84e02f35a 100644
--- a/arch/s390/mm/maccess.c
+++ b/arch/s390/mm/maccess.c
@@ -171,32 +171,6 @@ void memcpy_absolute(void *dest, void *src, size_t count)
arch_local_irq_restore(flags);
}
-/*
- * Copy memory from kernel (real) to user (virtual)
- */
-int copy_to_user_real(void __user *dest, unsigned long src, unsigned long count)
-{
- int offs = 0, size, rc;
- char *buf;
-
- buf = (char *) __get_free_page(GFP_KERNEL);
- if (!buf)
- return -ENOMEM;
- rc = -EFAULT;
- while (offs < count) {
- size = min(PAGE_SIZE, count - offs);
- if (memcpy_real(buf, src + offs, size))
- goto out;
- if (copy_to_user(dest + offs, buf, size))
- goto out;
- offs += size;
- }
- rc = 0;
-out:
- free_page((unsigned long) buf);
- return rc;
-}
-
/*
* Check if physical address is within prefix or zero page
*/
--
2.34.1
next prev parent reply other threads:[~2022-07-19 5:26 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-19 5:16 [PATCH v4 0/4] s390/crash: support multi-segment iterators Alexander Gordeev
2022-07-19 5:16 ` [PATCH v4 1/4] s390/zcore: fix race when reading from hardware system area Alexander Gordeev
2022-07-19 5:16 ` Alexander Gordeev [this message]
2022-07-19 5:16 ` [PATCH v4 3/4] s390/crash: use static swap buffer for copy_to_user_real() Alexander Gordeev
2022-07-19 5:16 ` [PATCH v4 4/4] s390/crash: support multi-segment iterators Alexander Gordeev
2022-07-20 3:17 ` [PATCH v4 0/4] " Al Viro
2022-07-20 15:44 ` Alexander Gordeev
2022-07-21 8:46 ` Alexander Gordeev
2022-07-21 20:05 ` Al Viro
2022-07-20 9:47 ` Heiko Carstens
2022-07-20 12:15 ` Alexander Egorenkov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e8de968d40202d87caa09aef12e9c67ec23a1c1a.1658206891.git.agordeev@linux.ibm.com \
--to=agordeev@linux.ibm.com \
--cc=bhe@redhat.com \
--cc=egorenar@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=hch@lst.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®