From patchwork Tue Feb 28 08:02:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinyang He X-Patchwork-Id: 62330 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2887861wrd; Tue, 28 Feb 2023 00:24:55 -0800 (PST) X-Google-Smtp-Source: AK7set9ZfPozvxFJPT8NJrHWt9Rm/FjnVjD7M4iwX2y9LfKsgWsQih7ODpL9Fq0BHIV7iu9jYcFN X-Received: by 2002:a17:907:72cb:b0:8ed:5a7e:5e44 with SMTP id du11-20020a17090772cb00b008ed5a7e5e44mr2106631ejc.34.1677572695458; Tue, 28 Feb 2023 00:24:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677572695; cv=none; d=google.com; s=arc-20160816; b=bN7tqsRH6GyvoZFCwjVCifEYhnV1NJ456Rksx9pbyFGU0gMz5YjgQxXmjdjFabhcSo 2VQSQp7Y3BwxxtdkBDHjxdI3weT68gaAIKtb0Yhs3y3rOEtqPzgiFAYtLeRNo1VTxysN szZZqmEMR5Bnd5RCPP6DADtXOFsV3GRzEcch1vEGkPKLNoYu8sBMge1VMZka2WsZes60 WONoB/twUdW9IPOk3272tDGA4jGy10rhPxMv4NxT0mWDtUxxwIhHX655TGP1lXxcTOJn dVXUZSw/f0nP1jUOd3pglxWOkdpiTm+iZZSRoprF+1/hETvOqHgMN5a6a2jqurJQMliJ 7dGg== 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=KECO5yaAp2mLcP+ZY1HgWfpR4ykHQzUuWoQ6jFyTkms=; b=LUaspRJO79Aex0jzcIFO1dGXmQ6++MPk1Uvot3gXcBLkMLmyNRvm2vRS6R1STYoPNq 5mI/pmygFjG33jpCslVhrTnoRvfLVpwc1Qlwq5ZmwCdSuDdMsfuEg0bPbljcC5xqeLGh uS49Frht3usSofhYzvMhE41HCdP+kwIcXxLOnckYSJlOdL8QsvfoSuVRbgyrFFMqm9Vm NvJoPLXCF6kP1kpWTPAI7LYLzwgRYHf4jczhavSDV3ehWeMvBq14MmxBoJsR2dvlVJUw jG4oSvWC2IpTwiovXh96udJHDO9aHbrh0kmFdy6kD7KqdX98qmOtHhCQKfEDhgD41+4a 4Jpg== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s9-20020a170906960900b008df5a5088cesi455906ejx.163.2023.02.28.00.24.33; Tue, 28 Feb 2023 00:24:55 -0800 (PST) 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 S230274AbjB1ID2 (ORCPT + 99 others); Tue, 28 Feb 2023 03:03:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230204AbjB1IDV (ORCPT ); Tue, 28 Feb 2023 03:03:21 -0500 Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3F31519F2F for ; Tue, 28 Feb 2023 00:03:18 -0800 (PST) Received: from loongson.cn (unknown [111.9.175.10]) by gateway (Coremail) with SMTP id _____8DxJYxDtf1jt2UGAA--.6509S3; Tue, 28 Feb 2023 16:03:15 +0800 (CST) Received: from localhost.localdomain (unknown [111.9.175.10]) by localhost.localdomain (Coremail) with SMTP id AQAAf8BxB707tf1jb3tAAA--.49681S3; Tue, 28 Feb 2023 16:03:12 +0800 (CST) From: Jinyang He To: Huacai Chen , WANG Xuerui Cc: Xi Ruoyao , Youling Tang , loongarch@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/6] LoongArch: Rename handle_syscall to handle_sys Date: Tue, 28 Feb 2023 16:02:52 +0800 Message-Id: <20230228080257.28807-2-hejinyang@loongson.cn> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20230228080257.28807-1-hejinyang@loongson.cn> References: <20230228080257.28807-1-hejinyang@loongson.cn> MIME-Version: 1.0 X-CM-TRANSID: AQAAf8BxB707tf1jb3tAAA--.49681S3 X-CM-SenderInfo: pkhmx0p1dqwqxorr0wxvrqhubq/ X-Coremail-Antispam: 1Uk129KBjvJXoW7WF13Kw43Kw17GF1rCw15urg_yoW8Ar1Dp3 45Ar4kZrWkKFnxZasxC3WUurW8AasrWw129a1UKFWrCFnxXFnY9ry0va93XF1agw4xWFW0 vFn5J392qay5GwUanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUj1kv1TuYvTs0mT0YCTnIWj qI5I8CrVACY4xI64kE6c02F40Ex7xfYxn0WfASr-VFAUDa7-sFnT9fnUUIcSsGvfJTRUUU b7xYFVCjjxCrM7AC8VAFwI0_Jr0_Gr1l1xkIjI8I6I8E6xAIw20EY4v20xvaj40_Wr0E3s 1l1IIY67AEw4v_JrI_Jryl8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xv wVC0I7IYx2IY67AKxVW8JVW5JwA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxVW8JVWxJwA2z4 x0Y4vEx4A2jsIE14v26F4UJVW0owA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_Cr1j6rxdM2AI xVAIcxkEcVAq07x20xvEncxIr21l57IF6xkI12xvs2x26I8E6xACxx1l5I8CrVACY4xI64 kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r126r1DMcIj6I8E87Iv67AKxVWUJVW8JwAm 72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41l42xK82IYc2Ij64vIr41l4I8I3I 0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWU GVWUWwC2zVAF1VAY17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI 0_JFI_Gr1lIxAIcVC0I7IYx2IY6xkF7I0E14v26r1j6r4UMIIF0xvE42xK8VAvwI8IcIk0 rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r1j6r 4UYxBIdaVFxhVjvjDU0xZFpf9x07j1LvtUUUUU= X-Spam-Status: No, score=1.4 required=5.0 tests=BAYES_00,RCVD_IN_SBL_CSS, SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: * 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?1759062466630617415?= X-GMAIL-MSGID: =?utf-8?q?1759062466630617415?= The original handle_sys() is a trampline for handler_syscall. Drop it and rename handle_syscall to handle_sys for invoking it directly. Signed-off-by: Jinyang He --- arch/loongarch/kernel/entry.S | 13 +++++++------ arch/loongarch/kernel/genex.S | 5 ----- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/arch/loongarch/kernel/entry.S b/arch/loongarch/kernel/entry.S index d737e3cf42d3..d6e9572eb279 100644 --- a/arch/loongarch/kernel/entry.S +++ b/arch/loongarch/kernel/entry.S @@ -18,9 +18,9 @@ .text .cfi_sections .debug_frame .align 5 -SYM_FUNC_START(handle_syscall) +SYM_FUNC_START(handle_sys) csrrd t0, PERCPU_BASE_KS - la.pcrel t1, kernelsp + la_abs t1, kernelsp add.d t1, t1, t0 move t2, sp ld.d sp, t1, 0 @@ -62,12 +62,13 @@ SYM_FUNC_START(handle_syscall) li.d tp, ~_THREAD_MASK and tp, tp, sp - move a0, sp - bl do_syscall + move a0, sp + la_abs ra, do_syscall + jirl ra, ra, 0 RESTORE_ALL_AND_RET -SYM_FUNC_END(handle_syscall) -_ASM_NOKPROBE(handle_syscall) +SYM_FUNC_END(handle_sys) +_ASM_NOKPROBE(handle_sys) SYM_CODE_START(ret_from_fork) bl schedule_tail # a0 = struct task_struct *prev diff --git a/arch/loongarch/kernel/genex.S b/arch/loongarch/kernel/genex.S index 44ff1ff64260..1af169ca3734 100644 --- a/arch/loongarch/kernel/genex.S +++ b/arch/loongarch/kernel/genex.S @@ -91,8 +91,3 @@ SYM_FUNC_END(except_vec_cex) BUILD_HANDLER ri ri none BUILD_HANDLER watch watch none BUILD_HANDLER reserved reserved none /* others */ - -SYM_FUNC_START(handle_sys) - la_abs t0, handle_syscall - jr t0 -SYM_FUNC_END(handle_sys) From patchwork Tue Feb 28 08:02:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinyang He X-Patchwork-Id: 62329 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2887835wrd; Tue, 28 Feb 2023 00:24:51 -0800 (PST) X-Google-Smtp-Source: AK7set/mygNk1FNmbeWMDzW7qXAghZmKjJo0rW3CES90OpawhHaZ1UK0yKbF2fMUetYGBEikbjUV X-Received: by 2002:aa7:d414:0:b0:4ad:99de:91bc with SMTP id z20-20020aa7d414000000b004ad99de91bcmr2435276edq.31.1677572691586; Tue, 28 Feb 2023 00:24:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677572691; cv=none; d=google.com; s=arc-20160816; b=dl1Accz3Sy33+6/KYWwRJJz0T+EDSi8lXioRXHFv7G75kWmEVWYYX+ZGYOYlWPdFX8 9R0fbEByVHLJWtxETKNEjQ5D7GXxKsV+iG0UPkIZ475n3XYiWS8Gzgy8KsRo/ppey7nl vCGXmklhX/8QG2RltfrIVnxeblAAHa6qWZucMZ18Jry3/RkAuayEypd/NEhEhkwDzr1W trmHDoc9OArghgm/B0c2yWljZ3ZeUIWRSzcZb99ZjYHetpKDrfEq0gp0DpQlR6ycqsHF eMnXpU6hXTCXOhKAL/vr1We6JtLPHNWnAg52rIrp8RaXdBig0knlqzKKyMbMJbDcivZu kv8g== 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=N3/o7kiUNEOCbui8RIWH1yLk9mzE78e2yb9oSTMiGXc=; b=tku2n121hy87QGHkkJAO4otVDQTcWNXH33HeAqVatFOLGXfodggav5YQVE7jzDDvwN c+G9TkcGQxHEQfFocNNZmbKv6HbKjAj197yc3CxZdLCq06QzFsvv+IPxyqDp9gVVt+pI xZPBTbZSR4Ou79erd/oyEBgkvTjOK+tx6ush6d4xIii2l7Sptp78oW0L6CuEvBFJz8cv T0w9agKcHksjvAfVUfUiTSDTpu4q2Q++XZdVSfXcCV0uhfWvkuQgXn1dJDU39m4eZ2ye fws3XN87QS6oLkLGp9QUyAem4o/gIA3MjUtRZ9N6x8jJEqUWzOxPtYIOEsvCMUT4wZ/z p/qA== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m12-20020aa7c48c000000b004af5fff1c7asi11000627edq.214.2023.02.28.00.24.29; Tue, 28 Feb 2023 00:24:51 -0800 (PST) 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 S230348AbjB1ID7 (ORCPT + 99 others); Tue, 28 Feb 2023 03:03:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230349AbjB1IDs (ORCPT ); Tue, 28 Feb 2023 03:03:48 -0500 Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5380822000 for ; Tue, 28 Feb 2023 00:03:31 -0800 (PST) Received: from loongson.cn (unknown [111.9.175.10]) by gateway (Coremail) with SMTP id _____8AxJPxQtf1jymUGAA--.6379S3; Tue, 28 Feb 2023 16:03:28 +0800 (CST) Received: from localhost.localdomain (unknown [111.9.175.10]) by localhost.localdomain (Coremail) with SMTP id AQAAf8BxB707tf1jb3tAAA--.49681S4; Tue, 28 Feb 2023 16:03:18 +0800 (CST) From: Jinyang He To: Huacai Chen , WANG Xuerui Cc: Xi Ruoyao , Youling Tang , loongarch@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/6] LoongArch: Move the content defined by SYM_DATA to data or rodata section Date: Tue, 28 Feb 2023 16:02:53 +0800 Message-Id: <20230228080257.28807-3-hejinyang@loongson.cn> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20230228080257.28807-1-hejinyang@loongson.cn> References: <20230228080257.28807-1-hejinyang@loongson.cn> MIME-Version: 1.0 X-CM-TRANSID: AQAAf8BxB707tf1jb3tAAA--.49681S4 X-CM-SenderInfo: pkhmx0p1dqwqxorr0wxvrqhubq/ X-Coremail-Antispam: 1Uk129KBjvJXoWrtFWxGF45uFy8GFyxXF1xAFb_yoW8Jr4fpr 13ArykWrZ8KFn3Aas8Ja4F9rWDJ34DGw1ag3WqyFyrKanrWrykXrnYvr9FgFyjga1SkrWF qrn5J39rKa1UA3JanT9S1TB71UUUUUDqnTZGkaVYY2UrUUUUj1kv1TuYvTs0mT0YCTnIWj qI5I8CrVACY4xI64kE6c02F40Ex7xfYxn0WfASr-VFAUDa7-sFnT9fnUUIcSsGvfJTRUUU b7kYFVCjjxCrM7AC8VAFwI0_Jr0_Gr1l1xkIjI8I6I8E6xAIw20EY4v20xvaj40_Wr0E3s 1l1IIY67AEw4v_Jrv_JF1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xv wVC0I7IYx2IY67AKxVW5JVW7JwA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxVW8JVWxJwA2z4 x0Y4vEx4A2jsIE14v26F4UJVW0owA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_Cr1j6rxdM2AI xVAIcxkEcVAq07x20xvEncxIr21l57IF6xkI12xvs2x26I8E6xACxx1l5I8CrVACY4xI64 kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r1q6rW5McIj6I8E87Iv67AKxVW8JVWxJwAm 72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41l42xK82IYc2Ij64vIr41l4I8I3I 0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWU GVWUWwC2zVAF1VAY17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI 0_Gr0_Xr1lIxAIcVC0I7IYx2IY6xkF7I0E14v26r4j6F4UMIIF0xvE42xK8VAvwI8IcIk0 rVWUJVWUCwCI42IY6I8E87Iv67AKxVW8JVWxJwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r 4UJbIYCTnIWIevJa73UjIFyTuYvjxUcCD7UUUUU X-Spam-Status: No, score=1.4 required=5.0 tests=BAYES_00,RCVD_IN_SBL_CSS, SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: * 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?1759062462740565842?= X-GMAIL-MSGID: =?utf-8?q?1759062462740565842?= Due to the SYM_DATA do not give the section notes, manually set it. Reported-by: Youling Tang Signed-off-by: Jinyang He --- arch/loongarch/kernel/genex.S | 2 ++ arch/loongarch/kernel/head.S | 2 ++ 2 files changed, 4 insertions(+) diff --git a/arch/loongarch/kernel/genex.S b/arch/loongarch/kernel/genex.S index 1af169ca3734..de591a9270bd 100644 --- a/arch/loongarch/kernel/genex.S +++ b/arch/loongarch/kernel/genex.S @@ -77,7 +77,9 @@ SYM_FUNC_END(except_vec_cex) 668: RESTORE_ALL_AND_RET SYM_FUNC_END(handle_\exception) + .pushsection .rodata SYM_DATA(unwind_hint_\exception, .word 668b - 666b) + .popsection .endm BUILD_HANDLER ade ade badv diff --git a/arch/loongarch/kernel/head.S b/arch/loongarch/kernel/head.S index aa64b179744f..7cfa1f850e54 100644 --- a/arch/loongarch/kernel/head.S +++ b/arch/loongarch/kernel/head.S @@ -32,9 +32,11 @@ _head: pe_header: __EFI_PE_HEADER +.pushsection .rodata SYM_DATA(kernel_asize, .long _end - _text); SYM_DATA(kernel_fsize, .long _edata - _text); SYM_DATA(kernel_offset, .long kernel_offset - _text); +.popsection #endif From patchwork Tue Feb 28 08:02:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinyang He X-Patchwork-Id: 62327 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2885011wrd; Tue, 28 Feb 2023 00:16:31 -0800 (PST) X-Google-Smtp-Source: AK7set+Epzs/pssl0Vz9+tBi/lIvYOOxNvBtNtX9TgJXEmKNLfxpGjbxUk9YAOTYoxkCGRX2nFJt X-Received: by 2002:a17:907:c71a:b0:8b1:4516:238 with SMTP id ty26-20020a170907c71a00b008b145160238mr11117279ejc.26.1677572191055; Tue, 28 Feb 2023 00:16:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677572191; cv=none; d=google.com; s=arc-20160816; b=ne8xA1HnaP99XAFozSudJTaBMirycjJ+JxQyvkyJZkJ5r1oHFZocMmr24VRBP+rxyK 1empw10n//+RKZ0/d3Fq5RhBcCo1gHS/pS0gFZ6FW9qf92qu4T8fQ/Z6EM8hOEMNyPeF G2DOkVXM4YUjlLwofYdeU1vr9+I01Cm6WYBTSUS7VVjTJPcAP/zWmsvYYS5xQfcw/KsV vsrTVuNf/u//rE9MlUQ+I3pxX2F74eTIPO4BtmyGPIGxHrAiiRz1mKdF5m50OfW3DTwu GJm0MJEUnca6m1msF2VqnY/+dMF5hmyi7pdKrzWGKz2iVZ4NUSNNBigYSVptU0Fma4Vn YYHA== 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=xvxpiaGD6ApW17bJSE55QIc+BPfsrAw6DCWdd+W1mXk=; b=GyS6cwqN+Ng7PCPLdp/g/ZTPd98B+UQ45eB796I5KbK14fsWvFCb461H2U548U/H8u bSJXfM8SGj9KrFUuPIvDsIPCHmsGcf7Kru/+IxnebEdlngnjcBwjopuocqLjckXgFwun KWvJV+vs9m0fu0wLHUtzeVYs0rAq+TdV+Q7+vp3DSg4yX68VfaMVvVNDOrqO3kelleo4 IUFCBq3h2xq0HJ1FLmrMaqPUhR8oX9G1vBi1WGN6wesVqguOkM10TTyMRZFnlwpHroLg dzKVkeJNIfPo5GeBNJFCcMFvR8xGK3YjMoAWC3X45t0ku2DkX9+Cxi+tt9afR0Z7oDoU snTQ== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y18-20020a170906559200b008e3da5c56f4si9612738ejp.485.2023.02.28.00.16.05; Tue, 28 Feb 2023 00:16:31 -0800 (PST) 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 S230349AbjB1IES (ORCPT + 99 others); Tue, 28 Feb 2023 03:04:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230369AbjB1IED (ORCPT ); Tue, 28 Feb 2023 03:04:03 -0500 Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2EA6522002 for ; Tue, 28 Feb 2023 00:03:41 -0800 (PST) Received: from loongson.cn (unknown [111.9.175.10]) by gateway (Coremail) with SMTP id _____8Dx_5dUtf1j42UGAA--.6634S3; Tue, 28 Feb 2023 16:03:32 +0800 (CST) Received: from localhost.localdomain (unknown [111.9.175.10]) by localhost.localdomain (Coremail) with SMTP id AQAAf8BxB707tf1jb3tAAA--.49681S5; Tue, 28 Feb 2023 16:03:28 +0800 (CST) From: Jinyang He To: Huacai Chen , WANG Xuerui Cc: Xi Ruoyao , Youling Tang , loongarch@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH v2 3/6] LoongArch: Create a exception handlers section Date: Tue, 28 Feb 2023 16:02:54 +0800 Message-Id: <20230228080257.28807-4-hejinyang@loongson.cn> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20230228080257.28807-1-hejinyang@loongson.cn> References: <20230228080257.28807-1-hejinyang@loongson.cn> MIME-Version: 1.0 X-CM-TRANSID: AQAAf8BxB707tf1jb3tAAA--.49681S5 X-CM-SenderInfo: pkhmx0p1dqwqxorr0wxvrqhubq/ X-Coremail-Antispam: 1Uk129KBjvAXoW3ZF4DZr47uryxWFyxWFyrXrb_yoW8Jr13to W3C3W09F1rKa12vF9xJF4xJa18XF1ktrZ5A397AFyru3yDu34UW34rt3WvvryjvFs3JrW7 Cay3JF1kGws3Zrnrn29KB7ZKAUJUUUU5529EdanIXcx71UUUUU7KY7ZEXasCq-sGcSsGvf J3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU0xBIdaVrnRJU UUkYb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2IYs7xG6rWj6s 0DM7CIcVAFz4kK6r1Y6r17M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0 Y4vE2Ix0cI8IcVAFwI0_Xr0_Ar1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr0_Cr1l84 ACjcxK6I8E87Iv67AKxVWxJr0_GcWl84ACjcxK6I8E87Iv6xkF7I0E14v26F4UJVW0owAS 0I0E0xvYzxvE52x082IY62kv0487Mc804VCY07AIYIkI8VC2zVCFFI0UMc02F40EFcxC0V AKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUtVWrXwAv7VC2z280aVAFwI0_Gr0_Cr1l Ox8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI48JMxAIw28IcxkI7VAKI48JMxC20s 026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_ JrI_JrWlx4CE17CEb7AF67AKxVWUAVWUtwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14 v26r4j6ryUMIIF0xvE2Ix0cI8IcVCY1x0267AKxVW8JVWxJwCI42IY6xAIw20EY4v20xva j40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Gr0_Cr1lIxAIcVC2z280aVCY1x0267AKxVW8JV W8JrUvcSsGvfC2KfnxnUUI43ZEXa7IU8l38UUUUUU== X-Spam-Status: No, score=1.4 required=5.0 tests=BAYES_00,RCVD_IN_SBL_CSS, SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: * 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?1759061937790951050?= X-GMAIL-MSGID: =?utf-8?q?1759061937790951050?= Create a section named .ex_handlers to collect exception handlers. Use strict alignment for using it later. As some handlers is shared to other exception, we can not define symbol directly. Correct these symbols by adding suffix or by using number label. Signed-off-by: Jinyang He --- arch/loongarch/include/asm/traps.h | 39 +++++++++++++++++ arch/loongarch/kernel/entry.S | 5 +++ arch/loongarch/kernel/genex.S | 65 ++++++++++++++++++++++------- arch/loongarch/kernel/vmlinux.lds.S | 19 +++++++++ arch/loongarch/mm/tlbex.S | 53 ++++++++++++++++------- 5 files changed, 149 insertions(+), 32 deletions(-) create mode 100644 arch/loongarch/include/asm/traps.h diff --git a/arch/loongarch/include/asm/traps.h b/arch/loongarch/include/asm/traps.h new file mode 100644 index 000000000000..b348d66c16a1 --- /dev/null +++ b/arch/loongarch/include/asm/traps.h @@ -0,0 +1,39 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2023 Loongson Technology Corporation Limited + */ +#ifndef _ASM_TRAPS_H +#define _ASM_TRAPS_H + +#include // For EXCCODES + +#ifdef __ASSEMBLY__ +/* Used for create exception handlers. */ +#define EXCCODE_UNDEF 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, \ + 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, \ + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, \ + 59, 60, 61, 62, 63 +#define EXCCODE_NOHND EXCCODE_OOB, EXCCODE_BTE, EXCCODE_PSI, \ + EXCCODE_HYP, EXCCODE_GCM, EXCCODE_SE + +/* As merrentry is set to the same value as eentry, the merr handler can + * be thought as the first exception handler. + */ +#define EXCCODE_MERR EXCCODE_RSV + +#define _SET_EXCEPTION_HANDLER(EXCCODE, ...) \ + .pushsection .exception_handlers.##EXCCODE, "ax"; \ + .align 9; \ + __VA_ARGS__; \ + .popsection; + +#define SET_EXCEPTION_HANDLER(EXCCODE, ...) \ + _SET_EXCEPTION_HANDLER(EXCCODE, __VA_ARGS__) + +#define SET_TLBR_HANDLER(...) \ + .pushsection .tlbrhandler, "ax"; \ + __VA_ARGS__; \ + .popsection; +#endif /* __ASSEMBLY__ */ + +#endif /* _ASM_TRAPS_H */ diff --git a/arch/loongarch/kernel/entry.S b/arch/loongarch/kernel/entry.S index d6e9572eb279..ca4651f91e73 100644 --- a/arch/loongarch/kernel/entry.S +++ b/arch/loongarch/kernel/entry.S @@ -14,9 +14,11 @@ #include #include #include +#include .text .cfi_sections .debug_frame + .macro _handle_sys .align 5 SYM_FUNC_START(handle_sys) csrrd t0, PERCPU_BASE_KS @@ -69,6 +71,9 @@ SYM_FUNC_START(handle_sys) RESTORE_ALL_AND_RET SYM_FUNC_END(handle_sys) _ASM_NOKPROBE(handle_sys) + .endm + +SET_EXCEPTION_HANDLER(EXCCODE_SYS, _handle_sys) SYM_CODE_START(ret_from_fork) bl schedule_tail # a0 = struct task_struct *prev diff --git a/arch/loongarch/kernel/genex.S b/arch/loongarch/kernel/genex.S index de591a9270bd..86abafc8b95b 100644 --- a/arch/loongarch/kernel/genex.S +++ b/arch/loongarch/kernel/genex.S @@ -15,6 +15,7 @@ #include #include #include +#include .align 5 SYM_FUNC_START(__arch_cpu_idle) @@ -31,7 +32,8 @@ SYM_FUNC_START(__arch_cpu_idle) 1: jr ra SYM_FUNC_END(__arch_cpu_idle) -SYM_FUNC_START(handle_vint) + .macro _handle_vint idx +SYM_FUNC_START(handle_vint\idx) BACKUP_T0T1 SAVE_ALL la_abs t1, __arch_cpu_idle @@ -46,11 +48,14 @@ SYM_FUNC_START(handle_vint) la_abs t0, do_vint jirl ra, t0, 0 RESTORE_ALL_AND_RET -SYM_FUNC_END(handle_vint) +SYM_FUNC_END(handle_vint\idx) + .endm + .macro _except_vec_cex SYM_FUNC_START(except_vec_cex) b cache_parity_error SYM_FUNC_END(except_vec_cex) + .endm .macro build_prep_badv csrrd t0, LOONGARCH_CSR_BADV @@ -66,7 +71,7 @@ SYM_FUNC_END(except_vec_cex) .macro BUILD_HANDLER exception handler prep .align 5 - SYM_FUNC_START(handle_\exception) +SYM_FUNC_START(handle_\exception) 666: BACKUP_T0T1 SAVE_ALL @@ -76,20 +81,48 @@ SYM_FUNC_END(except_vec_cex) jirl ra, t0, 0 668: RESTORE_ALL_AND_RET - SYM_FUNC_END(handle_\exception) +SYM_FUNC_END(handle_\exception) .pushsection .rodata - SYM_DATA(unwind_hint_\exception, .word 668b - 666b) +SYM_DATA(unwind_hint_\exception, .word 668b - 666b) .popsection .endm - BUILD_HANDLER ade ade badv - BUILD_HANDLER ale ale badv - BUILD_HANDLER bp bp none - BUILD_HANDLER fpe fpe fcsr - BUILD_HANDLER fpu fpu none - BUILD_HANDLER lsx lsx none - BUILD_HANDLER lasx lasx none - BUILD_HANDLER lbt lbt none - BUILD_HANDLER ri ri none - BUILD_HANDLER watch watch none - BUILD_HANDLER reserved reserved none /* others */ +SET_EXCEPTION_HANDLER(EXCCODE_SIP0, _handle_vint) +SET_EXCEPTION_HANDLER(EXCCODE_SIP1, _handle_vint 1) +SET_EXCEPTION_HANDLER(EXCCODE_IP0, _handle_vint 2) +SET_EXCEPTION_HANDLER(EXCCODE_IP1, _handle_vint 3) +SET_EXCEPTION_HANDLER(EXCCODE_IP2, _handle_vint 4) +SET_EXCEPTION_HANDLER(EXCCODE_IP3, _handle_vint 5) +SET_EXCEPTION_HANDLER(EXCCODE_IP4, _handle_vint 6) +SET_EXCEPTION_HANDLER(EXCCODE_IP5, _handle_vint 7) +SET_EXCEPTION_HANDLER(EXCCODE_IP6, _handle_vint 8) +SET_EXCEPTION_HANDLER(EXCCODE_IP7, _handle_vint 9) +SET_EXCEPTION_HANDLER(EXCCODE_PMC, _handle_vint 10) +SET_EXCEPTION_HANDLER(EXCCODE_TIMER, _handle_vint 11) +SET_EXCEPTION_HANDLER(EXCCODE_IPI, _handle_vint 12) +SET_EXCEPTION_HANDLER(EXCCODE_NMI, _handle_vint 13) + +SET_EXCEPTION_HANDLER(EXCCODE_MERR, _except_vec_cex) + +SET_EXCEPTION_HANDLER(EXCCODE_ADE, BUILD_HANDLER ade ade badv) +SET_EXCEPTION_HANDLER(EXCCODE_ALE, BUILD_HANDLER ale ale badv) +SET_EXCEPTION_HANDLER(EXCCODE_BP, BUILD_HANDLER bp bp none) +SET_EXCEPTION_HANDLER(EXCCODE_FPE, BUILD_HANDLER fpe fpe fcsr) +SET_EXCEPTION_HANDLER(EXCCODE_FPDIS, BUILD_HANDLER fpu fpu none) +SET_EXCEPTION_HANDLER(EXCCODE_LSXDIS, BUILD_HANDLER lsx lsx none) +SET_EXCEPTION_HANDLER(EXCCODE_LASXDIS, BUILD_HANDLER lasx lasx none) +SET_EXCEPTION_HANDLER(EXCCODE_BTDIS, BUILD_HANDLER lbt lbt none) +SET_EXCEPTION_HANDLER(EXCCODE_INE, BUILD_HANDLER ri ri none) +SET_EXCEPTION_HANDLER(EXCCODE_IPE, BUILD_HANDLER ri1 ri none) +SET_EXCEPTION_HANDLER(EXCCODE_WATCH, BUILD_HANDLER watch watch none) + +.irp i, EXCCODE_UNDEF +SET_EXCEPTION_HANDLER(\i, BUILD_HANDLER reserved\i reserved none) +.endr + +.irp i, EXCCODE_NOHND +SET_EXCEPTION_HANDLER(\i, BUILD_HANDLER reserved\i reserved none) +.endr + +/* Create handle_reserved for temporary build. */ +BUILD_HANDLER reserved reserved none diff --git a/arch/loongarch/kernel/vmlinux.lds.S b/arch/loongarch/kernel/vmlinux.lds.S index ad2ce1a0908e..e99b50359900 100644 --- a/arch/loongarch/kernel/vmlinux.lds.S +++ b/arch/loongarch/kernel/vmlinux.lds.S @@ -21,6 +21,11 @@ */ PECOFF_FILE_ALIGN = 0x200; PECOFF_SEGMENT_ALIGN = 0x10000; +EX_HANDLER_ALIGN = SZ_512; +EX_HANDLER_SIZE = SZ_512; +EX_HANDLER_TOTAL = 78; /* 64 Exceptions + 14 Interrupts */ +EXCEPTION_ENTRY_ALIGN = SZ_64K; +TLBR_ENTRY_ALIGN = SZ_4K; OUTPUT_ARCH(loongarch) ENTRY(kernel_entry) @@ -54,6 +59,17 @@ SECTIONS . = ALIGN(PECOFF_SEGMENT_ALIGN); _etext = .; + . = ALIGN(EXCEPTION_ENTRY_ALIGN); + .ex_handlers : { + __ex_handlers = .; + *(SORT_BY_INIT_PRIORITY(.exception_handlers.*)) + . = ALIGN(EX_HANDLER_ALIGN); + __ex_handlers_end = .; + . = ALIGN(TLBR_ENTRY_ALIGN); + __tlbr_entry = .; + *(.tlbrhandler) + } + /* * struct alt_inst entries. From the header (alternative.h): * "Alternative instructions for different CPU types or capabilities" @@ -154,3 +170,6 @@ SECTIONS *(.eh_frame) } } + +ASSERT(__ex_handlers_end == (__ex_handlers + EX_HANDLER_SIZE * EX_HANDLER_TOTAL), + "The amount of exception handlers does not match!"); diff --git a/arch/loongarch/mm/tlbex.S b/arch/loongarch/mm/tlbex.S index 244e2f5aeee5..53321d3447a2 100644 --- a/arch/loongarch/mm/tlbex.S +++ b/arch/loongarch/mm/tlbex.S @@ -9,6 +9,7 @@ #include #include #include +#include #define INVTLB_ADDR_GFALSE_AND_ASID 5 @@ -32,7 +33,8 @@ tlb_do_page_fault 0 tlb_do_page_fault 1 -SYM_FUNC_START(handle_tlb_protect) + .macro _handle_tlb_protect idx +SYM_FUNC_START(handle_tlb_protect\idx) BACKUP_T0T1 SAVE_ALL move a0, sp @@ -42,9 +44,11 @@ SYM_FUNC_START(handle_tlb_protect) la_abs t0, do_page_fault jirl ra, t0, 0 RESTORE_ALL_AND_RET -SYM_FUNC_END(handle_tlb_protect) +SYM_FUNC_END(handle_tlb_protect\idx) + .endm -SYM_FUNC_START(handle_tlb_load) + .macro _handle_tlb_load idx +SYM_FUNC_START(handle_tlb_load\idx) csrwr t0, EXCEPTION_KS0 csrwr t1, EXCEPTION_KS1 csrwr ra, EXCEPTION_KS2 @@ -53,10 +57,10 @@ SYM_FUNC_START(handle_tlb_load) * The vmalloc handling is not in the hotpath. */ csrrd t0, LOONGARCH_CSR_BADV - bltz t0, vmalloc_load + bltz t0, 3f csrrd t1, LOONGARCH_CSR_PGDL -vmalloc_done_load: +1: /* vmalloc_done_load: */ /* Get PGD offset in bytes */ bstrpick.d ra, t0, PTRS_PER_PGD_BITS + PGDIR_SHIFT - 1, PGDIR_SHIFT alsl.d t1, ra, t1, 3 @@ -78,25 +82,25 @@ vmalloc_done_load: * see if we need to jump to huge tlb processing. */ rotri.d ra, ra, _PAGE_HUGE_SHIFT + 1 - bltz ra, tlb_huge_update_load + bltz ra, 4f rotri.d ra, ra, 64 - (_PAGE_HUGE_SHIFT + 1) bstrpick.d t0, t0, PTRS_PER_PTE_BITS + PAGE_SHIFT - 1, PAGE_SHIFT alsl.d t1, t0, ra, _PTE_T_LOG2 #ifdef CONFIG_SMP -smp_pgtable_change_load: +2: /* smp_pgtable_change_load: */ ll.d t0, t1, 0 #else ld.d t0, t1, 0 #endif andi ra, t0, _PAGE_PRESENT - beqz ra, nopage_tlb_load + beqz ra, 5f ori t0, t0, _PAGE_VALID #ifdef CONFIG_SMP sc.d t0, t1, 0 - beqz t0, smp_pgtable_change_load + beqz t0, 2b #else st.d t0, t1, 0 #endif @@ -114,23 +118,23 @@ smp_pgtable_change_load: ertn #ifdef CONFIG_64BIT -vmalloc_load: +3: /* vmalloc_load: */ la_abs t1, swapper_pg_dir - b vmalloc_done_load + b 1b #endif /* This is the entry point of a huge page. */ -tlb_huge_update_load: +4: /* tlb_huge_update_load: */ #ifdef CONFIG_SMP ll.d ra, t1, 0 #endif andi t0, ra, _PAGE_PRESENT - beqz t0, nopage_tlb_load + beqz t0, 5f #ifdef CONFIG_SMP ori t0, ra, _PAGE_VALID sc.d t0, t1, 0 - beqz t0, tlb_huge_update_load + beqz t0, 4b ori t0, ra, _PAGE_VALID #else rotri.d ra, ra, 64 - (_PAGE_HUGE_SHIFT + 1) @@ -183,13 +187,15 @@ tlb_huge_update_load: csrrd ra, EXCEPTION_KS2 ertn -nopage_tlb_load: +5: /* nopage_tlb_load: */ dbar 0 csrrd ra, EXCEPTION_KS2 la_abs t0, tlb_do_page_fault_0 jr t0 -SYM_FUNC_END(handle_tlb_load) +SYM_FUNC_END(handle_tlb_load\idx) + .endm + .macro _handle_tlb_store SYM_FUNC_START(handle_tlb_store) csrwr t0, EXCEPTION_KS0 csrwr t1, EXCEPTION_KS1 @@ -338,7 +344,9 @@ nopage_tlb_store: la_abs t0, tlb_do_page_fault_1 jr t0 SYM_FUNC_END(handle_tlb_store) + .endm + .macro _handle_tlb_modify SYM_FUNC_START(handle_tlb_modify) csrwr t0, EXCEPTION_KS0 csrwr t1, EXCEPTION_KS1 @@ -485,7 +493,9 @@ nopage_tlb_modify: la_abs t0, tlb_do_page_fault_1 jr t0 SYM_FUNC_END(handle_tlb_modify) + .endm + .macro _handle_tlb_refill SYM_FUNC_START(handle_tlb_refill) csrwr t0, LOONGARCH_CSR_TLBRSAVE csrrd t0, LOONGARCH_CSR_PGD @@ -502,3 +512,14 @@ SYM_FUNC_START(handle_tlb_refill) csrrd t0, LOONGARCH_CSR_TLBRSAVE ertn SYM_FUNC_END(handle_tlb_refill) + .endm + +SET_EXCEPTION_HANDLER(EXCCODE_TLBI, _handle_tlb_load) +SET_EXCEPTION_HANDLER(EXCCODE_TLBL, _handle_tlb_load 1) +SET_EXCEPTION_HANDLER(EXCCODE_TLBS, _handle_tlb_store) +SET_EXCEPTION_HANDLER(EXCCODE_TLBM, _handle_tlb_modify) +SET_EXCEPTION_HANDLER(EXCCODE_TLBNR, _handle_tlb_protect) +SET_EXCEPTION_HANDLER(EXCCODE_TLBNX, _handle_tlb_protect 1) +SET_EXCEPTION_HANDLER(EXCCODE_TLBPE, _handle_tlb_protect 2) + +SET_TLBR_HANDLER(_handle_tlb_refill) From patchwork Tue Feb 28 08:02:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinyang He X-Patchwork-Id: 62331 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2888196wrd; Tue, 28 Feb 2023 00:25:57 -0800 (PST) X-Google-Smtp-Source: AK7set9J+13n6xmgh7CUZmEwv7DBlHSi6XdrTKnjwh4gX1gFMYhUo5e6xglOj3ON9xPBJAB74pdN X-Received: by 2002:a17:906:6d88:b0:86f:763c:2695 with SMTP id h8-20020a1709066d8800b0086f763c2695mr1948385ejt.17.1677572756895; Tue, 28 Feb 2023 00:25:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677572756; cv=none; d=google.com; s=arc-20160816; b=h7F/qaNdKY21drDmXWCeS1v/Go2YzHjz4NWCLRqienLuKXI/QdxN+VScdJmpPhYONU n2PrK+8z6Q9DpUxf4RJKWLjHW4b4TWlSNEk34y0gNuiff+u3k8nkfni8b4Ql6rRA5yEt EWpfUvsgV4CzBHTjsmiouIDh90Rlsqee7h5825OBFhKgK5qqAcM7dC51ONidJnTpOKh5 LT8mt+hYrVfCObKl5wrtM8t/gHwGsrswgVfm9jHxVC6KUZ7i0thm0x58g/2Ib4382PvC qHX+Xf3corITbfp/2ugwM9c9GKeACWnrMs2Dvd10/oOMpzCtvOMbeYa5vx0WRmR0EKJh FYEA== 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=XoNbdgSiLEK9HQpTvIPojfsmTImzSmbkJXLZEt7m9H0=; b=B3V0Rz5gurC2kumgrCdGp2mIVwMaCYRnfBzp3K7T4yHu0HnMvnQwhpE0YOj8r7oIr9 v0S6sv958xSkcDHRaPDTEeBLF/Em3BH3Eee0TSUhVT1s3C+ZkF4zP/fhNk2ug+KOFmfr tLmc7gkzteiN5Mk4tt4+xkX+O+5Jc//4jhnJ39M8sO8Im/Ckpb1lCiqyenUWFFf9yVEg j17VPx1AhKk0w2tGofMKtnp9LQVBsW2d+Qca96/P2KbWoOQpleaOcYF6UAeWrRSuFae+ 1f8/ZVBBK6rUo7yg95RMy0Q4aIliY/5eWvQUJZVlh75XLLIsdd+2BJrVtdXpU8k+D/ej SwBg== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a4-20020a170906684400b008e65505a1ebsi11078174ejs.0.2023.02.28.00.25.34; Tue, 28 Feb 2023 00:25:56 -0800 (PST) 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 S230478AbjB1IEY (ORCPT + 99 others); Tue, 28 Feb 2023 03:04:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230381AbjB1IEH (ORCPT ); Tue, 28 Feb 2023 03:04:07 -0500 Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E3D37234DA for ; Tue, 28 Feb 2023 00:03:43 -0800 (PST) Received: from loongson.cn (unknown [111.9.175.10]) by gateway (Coremail) with SMTP id _____8DxJYxatf1j+GUGAA--.6516S3; Tue, 28 Feb 2023 16:03:38 +0800 (CST) Received: from localhost.localdomain (unknown [111.9.175.10]) by localhost.localdomain (Coremail) with SMTP id AQAAf8BxB707tf1jb3tAAA--.49681S6; Tue, 28 Feb 2023 16:03:32 +0800 (CST) From: Jinyang He To: Huacai Chen , WANG Xuerui Cc: Xi Ruoyao , Youling Tang , loongarch@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH v2 4/6] LoongArch: Drop pernode exception handlers Date: Tue, 28 Feb 2023 16:02:55 +0800 Message-Id: <20230228080257.28807-5-hejinyang@loongson.cn> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20230228080257.28807-1-hejinyang@loongson.cn> References: <20230228080257.28807-1-hejinyang@loongson.cn> MIME-Version: 1.0 X-CM-TRANSID: AQAAf8BxB707tf1jb3tAAA--.49681S6 X-CM-SenderInfo: pkhmx0p1dqwqxorr0wxvrqhubq/ X-Coremail-Antispam: 1Uk129KBjvAXoW3KryfuFyDtr4xWFW5Aw1xGrg_yoW8Jr18to Wava1jyr1rGw47t343t3Zxta48ZF9IyrWkC3sayan3Wr9rAFyUWw4UKFn8t3ySgwn5Jryx Ca43Wrn8Zas7Xr1kn29KB7ZKAUJUUUU5529EdanIXcx71UUUUU7KY7ZEXasCq-sGcSsGvf J3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU0xBIdaVrnRJU UUkYb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2IYs7xG6rWj6s 0DM7CIcVAFz4kK6r126r13M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0 Y4vE2Ix0cI8IcVAFwI0_Xr0_Ar1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr0_Cr1l84 ACjcxK6I8E87Iv67AKxVWxJr0_GcWl84ACjcxK6I8E87Iv6xkF7I0E14v26F4UJVW0owAS 0I0E0xvYzxvE52x082IY62kv0487Mc804VCY07AIYIkI8VC2zVCFFI0UMc02F40EFcxC0V AKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUtVWrXwAv7VC2z280aVAFwI0_Gr0_Cr1l Ox8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI48JMxAIw28IcxkI7VAKI48JMxC20s 026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_ JrI_JrWlx4CE17CEb7AF67AKxVWUAVWUtwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14 v26ryj6F1UMIIF0xvE2Ix0cI8IcVCY1x0267AKxVW8JVWxJwCI42IY6xAIw20EY4v20xva j40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Gr0_Cr1lIxAIcVC2z280aVCY1x0267AKxVW8JV W8JrUvcSsGvfC2KfnxnUUI43ZEXa7IU8gAw7UUUUU== X-Spam-Status: No, score=1.4 required=5.0 tests=BAYES_00,RCVD_IN_SBL_CSS, SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: * 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?1759062531007329012?= X-GMAIL-MSGID: =?utf-8?q?1759062531007329012?= 1, set the value of CSR.EENTRY to &__ex_handlers. 2, set the value of CSR.TLBRENTRY to &__tlbr_entry. 3, set the value of CSR.MERRENTRY to &__ex_handlers. Then, we can drop the pernode exception handlers. Signed-off-by: Jinyang He --- arch/loongarch/include/asm/setup.h | 7 --- arch/loongarch/include/asm/traps.h | 29 ++++++++++ arch/loongarch/kernel/genex.S | 8 --- arch/loongarch/kernel/traps.c | 74 +------------------------ arch/loongarch/kernel/unwind_prologue.c | 62 +-------------------- arch/loongarch/mm/cache.c | 6 -- arch/loongarch/mm/tlb.c | 40 ------------- arch/loongarch/power/suspend.c | 5 +- 8 files changed, 33 insertions(+), 198 deletions(-) diff --git a/arch/loongarch/include/asm/setup.h b/arch/loongarch/include/asm/setup.h index be05c0e706a2..4074225339ec 100644 --- a/arch/loongarch/include/asm/setup.h +++ b/arch/loongarch/include/asm/setup.h @@ -9,17 +9,10 @@ #include #include -#define VECSIZE 0x200 - -extern unsigned long eentry; -extern unsigned long tlbrentry; extern char init_command_line[COMMAND_LINE_SIZE]; extern void tlb_init(int cpu); extern void cpu_cache_init(void); -extern void cache_error_setup(void); extern void per_cpu_trap_init(int cpu); -extern void set_handler(unsigned long offset, void *addr, unsigned long len); -extern void set_merr_handler(unsigned long offset, void *addr, unsigned long len); #ifdef CONFIG_RELOCATABLE diff --git a/arch/loongarch/include/asm/traps.h b/arch/loongarch/include/asm/traps.h index b348d66c16a1..8f276253f145 100644 --- a/arch/loongarch/include/asm/traps.h +++ b/arch/loongarch/include/asm/traps.h @@ -34,6 +34,35 @@ .pushsection .tlbrhandler, "ax"; \ __VA_ARGS__; \ .popsection; + +#else /* __ASSEMBLY__ */ + +#define VECSIZE 0x200 +extern void *__ex_handlers; +extern void *__tlbr_entry; + +static inline void set_eentry(void *entry) +{ + csr_write64((unsigned long)entry, LOONGARCH_CSR_EENTRY); +} + +static inline void set_tlbrentry(void *entry) +{ + csr_write64((unsigned long)entry, LOONGARCH_CSR_TLBRENTRY); +} + +static inline void set_merrentry(void *entry) +{ + csr_write64((unsigned long)entry, LOONGARCH_CSR_MERRENTRY); +} + +static inline void configure_exception_vector(void) +{ + set_eentry(&__ex_handlers); + set_tlbrentry(&__tlbr_entry); + set_merrentry(&__ex_handlers); +} + #endif /* __ASSEMBLY__ */ #endif /* _ASM_TRAPS_H */ diff --git a/arch/loongarch/kernel/genex.S b/arch/loongarch/kernel/genex.S index 86abafc8b95b..256e2e5b83d4 100644 --- a/arch/loongarch/kernel/genex.S +++ b/arch/loongarch/kernel/genex.S @@ -72,19 +72,14 @@ SYM_FUNC_END(except_vec_cex) .macro BUILD_HANDLER exception handler prep .align 5 SYM_FUNC_START(handle_\exception) - 666: BACKUP_T0T1 SAVE_ALL build_prep_\prep move a0, sp la_abs t0, do_\handler jirl ra, t0, 0 - 668: RESTORE_ALL_AND_RET SYM_FUNC_END(handle_\exception) - .pushsection .rodata -SYM_DATA(unwind_hint_\exception, .word 668b - 666b) - .popsection .endm SET_EXCEPTION_HANDLER(EXCCODE_SIP0, _handle_vint) @@ -123,6 +118,3 @@ SET_EXCEPTION_HANDLER(\i, BUILD_HANDLER reserved\i reserved none) .irp i, EXCCODE_NOHND SET_EXCEPTION_HANDLER(\i, BUILD_HANDLER reserved\i reserved none) .endr - -/* Create handle_reserved for temporary build. */ -BUILD_HANDLER reserved reserved none diff --git a/arch/loongarch/kernel/traps.c b/arch/loongarch/kernel/traps.c index c8b3bd76c941..84ac78bc8c57 100644 --- a/arch/loongarch/kernel/traps.c +++ b/arch/loongarch/kernel/traps.c @@ -43,6 +43,7 @@ #include #include #include +#include #include #include @@ -798,25 +799,8 @@ asmlinkage void noinstr do_vint(struct pt_regs *regs, unsigned long sp) irqentry_exit(regs, state); } -unsigned long eentry; -unsigned long tlbrentry; - -long exception_handlers[VECSIZE * 128 / sizeof(long)] __aligned(SZ_64K); - -static void configure_exception_vector(void) -{ - eentry = (unsigned long)exception_handlers; - tlbrentry = (unsigned long)exception_handlers + 80*VECSIZE; - - csr_write64(eentry, LOONGARCH_CSR_EENTRY); - csr_write64(eentry, LOONGARCH_CSR_MERRENTRY); - csr_write64(tlbrentry, LOONGARCH_CSR_TLBRENTRY); -} - void per_cpu_trap_init(int cpu) { - unsigned int i; - setup_vint_size(VECSIZE); configure_exception_vector(); @@ -829,62 +813,6 @@ void per_cpu_trap_init(int cpu) BUG_ON(current->mm); enter_lazy_tlb(&init_mm, current); - /* Initialise exception handlers */ - if (cpu == 0) - for (i = 0; i < 64; i++) - set_handler(i * VECSIZE, handle_reserved, VECSIZE); - tlb_init(cpu); cpu_cache_init(); } - -/* Install CPU exception handler */ -void set_handler(unsigned long offset, void *addr, unsigned long size) -{ - memcpy((void *)(eentry + offset), addr, size); - local_flush_icache_range(eentry + offset, eentry + offset + size); -} - -static const char panic_null_cerr[] = - "Trying to set NULL cache error exception handler\n"; - -/* - * Install uncached CPU exception handler. - * This is suitable only for the cache error exception which is the only - * exception handler that is being run uncached. - */ -void set_merr_handler(unsigned long offset, void *addr, unsigned long size) -{ - unsigned long uncached_eentry = TO_UNCACHE(__pa(eentry)); - - if (!addr) - panic(panic_null_cerr); - - memcpy((void *)(uncached_eentry + offset), addr, size); -} - -void __init trap_init(void) -{ - long i; - - /* Set interrupt vector handler */ - for (i = EXCCODE_INT_START; i < EXCCODE_INT_END; i++) - set_handler(i * VECSIZE, handle_vint, VECSIZE); - - set_handler(EXCCODE_ADE * VECSIZE, handle_ade, VECSIZE); - set_handler(EXCCODE_ALE * VECSIZE, handle_ale, VECSIZE); - set_handler(EXCCODE_SYS * VECSIZE, handle_sys, VECSIZE); - set_handler(EXCCODE_BP * VECSIZE, handle_bp, VECSIZE); - set_handler(EXCCODE_INE * VECSIZE, handle_ri, VECSIZE); - set_handler(EXCCODE_IPE * VECSIZE, handle_ri, VECSIZE); - set_handler(EXCCODE_FPDIS * VECSIZE, handle_fpu, VECSIZE); - set_handler(EXCCODE_LSXDIS * VECSIZE, handle_lsx, VECSIZE); - set_handler(EXCCODE_LASXDIS * VECSIZE, handle_lasx, VECSIZE); - set_handler(EXCCODE_FPE * VECSIZE, handle_fpe, VECSIZE); - set_handler(EXCCODE_BTDIS * VECSIZE, handle_lbt, VECSIZE); - set_handler(EXCCODE_WATCH * VECSIZE, handle_watch, VECSIZE); - - cache_error_setup(); - - local_flush_icache_range(eentry, eentry + 0x400); -} diff --git a/arch/loongarch/kernel/unwind_prologue.c b/arch/loongarch/kernel/unwind_prologue.c index 9095fde8e55d..de18335c6ba6 100644 --- a/arch/loongarch/kernel/unwind_prologue.c +++ b/arch/loongarch/kernel/unwind_prologue.c @@ -12,69 +12,9 @@ #include #include -extern const int unwind_hint_ade; -extern const int unwind_hint_ale; -extern const int unwind_hint_bp; -extern const int unwind_hint_fpe; -extern const int unwind_hint_fpu; -extern const int unwind_hint_lsx; -extern const int unwind_hint_lasx; -extern const int unwind_hint_lbt; -extern const int unwind_hint_ri; -extern const int unwind_hint_watch; -extern unsigned long eentry; -#ifdef CONFIG_NUMA -extern unsigned long pcpu_handlers[NR_CPUS]; -#endif - -static inline bool scan_handlers(unsigned long entry_offset) -{ - int idx, offset; - - if (entry_offset >= EXCCODE_INT_START * VECSIZE) - return false; - - idx = entry_offset / VECSIZE; - offset = entry_offset % VECSIZE; - switch (idx) { - case EXCCODE_ADE: - return offset == unwind_hint_ade; - case EXCCODE_ALE: - return offset == unwind_hint_ale; - case EXCCODE_BP: - return offset == unwind_hint_bp; - case EXCCODE_FPE: - return offset == unwind_hint_fpe; - case EXCCODE_FPDIS: - return offset == unwind_hint_fpu; - case EXCCODE_LSXDIS: - return offset == unwind_hint_lsx; - case EXCCODE_LASXDIS: - return offset == unwind_hint_lasx; - case EXCCODE_BTDIS: - return offset == unwind_hint_lbt; - case EXCCODE_INE: - return offset == unwind_hint_ri; - case EXCCODE_WATCH: - return offset == unwind_hint_watch; - default: - return false; - } -} - static inline bool fix_exception(unsigned long pc) { -#ifdef CONFIG_NUMA - int cpu; - - for_each_possible_cpu(cpu) { - if (!pcpu_handlers[cpu]) - continue; - if (scan_handlers(pc - pcpu_handlers[cpu])) - return true; - } -#endif - return scan_handlers(pc - eentry); + return false; } /* diff --git a/arch/loongarch/mm/cache.c b/arch/loongarch/mm/cache.c index 72685a48eaf0..d8e53702d61f 100644 --- a/arch/loongarch/mm/cache.c +++ b/arch/loongarch/mm/cache.c @@ -25,12 +25,6 @@ #include #include -void cache_error_setup(void) -{ - extern char __weak except_vec_cex; - set_merr_handler(0x0, &except_vec_cex, 0x80); -} - /* * LoongArch maintains ICache/DCache coherency by hardware, * we just need "ibar" to avoid instruction hazard here. diff --git a/arch/loongarch/mm/tlb.c b/arch/loongarch/mm/tlb.c index 8bad6b0cff59..dda35eae1c49 100644 --- a/arch/loongarch/mm/tlb.c +++ b/arch/loongarch/mm/tlb.c @@ -250,50 +250,10 @@ static void output_pgtable_bits_defines(void) pr_debug("\n"); } -#ifdef CONFIG_NUMA -unsigned long pcpu_handlers[NR_CPUS]; -#endif -extern long exception_handlers[VECSIZE * 128 / sizeof(long)]; - void setup_tlb_handler(int cpu) { setup_ptwalker(); local_flush_tlb_all(); - - /* The tlb handlers are generated only once */ - if (cpu == 0) { - memcpy((void *)tlbrentry, handle_tlb_refill, 0x80); - local_flush_icache_range(tlbrentry, tlbrentry + 0x80); - set_handler(EXCCODE_TLBI * VECSIZE, handle_tlb_load, VECSIZE); - set_handler(EXCCODE_TLBL * VECSIZE, handle_tlb_load, VECSIZE); - set_handler(EXCCODE_TLBS * VECSIZE, handle_tlb_store, VECSIZE); - set_handler(EXCCODE_TLBM * VECSIZE, handle_tlb_modify, VECSIZE); - set_handler(EXCCODE_TLBNR * VECSIZE, handle_tlb_protect, VECSIZE); - set_handler(EXCCODE_TLBNX * VECSIZE, handle_tlb_protect, VECSIZE); - set_handler(EXCCODE_TLBPE * VECSIZE, handle_tlb_protect, VECSIZE); - } -#ifdef CONFIG_NUMA - else { - void *addr; - struct page *page; - const int vec_sz = sizeof(exception_handlers); - - if (pcpu_handlers[cpu]) - return; - - page = alloc_pages_node(cpu_to_node(cpu), GFP_ATOMIC, get_order(vec_sz)); - if (!page) - return; - - addr = page_address(page); - pcpu_handlers[cpu] = (unsigned long)addr; - memcpy((void *)addr, (void *)eentry, vec_sz); - local_flush_icache_range((unsigned long)addr, (unsigned long)addr + vec_sz); - csr_write64(pcpu_handlers[cpu], LOONGARCH_CSR_EENTRY); - csr_write64(pcpu_handlers[cpu], LOONGARCH_CSR_MERRENTRY); - csr_write64(pcpu_handlers[cpu] + 80*VECSIZE, LOONGARCH_CSR_TLBRENTRY); - } -#endif } void tlb_init(int cpu) diff --git a/arch/loongarch/power/suspend.c b/arch/loongarch/power/suspend.c index 5e19733e5e05..b2a10a33b372 100644 --- a/arch/loongarch/power/suspend.c +++ b/arch/loongarch/power/suspend.c @@ -14,6 +14,7 @@ #include #include #include +#include u64 loongarch_suspend_addr; @@ -45,9 +46,7 @@ static void arch_common_resume(void) sync_counter(); local_flush_tlb_all(); csr_write64(per_cpu_offset(0), PERCPU_BASE_KS); - csr_write64(eentry, LOONGARCH_CSR_EENTRY); - csr_write64(eentry, LOONGARCH_CSR_MERRENTRY); - csr_write64(tlbrentry, LOONGARCH_CSR_TLBRENTRY); + configure_exception_vector(); csr_write64(saved_regs.pgd, LOONGARCH_CSR_PGDL); csr_write64(saved_regs.kpgd, LOONGARCH_CSR_PGDH); From patchwork Tue Feb 28 08:02:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinyang He X-Patchwork-Id: 62328 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2886081wrd; Tue, 28 Feb 2023 00:19:15 -0800 (PST) X-Google-Smtp-Source: AK7set8P+UIo7XCTitNAB9B23XgfFzMG9o07hHAdglsZqeT1L5whBWZUTh3cFe8eAu+apFqwUG/Q X-Received: by 2002:a05:6402:481:b0:4b0:616d:48a8 with SMTP id k1-20020a056402048100b004b0616d48a8mr2329370edv.16.1677572354953; Tue, 28 Feb 2023 00:19:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677572354; cv=none; d=google.com; s=arc-20160816; b=JH57CuDQLSSO55R2iL0cs9jhmA5D6JaI2NPLRWve7JfRqmNVKgqB0EOYHWIjZ6m9eQ Ng0cOV3kis8Rr6q+dMYrsnmAo26ZUOwJ+J5/0RDeaIez8F3kASr4DaXhc627gkSsaFY2 vEDxVsf/drY60jdRTZOieapluMqPIV6b37px7BZ+OqH87unlIIj2ZKR3Mbz7uw8Vj8p/ HUHJRDqQqpCOnwPm9bFnEvKxjcnXhr+yaQkyIQ8rB4AFaM50PyzC+jtLilE8eUxoFK7C BErWJwvop8O5EjhhKDNdJAEp9razhdrDdVVbNpd4uqgn1XrTc4UdAPmV6Gl6pTet/THL paCw== 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=5RiNQLyuCDCQ6GxJ6/vqExptLTwq1OkcTlujNMa2awM=; b=QXnOQfNmNQxKRCtju5HBH+MJjcu+ej7oBPebo2bddgmF5mSMvvZBoF0wQkOxQMzNyZ yDcwrrS2RJJGe73bo4wp6fIdYmuYGv8X+Hh+9jLNoBn4gxSXP5enw3+pFPDmvmKkhsCa Jmdw2pYaHe/4ZEF5MPFI39tLl49AuhVDP6edVnHTQJPgYv5Ehb+b0WUHJjzndZWnUQgy s4r++9d6610hjqNmV0djS2csTcTSb0aFOs3WFECeQ4XGHtsxHvMJQy5lBZpOr/8a4686 2CK4aEl25RkXCtMIHuvpf5znIfdBFJRkb1Nlh0GfUQ175ubE6EqDxmaoAiRiNB6vLCU5 hG0Q== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gv29-20020a1709072bdd00b008ddf3c18314si8711ejc.372.2023.02.28.00.18.52; Tue, 28 Feb 2023 00:19:14 -0800 (PST) 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 S230514AbjB1IEi (ORCPT + 99 others); Tue, 28 Feb 2023 03:04:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51046 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230443AbjB1IEL (ORCPT ); Tue, 28 Feb 2023 03:04:11 -0500 Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 96053FF0D for ; Tue, 28 Feb 2023 00:03:47 -0800 (PST) Received: from loongson.cn (unknown [111.9.175.10]) by gateway (Coremail) with SMTP id _____8CxQMxdtf1j_mUGAA--.6519S3; Tue, 28 Feb 2023 16:03:41 +0800 (CST) Received: from localhost.localdomain (unknown [111.9.175.10]) by localhost.localdomain (Coremail) with SMTP id AQAAf8BxB707tf1jb3tAAA--.49681S7; Tue, 28 Feb 2023 16:03:38 +0800 (CST) From: Jinyang He To: Huacai Chen , WANG Xuerui Cc: Xi Ruoyao , Youling Tang , loongarch@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH v2 5/6] LoongArch: Fix up the prologue unwinder unwind exception frame Date: Tue, 28 Feb 2023 16:02:56 +0800 Message-Id: <20230228080257.28807-6-hejinyang@loongson.cn> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20230228080257.28807-1-hejinyang@loongson.cn> References: <20230228080257.28807-1-hejinyang@loongson.cn> MIME-Version: 1.0 X-CM-TRANSID: AQAAf8BxB707tf1jb3tAAA--.49681S7 X-CM-SenderInfo: pkhmx0p1dqwqxorr0wxvrqhubq/ X-Coremail-Antispam: 1Uk129KBjvJXoW3GryDAr43AF48uFy5tw45trb_yoW7AF48pF nrAF1kGrWrWasaqryDtryDur98A3s3Gw1aga9rKa4rCF17XF15Wr1vvryDZFyjqaykXrW0 qFyfGFyY9F4Uta7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUj1kv1TuYvTs0mT0YCTnIWj qI5I8CrVACY4xI64kE6c02F40Ex7xfYxn0WfASr-VFAUDa7-sFnT9fnUUIcSsGvfJTRUUU b7kYFVCjjxCrM7AC8VAFwI0_Jr0_Gr1l1xkIjI8I6I8E6xAIw20EY4v20xvaj40_Wr0E3s 1l1IIY67AEw4v_Jrv_JF1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xv wVC0I7IYx2IY67AKxVW5JVW7JwA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxVW8JVWxJwA2z4 x0Y4vEx4A2jsIE14v26F4UJVW0owA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_Cr1j6rxdM2AI xVAIcxkEcVAq07x20xvEncxIr21l57IF6xkI12xvs2x26I8E6xACxx1l5I8CrVACY4xI64 kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r1q6rW5McIj6I8E87Iv67AKxVW8JVWxJwAm 72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41l42xK82IYc2Ij64vIr41l4I8I3I 0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWU GVWUWwC2zVAF1VAY17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI 0_Xr0_Ar1lIxAIcVC0I7IYx2IY6xkF7I0E14v26r4j6F4UMIIF0xvE42xK8VAvwI8IcIk0 rVWUJVWUCwCI42IY6I8E87Iv67AKxVW8JVWxJwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r 4UJbIYCTnIWIevJa73UjIFyTuYvjxUcCD7UUUUU X-Spam-Status: No, score=1.4 required=5.0 tests=BAYES_00,RCVD_IN_SBL_CSS, SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: * 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?1759062109527136615?= X-GMAIL-MSGID: =?utf-8?q?1759062109527136615?= It is a simply way to correct the unwind info when the special functions influence the normal prologue analysis. We find out the position where should unwind by PT_REGS, and mark it UNW_NEED_RESET. Linkers will collect them and the prologue unwinder will compare them to pc. Signed-off-by: Jinyang He --- arch/loongarch/include/asm/traps.h | 13 +++++++++ arch/loongarch/include/asm/unwind.h | 2 +- arch/loongarch/kernel/genex.S | 1 + arch/loongarch/kernel/mcount_dyn.S | 2 ++ arch/loongarch/kernel/unwind_prologue.c | 37 +++++++++---------------- arch/loongarch/kernel/vmlinux.lds.S | 9 ++++++ 6 files changed, 39 insertions(+), 25 deletions(-) diff --git a/arch/loongarch/include/asm/traps.h b/arch/loongarch/include/asm/traps.h index 8f276253f145..0c30a024a9e5 100644 --- a/arch/loongarch/include/asm/traps.h +++ b/arch/loongarch/include/asm/traps.h @@ -5,6 +5,7 @@ #ifndef _ASM_TRAPS_H #define _ASM_TRAPS_H +#include #include // For EXCCODES #ifdef __ASSEMBLY__ @@ -35,11 +36,23 @@ __VA_ARGS__; \ .popsection; +#ifdef CONFIG_UNWINDER_PROLOGUE +#define UNW_NEED_RESET \ + 668: \ + .pushsection .unw_need_reset, "a"; \ + PTR 668b; \ + .popsection; +#else /* CONFIG_UNWINDER_PROLOGUE */ +#define UNW_NEED_RESET +#endif + #else /* __ASSEMBLY__ */ #define VECSIZE 0x200 extern void *__ex_handlers; extern void *__tlbr_entry; +extern void *__unw_need_reset; +extern void *__unw_need_reset_end; static inline void set_eentry(void *entry) { diff --git a/arch/loongarch/include/asm/unwind.h b/arch/loongarch/include/asm/unwind.h index b9dce87afd2e..d9a10e264bdd 100644 --- a/arch/loongarch/include/asm/unwind.h +++ b/arch/loongarch/include/asm/unwind.h @@ -22,7 +22,7 @@ struct unwind_state { char type; /* UNWINDER_XXX */ struct stack_info stack_info; struct task_struct *task; - bool first, error, reset; + bool first, error, need_reset; int graph_idx; unsigned long sp, pc, ra; }; diff --git a/arch/loongarch/kernel/genex.S b/arch/loongarch/kernel/genex.S index 256e2e5b83d4..8705a7661ce9 100644 --- a/arch/loongarch/kernel/genex.S +++ b/arch/loongarch/kernel/genex.S @@ -78,6 +78,7 @@ SYM_FUNC_START(handle_\exception) move a0, sp la_abs t0, do_\handler jirl ra, t0, 0 + UNW_NEED_RESET RESTORE_ALL_AND_RET SYM_FUNC_END(handle_\exception) .endm diff --git a/arch/loongarch/kernel/mcount_dyn.S b/arch/loongarch/kernel/mcount_dyn.S index bbabf06244c2..3550bab52ff0 100644 --- a/arch/loongarch/kernel/mcount_dyn.S +++ b/arch/loongarch/kernel/mcount_dyn.S @@ -7,6 +7,7 @@ #include #include #include +#include .text /* @@ -81,6 +82,7 @@ SYM_CODE_START(ftrace_common) SYM_INNER_LABEL(ftrace_call, SYM_L_GLOBAL) bl ftrace_stub + UNW_NEED_RESET #ifdef CONFIG_FUNCTION_GRAPH_TRACER SYM_INNER_LABEL(ftrace_graph_call, SYM_L_GLOBAL) nop /* b ftrace_graph_caller */ diff --git a/arch/loongarch/kernel/unwind_prologue.c b/arch/loongarch/kernel/unwind_prologue.c index de18335c6ba6..aa01c881481c 100644 --- a/arch/loongarch/kernel/unwind_prologue.c +++ b/arch/loongarch/kernel/unwind_prologue.c @@ -10,33 +10,22 @@ #include #include #include +#include #include -static inline bool fix_exception(unsigned long pc) -{ - return false; -} - -/* - * As we meet ftrace_regs_entry, reset first flag like first doing - * tracing. Prologue analysis will stop soon because PC is at entry. - */ -static inline bool fix_ftrace(unsigned long pc) -{ -#ifdef CONFIG_DYNAMIC_FTRACE - return pc == (unsigned long)ftrace_call + LOONGARCH_INSN_SIZE; -#else - return false; -#endif -} - static inline bool unwind_state_fixup(struct unwind_state *state) { - if (!fix_exception(state->pc) && !fix_ftrace(state->pc)) - return false; + unsigned long *p = (unsigned long *)&__unw_need_reset; + unsigned long *q = (unsigned long *)&__unw_need_reset_end; - state->reset = true; - return true; + for (; p < q; p++) { + if (*p != state->pc) + continue; + state->need_reset = true; + return true; + } + + return false; } /* @@ -59,10 +48,10 @@ static bool unwind_by_prologue(struct unwind_state *state) if (state->sp >= info->end || state->sp < info->begin) return false; - if (state->reset) { + if (state->need_reset) { regs = (struct pt_regs *)state->sp; state->first = true; - state->reset = false; + state->need_reset = false; state->pc = regs->csr_era; state->ra = regs->regs[1]; state->sp = regs->regs[3]; diff --git a/arch/loongarch/kernel/vmlinux.lds.S b/arch/loongarch/kernel/vmlinux.lds.S index e99b50359900..00f1f9061961 100644 --- a/arch/loongarch/kernel/vmlinux.lds.S +++ b/arch/loongarch/kernel/vmlinux.lds.S @@ -70,6 +70,15 @@ SECTIONS *(.tlbrhandler) } +#ifdef CONFIG_UNWINDER_PROLOGUE + . = ALIGN(8); + .unw_need_reset : { + __unw_need_reset = .; + *(.unw_need_reset) + __unw_need_reset_end = .; + } +#endif + /* * struct alt_inst entries. From the header (alternative.h): * "Alternative instructions for different CPU types or capabilities" From patchwork Tue Feb 28 08:02:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinyang He X-Patchwork-Id: 62326 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2881252wrd; Tue, 28 Feb 2023 00:06:28 -0800 (PST) X-Google-Smtp-Source: AK7set8GaEsx9ZQ+V+Nn3d1MyJxKSa6WzbobolnZDwKPKSEbUZJtFiTHkXXLhlFgv7On/lsrGscI X-Received: by 2002:a62:3204:0:b0:5dc:ecea:f650 with SMTP id y4-20020a623204000000b005dceceaf650mr1666846pfy.19.1677571588236; Tue, 28 Feb 2023 00:06:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677571588; cv=none; d=google.com; s=arc-20160816; b=y8WSGxtO+nzko1zquZIe2bPKvwFbmblORTpAGp+m8b46y1+OoRbbLdSK5HMqAZFBQm URz1SqxJAccpaW5oFwCQoBVNXAJXEJ6cFxXMICm32jc0r+6/SY24uj2wM0WFpGGIdWbR VTQwmKDKNyxLIa1oT4y8Qx/SC67N+iwqGWbjufhJR5mmXlyy4MGiKbqgEsq0rURejloQ oudH3wU22C4dCrH2I+Wnx70wGlV6Ejy5Mt6RJdX2mXkWGqrvxzSLXrxFToyNsXoApk21 JrmaxRO1dKsVxO0WALe+fdzSIbabo0gCVYtOxkPgjxfhZHmzu1PoxERGjDGlLalY/esd jU8g== 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=isns35H4wTnK/VFJu6gkq6qW+9NI2n5qcG9ZkaIWJiQ=; b=aFsUPrQwJl5BOXUnNo0GZHYJyEfQwOyLpDvu7h0mSkfm9u86/EAXtIKZVshbN9pmaR juYEpcuAlaGu2cdJfuP4oggPh864t9GFILH1WalX8fO8+yp6pGAJpkOjSUu8ZI2aOUG2 09tu/MHtCBGCmLswlxwq6QIHCdwKhGd2CCAlCQIuxP1rrItrBOnM7rHVdRznLWTY+/cX wkXTlS2pBhJOoLM356glIPX1NNzZ6etkXxm0uurhbjl2F3OD+Eg5H4h9LzgdI6pnq9qC 6k1aO7BMrATPgRnLElkJi9K/yO/lqvRb7un3JU5OrPsPTcRkAz1GVRvDMufqDpmi9tj0 XTow== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s140-20020a632c92000000b004ee45f5eaf0si10035872pgs.622.2023.02.28.00.06.13; Tue, 28 Feb 2023 00:06:28 -0800 (PST) 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 S231126AbjB1IEk (ORCPT + 99 others); Tue, 28 Feb 2023 03:04:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230258AbjB1IEN (ORCPT ); Tue, 28 Feb 2023 03:04:13 -0500 Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5B00D21948 for ; Tue, 28 Feb 2023 00:03:49 -0800 (PST) Received: from loongson.cn (unknown [111.9.175.10]) by gateway (Coremail) with SMTP id _____8DxE4Ritf1jGWYGAA--.6445S3; Tue, 28 Feb 2023 16:03:46 +0800 (CST) Received: from localhost.localdomain (unknown [111.9.175.10]) by localhost.localdomain (Coremail) with SMTP id AQAAf8BxB707tf1jb3tAAA--.49681S8; Tue, 28 Feb 2023 16:03:42 +0800 (CST) From: Jinyang He To: Huacai Chen , WANG Xuerui Cc: Xi Ruoyao , Youling Tang , loongarch@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH v2 6/6] LoongArch: Clean up la_abs macro Date: Tue, 28 Feb 2023 16:02:57 +0800 Message-Id: <20230228080257.28807-7-hejinyang@loongson.cn> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20230228080257.28807-1-hejinyang@loongson.cn> References: <20230228080257.28807-1-hejinyang@loongson.cn> MIME-Version: 1.0 X-CM-TRANSID: AQAAf8BxB707tf1jb3tAAA--.49681S8 X-CM-SenderInfo: pkhmx0p1dqwqxorr0wxvrqhubq/ X-Coremail-Antispam: 1Uk129KBjvJXoWxKryDGFWUXr1xtw13tF4rGrg_yoW3JF1kpr nxZrn7Ja1rWrn3Za4Dta4DurZ8AwnFg342ganIkFyru3W7ZF18XrykA3s7ZF97Kay8XF4I gF1ftws2qF4UJwUanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUj1kv1TuYvTs0mT0YCTnIWj qI5I8CrVACY4xI64kE6c02F40Ex7xfYxn0WfASr-VFAUDa7-sFnT9fnUUIcSsGvfJTRUUU b7kYFVCjjxCrM7AC8VAFwI0_Jr0_Gr1l1xkIjI8I6I8E6xAIw20EY4v20xvaj40_Wr0E3s 1l1IIY67AEw4v_Jrv_JF1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xv wVC0I7IYx2IY67AKxVW7JVWDJwA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxVW8JVWxJwA2z4 x0Y4vEx4A2jsIE14v26F4UJVW0owA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_Cr1j6rxdM2AI xVAIcxkEcVAq07x20xvEncxIr21l57IF6xkI12xvs2x26I8E6xACxx1l5I8CrVACY4xI64 kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r1q6rW5McIj6I8E87Iv67AKxVW8JVWxJwAm 72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41l42xK82IYc2Ij64vIr41l4I8I3I 0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWU GVWUWwC2zVAF1VAY17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI 0_Xr0_Ar1lIxAIcVC0I7IYx2IY6xkF7I0E14v26r4j6F4UMIIF0xvE42xK8VAvwI8IcIk0 rVWUJVWUCwCI42IY6I8E87Iv67AKxVW8JVWxJwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r 4UJbIYCTnIWIevJa73UjIFyTuYvjxUcCD7UUUUU X-Spam-Status: No, score=1.4 required=5.0 tests=BAYES_00,RCVD_IN_SBL_CSS, SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: * 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?1759061305692943304?= X-GMAIL-MSGID: =?utf-8?q?1759061305692943304?= Now we can replace la_abs with la.pcrel. Clean up the la_abs macro. Signed-off-by: Jinyang He --- arch/loongarch/include/asm/asmmacro.h | 17 --------------- arch/loongarch/include/asm/setup.h | 7 ------- arch/loongarch/include/asm/stackframe.h | 2 +- arch/loongarch/kernel/entry.S | 5 ++--- arch/loongarch/kernel/genex.S | 8 +++---- arch/loongarch/kernel/relocate.c | 28 ------------------------- arch/loongarch/kernel/vmlinux.lds.S | 9 -------- arch/loongarch/mm/tlbex.S | 18 +++++++--------- 8 files changed, 13 insertions(+), 81 deletions(-) diff --git a/arch/loongarch/include/asm/asmmacro.h b/arch/loongarch/include/asm/asmmacro.h index 79e1d53fea89..328bb956f241 100644 --- a/arch/loongarch/include/asm/asmmacro.h +++ b/arch/loongarch/include/asm/asmmacro.h @@ -667,21 +667,4 @@ nor \dst, \src, zero .endm -.macro la_abs reg, sym -#ifndef CONFIG_RELOCATABLE - la.abs \reg, \sym -#else - 766: - lu12i.w \reg, 0 - ori \reg, \reg, 0 - lu32i.d \reg, 0 - lu52i.d \reg, \reg, 0 - .pushsection ".la_abs", "aw", %progbits - 768: - .dword 768b-766b - .dword \sym - .popsection -#endif -.endm - #endif /* _ASM_ASMMACRO_H */ diff --git a/arch/loongarch/include/asm/setup.h b/arch/loongarch/include/asm/setup.h index 4074225339ec..84d131f29e0c 100644 --- a/arch/loongarch/include/asm/setup.h +++ b/arch/loongarch/include/asm/setup.h @@ -16,13 +16,6 @@ extern void per_cpu_trap_init(int cpu); #ifdef CONFIG_RELOCATABLE -struct rela_la_abs { - long offset; - long symvalue; -}; - -extern long __la_abs_begin; -extern long __la_abs_end; extern long __rela_dyn_begin; extern long __rela_dyn_end; diff --git a/arch/loongarch/include/asm/stackframe.h b/arch/loongarch/include/asm/stackframe.h index bb5e0e2bd3a9..fff4a0ce7750 100644 --- a/arch/loongarch/include/asm/stackframe.h +++ b/arch/loongarch/include/asm/stackframe.h @@ -86,7 +86,7 @@ * new value in sp. */ .macro get_saved_sp docfi=0 - la_abs t1, kernelsp + la.pcrel t1, kernelsp #ifdef CONFIG_SMP csrrd t0, PERCPU_BASE_KS LONG_ADD t1, t1, t0 diff --git a/arch/loongarch/kernel/entry.S b/arch/loongarch/kernel/entry.S index ca4651f91e73..87b620a0aa13 100644 --- a/arch/loongarch/kernel/entry.S +++ b/arch/loongarch/kernel/entry.S @@ -22,7 +22,7 @@ .align 5 SYM_FUNC_START(handle_sys) csrrd t0, PERCPU_BASE_KS - la_abs t1, kernelsp + la.pcrel t1, kernelsp add.d t1, t1, t0 move t2, sp ld.d sp, t1, 0 @@ -65,8 +65,7 @@ SYM_FUNC_START(handle_sys) and tp, tp, sp move a0, sp - la_abs ra, do_syscall - jirl ra, ra, 0 + bl do_syscall RESTORE_ALL_AND_RET SYM_FUNC_END(handle_sys) diff --git a/arch/loongarch/kernel/genex.S b/arch/loongarch/kernel/genex.S index 8705a7661ce9..061727164ec2 100644 --- a/arch/loongarch/kernel/genex.S +++ b/arch/loongarch/kernel/genex.S @@ -36,7 +36,7 @@ SYM_FUNC_END(__arch_cpu_idle) SYM_FUNC_START(handle_vint\idx) BACKUP_T0T1 SAVE_ALL - la_abs t1, __arch_cpu_idle + la.pcrel t1, __arch_cpu_idle LONG_L t0, sp, PT_ERA /* 32 byte rollback region */ ori t0, t0, 0x1f @@ -45,8 +45,7 @@ SYM_FUNC_START(handle_vint\idx) LONG_S t0, sp, PT_ERA 1: move a0, sp move a1, sp - la_abs t0, do_vint - jirl ra, t0, 0 + bl do_vint RESTORE_ALL_AND_RET SYM_FUNC_END(handle_vint\idx) .endm @@ -76,8 +75,7 @@ SYM_FUNC_START(handle_\exception) SAVE_ALL build_prep_\prep move a0, sp - la_abs t0, do_\handler - jirl ra, t0, 0 + bl do_\handler UNW_NEED_RESET RESTORE_ALL_AND_RET SYM_FUNC_END(handle_\exception) diff --git a/arch/loongarch/kernel/relocate.c b/arch/loongarch/kernel/relocate.c index 070b9fb87ebc..5ecfd7791268 100644 --- a/arch/loongarch/kernel/relocate.c +++ b/arch/loongarch/kernel/relocate.c @@ -12,7 +12,6 @@ #include #include #include -#include #include #include @@ -41,31 +40,6 @@ static inline __init void relocate_relative(void) } } -static inline void __init relocate_la_abs(long random_offset) -{ - void *begin, *end; - struct rela_la_abs *p; - - begin = RELOCATED_KASLR(&__la_abs_begin); - end = RELOCATED_KASLR(&__la_abs_end); - - for (p = begin; (void *)p < end; p++) { - long v = p->symvalue; - uint32_t lu12iw, ori, lu32id, lu52id; - union loongarch_instruction *insn = (void *)p - p->offset; - - lu12iw = (v >> 12) & 0xfffff; - ori = v & 0xfff; - lu32id = (v >> 32) & 0xfffff; - lu52id = v >> 52; - - insn[0].reg1i20_format.immediate = lu12iw; - insn[1].reg2i12_format.immediate = ori; - insn[2].reg1i20_format.immediate = lu32id; - insn[3].reg2i12_format.immediate = lu52id; - } -} - #ifdef CONFIG_RANDOMIZE_BASE static inline __init unsigned long rotate_xor(unsigned long hash, const void *area, size_t size) @@ -202,8 +176,6 @@ void * __init relocate_kernel(void) if (reloc_offset) relocate_relative(); - relocate_la_abs(random_offset); - return kernel_entry; } diff --git a/arch/loongarch/kernel/vmlinux.lds.S b/arch/loongarch/kernel/vmlinux.lds.S index 00f1f9061961..8ae5f245eb2f 100644 --- a/arch/loongarch/kernel/vmlinux.lds.S +++ b/arch/loongarch/kernel/vmlinux.lds.S @@ -91,15 +91,6 @@ SECTIONS __alt_instructions_end = .; } -#ifdef CONFIG_RELOCATABLE - . = ALIGN(8); - .la_abs : AT(ADDR(.la_abs) - LOAD_OFFSET) { - __la_abs_begin = .; - *(.la_abs) - __la_abs_end = .; - } -#endif - .got : ALIGN(16) { *(.got) } .plt : ALIGN(16) { *(.plt) } .got.plt : ALIGN(16) { *(.got.plt) } diff --git a/arch/loongarch/mm/tlbex.S b/arch/loongarch/mm/tlbex.S index 53321d3447a2..3ee16fc61788 100644 --- a/arch/loongarch/mm/tlbex.S +++ b/arch/loongarch/mm/tlbex.S @@ -41,8 +41,7 @@ SYM_FUNC_START(handle_tlb_protect\idx) move a1, zero csrrd a2, LOONGARCH_CSR_BADV REG_S a2, sp, PT_BVADDR - la_abs t0, do_page_fault - jirl ra, t0, 0 + bl do_page_fault RESTORE_ALL_AND_RET SYM_FUNC_END(handle_tlb_protect\idx) .endm @@ -119,7 +118,7 @@ SYM_FUNC_START(handle_tlb_load\idx) #ifdef CONFIG_64BIT 3: /* vmalloc_load: */ - la_abs t1, swapper_pg_dir + la.pcrel t1, swapper_pg_dir b 1b #endif @@ -190,8 +189,7 @@ SYM_FUNC_START(handle_tlb_load\idx) 5: /* nopage_tlb_load: */ dbar 0 csrrd ra, EXCEPTION_KS2 - la_abs t0, tlb_do_page_fault_0 - jr t0 + b tlb_do_page_fault_0 SYM_FUNC_END(handle_tlb_load\idx) .endm @@ -268,7 +266,7 @@ smp_pgtable_change_store: #ifdef CONFIG_64BIT vmalloc_store: - la_abs t1, swapper_pg_dir + la.pcrel t1, swapper_pg_dir b vmalloc_done_store #endif @@ -341,8 +339,7 @@ tlb_huge_update_store: nopage_tlb_store: dbar 0 csrrd ra, EXCEPTION_KS2 - la_abs t0, tlb_do_page_fault_1 - jr t0 + b tlb_do_page_fault_1 SYM_FUNC_END(handle_tlb_store) .endm @@ -418,7 +415,7 @@ smp_pgtable_change_modify: #ifdef CONFIG_64BIT vmalloc_modify: - la_abs t1, swapper_pg_dir + la.pcrel t1, swapper_pg_dir b vmalloc_done_modify #endif @@ -490,8 +487,7 @@ tlb_huge_update_modify: nopage_tlb_modify: dbar 0 csrrd ra, EXCEPTION_KS2 - la_abs t0, tlb_do_page_fault_1 - jr t0 + b tlb_do_page_fault_1 SYM_FUNC_END(handle_tlb_modify) .endm