From patchwork Wed Jun 28 14:55:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Van Oostenryck X-Patchwork-Id: 9814429 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 18A4260365 for ; Wed, 28 Jun 2017 14:56:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 09F4622376 for ; Wed, 28 Jun 2017 14:56:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F05B426E76; Wed, 28 Jun 2017 14:56:32 +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=-1.9 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 910FA22376 for ; Wed, 28 Jun 2017 14:56:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=7EkNLVhhnRmpqBwbGpgWFJBa1qOulbpKwbLjedUj0u8=; b=USA 3/7gSNJRX2C+tDh45vxWqZTVZrulNxpY4xMpBjfUAnlz51SAYKzmMhb/kVXUQiHU6qL+8omJXLRMe IIcpMt/66ZdmUy+90ze3lRDISGUj75TQ9d+A/wt7hxvcS7PK/R0csUfIr0xguO0Ya7ZC0kYhTjJf2 kpUINEfKrDpYr/u1nnybYd5OIvu6bAQ3LFhiedghcia/yimRelVe9hsU/lOFi4aQUXIUdXwLXxFHW Fi1hO3XGYhaD5EpqkCNJUVGaXmnJLss51wwQm1GKilrRZZFXd5YCzviBPSAR11xL6die6v8abGKmh UsGSMcZTDqDNENhpqW2lDkiG4ejFWTg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dQEOM-0003Qf-Ed; Wed, 28 Jun 2017 14:56:30 +0000 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dQEO9-0003Da-4D for linux-arm-kernel@lists.infradead.org; Wed, 28 Jun 2017 14:56:18 +0000 Received: by mail-wm0-x242.google.com with SMTP id y5so11995479wmh.3 for ; Wed, 28 Jun 2017 07:55:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=RkyUkBED8SnYjDvYmHhXyc/6lSNRTmXChaPVoIV/tU4=; b=hUV8dNebK1zmCrloiahbxoiwXZ1ZLmWJgKRPvZmHs23H011JvKH7Tw6EZbi1y2j+g4 0cM+tVqZwb6ZPO7oELzM12xTDN/1QJ8Uq9X3zLxi8HBc4aWWWcOVk/zYRCMGhKBo6wEc iv+X5HJQWfujRTafO714oQJXdJrh2eMM519OBvzHpZkQtI/7DlXMswnevcZvwhnu7yBJ xiSkC9AC6kCQzo6Q9ovJ7n+F0INtO2pjCfGQ84Tc/N1eTcgZwgmzUbpuWxErPcdcNxAg XjApw1HmcXRl1dpsFgLPvZYGMbMZWqQWxNrNZo3Wf0aUcoyQvpzekWC109VOCxlsb2ds hJ0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=RkyUkBED8SnYjDvYmHhXyc/6lSNRTmXChaPVoIV/tU4=; b=SKfs3rht134tC3as5wAUeBPfA4OiCHPi5twCr71aMWDJh3jeVrh6ze4zTb8a1SVxNA SA3pypuk5qDMeiDwEwPlqTyVcWc/dovbYJp0grenH6wNTr0vX/jo3luPsqFDmHdxCA2g QU6dm0WuhIjnEn6CJoRy827cGeYajkZ3WPeUhiZ6Iill9v1aXXXQdrdpQWHwqM82pE7R X1P5q7sNxtnvNfyn3JU2E+KrGPgIHLOPW6h+jqvNwtw6jAFUJf6BIJYMQnArdC4w6IzY XUPpwz9TWMtcb1iq6MIQlZtiSCDHVdCepJS4t6v2lbyZhvNmF74tNo32Ab/Qgj3yYA1M Q8yQ== X-Gm-Message-State: AKS2vOy9QUDG9T2wkrZ/88SrmMjUSvkutl5ebx6V3N22kVWvc7ISlRG5 p+zMPtQOOgPdBw== X-Received: by 10.80.171.28 with SMTP id s28mr7886743edc.146.1498661754723; Wed, 28 Jun 2017 07:55:54 -0700 (PDT) Received: from localhost.localdomain ([91.177.84.115]) by smtp.gmail.com with ESMTPSA id w49sm1205765eda.61.2017.06.28.07.55.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Jun 2017 07:55:54 -0700 (PDT) From: Luc Van Oostenryck To: Will Deacon Subject: [PATCH] arm64: fix endianness annotation for debug-monitors.c Date: Wed, 28 Jun 2017 16:55:52 +0200 Message-Id: <20170628145552.24365-1-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.13.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170628_075617_386877_BCEFEF9E X-CRM114-Status: GOOD ( 11.50 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Pratyush Anand , Mark Rutland , Catalin Marinas , linux-arm-kernel@lists.infradead.org, Sandeepa Prabhu , Luc Van Oostenryck MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Here we're reading thumb or ARM instructions, which are always stored in memory in little-endian order. These values are thus correctly converted to native order but the intermediate value should be annotated as for little-endian values. Fix this by declaring the intermediate var as __le32 or __le16. Signed-off-by: Luc Van Oostenryck --- arch/arm64/kernel/debug-monitors.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/arch/arm64/kernel/debug-monitors.c b/arch/arm64/kernel/debug-monitors.c index d618e25c3..c7ef99904 100644 --- a/arch/arm64/kernel/debug-monitors.c +++ b/arch/arm64/kernel/debug-monitors.c @@ -341,20 +341,22 @@ int aarch32_break_handler(struct pt_regs *regs) if (compat_thumb_mode(regs)) { /* get 16-bit Thumb instruction */ - get_user(thumb_instr, (u16 __user *)pc); - thumb_instr = le16_to_cpu(thumb_instr); + __le16 instr; + get_user(instr, (__le16 __user *)pc); + thumb_instr = le16_to_cpu(instr); if (thumb_instr == AARCH32_BREAK_THUMB2_LO) { /* get second half of 32-bit Thumb-2 instruction */ - get_user(thumb_instr, (u16 __user *)(pc + 2)); - thumb_instr = le16_to_cpu(thumb_instr); + get_user(instr, (__le16 __user *)(pc + 2)); + thumb_instr = le16_to_cpu(instr); bp = thumb_instr == AARCH32_BREAK_THUMB2_HI; } else { bp = thumb_instr == AARCH32_BREAK_THUMB; } } else { /* 32-bit ARM instruction */ - get_user(arm_instr, (u32 __user *)pc); - arm_instr = le32_to_cpu(arm_instr); + __le32 instr; + get_user(instr, (__le32 __user *)pc); + arm_instr = le32_to_cpu(instr); bp = (arm_instr & ~0xf0000000) == AARCH32_BREAK_ARM; }