From patchwork Fri Oct 24 10:37:15 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Nan X-Patchwork-Id: 39419 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f72.google.com (mail-ee0-f72.google.com [74.125.83.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 42DF324026 for ; Fri, 24 Oct 2014 10:39:51 +0000 (UTC) Received: by mail-ee0-f72.google.com with SMTP id d49sf6303eek.3 for ; Fri, 24 Oct 2014 03:39:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe:content-type; bh=nful2lQvXB8xS/ebWV6vGCXEbIcOL0MVoHBxuLGFO7w=; b=GhbqxqObqm65zc/ci68biFzCkKe+SOywXioJ8BGvy7y/2jvbkbB2emZyrNh6RooTbl ncarECxqqjtPE9w7QoLUqxiyK4zHAq7lOuC98z0XhMMvSH0fd/+tnHbizf1yu8EFEAIj gsPYrEnlqR3YaCO7Yp8u9XlFtlXx9coWi3voL9jZCNovytKWgaxSOmSRBGLJ8HxSrq9E d7C/r1L/iBymAGu3LWUr0dq191BaNd7nfk4z03K56iEZHAs2MmPqrQk19q2owWY7ZAjp JyMsU79AAyvdeh1R0ZuWhiMBAg752aYdjPF4iECgXNWQobUjsmxAJvFc0h0GYKXGIuyj ZMsg== X-Gm-Message-State: ALoCoQnDm99RLSuj9PrVH60x4heO5wxublHKl4E0sjBqgMlDWV1nb42hmklrdf4Imnu2KASZ7YDG X-Received: by 10.112.180.71 with SMTP id dm7mr300133lbc.18.1414147189995; Fri, 24 Oct 2014 03:39:49 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.5.9 with SMTP id o9ls359635lao.97.gmail; Fri, 24 Oct 2014 03:39:49 -0700 (PDT) X-Received: by 10.152.36.230 with SMTP id t6mr2082394laj.88.1414147189788; Fri, 24 Oct 2014 03:39:49 -0700 (PDT) Received: from mail-la0-f46.google.com (mail-la0-f46.google.com. [209.85.215.46]) by mx.google.com with ESMTPS id u7si6358997lau.44.2014.10.24.03.39.49 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 24 Oct 2014 03:39:49 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.46 as permitted sender) client-ip=209.85.215.46; Received: by mail-la0-f46.google.com with SMTP id gi9so2397323lab.19 for ; Fri, 24 Oct 2014 03:39:49 -0700 (PDT) X-Received: by 10.112.189.10 with SMTP id ge10mr3455851lbc.23.1414147189248; Fri, 24 Oct 2014 03:39:49 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.84.229 with SMTP id c5csp403358lbz; Fri, 24 Oct 2014 03:39:48 -0700 (PDT) X-Received: by 10.66.165.200 with SMTP id za8mr141761pab.156.1414147187591; Fri, 24 Oct 2014 03:39:47 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id nz8si3896030pab.116.2014.10.24.03.39.47 for ; Fri, 24 Oct 2014 03:39:47 -0700 (PDT) Received-SPF: none (google.com: stable-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756435AbaJXKjq (ORCPT + 1 other); Fri, 24 Oct 2014 06:39:46 -0400 Received: from szxga02-in.huawei.com ([119.145.14.65]:61578 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756430AbaJXKjo (ORCPT ); Fri, 24 Oct 2014 06:39:44 -0400 Received: from 172.24.2.119 (EHLO lggeml422-hub.china.huawei.com) ([172.24.2.119]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id CBF11850; Fri, 24 Oct 2014 18:39:12 +0800 (CST) Received: from kernel-host.huawei (10.107.197.247) by lggeml422-hub.china.huawei.com (10.72.61.32) with Microsoft SMTP Server id 14.3.158.1; Fri, 24 Oct 2014 18:39:01 +0800 From: Wang Nan To: CC: , , , , Subject: [request for stable inclusion 1/2] ARM: Correct BUG() assembly to ensure it is endian-agnostic Date: Fri, 24 Oct 2014 18:37:15 +0800 Message-ID: <1414147036-12135-2-git-send-email-wangnan0@huawei.com> X-Mailer: git-send-email 1.8.4 In-Reply-To: <1414147036-12135-1-git-send-email-wangnan0@huawei.com> References: <1414147036-12135-1-git-send-email-wangnan0@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.107.197.247] X-CFilter-Loop: Reflected Sender: stable-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: stable@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: wangnan0@huawei.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.46 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Ben Dooks commit 63328070eff2f4fd730c86966a0dbc976147c39f upstream. Currently BUG() uses .word or .hword to create the necessary illegal instructions. However if we are building BE8 then these get swapped by the linker into different illegal instructions in the text. This means that the BUG() macro does not get trapped properly. Change to using to provide the necessary ARM instruction building as we cannot rely on gcc/gas having the `.inst` instructions which where added to try and resolve this issue (reported by Dave Martin ). Signed-off-by: Ben Dooks Reviewed-by: Dave Martin --- arch/arm/include/asm/bug.h | 10 ++++++---- arch/arm/kernel/traps.c | 8 +++++--- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/arch/arm/include/asm/bug.h b/arch/arm/include/asm/bug.h index 7af5c6c..b274bde 100644 --- a/arch/arm/include/asm/bug.h +++ b/arch/arm/include/asm/bug.h @@ -2,6 +2,8 @@ #define _ASMARM_BUG_H #include +#include +#include #ifdef CONFIG_BUG @@ -12,10 +14,10 @@ */ #ifdef CONFIG_THUMB2_KERNEL #define BUG_INSTR_VALUE 0xde02 -#define BUG_INSTR_TYPE ".hword " +#define BUG_INSTR(__value) __inst_thumb16(__value) #else #define BUG_INSTR_VALUE 0xe7f001f2 -#define BUG_INSTR_TYPE ".word " +#define BUG_INSTR(__value) __inst_arm(__value) #endif @@ -33,7 +35,7 @@ #define __BUG(__file, __line, __value) \ do { \ - asm volatile("1:\t" BUG_INSTR_TYPE #__value "\n" \ + asm volatile("1:\t" BUG_INSTR(__value) "\n" \ ".pushsection .rodata.str, \"aMS\", %progbits, 1\n" \ "2:\t.asciz " #__file "\n" \ ".popsection\n" \ @@ -48,7 +50,7 @@ do { \ #define __BUG(__file, __line, __value) \ do { \ - asm volatile(BUG_INSTR_TYPE #__value); \ + asm volatile(BUG_INSTR(__value) "\n"); \ unreachable(); \ } while (0) #endif /* CONFIG_DEBUG_BUGVERBOSE */ diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c index 7c78825..74d15ad 100644 --- a/arch/arm/kernel/traps.c +++ b/arch/arm/kernel/traps.c @@ -349,15 +349,17 @@ void arm_notify_die(const char *str, struct pt_regs *regs, int is_valid_bugaddr(unsigned long pc) { #ifdef CONFIG_THUMB2_KERNEL - unsigned short bkpt; + u16 bkpt; + u16 insn = __opcode_to_mem_thumb16(BUG_INSTR_VALUE); #else - unsigned long bkpt; + u32 bkpt; + u32 insn = __opcode_to_mem_arm(BUG_INSTR_VALUE); #endif if (probe_kernel_address((unsigned *)pc, bkpt)) return 0; - return bkpt == BUG_INSTR_VALUE; + return bkpt == insn; } #endif