From patchwork Tue Aug 8 08:25:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 132797 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c44e:0:b0:3f2:4152:657d with SMTP id w14csp2356906vqr; Tue, 8 Aug 2023 12:46:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE2JWT9k55ArXuz6eC2RmrAojDyIw5V87v0CWr0Lh8zso+gRCCxYeYwNSmf2UDP1QZW0tyV X-Received: by 2002:a17:906:4ca:b0:99c:9e69:6a19 with SMTP id g10-20020a17090604ca00b0099c9e696a19mr375560eja.18.1691524013639; Tue, 08 Aug 2023 12:46:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691524013; cv=none; d=google.com; s=arc-20160816; b=fqHoCAqjaRTXibUVJqVETEv/aQq1tB3S4CPkPrIx9yCHiFsS+wBYClmqWv6ys1Zhg4 ejOUgxuF9h3e246lHUrqqRFqjGqtNw+BdMzkaLa9j7VNOHyIHX2kniyPqCHQD5ttVp8M SGm3LQNV5mMhrDRAm5l1DvZwM/sSISyRaslpvgDF/MwUL1s8lJgIQvDfjpuT2mMmNNw6 czJNFxlNkQsPjWUkXlYHyPm0xj6YGqPNpFEvVSfJ75Inn+/zkOHbJEc5cSSGqGsQakMo He4q8I7Ma+lhZcBYrHtsnfumrfA09dW9sL6D/0TOop/5paCZUhHdJZixrPyYYAcN6Evk gdMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=J6m3K/inEtRmdGEBBt/pEMpMfJWtxVrjJEBC47w+pHA=; fh=U9aMXhC4C3vp50RpX5/W/je1e0oxyhy5HPsCZC8XORg=; b=H2D6zDM612DguK9MlONyFhXYqpe/NKEsmfQTYo6Pw4nKtwHOqp/JvQ/B1RQJr2fD18 FwEKCuPyc94YCvsbMDdjlkW5/0Poyfpmu+dcmKW217XVSuDf4+cR5U86WvrnY/Z302On 32McH3hK3cfdwL4NBIZl4wB/taHGR8QlRV1XQqtx0GlmHAHZmegRd1Tj1Bv4LGxGAgPi yN5MJJuPWkHW1cz8KWCbsUDvxIgCD380tKJNDkNg9CMbiPOXqCBJCzbZ3diGKWMa2Ev4 7eRJm1Q9veiNa2aEHzf3lik9St64JSo1M3dGdrAz3rSrnKMsUMIOVnOjz8H6izUc9ve8 MKVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Q66y5Osq; 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=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c8-20020a170906170800b00988939ad0bdsi8311815eje.321.2023.08.08.12.46.30; Tue, 08 Aug 2023 12:46:53 -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=@linaro.org header.s=google header.b=Q66y5Osq; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236037AbjHHTVI (ORCPT + 99 others); Tue, 8 Aug 2023 15:21:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236097AbjHHTUo (ORCPT ); Tue, 8 Aug 2023 15:20:44 -0400 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1509D59C7 for ; Tue, 8 Aug 2023 09:44:07 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-3fe1a17f983so50053705e9.3 for ; Tue, 08 Aug 2023 09:44:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1691513045; x=1692117845; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=J6m3K/inEtRmdGEBBt/pEMpMfJWtxVrjJEBC47w+pHA=; b=Q66y5OsqazL/NZP2PQHViU2OkzU5RD4Gz4TC2r1C2MSl5aRgpQ7mAowcG2C/sJYMnd NxiFGQZCB1GL0dTMMLRlnr4A/MkxQnf0BbJz6d6Naa8LQEMwcxD3Lky9torH292+rpcv O7dpfE8eNeEJJt1U02MDJIfZhj9uJgxtLMepu5FAFSebfHsNYpt7rZQ7bK9X/6Qds7mg XLIDNi1Jt9E1zZHg9NE4T0XlLXqPFvoMWit7w85sKkf2MTxxs4Se3+AUu7Phy1KejlAb Sx5TEyzWqzdxMQSvuaM9FwMMTgh84dNS+2CNnAsY8nbi3RTwUCJ/gbwcP1rRdTnZ1Z1j Dnow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691513045; x=1692117845; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=J6m3K/inEtRmdGEBBt/pEMpMfJWtxVrjJEBC47w+pHA=; b=HJRea8AleOU0cEbR8oGynHd3pdYBIlg2ILfxLrUutPLXIj1FHDvJ5rtLhcCDNujQYY hWKZZ5rQYifQg7gx/ZOdyjc5eegQLaYGSMVeIxMhkKZVXePv0nyn9UsRWf8X3IJnMarq uYCUvTemXcMSmsxCdedHxOk753BOQF2LhmEvhseL9VB+0g/uFmguk8pBIyHZKSyhxIMP IkUvMD/AscR7DQ11fMcbAshE5ZiuhkOfkjIjrrTkF8nX3N7iBoBKBL8UqTGHbHu2CAeH tP1VrjumIs1n+qGf8I+p/ngMcr6DpwT3twnL6PN83IL6ja6TLUWVp6NaI9zRHhBKrhvj 3hfg== X-Gm-Message-State: AOJu0YySWSfBWnpSXOUZylxV6DBIAhs5viJt6EuvxR5DVjRnH/lg2FQK tvwBw0fu94Qm+V8OFMmMYwixLzT+LAKsE8c7zNE= X-Received: by 2002:a05:6512:ad5:b0:4fb:9050:1d92 with SMTP id n21-20020a0565120ad500b004fb90501d92mr8131994lfu.51.1691483163361; Tue, 08 Aug 2023 01:26:03 -0700 (PDT) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id t13-20020a19ad0d000000b004fbae18984dsm1787087lfc.255.2023.08.08.01.26.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Aug 2023 01:26:02 -0700 (PDT) From: Linus Walleij Date: Tue, 08 Aug 2023 10:25:55 +0200 Subject: [PATCH 1/2] csky: Cast argument to virt_to_pfn() to (void *) MIME-Version: 1.0 Message-Id: <20230808-csky-virt-to-phys-v1-1-ac727f8def2f@linaro.org> References: <20230808-csky-virt-to-phys-v1-0-ac727f8def2f@linaro.org> In-Reply-To: <20230808-csky-virt-to-phys-v1-0-ac727f8def2f@linaro.org> To: Vineet Gupta , Guo Ren Cc: linux-snps-arc@lists.infradead.org, linux-kernel@vger.kernel.org, linux-csky@vger.kernel.org, Linus Walleij X-Mailer: b4 0.12.3 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable 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: INBOX X-GMAIL-THRID: 1773691484455950431 X-GMAIL-MSGID: 1773691484455950431 The virt_to_pfn() function takes a (void *) as argument, fix this up to avoid exploiting the unintended polymorphism of virt_to_pfn. Signed-off-by: Linus Walleij --- arch/arc/include/asm/page.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arc/include/asm/page.h b/arch/arc/include/asm/page.h index e43fe27ec54d..02b53ad811fb 100644 --- a/arch/arc/include/asm/page.h +++ b/arch/arc/include/asm/page.h @@ -108,7 +108,7 @@ extern int pfn_valid(unsigned long pfn); #else /* CONFIG_HIGHMEM */ -#define ARCH_PFN_OFFSET virt_to_pfn(CONFIG_LINUX_RAM_BASE) +#define ARCH_PFN_OFFSET virt_to_pfn((void *)CONFIG_LINUX_RAM_BASE) #endif /* CONFIG_HIGHMEM */ From patchwork Tue Aug 8 08:25:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 132635 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c44e:0:b0:3f2:4152:657d with SMTP id w14csp2292465vqr; Tue, 8 Aug 2023 10:51:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHEZGzU8eez5LIaD2VxIJVIBGzilpZhicjlKYyYa7qptUD8kki0mPJ/YRMG3XazZrd6Xzq2 X-Received: by 2002:a05:6a00:158e:b0:687:955:8640 with SMTP id u14-20020a056a00158e00b0068709558640mr258400pfk.31.1691517105723; Tue, 08 Aug 2023 10:51:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691517105; cv=none; d=google.com; s=arc-20160816; b=MhCDlloBnZC5bx50AE3KxJ/7/39CmXKvMPtdain245nWIvnX6b0pnjrAlenuzk7T57 nLTyuEe/t61nM1/7ie9LHR6ryrFl3r5O2N/fgaTKx0NjxOMEwg/gPjwvqBUeulQBtuX0 MMQJvcw73CEI9/tISbnwvJ9EYx9Yo8nb/MMLUiD1qq9zrhbEk3JLa4LW9Xw6c9rgJWE0 U6X9rJRKV7GVom9uYj9dPcYjTCdRpFemSbETi4/QqAv6HaGTi6B4qMAgGeuZ/SsEMI0z T88mWLHCMLsa5mUF42Eg/GINGf/GXJNCR3ReI8YpFQvlfMBFEFxt3vQ8RPxvlNJW9aeG NNkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=bRPNurCVUK+kZN7q7E8TsOpZ2X9nLclQ5Lcqn45M43Y=; fh=U9aMXhC4C3vp50RpX5/W/je1e0oxyhy5HPsCZC8XORg=; b=pC891fNXtig+0qXNf7IGDOSgVwJJkiqNJkmHU34NY0cKPvNv/nb/wUed1TkWNM6uZo ngoE4BagD17wpR/hKYm3jbIT0phyy9t9Kt6H8CwT2BagMrOojZO8OZzsjMiz1zpK8T28 nCieRCOYrkRU/tQihDyQHZ/nrDNhVL/M5ti9GPo6Xhbv6fFVxahH5QSKQvDBLAOmZwSx Hkw4MBp99WIkIUc1M73pQl86LtVr2R5sU0JWzZ7JXb1luratgIm7CoOPsqMTBJwcssXE 9fAmib8hh3tWM09Q6ZouFOHc/rz+zP6P+bXbSRqwf/30lZVZC0bSpi1wAmPpyNEYF52U aBhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=D3+x+5n0; 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=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t20-20020a056a00139400b0067af445c0dfsi7791779pfg.290.2023.08.08.10.51.32; Tue, 08 Aug 2023 10:51:45 -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=@linaro.org header.s=google header.b=D3+x+5n0; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233413AbjHHQrw (ORCPT + 99 others); Tue, 8 Aug 2023 12:47:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230512AbjHHQqi (ORCPT ); Tue, 8 Aug 2023 12:46:38 -0400 Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58514170F8 for ; Tue, 8 Aug 2023 08:56:40 -0700 (PDT) Received: by mail-ed1-x534.google.com with SMTP id 4fb4d7f45d1cf-523100882f2so7029207a12.2 for ; Tue, 08 Aug 2023 08:56:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1691510170; x=1692114970; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=bRPNurCVUK+kZN7q7E8TsOpZ2X9nLclQ5Lcqn45M43Y=; b=D3+x+5n0GK3u4IvyihWkyCDxlrk5NlbF30zhFFSecLGrMNk+OEE3v4EwF9AfA1eH28 aWko4PAPAhq3crmSkM4DS9FaQXVn59L/RJ2o0WbCUeXbJQD80e542cRGjBKeThWKzDp5 RzdGlI0QNdni3iyzCyR0dA+N850UqCvO3wH+CivA8vWzB1Ad4ShikNMWhkDhNImk++2a aVGQd/lEfDlS+G0RSjnqQ3RrtwWiUX4852zTl99SWCCAvI9tdzFZa1hDYkViTWMTbPLr FYbgStzldNz+GSaLyS37jAl3hfVSMLJzdvkC2z/k/Pqe/VgW1WLWi/GHMm76YEA2c5pt mSSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691510170; x=1692114970; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bRPNurCVUK+kZN7q7E8TsOpZ2X9nLclQ5Lcqn45M43Y=; b=ilAITqXFVU4dSf0PSK1SNapD2fDIq/3i4tztPNrBX1c7GgqX7xGEBdX93gNbH44FZD wpyux/k48xJAco5Tqz0HBeYDW8FZ4q77iY7IdocU+uPQ9j010dwO9TxOIGCjEdbyKI7l 9BQpyJHUwElrAAwFHijrJ9/vIh+x7H2RTaE6W+ogkXLEAvImMZgL6pAm3Co9sWQk0Hj2 p05eU0LhshPEgBEFvDTzpEEhf3kgNoW8ZC93Ot7DEQEKsAxz/I5iYDe32hR+cAEtpMid gO+KvYYwf4kv0A/Kg9FPJANDAGqLUc3WT+Ml7K0QQbheanwoWW33N/If1cFzbs+BKhtV iajQ== X-Gm-Message-State: AOJu0Yz2L8MjDq9O5urZPyEMNNSKjgdp7Hwms6rYDjT5RNMIUklqaDcZ BN+84SBwotEH56j+tJMrDai7JSbTlmZBZ3rFtTk= X-Received: by 2002:a05:6512:358b:b0:4fd:d4b4:faba with SMTP id m11-20020a056512358b00b004fdd4b4fabamr7004297lfr.51.1691483164349; Tue, 08 Aug 2023 01:26:04 -0700 (PDT) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id t13-20020a19ad0d000000b004fbae18984dsm1787087lfc.255.2023.08.08.01.26.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Aug 2023 01:26:03 -0700 (PDT) From: Linus Walleij Date: Tue, 08 Aug 2023 10:25:56 +0200 Subject: [PATCH 2/2] csky: Make pfn accessors static inlines MIME-Version: 1.0 Message-Id: <20230808-csky-virt-to-phys-v1-2-ac727f8def2f@linaro.org> References: <20230808-csky-virt-to-phys-v1-0-ac727f8def2f@linaro.org> In-Reply-To: <20230808-csky-virt-to-phys-v1-0-ac727f8def2f@linaro.org> To: Vineet Gupta , Guo Ren Cc: linux-snps-arc@lists.infradead.org, linux-kernel@vger.kernel.org, linux-csky@vger.kernel.org, Linus Walleij X-Mailer: b4 0.12.3 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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: INBOX X-GMAIL-THRID: 1773684240344668121 X-GMAIL-MSGID: 1773684240344668121 Making virt_to_pfn() a static inline taking a strongly typed (const void *) makes the contract of a passing a pointer of that type to the function explicit and exposes any misuse of the macro virt_to_pfn() acting polymorphic and accepting many types such as (void *), (unitptr_t) or (unsigned long) as arguments without warnings. For symmetry to the same thing with pfn_to_virt(). In order to do this we move the virt_to_phys() and phys_to_virt() below the definitions of the __pa() and __va() macros so it compiles. The macro version was also able to do recursive symbol resolution. Signed-off-by: Linus Walleij --- arch/csky/include/asm/page.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/arch/csky/include/asm/page.h b/arch/csky/include/asm/page.h index b23e3006a9e0..80da7e96a8fa 100644 --- a/arch/csky/include/asm/page.h +++ b/arch/csky/include/asm/page.h @@ -34,9 +34,6 @@ #include -#define virt_to_pfn(kaddr) (__pa(kaddr) >> PAGE_SHIFT) -#define pfn_to_virt(pfn) __va((pfn) << PAGE_SHIFT) - #define virt_addr_valid(kaddr) ((void *)(kaddr) >= (void *)PAGE_OFFSET && \ (void *)(kaddr) < high_memory) @@ -80,6 +77,16 @@ extern unsigned long va_pa_offset; #define __pa_symbol(x) __pa(RELOC_HIDE((unsigned long)(x), 0)) +static inline unsigned long virt_to_pfn(const void *kaddr) +{ + return __pa(kaddr) >> PAGE_SHIFT; +} + +static inline void * pfn_to_virt(unsigned long pfn) +{ + return __va(pfn) << PAGE_SHIFT; +} + #define MAP_NR(x) PFN_DOWN((unsigned long)(x) - PAGE_OFFSET - \ PHYS_OFFSET_OFFSET) #define virt_to_page(x) (mem_map + MAP_NR(x))