Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp1752276rwi; Thu, 13 Oct 2022 19:32:41 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6IpB99nWlmzmRaQY42cABOmisKV9Yye2I+mRS9DTHSaE5A63BnHeKhiwbPBd9Jm5ByHoBx X-Received: by 2002:a17:907:3d9e:b0:78d:e7be:1ee8 with SMTP id he30-20020a1709073d9e00b0078de7be1ee8mr1941539ejc.164.1665714761384; Thu, 13 Oct 2022 19:32:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665714761; cv=none; d=google.com; s=arc-20160816; b=XqyPyZqHv7ZZz47lAnx/P7JsyK/Ac0w6aI31Ylvawi6SR2ha/UnD3xmRIPZR7IQClW YYn17UXssHH/PA8HLeu4z4iAyBKErZBd67mhfumuq+YM5i9EjsEggaecrA6286pIEYbg ZTrhbiVmrBUXfSOrOP9YPz/Gq2eQkOLkQjiYgkRb91c6uV6/S/eCduDn6oz9hW9z377g i+Q/U5miKK5XujTndjrhfI9jln+SGih7LzBkWSsDKzzGI04+I0cPsl0sKRPyusApKRAc EHVGNjH7DRudJe2SyjGL6dEKGu+qTbezPfWpx/3U6OoqRodv+ChrgW9O2js+ceT8ceGZ bT8g== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qw5-20020a1709066a0500b0077b45792af2si1186060ejc.464.2022.10.13.19.32.16; Thu, 13 Oct 2022 19:32:41 -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 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII 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 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) -- 2.25.1