Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp319882rwb; Wed, 21 Sep 2022 23:12:50 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5hnqnjiIrfTOw8Si0blWIhX4QWWC1AvHLmNS1n+hYq/LHGh4e4UixLbd+kcOkggEhs09dL X-Received: by 2002:a17:90a:f3d3:b0:203:182b:9cd9 with SMTP id ha19-20020a17090af3d300b00203182b9cd9mr1949153pjb.41.1663827170355; Wed, 21 Sep 2022 23:12:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663827170; cv=none; d=google.com; s=arc-20160816; b=BIkiwpGRqjJoIxViuLG8CtmnazA798hmHpKAbDdjIHOAyOJVKsSXPGFyc9gcAwiD/V 2PDJKuDBo53aHJZxPxeALsRSLA2NHYcR69zh/pwgAb3gc3WWslZKrafznw4F4ynb7myD i4zHry1JFim6gJ0LgYr1TQhPm4CGtIwr/1vm4tetLEIsBPTkK1Dc/VVTv5XCUe9eC0hq C3x+D+YDMc6MGNXXPYRIftQnIEwoNGNnpCOyzt11Ra7pLh7Puf42W4QDgHf6Bwn5b1Dv dYy63JUqy66DPFlPc7ZMth8ui6/LpRSHdZz519aouwmd2985NLQRZfI4GdzzvkK70f2N pDZg== 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=UqjCW3qPBJkpy6ChCD9FJVMBBqKF8phiOGscINT6xB0=; b=rcwyW7vU8I2LXMVqOsBLZjJrzCGRaoMMXq57IvBAtBAbWjLlEBiHAvEEViHGrgk2vM qfO6haUEuaxuK/59vhfJkadjkuxNEc7S3dGXVr5noZcO6njLnRKAUgvRv+vanZId/qVo BSCdQue5vPCTPerf2kR8p8jHGtvn1FiOxugkds+5Z9OKRtruIFIBAe08NV7m3i4Fx4Ml UeRojhf8g4hjeReRfczqrT0XBKGh7Avx3WDuHVgXCcGmJc3Sx+04fvIPYWk47QxbrdN3 se+5U+CgnJt+GI+jV2RnbGSmlOA6L4Tk7wMNhUg5rwBZFGGCFsG3AWq5fGMDy41mPZr7 2X+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sholland.org header.s=fm3 header.b=dZRNitQI; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=PsJgMrr2; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 65-20020a630444000000b0043a107cd09esi5300410pge.377.2022.09.21.23.12.39; Wed, 21 Sep 2022 23:12:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@sholland.org header.s=fm3 header.b=dZRNitQI; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=PsJgMrr2; 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 S229890AbiIVFsD (ORCPT + 99 others); Thu, 22 Sep 2022 01:48:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229887AbiIVFrx (ORCPT ); Thu, 22 Sep 2022 01:47:53 -0400 Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19607B440E for ; Wed, 21 Sep 2022 22:47:51 -0700 (PDT) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 0FC623200A1A; Thu, 22 Sep 2022 01:47:48 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Thu, 22 Sep 2022 01:47:50 -0400 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=fm3; t=1663825668; x=1663912068; bh=Uq jCW3qPBJkpy6ChCD9FJVMBBqKF8phiOGscINT6xB0=; b=dZRNitQI2aetBfKvpa qTSXiJOSCa38zRkjxJE7qkICjlv+38VuhY/E9skWqJ5ikbXls2e5OyBrR21P0/Vv yGzMhHLA6CH9kNym0aYydBa0w6J7dyU0kl++3QxdekvAtmgieitEyreyxh4NCCwl noytZ+NpLMMcSDPhXZnQpUdC41DJmSyg1nNewR59P3uIY3BX8cjhaYrwmePHM56V TUy8e6+TDVrsQX7BNit+u1yIBrf87QQtUIpiHy4ZBbbTp2IchdramdAMYJFQ8xeY rNps6qMHq9QNbfqn1TtupFeR/knKF3xVAFvidzeyWDoPPjAEdMk+CJ8VNLGPnzwa KuqQ== 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=fm2; t=1663825668; x=1663912068; bh=UqjCW3qPBJkpy 6ChCD9FJVMBBqKF8phiOGscINT6xB0=; b=PsJgMrr27dcYOsBK1FLrzsHmHdrNv 0EGKdXYrmHeJi/oA41c9NBX9uS3l+FbgkI9hz7DdLHc+P8AjUIyEJozjOMTcM2sh Dze3u5fN7pye1lzdzXsNJBA0yoS+t5ZHA8eYKSpN1+LPdOvMLAoOKneLocNe7sRG DIprfs4gVoqb8fxM+vaG7qCKIq2MoYrjcGK8zTVpoZtn9QabjL1V07PmffgRTbAv XC/90VvXX+RbKIxhifMzJIcKffZj3GbbpmSCg4SWqH4jd3VPxamLRokAjXUC3nJV PtTKJfWFHqdyh9P5TKe3FSdlcd51pRKx8S9aqqhKyzyzAPg2HPPnFTxHQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeefvddgleelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomhepufgrmhhu vghlucfjohhllhgrnhguuceoshgrmhhuvghlsehshhholhhlrghnugdrohhrgheqnecugg ftrfgrthhtvghrnhepudekteeuudehtdelteevgfduvddvjefhfedulefgudevgeeghefg udefiedtveetnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrh homhepshgrmhhuvghlsehshhholhhlrghnugdrohhrgh X-ME-Proxy: Feedback-ID: i0ad843c9:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 22 Sep 2022 01:47:46 -0400 (EDT) From: Samuel Holland To: Palmer Dabbelt , linux-riscv@lists.infradead.org Cc: Samuel Holland , Albert Ou , Guo Ren , Heiko Stuebner , Paul Walmsley , linux-kernel@vger.kernel.org, Alexandre Ghiti , Arnd Bergmann , Geert Uytterhoeven , Jisheng Zhang , Nick Kossifidis , Qinglin Pan , Tong Tiangen Subject: [PATCH 2/2] riscv: Move cast inside kernel_mapping_[pv]a_to_[vp]a Date: Thu, 22 Sep 2022 00:47:42 -0500 Message-Id: <20220922054743.30159-2-samuel@sholland.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220922054743.30159-1-samuel@sholland.org> References: <20220922054743.30159-1-samuel@sholland.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 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. Signed-off-by: Samuel Holland --- arch/riscv/errata/thead/errata.c | 4 ++-- arch/riscv/include/asm/page.h | 18 +++++++++--------- arch/riscv/mm/init.c | 16 ++++++++-------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/arch/riscv/errata/thead/errata.c b/arch/riscv/errata/thead/errata.c index 83174f13783e..38c2c6b0f6b8 100644 --- a/arch/riscv/errata/thead/errata.c +++ b/arch/riscv/errata/thead/errata.c @@ -76,8 +76,8 @@ void __init_or_module thead_errata_patch_func(struct alt_entry *begin, struct al if (cpu_req_errata & tmp) { /* On vm-alternatives, the mmu isn't running yet */ if (stage == RISCV_ALTERNATIVES_EARLY_BOOT) - memcpy((void *)kernel_mapping_va_to_pa((unsigned long)alt->old_ptr), - (void *)kernel_mapping_va_to_pa((unsigned long)alt->alt_ptr), + memcpy((void *)kernel_mapping_va_to_pa(alt->old_ptr), + (void *)kernel_mapping_va_to_pa(alt->alt_ptr), alt->alt_len); else patch_text_nosync(alt->old_ptr, alt->alt_ptr, alt->alt_len); 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 b56a0a75533f..7d59516ce6b3 100644 --- a/arch/riscv/mm/init.c +++ b/arch/riscv/mm/init.c @@ -927,15 +927,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 } -- 2.35.1