From patchwork Sat Nov 26 06:09:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 26190 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp4487063wrr; Fri, 25 Nov 2022 22:34:12 -0800 (PST) X-Google-Smtp-Source: AA0mqf7PIrHys5OFNlUlxwt3nEtxlvfoL/hYP67wgW7PQ38r4LSfmeXH3wmk5Q8xjJsH7RiqF5M2 X-Received: by 2002:a17:906:79d3:b0:78d:b6f7:53c0 with SMTP id m19-20020a17090679d300b0078db6f753c0mr21175266ejo.527.1669444451916; Fri, 25 Nov 2022 22:34:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669444451; cv=none; d=google.com; s=arc-20160816; b=lCrFIgx5wmeE6BDBobQejYRMs9iPwfome4/Pb9kDe3lor/+qiIn6MSGp6oEpJZ/5oF ah6eyj6nZWyqyRW75CSA97+KO6Y074gNnrZ0g0kp3U9GCppy9l9JDKaIL50k8kVEs46a 26REx3QosC8S7mBAcNGvA3icX9HZq1tqPUrzxoxonV9ynMqUuMcF8C8cVbIgoY39ZkGZ 9gF+rDTn2OVjOA1s4REp8W21x/ckSWtE7VdjH3giyuVE7eOyQD+FnBDgnRYXk+LfmeA/ UJs+lAG5Rg47qjB19WCjNsfmBFqvTVgCYuOCpwP1eakOeP79pJbYtobSCXi5HL0kGYQF Gl3g== 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 :feedback-id:dkim-signature:dkim-signature; bh=09Mg6EEBRTEKmXamOwdaq9np8wWtNcmlu/wFj129aKE=; b=Roje/t0FRRLAD3sX2ssU8Y7fOOmNNcERXIo4vdFOdklcoAu29KF2XRAs4sLIOjORx3 LA33zqjxxbUoVPxJLYJsXpzVa3BsNS7KjM0Tur7HlxSizL0Jqf+/lu4K2AYqszu7mhCv mZSHb6g6kFelrtDezfvC9HS5ZJQDYlIbUL0dMsCqVWkaPxXoRUqnu4aIQrC/JclLFwOM 0sfYSp9fAK8BSuT3QgqaIZSgISd7WfEb/ASmnTTBnP63BdFbnFd7VYsmYIwFBrVzxQvd 6ykKgsnGOc9rVXAG8sicKFQhaZh/zbeKcK6XUan22ccTGLJBRQBHofLWrhsEdH38LwSH QdMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sholland.org header.s=fm2 header.b=JuIs6MYm; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=LM0sSvA6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sholland.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f13-20020a056402354d00b00461b661d906si6149631edd.256.2022.11.25.22.33.37; Fri, 25 Nov 2022 22:34:11 -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; dkim=pass header.i=@sholland.org header.s=fm2 header.b=JuIs6MYm; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=LM0sSvA6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sholland.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230152AbiKZGJ3 (ORCPT + 99 others); Sat, 26 Nov 2022 01:09:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230064AbiKZGJ0 (ORCPT ); Sat, 26 Nov 2022 01:09:26 -0500 Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6CCF2F02D for ; Fri, 25 Nov 2022 22:09:25 -0800 (PST) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 479DE5C00DD; Sat, 26 Nov 2022 01:09:25 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Sat, 26 Nov 2022 01:09:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= cc:cc:content-transfer-encoding:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm2; t=1669442965; x=1669529365; bh=09 Mg6EEBRTEKmXamOwdaq9np8wWtNcmlu/wFj129aKE=; b=JuIs6MYmkW8cPwn0MG 08LGEF8qd/wseB8sUcBwcA2au8V3H2nr4FboYvj36m9UPh5h0mxCPhqZ9Eg8MSKj iCzP2Rnz4T2npkC7O0FhOIvhe2XUOsIyfPAU43IxHgwiuc8bMGdFmgw9yd21/FEW AHF2zPkCqol18NI47HLKvPs24l9Ak+PzV5MARyg7chnvbKNm5WVWWupJQLOr5cLZ eFncCPORXt2Eibw9cLboVV4msouFUmrzVTkR+EhMRUtzDqZ6hXiIh5hfn78xE7sA jui0LJtc6Eg/u+dQILurZQxaJtvgqJUzg5hqZqamUP0GesRniwmYj2gtCiVIjxTx ztlQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; t=1669442965; x=1669529365; bh=09Mg6EEBRTEKm XamOwdaq9np8wWtNcmlu/wFj129aKE=; b=LM0sSvA6v18nkF0en0CFPKqdDcT+L GIQsqJ8ZELFGTzRsjlwkOw4DzL49hGPn3MgOP6hrWQP3Z+C171bTSa8yeGg1JyUL PRYvCDeMc0XpMobdAtIfEeRQkd0gmfNn0Wq+gA6EzaAgtcmUZUUjQyl60ObBhL2D 1BUcpAv55MQx2NwbQo3991MGY2GTOGKAoTsGqK6oVEGmSO4u1t0XRTsQx/rCrLgj K3cmlbv0yMgZx7IaIfxeGRfsE9EczHu+jHDVacdW0GrABwdgzpkkEcCeo9RJPlyv Vv9Bd/xzqt6WXiLvL8MeeiSQWPP8pYMkFJRw68mhS6KFlCCCzhOf6s1Cg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvgedrieeigdeltdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefurghmuhgv lhcujfholhhlrghnugcuoehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhgqeenucggtf frrghtthgvrhhnpedukeetueduhedtleetvefguddvvdejhfefudelgfduveeggeehgfdu feeitdevteenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhroh hmpehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhg X-ME-Proxy: Feedback-ID: i0ad843c9:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 26 Nov 2022 01:09:22 -0500 (EST) From: Samuel Holland To: Palmer Dabbelt , linux-riscv@lists.infradead.org Cc: Samuel Holland , Heiko Stuebner , Albert Ou , Alexandre Ghiti , Paul Walmsley , linux-kernel@vger.kernel.org, Arnd Bergmann , Geert Uytterhoeven , Helge Deller , Jisheng Zhang , Michael Ellerman , Nick Kossifidis , Qinglin Pan Subject: [PATCH v2 2/2] riscv: Move cast inside kernel_mapping_[pv]a_to_[vp]a Date: Sat, 26 Nov 2022 00:09:20 -0600 Message-Id: <20221126060920.65009-2-samuel@sholland.org> X-Mailer: git-send-email 2.37.4 In-Reply-To: <20221126060920.65009-1-samuel@sholland.org> References: <20221126060920.65009-1-samuel@sholland.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,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?1750539385732588554?= X-GMAIL-MSGID: =?utf-8?q?1750539385732588554?= Before commit 44c922572952 ("RISC-V: enable XIP"), these macros cast their argument to unsigned long. That commit moved the cast after an assignment to an unsigned long variable, rendering it ineffectual. Move the cast back, so we can remove the cast at each call site. Reviewed-by: Alexandre Ghiti Reviewed-by: Heiko Stuebner Signed-off-by: Samuel Holland --- (no changes since v1) arch/riscv/include/asm/page.h | 18 +++++++++--------- arch/riscv/mm/init.c | 16 ++++++++-------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/arch/riscv/include/asm/page.h b/arch/riscv/include/asm/page.h index ac70b0fd9a9a..9f432c1b5289 100644 --- a/arch/riscv/include/asm/page.h +++ b/arch/riscv/include/asm/page.h @@ -123,20 +123,20 @@ extern phys_addr_t phys_ram_base; ((x) >= PAGE_OFFSET && (!IS_ENABLED(CONFIG_64BIT) || (x) < PAGE_OFFSET + KERN_VIRT_SIZE)) #define linear_mapping_pa_to_va(x) ((void *)((unsigned long)(x) + kernel_map.va_pa_offset)) -#define kernel_mapping_pa_to_va(y) ({ \ - unsigned long _y = y; \ - (IS_ENABLED(CONFIG_XIP_KERNEL) && _y < phys_ram_base) ? \ - (void *)((unsigned long)(_y) + kernel_map.va_kernel_xip_pa_offset) : \ - (void *)((unsigned long)(_y) + kernel_map.va_kernel_pa_offset + XIP_OFFSET); \ +#define kernel_mapping_pa_to_va(y) ({ \ + unsigned long _y = (unsigned long)(y); \ + (IS_ENABLED(CONFIG_XIP_KERNEL) && _y < phys_ram_base) ? \ + (void *)(_y + kernel_map.va_kernel_xip_pa_offset) : \ + (void *)(_y + kernel_map.va_kernel_pa_offset + XIP_OFFSET); \ }) #define __pa_to_va_nodebug(x) linear_mapping_pa_to_va(x) #define linear_mapping_va_to_pa(x) ((unsigned long)(x) - kernel_map.va_pa_offset) #define kernel_mapping_va_to_pa(y) ({ \ - unsigned long _y = y; \ - (IS_ENABLED(CONFIG_XIP_KERNEL) && _y < kernel_map.virt_addr + XIP_OFFSET) ? \ - ((unsigned long)(_y) - kernel_map.va_kernel_xip_pa_offset) : \ - ((unsigned long)(_y) - kernel_map.va_kernel_pa_offset - XIP_OFFSET); \ + unsigned long _y = (unsigned long)(y); \ + (IS_ENABLED(CONFIG_XIP_KERNEL) && _y < kernel_map.virt_addr + XIP_OFFSET) ? \ + (_y - kernel_map.va_kernel_xip_pa_offset) : \ + (_y - kernel_map.va_kernel_pa_offset - XIP_OFFSET); \ }) #define __va_to_pa_nodebug(x) ({ \ diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c index 50a1b6edd491..dc1ddfa6dedc 100644 --- a/arch/riscv/mm/init.c +++ b/arch/riscv/mm/init.c @@ -926,15 +926,15 @@ static void __init pt_ops_set_early(void) */ static void __init pt_ops_set_fixmap(void) { - pt_ops.alloc_pte = kernel_mapping_pa_to_va((uintptr_t)alloc_pte_fixmap); - pt_ops.get_pte_virt = kernel_mapping_pa_to_va((uintptr_t)get_pte_virt_fixmap); + pt_ops.alloc_pte = kernel_mapping_pa_to_va(alloc_pte_fixmap); + pt_ops.get_pte_virt = kernel_mapping_pa_to_va(get_pte_virt_fixmap); #ifndef __PAGETABLE_PMD_FOLDED - pt_ops.alloc_pmd = kernel_mapping_pa_to_va((uintptr_t)alloc_pmd_fixmap); - pt_ops.get_pmd_virt = kernel_mapping_pa_to_va((uintptr_t)get_pmd_virt_fixmap); - pt_ops.alloc_pud = kernel_mapping_pa_to_va((uintptr_t)alloc_pud_fixmap); - pt_ops.get_pud_virt = kernel_mapping_pa_to_va((uintptr_t)get_pud_virt_fixmap); - pt_ops.alloc_p4d = kernel_mapping_pa_to_va((uintptr_t)alloc_p4d_fixmap); - pt_ops.get_p4d_virt = kernel_mapping_pa_to_va((uintptr_t)get_p4d_virt_fixmap); + pt_ops.alloc_pmd = kernel_mapping_pa_to_va(alloc_pmd_fixmap); + pt_ops.get_pmd_virt = kernel_mapping_pa_to_va(get_pmd_virt_fixmap); + pt_ops.alloc_pud = kernel_mapping_pa_to_va(alloc_pud_fixmap); + pt_ops.get_pud_virt = kernel_mapping_pa_to_va(get_pud_virt_fixmap); + pt_ops.alloc_p4d = kernel_mapping_pa_to_va(alloc_p4d_fixmap); + pt_ops.get_p4d_virt = kernel_mapping_pa_to_va(get_p4d_virt_fixmap); #endif }