From patchwork Wed Feb 22 03:16:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Youling Tang X-Patchwork-Id: 60324 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp357735wrd; Tue, 21 Feb 2023 19:17:48 -0800 (PST) X-Google-Smtp-Source: AK7set8bIz4oeU7KyocXNEaVy6QofT0s1DfuoFrP6RyyDeL8HXZ+XUPqhTmqIBZuRovfXzZT0x8e X-Received: by 2002:a17:902:d2ca:b0:19a:e762:a1af with SMTP id n10-20020a170902d2ca00b0019ae762a1afmr8615077plc.33.1677035867756; Tue, 21 Feb 2023 19:17:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677035867; cv=none; d=google.com; s=arc-20160816; b=opjtF/36HDezpWyGGxtaUxapA/KWTYz+wJs+Uj3jhimTPyxR92p7IfFeLi4l3GDIda qNCRwtW0ypD9WpQQEq0UymDRd7tMMKtbboJxQdDIFMEd68pHFnZoVrFOcfsFwGi93HpI lj91Rz5BQFPSS5zBI0Ym15ys/0SuhuLZdtjTUQJYBDgsNxodlv91oKk6Pk8BI5H7BYnd nWBxfzWwDFoXVCGM6jcIhr/+JfSCOe6dYRFvGCr6lGgQE66OIiNnify8/pXFJj7p7hQ0 DcyAspID2TApqHfG47OMXasZqPgHWCp8VPHbqyZyjdmJ/LbHg3MuxC06ZU19Px0OjB2N z/Lg== 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=stEoEH/tagQBuP8iKwTP7wP/DlFXsyNRxV02uFeIrXU=; b=r2I23OmfbR//RWA8h6SinQCqx77USmcRlmlUCn9UV9L+QYKUqH2JnAJvIbl6oFN+YI vI6cGUJhmQEhIU8V/SGWgGXX+HPCmGIKfVrTWc4/hyY8qHi+NrhU7PRqQghQRVgh3oq5 k08hwJROoCP6oqb4sjnTdPSLdK+t2SK19uN58qdfSQ0znFNxwgJXvVrqT17FgxjK1dLq AcRF72EiWPmb+LzvFPaHmvmFRwm4cd+S96ylK938Uyx25g5V4YMQnzOxJHDXIAm3vsOK vScRBCnKgewojHNvM3znxvEq005kJFsuzeOk2a0HZAlbHWWjFIdpS6xFpDFfdzm9nubL pobQ== 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 32-20020a631160000000b004fc1da19518si7602160pgr.1.2023.02.21.19.17.34; Tue, 21 Feb 2023 19:17:47 -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 S230129AbjBVDQy (ORCPT + 99 others); Tue, 21 Feb 2023 22:16:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230013AbjBVDQu (ORCPT ); Tue, 21 Feb 2023 22:16:50 -0500 Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D36AC2CC7C for ; Tue, 21 Feb 2023 19:16:48 -0800 (PST) Received: from loongson.cn (unknown [113.200.148.30]) by gateway (Coremail) with SMTP id _____8AxJEwfifVjUG8DAA--.1588S3; Wed, 22 Feb 2023 11:16:47 +0800 (CST) Received: from bogon.localdomain (unknown [113.200.148.30]) by localhost.localdomain (Coremail) with SMTP id AQAAf8DxUuUbifVj9l84AA--.2774S4; Wed, 22 Feb 2023 11:16:47 +0800 (CST) From: Youling Tang To: Huacai Chen , Xi Ruoyao , Jinyang He Cc: Xuerui Wang , loongarch@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH v6 2/5] LoongArch: Add JUMP_VIRT_ADDR macro implementation to avoid using la.abs Date: Wed, 22 Feb 2023 11:16:40 +0800 Message-Id: <1677035803-7932-3-git-send-email-tangyouling@loongson.cn> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1677035803-7932-1-git-send-email-tangyouling@loongson.cn> References: <1677035803-7932-1-git-send-email-tangyouling@loongson.cn> X-CM-TRANSID: AQAAf8DxUuUbifVj9l84AA--.2774S4 X-CM-SenderInfo: 5wdqw5prxox03j6o00pqjv00gofq/ X-Coremail-Antispam: 1Uk129KBjvJXoW7WF4kuw4ruFW3Jr13WF13XFb_yoW8Kw48pr nIvr4kGFWUGFn3AFyUt34j9r4UJa1vk3WaganFya40yF4aqryDX34vkr1DXF1qva1rJrW0 9F1fGwsIqF4UX3JanT9S1TB71UUUUUDqnTZGkaVYY2UrUUUUj1kv1TuYvTs0mT0YCTnIWj qI5I8CrVACY4xI64kE6c02F40Ex7xfYxn0WfASr-VFAUDa7-sFnT9fnUUIcSsGvfJTRUUU b28YFVCjjxCrM7AC8VAFwI0_Jr0_Gr1l1xkIjI8I6I8E6xAIw20EY4v20xvaj40_Wr0E3s 1l1IIY67AEw4v_Jrv_JF1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xv wVC0I7IYx2IY67AKxVW5JVW7JwA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxVW8JVWxJwA2z4 x0Y4vEx4A2jsIE14v26r4UJVWxJr1l84ACjcxK6I8E87Iv6xkF7I0E14v26r4UJVWxJr1l e2I262IYc4CY6c8Ij28IcVAaY2xG8wAqjxCEc2xF0cIa020Ex4CE44I27wAqx4xG64xvF2 IEw4CE5I8CrVC2j2WlYx0E2Ix0cI8IcVAFwI0_Jw0_WrylYx0Ex4A2jsIE14v26r4j6F4U McvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvY0x0EwIxGrwCF04k20xvY0x0EwIxGrwCFx2 IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v2 6r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67 AKxVW8JVW5JwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF04k26cxKx2IY s7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r4j6F4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr 0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x07josjUUUUUU= 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758499562355428942?= X-GMAIL-MSGID: =?utf-8?q?1758499562355428942?= Add JUMP_VIRT_ADDR macro implementation to avoid using la.abs. Signed-off-by: Youling Tang --- arch/loongarch/include/asm/stackframe.h | 9 +++++++++ arch/loongarch/kernel/head.S | 12 ++++-------- arch/loongarch/power/suspend_asm.S | 5 ++--- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/arch/loongarch/include/asm/stackframe.h b/arch/loongarch/include/asm/stackframe.h index 7deb043ce387..855c9d9e3210 100644 --- a/arch/loongarch/include/asm/stackframe.h +++ b/arch/loongarch/include/asm/stackframe.h @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -216,4 +217,12 @@ RESTORE_SP_AND_RET \docfi .endm +/* Jump to the virtual address. */ + .macro JUMP_VIRT_ADDR temp1 temp2 + li.d \temp1, CACHE_BASE + pcaddi \temp2, 0 + or \temp1, \temp1, \temp2 + jirl zero, \temp1, 0xc + .endm + #endif /* _ASM_STACKFRAME_H */ diff --git a/arch/loongarch/kernel/head.S b/arch/loongarch/kernel/head.S index aa6181714ec3..d2ac26b5b22b 100644 --- a/arch/loongarch/kernel/head.S +++ b/arch/loongarch/kernel/head.S @@ -50,11 +50,8 @@ SYM_CODE_START(kernel_entry) # kernel entry point li.d t0, CSR_DMW1_INIT # CA, PLV0, 0x9000 xxxx xxxx xxxx csrwr t0, LOONGARCH_CSR_DMWIN1 - /* 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_VIRT_ADDR t0, t1 + /* Enable PG */ li.w t0, 0xb0 # PLV=0, IE=0, PG=1 csrwr t0, LOONGARCH_CSR_CRMD @@ -106,9 +103,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_VIRT_ADDR t0, t1 + /* 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..90da899c06a1 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_VIRT_ADDR t0, t1 + la.pcrel t0, acpi_saved_sp ld.d sp, t0, 0 SETUP_WAKEUP