From patchwork Fri Apr 7 20:02:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?J=2E_Neusch=C3=A4fer?= X-Patchwork-Id: 9671859 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 808D460365 for ; Mon, 10 Apr 2017 00:50:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 74B9D27D29 for ; Mon, 10 Apr 2017 00:50:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 681B827F94; Mon, 10 Apr 2017 00:50:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.7 required=2.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_MED,RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1A00227D29 for ; Mon, 10 Apr 2017 00:50:18 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E7D916E1A6; Mon, 10 Apr 2017 00:49:59 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3AC1E6ED4D for ; Fri, 7 Apr 2017 20:03:18 +0000 (UTC) Received: from localhost.localdomain ([88.153.7.190]) by mail.gmx.com (mrgmx102 [212.227.17.168]) with ESMTPSA (Nemesis) id 0MTeVY-1cW4z62YWe-00QWLp; Fri, 07 Apr 2017 22:03:08 +0200 From: =?UTF-8?q?Jonathan=20Neusch=C3=A4fer?= To: dri-devel@lists.freedesktop.org Subject: [PATCH] drm/udl: Fix unaligned memory access in udl_render_hline Date: Fri, 7 Apr 2017 22:02:29 +0200 Message-Id: <20170407200229.20642-1-j.neuschaefer@gmx.net> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 X-Provags-ID: V03:K0:GEanotEHB0ByYDp/IWgtcCa4IAw0jG8aevKFzCZwQ+7D9FSZEj0 1apdoa86CQA84xUJ5ONIdlcjfyKKYsh0CQYFSxqD/HMdj0+iadNrmlIakcZH/Y+5HFsI3br rFTrptEoZokPmwevOEL2fvJoNP4TYes4d2j9kULQuBq25BuTPVZgDoJvhgenSM4v+Bl6oCM OWydFut5PRo5j3b5+MPJQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:mDhgrXGFp9Q=:oO5UcBQPIzPRspMFPtTPky OYJL1EhIzm5cWtS+Oa6wf5wItR9z4O249YWeOk3V3MnF7FzwQTG1pXjP74ikIbALPbC2w/RXZ 0XWyuGeQa/Jarb6AtypYQ8Wheh5tn35nqTQrhJZ3qW932MQdp6SSdmdHcb1moUvOyvxV+KakI 79yXjyDCEGvjQuwSMtM8GsY8vHbsleHK4OjMQvJ0JbVAKgrKqpgClMiSKH1+uQt+W9c9dlw4B bYEKbm/1QHP/YxFz1xBHoDQoS/Ioakom04aRBZMSzsSgnFBo6TPTPoTG/9asgMj5iGZgB95gz AnJhjYxuup86lttIcHnDuKCfhtT0510ucOaDOOquvvCeHVxk3xyfKlAwZhLQGWN4llJEl7Ifb Pmke71ka8xxLQeAUtZ7mWRfvlUFXxiqiC6qttdg/1MFZJD8WulmBpzvEUMENx5bXjfU5xeqIY WbJLDBonQZET2csCoymlRIGjxYpane4me2o2Gcs8no0qU37efh83m0YPYRayT+MbV59pu4Mfr ifDhvQikXdAUH/IHlMDBvLHhIoJeTqvEooJi20TVm+JgytTNMoeWhzxKbNugm92QZw2vGBhNo PFRUws6ekUWLSWt6/JoVfTvWhL+aOgohHQfLBqbZGG+z8HyM9R0RRzE6jhYOBABtQU/1xTCx/ a1QHKWN0i5Q7P+6oktYL3w6zkTtEiiJM8bJk1hBqgWP4M7Ygpbm9ONQJii4qr9zEPqnaOukOG b2k6DC+jlCdjguU8Hgny0EDSTZ7RwR8TjZcIoAjGgDPyTYpDsMIASZ6KCmfeiGJ39FDI5JB+z 8vx+2bB X-Mailman-Approved-At: Mon, 10 Apr 2017 00:49:50 +0000 Cc: Dave Airlie , linux-kernel@vger.kernel.org, =?UTF-8?q?Jonathan=20Neusch=C3=A4fer?= X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP On SPARC, the udl driver filled my kernel log with these messages: [186668.910612] Kernel unaligned access at TPC[76609c] udl_render_hline+0x13c/0x3a0 Use put_unaligned_be16 to avoid them. On x86 this results in the same code, but on SPARC the compiler emits two single-byte stores. Signed-off-by: Jonathan Neuschäfer --- drivers/gpu/drm/udl/udl_transfer.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/udl/udl_transfer.c b/drivers/gpu/drm/udl/udl_transfer.c index 917dcb978c2c..0c87b1ac6b68 100644 --- a/drivers/gpu/drm/udl/udl_transfer.c +++ b/drivers/gpu/drm/udl/udl_transfer.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include "udl_drv.h" @@ -163,7 +164,7 @@ static void udl_compress_hline16( const u8 *const start = pixel; const uint16_t repeating_pixel_val16 = pixel_val16; - *(uint16_t *)cmd = cpu_to_be16(pixel_val16); + put_unaligned_be16(pixel_val16, cmd); cmd += 2; pixel += bpp;