From: "Ozan Çağlayan" <ozancag@gmail.com>
To: mcgrof@kernel.org
Cc: linux-wireless@vger.kernel.org, "Ozan Çağlayan" <ozancag@gmail.com>
Subject: [PATCH 3/3] compat: Backport fault_in_multipages_{writeable,readable}
Date: Thu, 14 Jun 2012 20:52:46 +0300 [thread overview]
Message-ID: <1339696366-26970-3-git-send-email-ozancag@gmail.com> (raw)
In-Reply-To: <1339696366-26970-1-git-send-email-ozancag@gmail.com>
This backports:
commit f56f821feb7b36223f309e0ec05986bb137ce418
Author: Daniel Vetter <daniel.vetter@ffwll.ch>
Date: Sun Mar 25 19:47:41 2012 +0200
mm: extend prefault helpers to fault in more than PAGE_SIZE
The new functions are used by drm/i915 driver.
Trying kernel 3.4.0-030400-generic [OK]
Trying kernel 3.3.7-030307-generic [OK]
Trying kernel 3.2.2-030202-generic [OK]
Trying kernel 3.1.10-030110-generic [OK]
Trying kernel 3.0.18-030018-generic [OK]
Trying kernel 2.6.39-02063904-generic [OK]
Trying kernel 2.6.38-02063808-generic [OK]
Trying kernel 2.6.37-02063706-generic [OK]
Trying kernel 2.6.36-02063604-generic [OK]
Trying kernel 2.6.35-02063512-generic [OK]
Trying kernel 2.6.34-02063410-generic [OK]
Trying kernel 2.6.33-02063305-generic [OK]
Trying kernel 2.6.32-02063255-generic [OK]
Trying kernel 2.6.31-02063113-generic [OK]
Trying kernel 2.6.30-02063010-generic [OK]
Trying kernel 2.6.29-02062906-generic [OK]
Trying kernel 2.6.28-02062810-generic [OK]
Trying kernel 2.6.27-020627-generic [OK]
Trying kernel 2.6.26-020626-generic [OK]
Trying kernel 2.6.25-020625-generic [OK]
Trying kernel 2.6.24-020624-generic [OK]
Signed-off-by: Ozan Çağlayan <ozancag@gmail.com>
---
include/linux/compat-3.5.h | 67 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 67 insertions(+)
diff --git a/include/linux/compat-3.5.h b/include/linux/compat-3.5.h
index 1d9128a..74c8176 100644
--- a/include/linux/compat-3.5.h
+++ b/include/linux/compat-3.5.h
@@ -8,6 +8,73 @@
#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0))
+/*
+ * This backports:
+ *
+ * commit f56f821feb7b36223f309e0ec05986bb137ce418
+ * Author: Daniel Vetter <daniel.vetter@ffwll.ch>
+ * Date: Sun Mar 25 19:47:41 2012 +0200
+ *
+ * mm: extend prefault helpers to fault in more than PAGE_SIZE
+ *
+ * The new functions are used by drm/i915 driver.
+ *
+ */
+
+static inline int fault_in_multipages_writeable(char __user *uaddr, int size)
+{
+ int ret = 0;
+ char __user *end = uaddr + size - 1;
+
+ if (unlikely(size == 0))
+ return ret;
+
+ /*
+ * Writing zeroes into userspace here is OK, because we know that if
+ * the zero gets there, we'll be overwriting it.
+ */
+ while (uaddr <= end) {
+ ret = __put_user(0, uaddr);
+ if (ret != 0)
+ return ret;
+ uaddr += PAGE_SIZE;
+ }
+
+ /* Check whether the range spilled into the next page. */
+ if (((unsigned long)uaddr & PAGE_MASK) ==
+ ((unsigned long)end & PAGE_MASK))
+ ret = __put_user(0, end);
+
+ return ret;
+}
+
+static inline int fault_in_multipages_readable(const char __user *uaddr,
+ int size)
+{
+ volatile char c;
+ int ret = 0;
+ const char __user *end = uaddr + size - 1;
+
+ if (unlikely(size == 0))
+ return ret;
+
+ while (uaddr <= end) {
+ ret = __get_user(c, uaddr);
+ if (ret != 0)
+ return ret;
+ uaddr += PAGE_SIZE;
+ }
+
+ /* Check whether the range spilled into the next page. */
+ if (((unsigned long)uaddr & PAGE_MASK) ==
+ ((unsigned long)end & PAGE_MASK)) {
+ ret = __get_user(c, end);
+ (void)c;
+ }
+
+ return ret;
+}
+
/* switcheroo is available on >= 2.6.34 */
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34))
#include <linux/vga_switcheroo.h>
--
1.7.10.2
next prev parent reply other threads:[~2012-06-14 17:53 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-14 17:52 [PATCH 1/3] compat: Backport vga_switcheroo_client_ops Ozan Çağlayan
2012-06-14 17:52 ` [PATCH 2/3] compat: Fix cosmetic typo in compat-3.4.c Ozan Çağlayan
2012-06-14 17:52 ` Ozan Çağlayan [this message]
2012-06-14 21:30 ` [PATCH 3/3] compat: Backport fault_in_multipages_{writeable,readable} Luis R. Rodriguez
2012-06-14 17:57 ` [PATCH 1/3] compat: Backport vga_switcheroo_client_ops Ozan Çağlayan
2012-06-14 19:51 ` Luis R. Rodriguez
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=1339696366-26970-3-git-send-email-ozancag@gmail.com \
--to=ozancag@gmail.com \
--cc=linux-wireless@vger.kernel.org \
--cc=mcgrof@kernel.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;
as well as URLs for NNTP newsgroup(s).