Message ID | 1673255274-18238-3-git-send-email-tangyouling@loongson.cn |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2052484wrt; Mon, 9 Jan 2023 01:13:13 -0800 (PST) X-Google-Smtp-Source: AMrXdXun9NH725JA0PuNiDxTzuLpb4OgD9v6NcwrAhd4WLMgMGtHGVnPjdqSFfk/FPPfC6Bt9BRE X-Received: by 2002:a05:6a21:2d09:b0:a4:aa40:2253 with SMTP id tw9-20020a056a212d0900b000a4aa402253mr76483383pzb.21.1673255592967; Mon, 09 Jan 2023 01:13:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673255592; cv=none; d=google.com; s=arc-20160816; b=i8KhpADqMa2VFC9XcYOYYOPP1gag/qUJorNwn+D+HlviNr0uGsCoHaYAk/m6FYd4z6 RkluqCgUo/3gBcb8xSaMKBsvCaHZ/6h5BPeKkhGOFhl9TOAUcjkcuiI3uCFeLGkyBWjQ OzWPvc9zVvwokE4j6iCY5d3rDUcpV+JOv8Y1liaL/jtJJXCIMQp0os/VJ/IE1dJZlGW4 yn21tynKx/dy5N8YehXsSHh35ovP8bXAyz96JX4q676GWM8oJb1ao4vNIgYvcYxF3n8V Mos2DHEATka/ILMP4S/RTJ/BGmEVbRLZ67nVA300fY8EnpsXiIykoa8uHZu/xfzdzJ04 dqZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=cAHZ+Eokh1kaKk6pWU/wRMc2SbmYKqGAuEBuAaJul58=; b=ytjV/E1qwTcOAuGXA1fMQFr43K+3jk0NUepVprYoEMYD8kVL8PEUiHgAy3U4yN90Mp 8RgBxVqg00qH9and4My05uMZskIN66rFbP7dnpzmRin24l5N0ZvGRke3vsSvSpuTFON5 ulWkWF3SNuIqM2uupjoHTMSLZCtq78xB+ahTQ0nUOaJmEodw7dBRwz25badmNrvdklcU naOUMwCJZ2lt8z2jM8GU01xBm0+H31AUzoHCiZNpHFePn8crpDgwjacZo8SYUCIaHOrI qsTUzFoUkEV2J+CIyETSTtpKQiomSfgtOvVHb9NvTP1cWO64bL+Q7tGMKH2amDSFR+Nw Xkzg== 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 d12-20020a63360c000000b0049ca23dd6d9si9641596pga.134.2023.01.09.01.13.00; Mon, 09 Jan 2023 01:13:12 -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 S236390AbjAIJMa (ORCPT <rfc822;zhanglyra.2023@gmail.com> + 99 others); Mon, 9 Jan 2023 04:12:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236994AbjAIJLu (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 9 Jan 2023 04:11:50 -0500 Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7391A17E22 for <linux-kernel@vger.kernel.org>; Mon, 9 Jan 2023 01:08:14 -0800 (PST) Received: from loongson.cn (unknown [113.200.148.30]) by gateway (Coremail) with SMTP id _____8Dxi+p92btjhnUAAA--.1356S3; Mon, 09 Jan 2023 17:08:13 +0800 (CST) Received: from bogon.localdomain (unknown [113.200.148.30]) by localhost.localdomain (Coremail) with SMTP id AQAAf8DxTuRw2btj_6sWAA--.4042S4; Mon, 09 Jan 2023 17:08:12 +0800 (CST) From: Youling Tang <tangyouling@loongson.cn> To: Huacai Chen <chenhuacai@kernel.org>, Xi Ruoyao <xry111@xry111.site>, Jinyang He <hejinyang@loongson.cn> Cc: Xuerui Wang <kernel@xen0n.name>, loongarch@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH 2/4] LoongArch: Add JUMP_LINK_ADDR macro implementation to avoid using la.abs Date: Mon, 9 Jan 2023 17:07:52 +0800 Message-Id: <1673255274-18238-3-git-send-email-tangyouling@loongson.cn> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1673255274-18238-1-git-send-email-tangyouling@loongson.cn> References: <1673255274-18238-1-git-send-email-tangyouling@loongson.cn> X-CM-TRANSID: AQAAf8DxTuRw2btj_6sWAA--.4042S4 X-CM-SenderInfo: 5wdqw5prxox03j6o00pqjv00gofq/ X-Coremail-Antispam: 1Uk129KBjvJXoW7WF4kuw4rtr1rXw4xXr1DKFg_yoW8ur1fpr 90vr4kGFW8WFn3AFyUta4UurW5J3WkCa1aganrta4IkF43XFy8Xw1vkr1DXF1Utw4rJr40 93WfGw4agF1UJ3JanT9S1TB71UUUUUDqnTZGkaVYY2UrUUUUj1kv1TuYvTs0mT0YCTnIWj qI5I8CrVACY4xI64kE6c02F40Ex7xfYxn0WfASr-VFAUDa7-sFnT9fnUUIcSsGvfJTRUUU b28YFVCjjxCrM7AC8VAFwI0_Jr0_Gr1l1xkIjI8I6I8E6xAIw20EY4v20xvaj40_Wr0E3s 1l1IIY67AEw4v_JF0_JFyl8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xv wVC0I7IYx2IY67AKxVW8JVW5JwA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxVW8JVWxJwA2z4 x0Y4vEx4A2jsIE14v26r4UJVWxJr1l84ACjcxK6I8E87Iv6xkF7I0E14v26r4UJVWxJr1l e2I262IYc4CY6c8Ij28IcVAaY2xG8wAqjxCEc2xF0cIa020Ex4CE44I27wAqx4xG64xvF2 IEw4CE5I8CrVC2j2WlYx0E2Ix0cI8IcVAFwI0_Jw0_WrylYx0Ex4A2jsIE14v26r4j6F4U McvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvY0x0EwIxGrwCF04k20xvY0x0EwIxGrwCFx2 IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v2 6r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67 AKxVW8JVW5JwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF04k26cxKx2IY s7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r4j6F4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr 0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x07j5l1kUUUUU= X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754535656244685882?= X-GMAIL-MSGID: =?utf-8?q?1754535656244685882?= |
Series |
LoongArch: Add kernel relocation and KASLR support
|
|
Commit Message
Youling Tang
Jan. 9, 2023, 9:07 a.m. UTC
Add JUMP_LINK_ADDR macro implementation to avoid using la.abs.
Signed-off-by: Youling Tang <tangyouling@loongson.cn>
---
arch/loongarch/include/asm/stackframe.h | 8 ++++++++
arch/loongarch/kernel/head.S | 10 ++++------
arch/loongarch/power/suspend_asm.S | 5 ++---
3 files changed, 14 insertions(+), 9 deletions(-)
Comments
On 2023-01-09 17:07, Youling Tang wrote: > Add JUMP_LINK_ADDR macro implementation to avoid using la.abs. > > Signed-off-by: Youling Tang <tangyouling@loongson.cn> > --- > arch/loongarch/include/asm/stackframe.h | 8 ++++++++ > arch/loongarch/kernel/head.S | 10 ++++------ > arch/loongarch/power/suspend_asm.S | 5 ++--- > 3 files changed, 14 insertions(+), 9 deletions(-) > > diff --git a/arch/loongarch/include/asm/stackframe.h b/arch/loongarch/include/asm/stackframe.h > index 96c94035b5d0..f538b3a6d680 100644 > --- a/arch/loongarch/include/asm/stackframe.h > +++ b/arch/loongarch/include/asm/stackframe.h > @@ -216,4 +216,12 @@ > RESTORE_SP_AND_RET \docfi > .endm > > +/* Jump to the virtual address of the link. */ > + .macro JUMP_LINK_ADDR Hi, Youling IMHO the JUMP_CACHE_ADDR is more suitable. And it not clear higt bits, although the result always true currently. Lastly, this macro clobbers t0 and t1, I'd suggest pass them in as args. Thanks, Jinyang > + li.d t0, CACHE_BASE > + pcaddi t1, 0 > + or t0, t0, t1 > + jirl zero, t0, 0xc > + .endm > + > #endif /* _ASM_STACKFRAME_H */ > diff --git a/arch/loongarch/kernel/head.S b/arch/loongarch/kernel/head.S > index aa6181714ec3..e8a4bf9d7599 100644 > --- a/arch/loongarch/kernel/head.S > +++ b/arch/loongarch/kernel/head.S > @@ -52,9 +52,8 @@ SYM_CODE_START(kernel_entry) # kernel entry point > > /* We might not get launched at the address the kernel is linked to, > so we jump there. */ > - la.abs t0, 0f > - jr t0 > -0: > + JUMP_LINK_ADDR > + > /* Enable PG */ > li.w t0, 0xb0 # PLV=0, IE=0, PG=1 > csrwr t0, LOONGARCH_CSR_CRMD > @@ -106,9 +105,8 @@ SYM_CODE_START(smpboot_entry) > li.d t0, CSR_DMW1_INIT # CA, PLV0 > csrwr t0, LOONGARCH_CSR_DMWIN1 > > - la.abs t0, 0f > - jr t0 > -0: > + JUMP_LINK_ADDR > + > /* Enable PG */ > li.w t0, 0xb0 # PLV=0, IE=0, PG=1 > csrwr t0, LOONGARCH_CSR_CRMD > diff --git a/arch/loongarch/power/suspend_asm.S b/arch/loongarch/power/suspend_asm.S > index eb2675642f9f..596a682a7924 100644 > --- a/arch/loongarch/power/suspend_asm.S > +++ b/arch/loongarch/power/suspend_asm.S > @@ -78,9 +78,8 @@ SYM_INNER_LABEL(loongarch_wakeup_start, SYM_L_GLOBAL) > li.d t0, CSR_DMW1_INIT # CA, PLV0 > csrwr t0, LOONGARCH_CSR_DMWIN1 > > - la.abs t0, 0f > - jr t0 > -0: > + JUMP_LINK_ADDR > + > la.pcrel t0, acpi_saved_sp > ld.d sp, t0, 0 > SETUP_WAKEUP
Hi, Jinyang On 01/14/2023 02:40 PM, Jinyang He wrote: > > On 2023-01-09 17:07, Youling Tang wrote: >> Add JUMP_LINK_ADDR macro implementation to avoid using la.abs. >> >> Signed-off-by: Youling Tang <tangyouling@loongson.cn> >> --- >> arch/loongarch/include/asm/stackframe.h | 8 ++++++++ >> arch/loongarch/kernel/head.S | 10 ++++------ >> arch/loongarch/power/suspend_asm.S | 5 ++--- >> 3 files changed, 14 insertions(+), 9 deletions(-) >> >> diff --git a/arch/loongarch/include/asm/stackframe.h >> b/arch/loongarch/include/asm/stackframe.h >> index 96c94035b5d0..f538b3a6d680 100644 >> --- a/arch/loongarch/include/asm/stackframe.h >> +++ b/arch/loongarch/include/asm/stackframe.h >> @@ -216,4 +216,12 @@ >> RESTORE_SP_AND_RET \docfi >> .endm >> +/* Jump to the virtual address of the link. */ >> + .macro JUMP_LINK_ADDR > > Hi, Youling > > > IMHO the JUMP_CACHE_ADDR is more suitable. And it not clear higt bits, > although the result always true currently. Lastly, this macro clobbers > t0 and t1, I'd suggest pass them in as args. Ok, I will modify it as follows: .macro JUMP_CACHE_ADDR temp1 temp2 li.d \temp1, CACHE_BASE pcaddi \temp2, 0 or \temp1, \temp1, \temp2 jirl zero, \temp1, 0xc .endm There is also an alternative name "JUMP_DMW1_ADDR" for discussion. Thanks, Youling > > > Thanks, > > Jinyang > >> + li.d t0, CACHE_BASE >> + pcaddi t1, 0 >> + or t0, t0, t1 >> + jirl zero, t0, 0xc >> + .endm >> + >> #endif /* _ASM_STACKFRAME_H */ >> diff --git a/arch/loongarch/kernel/head.S b/arch/loongarch/kernel/head.S >> index aa6181714ec3..e8a4bf9d7599 100644 >> --- a/arch/loongarch/kernel/head.S >> +++ b/arch/loongarch/kernel/head.S >> @@ -52,9 +52,8 @@ SYM_CODE_START(kernel_entry) # kernel >> entry point >> /* We might not get launched at the address the kernel is >> linked to, >> so we jump there. */ >> - la.abs t0, 0f >> - jr t0 >> -0: >> + JUMP_LINK_ADDR >> + >> /* Enable PG */ >> li.w t0, 0xb0 # PLV=0, IE=0, PG=1 >> csrwr t0, LOONGARCH_CSR_CRMD >> @@ -106,9 +105,8 @@ SYM_CODE_START(smpboot_entry) >> li.d t0, CSR_DMW1_INIT # CA, PLV0 >> csrwr t0, LOONGARCH_CSR_DMWIN1 >> - la.abs t0, 0f >> - jr t0 >> -0: >> + JUMP_LINK_ADDR >> + >> /* Enable PG */ >> li.w t0, 0xb0 # PLV=0, IE=0, PG=1 >> csrwr t0, LOONGARCH_CSR_CRMD >> diff --git a/arch/loongarch/power/suspend_asm.S >> b/arch/loongarch/power/suspend_asm.S >> index eb2675642f9f..596a682a7924 100644 >> --- a/arch/loongarch/power/suspend_asm.S >> +++ b/arch/loongarch/power/suspend_asm.S >> @@ -78,9 +78,8 @@ SYM_INNER_LABEL(loongarch_wakeup_start, SYM_L_GLOBAL) >> li.d t0, CSR_DMW1_INIT # CA, PLV0 >> csrwr t0, LOONGARCH_CSR_DMWIN1 >> - la.abs t0, 0f >> - jr t0 >> -0: >> + JUMP_LINK_ADDR >> + >> la.pcrel t0, acpi_saved_sp >> ld.d sp, t0, 0 >> SETUP_WAKEUP >
But JUMP_LINK_ADDR looks fine to me. :) Huacai On Sat, Jan 14, 2023 at 3:25 PM Youling Tang <tangyouling@loongson.cn> wrote: > > Hi, Jinyang > > On 01/14/2023 02:40 PM, Jinyang He wrote: > > > > On 2023-01-09 17:07, Youling Tang wrote: > >> Add JUMP_LINK_ADDR macro implementation to avoid using la.abs. > >> > >> Signed-off-by: Youling Tang <tangyouling@loongson.cn> > >> --- > >> arch/loongarch/include/asm/stackframe.h | 8 ++++++++ > >> arch/loongarch/kernel/head.S | 10 ++++------ > >> arch/loongarch/power/suspend_asm.S | 5 ++--- > >> 3 files changed, 14 insertions(+), 9 deletions(-) > >> > >> diff --git a/arch/loongarch/include/asm/stackframe.h > >> b/arch/loongarch/include/asm/stackframe.h > >> index 96c94035b5d0..f538b3a6d680 100644 > >> --- a/arch/loongarch/include/asm/stackframe.h > >> +++ b/arch/loongarch/include/asm/stackframe.h > >> @@ -216,4 +216,12 @@ > >> RESTORE_SP_AND_RET \docfi > >> .endm > >> +/* Jump to the virtual address of the link. */ > >> + .macro JUMP_LINK_ADDR > > > > Hi, Youling > > > > > > IMHO the JUMP_CACHE_ADDR is more suitable. And it not clear higt bits, > > although the result always true currently. Lastly, this macro clobbers > > t0 and t1, I'd suggest pass them in as args. > > Ok, I will modify it as follows: > > .macro JUMP_CACHE_ADDR temp1 temp2 > li.d \temp1, CACHE_BASE > pcaddi \temp2, 0 > or \temp1, \temp1, \temp2 > jirl zero, \temp1, 0xc > .endm > > There is also an alternative name "JUMP_DMW1_ADDR" for discussion. > > Thanks, > Youling > > > > > > > Thanks, > > > > Jinyang > > > >> + li.d t0, CACHE_BASE > >> + pcaddi t1, 0 > >> + or t0, t0, t1 > >> + jirl zero, t0, 0xc > >> + .endm > >> + > >> #endif /* _ASM_STACKFRAME_H */ > >> diff --git a/arch/loongarch/kernel/head.S b/arch/loongarch/kernel/head.S > >> index aa6181714ec3..e8a4bf9d7599 100644 > >> --- a/arch/loongarch/kernel/head.S > >> +++ b/arch/loongarch/kernel/head.S > >> @@ -52,9 +52,8 @@ SYM_CODE_START(kernel_entry) # kernel > >> entry point > >> /* We might not get launched at the address the kernel is > >> linked to, > >> so we jump there. */ > >> - la.abs t0, 0f > >> - jr t0 > >> -0: > >> + JUMP_LINK_ADDR > >> + > >> /* Enable PG */ > >> li.w t0, 0xb0 # PLV=0, IE=0, PG=1 > >> csrwr t0, LOONGARCH_CSR_CRMD > >> @@ -106,9 +105,8 @@ SYM_CODE_START(smpboot_entry) > >> li.d t0, CSR_DMW1_INIT # CA, PLV0 > >> csrwr t0, LOONGARCH_CSR_DMWIN1 > >> - la.abs t0, 0f > >> - jr t0 > >> -0: > >> + JUMP_LINK_ADDR > >> + > >> /* Enable PG */ > >> li.w t0, 0xb0 # PLV=0, IE=0, PG=1 > >> csrwr t0, LOONGARCH_CSR_CRMD > >> diff --git a/arch/loongarch/power/suspend_asm.S > >> b/arch/loongarch/power/suspend_asm.S > >> index eb2675642f9f..596a682a7924 100644 > >> --- a/arch/loongarch/power/suspend_asm.S > >> +++ b/arch/loongarch/power/suspend_asm.S > >> @@ -78,9 +78,8 @@ SYM_INNER_LABEL(loongarch_wakeup_start, SYM_L_GLOBAL) > >> li.d t0, CSR_DMW1_INIT # CA, PLV0 > >> csrwr t0, LOONGARCH_CSR_DMWIN1 > >> - la.abs t0, 0f > >> - jr t0 > >> -0: > >> + JUMP_LINK_ADDR > >> + > >> la.pcrel t0, acpi_saved_sp > >> ld.d sp, t0, 0 > >> SETUP_WAKEUP > > >
diff --git a/arch/loongarch/include/asm/stackframe.h b/arch/loongarch/include/asm/stackframe.h index 96c94035b5d0..f538b3a6d680 100644 --- a/arch/loongarch/include/asm/stackframe.h +++ b/arch/loongarch/include/asm/stackframe.h @@ -216,4 +216,12 @@ RESTORE_SP_AND_RET \docfi .endm +/* Jump to the virtual address of the link. */ + .macro JUMP_LINK_ADDR + li.d t0, CACHE_BASE + pcaddi t1, 0 + or t0, t0, t1 + jirl zero, t0, 0xc + .endm + #endif /* _ASM_STACKFRAME_H */ diff --git a/arch/loongarch/kernel/head.S b/arch/loongarch/kernel/head.S index aa6181714ec3..e8a4bf9d7599 100644 --- a/arch/loongarch/kernel/head.S +++ b/arch/loongarch/kernel/head.S @@ -52,9 +52,8 @@ SYM_CODE_START(kernel_entry) # kernel entry point /* We might not get launched at the address the kernel is linked to, so we jump there. */ - la.abs t0, 0f - jr t0 -0: + JUMP_LINK_ADDR + /* Enable PG */ li.w t0, 0xb0 # PLV=0, IE=0, PG=1 csrwr t0, LOONGARCH_CSR_CRMD @@ -106,9 +105,8 @@ SYM_CODE_START(smpboot_entry) li.d t0, CSR_DMW1_INIT # CA, PLV0 csrwr t0, LOONGARCH_CSR_DMWIN1 - la.abs t0, 0f - jr t0 -0: + JUMP_LINK_ADDR + /* Enable PG */ li.w t0, 0xb0 # PLV=0, IE=0, PG=1 csrwr t0, LOONGARCH_CSR_CRMD diff --git a/arch/loongarch/power/suspend_asm.S b/arch/loongarch/power/suspend_asm.S index eb2675642f9f..596a682a7924 100644 --- a/arch/loongarch/power/suspend_asm.S +++ b/arch/loongarch/power/suspend_asm.S @@ -78,9 +78,8 @@ SYM_INNER_LABEL(loongarch_wakeup_start, SYM_L_GLOBAL) li.d t0, CSR_DMW1_INIT # CA, PLV0 csrwr t0, LOONGARCH_CSR_DMWIN1 - la.abs t0, 0f - jr t0 -0: + JUMP_LINK_ADDR + la.pcrel t0, acpi_saved_sp ld.d sp, t0, 0 SETUP_WAKEUP