Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp447124rwb; Mon, 26 Sep 2022 22:48:08 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7KZSqZcET+6tqhXG/TfjSohE/kvvpzHE5jbn5plDaZG0j0sdnI3KQR8whLLeGUajPUTp/m X-Received: by 2002:a05:6402:2b8b:b0:43a:5475:f1ae with SMTP id fj11-20020a0564022b8b00b0043a5475f1aemr26072817edb.363.1664257688655; Mon, 26 Sep 2022 22:48:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664257688; cv=none; d=google.com; s=arc-20160816; b=leBrXIOpi+D4c32TqaN7IiyqXVT1zpni6ShnpW5+r49dMVQzkMrSnD4dyMmhxrtjzK UqusBgqL0DQGD9og1SHa1M6X2zlBOrclaX3d40yQX9o1bqQXPLQrtIy47UxDGGOHu37e nFbyYeWJnC9G2CfYaePxehef9pSal3olU0HyQm9ZlxP3UIR52ogXu3OLTECzGtLR8qkb oM5wlgku6HWrrChhv5PY4HFD3MyE0Yx4cC0GwMK47VfoLHKm6jSxCFkB3a7/kuQSyfEX wMkY65kEk5ak4wJreVXx4anUKIpDgNrmAUsazaysZWLArBjnNykSCvlmvDBYhvXZOtOV H4mw== 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 :message-id:date:subject:cc:to:from; bh=I4QS6xArv5IxnOpbR+jTLPh0TxrVxkx0s7Enp+cJFZU=; b=S8YN6ezl2RUmMvva4dCYTp6EtXmUD7/cC0KwszbTXIsrPSwYYlGPzl5RtjQo56+3R6 oTtnDJ2mpZyX1Tkv7Bh+qPusGfkYp/zPwBiGAVn6OE/zjmiaqNIiKUCXEGQw/3Z71Vhv BLRdkHu1jqJ3JytdGuq1wDPEjswOLXtna7Hxcki3OeQfLfgP83oSKqJlN0aXRB+1ZZeS SOx4v5YdOoayd22q7MJj4HTrVt2cDFpvjY7Et3WFXJI4tTUrjl3rG38TiHDzCz+kSk0z q+9qfFnwM+QeXlZDJveslCYLn6scKt/2Dqe7UV4O+GrzJEei48An+WVpu2vfwhPlnwcF 5etw== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dr18-20020a170907721200b007848e6eaec0si342553ejc.463.2022.09.26.22.47.44; Mon, 26 Sep 2022 22:48:08 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229871AbiI0E7f (ORCPT + 99 others); Tue, 27 Sep 2022 00:59:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229968AbiI0E7c (ORCPT ); Tue, 27 Sep 2022 00:59:32 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1756B5FA5 for ; Mon, 26 Sep 2022 21:59:32 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A435A612E7 for ; Tue, 27 Sep 2022 04:59:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D7D03C433D6; Tue, 27 Sep 2022 04:59:28 +0000 (UTC) From: Huacai Chen To: Huacai Chen Cc: loongarch@lists.linux.dev, Xuefeng Li , Guo Ren , Xuerui Wang , Jiaxun Yang , linux-kernel@vger.kernel.org, Huacai Chen , Jun Yi Subject: [PATCH] LoongArch: Fix and cleanup csr_era handling in do_ri() Date: Tue, 27 Sep 2022 12:58:20 +0800 Message-Id: <20220927045820.2770062-1-chenhuacai@loongson.cn> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,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 We don't emulate reserved instructions and just send a signal to the current process now. So we don't need to call compute_return_era() to add 4 (point to the next instruction) to csr_era in pt_regs. RA/ERA's backup/restore is cleaned up as well. Signed-off-by: Jun Yi Signed-off-by: Huacai Chen --- arch/loongarch/kernel/traps.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/arch/loongarch/kernel/traps.c b/arch/loongarch/kernel/traps.c index aa1c95aaf595..5010e95cef84 100644 --- a/arch/loongarch/kernel/traps.c +++ b/arch/loongarch/kernel/traps.c @@ -461,11 +461,9 @@ asmlinkage void noinstr do_watch(struct pt_regs *regs) asmlinkage void noinstr do_ri(struct pt_regs *regs) { - int status = -1; + int status = SIGILL; unsigned int opcode = 0; unsigned int __user *era = (unsigned int __user *)exception_era(regs); - unsigned long old_era = regs->csr_era; - unsigned long old_ra = regs->regs[1]; irqentry_state_t state = irqentry_enter(regs); local_irq_enable(); @@ -477,21 +475,12 @@ asmlinkage void noinstr do_ri(struct pt_regs *regs) die_if_kernel("Reserved instruction in kernel code", regs); - compute_return_era(regs); - if (unlikely(get_user(opcode, era) < 0)) { status = SIGSEGV; current->thread.error_code = 1; } - if (status < 0) - status = SIGILL; - - if (unlikely(status > 0)) { - regs->csr_era = old_era; /* Undo skip-over. */ - regs->regs[1] = old_ra; - force_sig(status); - } + force_sig(status); out: local_irq_disable(); -- 2.31.1