From patchwork Fri Oct 14 01:59:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhen Lei X-Patchwork-Id: 2460 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp573267wrs; Thu, 13 Oct 2022 19:04:39 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4DmCMZlu2FJTRShZ9LdYl1zYczi96GNoj3c0lLge6wZlEKKZJe1sQ+O8N+cmez2+GLymlV X-Received: by 2002:a17:906:db0c:b0:77b:7d7d:5805 with SMTP id xj12-20020a170906db0c00b0077b7d7d5805mr1887375ejb.726.1665713079661; Thu, 13 Oct 2022 19:04:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665713079; cv=none; d=google.com; s=arc-20160816; b=KEowdl3JnuBoKUWwZzuq1SwmpPZk/vQURVDbFDWmI4/yhwubAhGQ754GhF2mXz9o8y kA2q23eF4ZWpEFz2r6ZWhyMzaijxFk6ImNuJRuTvyaMl9rHygPmrQl/U0C43EVuEDRrE +zkhsHc2B8MKJe9lDkxEq2iv0Cyj0EAuviFgw2UAyfKqfGWI7xtfcGb42AEWK7Lrit42 i/wYagdsZJlv1tpbhWpwMZva3VUVCQta0aLiveWQeyZGTOMKyqvXnVtc6+Dx93u+LMu3 WAVym8blZtZxJ6m7B5rYdUtKkQmt+yE9o/EU+BNfhdgiaaf9zhZD2cY65X3NmVw+A2dv r2Mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=W1NSoSq/ui76ohrJabsXNOWYo7p+amE9Ojaf1PB+jb0=; b=CtrjkZSnEl1eYFj0oAIrk8T5+QBr1RwMWv4J2lbMpzzRRwjxRH2P8QZqqpnxIjjMpx F70SlAxQXVNUc+M1WbYR8gqQzBrS3F+2U3ZUyuErqNmv8fUFEW0DCVfU9GGtMh7AJ8eJ ORFdXciv/yTl84Hb5nWL454GyavcIQQaXoyVl4UXa+ng9cUrd+azo4V/argXcf7rHDSu aMiSX075n9almlqXATR/Q3453CvFG2zs5S1sq4Ho61KiQr5c9kNPejGBRuJ1SAciSA6u vG8p9Qu7EsRm81WCbQIRW31ZL5M/SOL5570V+OfveFMdXR276sfb/ifaR4g4KXrwaCXE 2cAg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hg7-20020a1709072cc700b0078a891e407dsi926198ejc.974.2022.10.13.19.04.14; Thu, 13 Oct 2022 19:04:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229660AbiJNCAv (ORCPT + 99 others); Thu, 13 Oct 2022 22:00:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229496AbiJNCAq (ORCPT ); Thu, 13 Oct 2022 22:00:46 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 634337CE2A for ; Thu, 13 Oct 2022 19:00:45 -0700 (PDT) Received: from dggpemm500022.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4MpTxy5jV0zmVF0; Fri, 14 Oct 2022 09:56:06 +0800 (CST) Received: from dggpemm500006.china.huawei.com (7.185.36.236) by dggpemm500022.china.huawei.com (7.185.36.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Fri, 14 Oct 2022 10:00:43 +0800 Received: from thunder-town.china.huawei.com (10.174.178.55) by dggpemm500006.china.huawei.com (7.185.36.236) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Fri, 14 Oct 2022 10:00:43 +0800 From: Zhen Lei To: Russell King , Ard Biesheuvel , , CC: Zhen Lei Subject: [PATCH v3 1/3] ARM: Fix some check warnings of tool sparse Date: Fri, 14 Oct 2022 09:59:54 +0800 Message-ID: <20221014015956.2006-2-thunder.leizhen@huawei.com> X-Mailer: git-send-email 2.37.3.windows.1 In-Reply-To: <20221014015956.2006-1-thunder.leizhen@huawei.com> References: <20221014015956.2006-1-thunder.leizhen@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.174.178.55] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm500006.china.huawei.com (7.185.36.236) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746626758361480894?= X-GMAIL-MSGID: =?utf-8?q?1746626758361480894?= Fix the following warnings: warning: incorrect type in initializer (different address spaces) expected unsigned short [noderef] __user *register __p got unsigned short [usertype] * warning: cast removes address space '__user' of expression Signed-off-by: Zhen Lei --- arch/arm/kernel/traps.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c index 20b2db6dcd1ced7..d455c97237e2079 100644 --- a/arch/arm/kernel/traps.c +++ b/arch/arm/kernel/traps.c @@ -188,9 +188,9 @@ static void dump_instr(const char *lvl, struct pt_regs *regs) } } else { if (thumb) - bad = get_user(val, &((u16 *)addr)[i]); + bad = get_user(val, &((u16 __user *)addr)[i]); else - bad = get_user(val, &((u32 *)addr)[i]); + bad = get_user(val, &((u32 __user *)addr)[i]); } if (!bad) @@ -448,9 +448,9 @@ int call_undef_hook(struct pt_regs *regs, unsigned int instr) asmlinkage void do_undefinstr(struct pt_regs *regs) { unsigned int instr; - void __user *pc; + void *pc; - pc = (void __user *)instruction_pointer(regs); + pc = (void *)instruction_pointer(regs); if (processor_mode(regs) == SVC_MODE) { #ifdef CONFIG_THUMB2_KERNEL @@ -494,7 +494,7 @@ asmlinkage void do_undefinstr(struct pt_regs *regs) } #endif arm_notify_die("Oops - undefined instruction", regs, - SIGILL, ILL_ILLOPC, pc, 0, 6); + SIGILL, ILL_ILLOPC, (void __user *)pc, 0, 6); } NOKPROBE_SYMBOL(do_undefinstr) From patchwork Fri Oct 14 01:59:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhen Lei X-Patchwork-Id: 2461 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp573397wrs; Thu, 13 Oct 2022 19:05:02 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7l4wslkLQJOgv7oh/JCU2UzX3WGEBMybYgLnrVvY+eY0MVXcu/5gRvnUPez8uDtZEeWY6D X-Received: by 2002:a17:907:9627:b0:78d:a7d8:9407 with SMTP id gb39-20020a170907962700b0078da7d89407mr1773524ejc.675.1665713101794; Thu, 13 Oct 2022 19:05:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665713101; cv=none; d=google.com; s=arc-20160816; b=xELK/3kydfNnlaGHFfRCHt4rehkhtRnXA7vClzhGL/alvtQB7t5yYcqZCE3A9nxk7t OF3z0jYpI4AvMdyVYm60HTYRo8PQUdMEVwjxYKBu3XK8l77jcMvq2LnrrR66DNaBgrl2 dgYvtd9+YzmlVIligs/vW67s0HIswhLx4XzZXmnekYTJO8pYB1VadGJgkY3A47xBRxt3 g40oc5jlbagqBznTQXaZpD8nP2R3fQY/b+H4n1vmKInDXzXFHszNBjCI+/EWIZBv3NuE /VqeCxRcqeIcVgx2cT0NTWS7toXgvDTIBQFN7JTZho4eQw4myPUyuJrKr3sfTUppyY85 D2mg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=2WUUvaxfWFdKFuavy84D58WJMWa+7KZ1pEld0CUJVB4=; b=dQNrBcTH0ayzUlqpOKus8ysunzkECp9QWImHYRDjjWLwBQ7+EswAQNHR0Zd0Tt1TE3 f7CrKHHcMMC3y/5Yz3bWui1PLVRM5y6pu2M7Ul1Tji8DkuYDAzLYDsEGRQ/feTJf09ry cCFfKnHTBj0rbVU9+ne4OAcK1gJm6qepy+k1yz77ekcc+5Y2urY5FvEPVMPYULF77Gj/ V0T8n0SZn9JkJ+te3a47okL7jleBYDK1SJzC0f9WrZCxrmzb+QQ8goIebewl4qDZm/Kx ViUsuPEcsIIp7LOqhLEn0gwg65epy/D1EqkBIgT44PBlWEBFyjp2hoiUKaVFtggCxhDG XEyg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hq29-20020a1709073f1d00b0073866c0672asi1356617ejc.73.2022.10.13.19.04.35; Thu, 13 Oct 2022 19:05:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229656AbiJNCAz (ORCPT + 99 others); Thu, 13 Oct 2022 22:00:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43806 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229511AbiJNCAr (ORCPT ); Thu, 13 Oct 2022 22:00:47 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 196B87CE37 for ; Thu, 13 Oct 2022 19:00:45 -0700 (PDT) Received: from dggpemm500023.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4MpTzb3Q87zpVwV; Fri, 14 Oct 2022 09:57:31 +0800 (CST) Received: from dggpemm500006.china.huawei.com (7.185.36.236) by dggpemm500023.china.huawei.com (7.185.36.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Fri, 14 Oct 2022 10:00:44 +0800 Received: from thunder-town.china.huawei.com (10.174.178.55) by dggpemm500006.china.huawei.com (7.185.36.236) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Fri, 14 Oct 2022 10:00:43 +0800 From: Zhen Lei To: Russell King , Ard Biesheuvel , , CC: Zhen Lei Subject: [PATCH v3 2/3] ARM: Refactor dump_instr() Date: Fri, 14 Oct 2022 09:59:55 +0800 Message-ID: <20221014015956.2006-3-thunder.leizhen@huawei.com> X-Mailer: git-send-email 2.37.3.windows.1 In-Reply-To: <20221014015956.2006-1-thunder.leizhen@huawei.com> References: <20221014015956.2006-1-thunder.leizhen@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.174.178.55] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm500006.china.huawei.com (7.185.36.236) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746626781405445246?= X-GMAIL-MSGID: =?utf-8?q?1746626781405445246?= 1. Rename local variable 'val16' to 'tmp'. So that the processing statements of thumb and arm can be aligned. 2. Prepare for the next patch to avoid repeated judgment. Before: if (!user_mode(regs)) { if (thumb) else } else { if (thumb) else } After: if (thumb) { if (user_mode(regs)) else } else { if (user_mode(regs)) else } Signed-off-by: Zhen Lei --- arch/arm/kernel/traps.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c index d455c97237e2079..182469a5b28a394 100644 --- a/arch/arm/kernel/traps.c +++ b/arch/arm/kernel/traps.c @@ -178,19 +178,20 @@ static void dump_instr(const char *lvl, struct pt_regs *regs) for (i = -4; i < 1 + !!thumb; i++) { unsigned int val, bad; - if (!user_mode(regs)) { - if (thumb) { - u16 val16; - bad = get_kernel_nofault(val16, &((u16 *)addr)[i]); - val = val16; - } else { - bad = get_kernel_nofault(val, &((u32 *)addr)[i]); - } - } else { - if (thumb) - bad = get_user(val, &((u16 __user *)addr)[i]); + if (thumb) { + u16 tmp; + + if (user_mode(regs)) + bad = get_user(tmp, &((u16 __user *)addr)[i]); else + bad = get_kernel_nofault(tmp, &((u16 *)addr)[i]); + + val = tmp; + } else { + if (user_mode(regs)) bad = get_user(val, &((u32 __user *)addr)[i]); + else + bad = get_kernel_nofault(val, &((u32 *)addr)[i]); } if (!bad) From patchwork Fri Oct 14 01:59:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhen Lei X-Patchwork-Id: 2462 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp573402wrs; Thu, 13 Oct 2022 19:05:02 -0700 (PDT) X-Google-Smtp-Source: AMsMyM61QNuLPzeU5p3hbs94b1A3uW0eNeXYStUaqCRovvLmDUuXu58QC3V6mDBcRPar6fXGYGl9 X-Received: by 2002:a17:907:70a:b0:750:bf91:caa3 with SMTP id xb10-20020a170907070a00b00750bf91caa3mr1781944ejb.711.1665713102169; Thu, 13 Oct 2022 19:05:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665713102; cv=none; d=google.com; s=arc-20160816; b=BwyAwHf8zme9nQW0EB6gDPVRVgUk4bkqHqzwKtyGf/nmMwxfOAV4gXU6vu29GWsig1 tF8AzqVty5hQ99lC46LnAV2hxgYADbFJnKswytntxKuZJd7BNsZ7PoAuFTEefF+RWNGk lKkZ1peFBcJQgDK/T1x8w6Xaw8GjaAFhEhWaeGRMoV+U6eLNwBqA21/ZpF6xYe9rb6wn c0cc0iNRR/t/h1HriE01G4DZ9rqKerqIN7tUUcO8aRQl4oVaBeYmlrn31qrSQ82XUSAo f8aK3IHzjDjXu3DSJWOjNgfD9vTkdlspAl3yRVFnDd05L2aa4mqRHRadfzpD0+GwcJcB Ue+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=XNJJiMv2unl+KLI1jcBrnVMTTEMN2OihAodlahnnAxw=; b=lKCEXYTHJR0vHJ9zpxDghNrf2dVYjrXJuKeVnUMxmOriraTWbh2zpQyxohtWupk/ri G6bcKU/gX0SRTN4viVc+03/T3gNqwG/KJ2HCA4QdwFFZlF3xVvMsUbdN09fljZvJ6C5z OizFJwEDxmC1BgqgHMKrHDq7BnjnmTvg2zO6ElDP260vEhE43gReTxDYQOx30mfAecI6 qqW2kiHbQ9ZQZv5dGytrI/LjPIXF8KZjYEpVq1llwwaugtfEnwFsh6CxCO4I3UPXD+En r8QMLRsCxgiVxK+tYmsmIghQL/1u8Z9u2JKkW5Y7YluPWoIOweTTlhYsXRsvzQb4mWyJ M5xQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o8-20020a170906974800b0078c39937f73si1153857ejy.798.2022.10.13.19.04.36; Thu, 13 Oct 2022 19:05:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229733AbiJNCBA (ORCPT + 99 others); Thu, 13 Oct 2022 22:01:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229559AbiJNCAr (ORCPT ); Thu, 13 Oct 2022 22:00:47 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9DCB87CE30 for ; Thu, 13 Oct 2022 19:00:46 -0700 (PDT) Received: from dggpemm500024.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4MpV3G2JHHzHtxF; Fri, 14 Oct 2022 10:00:42 +0800 (CST) Received: from dggpemm500006.china.huawei.com (7.185.36.236) by dggpemm500024.china.huawei.com (7.185.36.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Fri, 14 Oct 2022 10:00:44 +0800 Received: from thunder-town.china.huawei.com (10.174.178.55) by dggpemm500006.china.huawei.com (7.185.36.236) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Fri, 14 Oct 2022 10:00:44 +0800 From: Zhen Lei To: Russell King , Ard Biesheuvel , , CC: Zhen Lei Subject: [PATCH v3 3/3] ARM: Make the dumped instructions are consistent with the disassembled ones Date: Fri, 14 Oct 2022 09:59:56 +0800 Message-ID: <20221014015956.2006-4-thunder.leizhen@huawei.com> X-Mailer: git-send-email 2.37.3.windows.1 In-Reply-To: <20221014015956.2006-1-thunder.leizhen@huawei.com> References: <20221014015956.2006-1-thunder.leizhen@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.174.178.55] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm500006.china.huawei.com (7.185.36.236) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746626755364769364?= X-GMAIL-MSGID: =?utf-8?q?1746626781590638555?= In ARM, the mapping of instruction memory is always little-endian, except some BE-32 supported ARM architectures. Such as ARMv7-R, its instruction endianness may be BE-32. Of course, its data endianness will also be BE-32 mode. Due to two negatives make a positive, the instruction stored in the register after reading is in little-endian format. But for the case of BE-8, the instruction endianness is LE, the instruction stored in the register after reading is in big-endian format, which is inconsistent with the disassembled one. For example: The content of disassembly: c0429ee8: e3500000 cmp r0, #0 c0429eec: 159f2044 ldrne r2, [pc, #68] c0429ef0: 108f2002 addne r2, pc, r2 c0429ef4: 1882000a stmne r2, {r1, r3} c0429ef8: e7f000f0 udf #0 The output of undefined instruction exception: Internal error: Oops - undefined instruction: 0 [#1] SMP ARM ... ... Code: 000050e3 44209f15 02208f10 0a008218 (f000f0e7) This inconveniences the checking of instructions. What's worse is that, for somebody who don't know about this, might think the instructions are all broken. So, when CONFIG_CPU_ENDIAN_BE8=y, let's convert the instructions to little-endian format before they are printed. The conversion result is as follows: Code: e3500000 159f2044 108f2002 1882000a (e7f000f0) Signed-off-by: Zhen Lei --- arch/arm/kernel/traps.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c index 182469a5b28a394..8a7f216156675a1 100644 --- a/arch/arm/kernel/traps.c +++ b/arch/arm/kernel/traps.c @@ -186,12 +186,14 @@ static void dump_instr(const char *lvl, struct pt_regs *regs) else bad = get_kernel_nofault(tmp, &((u16 *)addr)[i]); - val = tmp; + val = __mem_to_opcode_thumb16(tmp); } else { if (user_mode(regs)) bad = get_user(val, &((u32 __user *)addr)[i]); else bad = get_kernel_nofault(val, &((u32 *)addr)[i]); + + val = __mem_to_opcode_arm(val); } if (!bad)