From patchwork Tue Oct 29 16:52:09 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: William Cohen X-Patchwork-Id: 3109631 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 46997BF924 for ; Tue, 29 Oct 2013 16:53:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 19D312020F for ; Tue, 29 Oct 2013 16:53:45 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C2C4520203 for ; Tue, 29 Oct 2013 16:53:43 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VbCXX-00074s-Eb; Tue, 29 Oct 2013 16:53:11 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VbCXM-0008V8-9n; Tue, 29 Oct 2013 16:53:00 +0000 Received: from mx1.redhat.com ([209.132.183.28]) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VbCX2-0008QV-Ob for linux-arm-kernel@lists.infradead.org; Tue, 29 Oct 2013 16:52:42 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r9TGqIpo005512 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 29 Oct 2013 12:52:19 -0400 Received: from santana.rdu.redhat.com (dhcp129-104.rdu.redhat.com [10.13.129.104] (may be forged)) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r9TGqI2L028521; Tue, 29 Oct 2013 12:52:18 -0400 From: 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 Message-Id: <1383065529-20001-1-git-send-email-wcohen@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131029_125240_992787_EA96AB48 X-CRM114-Status: GOOD ( 14.85 ) X-Spam-Score: -7.4 (-------) Cc: William Cohen X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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