From: wcohen@redhat.com (William Cohen)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] Make the 32-bit ARM get_user() and put_user() work for 16-bit quantities
Date: Tue, 29 Oct 2013 12:52:09 -0400 [thread overview]
Message-ID: <1383065529-20001-1-git-send-email-wcohen@redhat.com> (raw)
The 32-bit ARM does not have instructions to perform 16-bit loads or
stores. The __get_user_asm_half and __put_user_asm_half macros
sythesize those operations. However, in most cases the pointers
passed into these macros are pointers to 16-bit types and the pointer
arithmetic will end up pointing at the next 16-bit quantity rather
than the second half (byte) of the 16-bit quantity. The macros need
to explicitly typecast the pointers as pointers to 8-bit quantities to
make the pointer arithmetic work out properly.
Signed-off-by: William Cohen <wcohen@redhat.com>
---
arch/arm/include/asm/uaccess.h | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h
index 7e1f760..c2d9439 100644
--- a/arch/arm/include/asm/uaccess.h
+++ b/arch/arm/include/asm/uaccess.h
@@ -277,16 +277,16 @@ do { \
#define __get_user_asm_half(x,__gu_addr,err) \
({ \
unsigned long __b1, __b2; \
- __get_user_asm_byte(__b1, __gu_addr, err); \
- __get_user_asm_byte(__b2, __gu_addr + 1, err); \
+ __get_user_asm_byte(__b1, (u8 *)(__gu_addr), err); \
+ __get_user_asm_byte(__b2, ((u8 *)(__gu_addr)) + 1, err);\
(x) = __b1 | (__b2 << 8); \
})
#else
#define __get_user_asm_half(x,__gu_addr,err) \
({ \
unsigned long __b1, __b2; \
- __get_user_asm_byte(__b1, __gu_addr, err); \
- __get_user_asm_byte(__b2, __gu_addr + 1, err); \
+ __get_user_asm_byte(__b1, (u8 *)(__gu_addr), err); \
+ __get_user_asm_byte(__b2, ((u8 *)(__gu_addr)) + 1, err);\
(x) = (__b1 << 8) | __b2; \
})
#endif
@@ -358,15 +358,15 @@ do { \
#define __put_user_asm_half(x,__pu_addr,err) \
({ \
unsigned long __temp = (unsigned long)(x); \
- __put_user_asm_byte(__temp, __pu_addr, err); \
- __put_user_asm_byte(__temp >> 8, __pu_addr + 1, err); \
+ __put_user_asm_byte(__temp, (u8 *)(__pu_addr), err); \
+ __put_user_asm_byte(__temp >> 8, ((u8 *)(__pu_addr)) + 1, err);\
})
#else
#define __put_user_asm_half(x,__pu_addr,err) \
({ \
unsigned long __temp = (unsigned long)(x); \
- __put_user_asm_byte(__temp >> 8, __pu_addr, err); \
- __put_user_asm_byte(__temp, __pu_addr + 1, err); \
+ __put_user_asm_byte(__temp >> 8, (u8 *)(__pu_addr), err);\
+ __put_user_asm_byte(__temp, ((u8 *)(__pu_addr)) + 1, err);\
})
#endif
--
1.8.3.1
next reply other threads:[~2013-10-29 16:52 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-29 16:52 William Cohen [this message]
2013-10-29 17:49 ` [PATCH] Make the 32-bit ARM get_user() and put_user() work for 16-bit quantities Marc Zyngier
2013-10-29 18:04 ` Russell King - ARM Linux
2013-10-29 18:38 ` William Cohen
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=1383065529-20001-1-git-send-email-wcohen@redhat.com \
--to=wcohen@redhat.com \
--cc=linux-arm-kernel@lists.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;
as well as URLs for NNTP newsgroup(s).