Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp869367rdb; Fri, 2 Feb 2024 06:35:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IG5gkwcwdXPEImLHmTufe6XjaEqHeC5kFLikXhEuhA+9KSGwntRBcIWnbA3pjUjYB2hFH7Q X-Received: by 2002:a17:907:960c:b0:a35:3718:997c with SMTP id gb12-20020a170907960c00b00a353718997cmr2399368ejc.28.1706884539581; Fri, 02 Feb 2024 06:35:39 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706884539; cv=pass; d=google.com; s=arc-20160816; b=Vhog3Zxbbi7kdktgL/2qgPl0mLTzN5aUYcsE3h6xOgkitPtRwqO0jSpvYQvzsn+sb7 AS+2mvzH6Ggu4cU8e1kJFZILtROjGXNt7bLPRXM8dFrLV9tvx4W/9xS7Jg1VbQwrc8GU rkzRQkPf1bif6y4KYXRtzkXF5s76S9+3ZFjxhGKci6ua3WPhhCcziXipVfP+7P+TFjxl G6YF8hGgYscVrlA8XZZwAgzlbRwJOLJZTSPriURsA8pKJrD0MohnBRsVuMU+YK7dGfyI xTZUpT7jnjWNggUCqL//zQC5xPgieajrlZKGdX9x8xVX6ezrUMbcurg/aDmKhqooQyPX k6hQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-id:precedence:message-id:date :subject:cc:to:from:dkim-signature; bh=VIxEEd/Q/55pMEhX7NWznX26/nKQ6+eUJs0Pb08CdjE=; fh=YA3g9XG1IZhIaU5AXy5ANEBsaH18EnpTDj0h9M9ZG64=; b=WvbrsIgwaudUWtaXLuDc6gv+ifFRQYnKfDvvKO2NNGq54qS4RBOLCuhdk0/kSxMWIy GASmsR8CZFslBZi/zcPkd2+zefOBxEzQuinSzQnMjTeoxifJwGhW7O4NTr6VGrwU7GMk Rrvk4umiC6+98n10KlgUnUCRfEyks0B9+aXTRKgHhq9up0lerpGjjzOBje/AnqVBMDLE avd+Tjdd9kGuwBI1yJvN6tGmqcNcKhiThQX+x4Tne4gIfjgoIqwgVUTUlFUzXoWvLcEl rBo8m+TTl5Ih3MvkjSSTQgrV2lXpI0+acKgGWcr2bxgp7rUvkMVCKXv+5r1UKtU92D7X +6jw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=GpRI3mL6; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-49957-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49957-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Forwarded-Encrypted: i=1; AJvYcCVzXlqXIo8GFFXH8AO/DJZLD/IYhcijTvKQC4MFU9fqRhZPh6FmnhNlqJT3OFDErdGxB+gcMTFrHcm5NR8yJSYon1qcEaazuqyBi8wmGg== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id p11-20020a1709060dcb00b00a3675353cccsi855623eji.262.2024.02.02.06.35.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 06:35:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-49957-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=GpRI3mL6; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-49957-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49957-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 535171F2C0C8 for ; Fri, 2 Feb 2024 14:35:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9A52913D509; Fri, 2 Feb 2024 14:35:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="GpRI3mL6" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D5E701798F; Fri, 2 Feb 2024 14:35:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.13 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706884529; cv=none; b=aMTKuz0eruMTwNU09ZZnCJ6biCLRFwl0IBllUbLzu3jrBrcDyXX/aPokq1fGUawWp9IF0KFN8gbiVnU2syDquOR3XOreOzxVh8yq3mLSWxcg9fNzyCmRofDcyVN0CKpp5ERsFjSSWUUBbFfmoIJub+o+BrnsNKWt4Gvl58cGzTE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706884529; c=relaxed/simple; bh=wriapjeWuh2ey1LerCDuOBHA5fjmti3BBGSuCxUGacE=; h=From:To:Cc:Subject:Date:Message-Id; b=aPKOo9B4RC27ncRebT2GjZDpzLFUqjlX/au/1f1ZCb8s47vyKQEsbZqReaNM9vI0WtRBB0bXxbSoi7G84quK7Raasrc/B+wkx3mvNMANVLVMfWeSqZI9VQDi+ra9+RleHdQ5qoQAQEK73vABoagmh3mx6Ow+aRw+PP3vFmNm5zo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=GpRI3mL6; arc=none smtp.client-ip=198.175.65.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1706884528; x=1738420528; h=from:to:cc:subject:date:message-id; bh=wriapjeWuh2ey1LerCDuOBHA5fjmti3BBGSuCxUGacE=; b=GpRI3mL618VYgPf6Axyxb/1UXZJJrEpk5NG49LBqgYybDS8MwCFuqnYT rXtU1cKU4UzPV99FdUtAWucK5wfZSa7iBrt+bQtD+dMWpgGSfVNd4Gfgc cdggaIzol+gfCguKIdK1x1AOgXrqjlL6w1cvz1g39KXJBCrNvMeqPGND8 t8BTYyUHDeTRQRcSyA7EURMJSl3VkS7e1FLtEko9seJiwWHKPEgSvpDAf pse4s8DFOyCDPy3TQ0eU8CWUPzSOqH1lw+GlBUL3im2kaok1IdyTIGOzD fdTbxFbKo/vXE77UU8uWu1zS+CjhHtkkHwQaDTTRqi5ZeIUyCUohWPsVc Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10971"; a="11265575" X-IronPort-AV: E=Sophos;i="6.05,238,1701158400"; d="scan'208";a="11265575" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Feb 2024 06:35:27 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,238,1701158400"; d="scan'208";a="4707751" Received: from yzhao56-desk.sh.intel.com ([10.239.159.62]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Feb 2024 06:35:23 -0800 From: Yan Zhao To: arnd@arndb.de, linus.walleij@linaro.org, guoren@kernel.org, bcain@quicinc.com, jonas@southpole.se, stefan.kristiansson@saunalahti.fi, shorne@gmail.com Cc: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, linux-csky@vger.kernel.org, linux-hexagon@vger.kernel.org, linux-openrisc@vger.kernel.org, Yan Zhao Subject: [PATCH] mm: Remove broken pfn_to_virt() on arch csky/hexagon/openrisc Date: Fri, 2 Feb 2024 22:05:50 +0800 Message-Id: <20240202140550.9886-1-yan.y.zhao@intel.com> X-Mailer: git-send-email 2.17.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Remove the broken pfn_to_virt() on architectures csky/hexagon/openrisc. The pfn_to_virt() on those architectures takes PFN instead of PA as the input to macro __va(), with PAGE_SHIFT applying to the converted VA, which is not right, especially when there's a non-zero offset in __va(). [1] The broken pfn_to_virt() was noticed when checking how page_to_virt() is unfolded on x86. It turns out that the one in linux/mm.h instead of in asm-generic/page.h is compiled for x86. However, page_to_virt() in asm-generic/page.h is found out expanding to pfn_to_virt() with a bug described above. The pfn_to_virt() is found out not right as well on architectures csky/hexagon/openrisc. Since there's no single caller on csky/hexagon/openrisc to pfn_to_virt() and there are functions doing similar things as pfn_to_virt() -- - pfn_to_kaddr() in asm/page.h for csky, - page_to_virt() in asm/page.h for hexagon, and - page_to_virt() in linux/mm.h for openrisc, just delete the pfn_to_virt() on those architectures. The pfn_to_virt() in asm-generic/page.h is not touched in this patch as it's referenced by page_to_virt() in that header while the whole header is going to be removed as a whole due to no one including it. Link:https://lore.kernel.org/all/20240131055159.2506-1-yan.y.zhao@intel.com [1] Cc: Linus Walleij Suggested-by: Arnd Bergmann Signed-off-by: Yan Zhao --- arch/csky/include/asm/page.h | 5 ----- arch/hexagon/include/asm/page.h | 6 ------ arch/openrisc/include/asm/page.h | 5 ----- 3 files changed, 16 deletions(-) diff --git a/arch/csky/include/asm/page.h b/arch/csky/include/asm/page.h index 4a0502e324a6..866855e1ab43 100644 --- a/arch/csky/include/asm/page.h +++ b/arch/csky/include/asm/page.h @@ -82,11 +82,6 @@ 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 (void *)((unsigned long)__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)) diff --git a/arch/hexagon/include/asm/page.h b/arch/hexagon/include/asm/page.h index 10f1bc07423c..32394b7e752e 100644 --- a/arch/hexagon/include/asm/page.h +++ b/arch/hexagon/include/asm/page.h @@ -133,12 +133,6 @@ 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 (void *)((unsigned long)__va(pfn) << PAGE_SHIFT); -} - - #define page_to_virt(page) __va(page_to_phys(page)) #include diff --git a/arch/openrisc/include/asm/page.h b/arch/openrisc/include/asm/page.h index 44fc1fd56717..de33ba10ee67 100644 --- a/arch/openrisc/include/asm/page.h +++ b/arch/openrisc/include/asm/page.h @@ -77,11 +77,6 @@ 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 (void *)((unsigned long)__va(pfn) << PAGE_SHIFT); -} - #define virt_to_page(addr) \ (mem_map + (((unsigned long)(addr)-PAGE_OFFSET) >> PAGE_SHIFT)) base-commit: 41bccc98fb7931d63d03f326a746ac4d429c1dd3 -- 2.17.1