From patchwork Tue Sep 3 16:45:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: D Scott Phillips X-Patchwork-Id: 13789115 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3BA75CD3448 for ; Tue, 3 Sep 2024 16:50:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-ID:Date:Subject:Cc:To:From:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=Df/XyA43DYdDjGBfCcgN8b3U54LTgkInDm9dCaMVI+I=; b=2spzvAchaLFWtKSGMo3OoPvmcI okhV8JOXRpkEHPw4AnxEkhTNf/TGsKg79fuoH+xbv7iDGLWWkqElo3e6sdMZxlRgufrSEmnZVLvTd QNHB2uyO0lm6z11AF5gRSq9wqetlNO1+cdUEMmK8Y/t8rmMUQkxksxY59fNrN1lAYzw3wDffmk/Xh AMRqwq9pU+0tE4C0rJ3M8Pq6bTrDcn0aqOVorgn+r8bFUWkA4H4fO2rPMs+33NiXuihs1C4/Aw4Ai GM1EfkYLc1r4Ral9NMpSl1hq6jpusm48mCHG3DY7JG9pwzaTBk1wGSChdNsslPxkSNRYF33fBV1kh plYH10bw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1slWj1-00000001C0E-0si7; Tue, 03 Sep 2024 16:49:51 +0000 Received: from mail-co1nam11on20718.outbound.protection.outlook.com ([2a01:111:f403:2416::718] helo=NAM11-CO1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1slWf2-00000001BAl-0mEm for linux-arm-kernel@lists.infradead.org; Tue, 03 Sep 2024 16:47:20 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=xlYcSJ43xxK4pKNKD7agVEQIKp8SvdXsvu+u5aUiqt/bA8IAQAuwSRBlWM9M7dR7GIgNF8h8xcxcevlHqtXen2vyclxaCl4Gm9jkGyBmpATYjIumn13/c1U9NutlqEqxUXQDYIWx+RY/bsIPZeA2QKfLKbiXBtvjqpNHFD993+KbsJAebNT7ECHQ1fE6fsE4MbPtLSQsFT8q4b9G/VDJVeX2/v0MG0FD+GapWw12i1FcgLdRjVGZLBSSgG+lCZzAYMoLXAUjB76o3Q19rgclgaPBiCUE1bkE7ZkSJB9lwuGarB72uxDn27wyaBpaLqBJyzQJpfoJFU0jemy+MDHsrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Df/XyA43DYdDjGBfCcgN8b3U54LTgkInDm9dCaMVI+I=; b=GslwLxHmOGiCan/rBjYs1w3m/tNcQs8XnSSuVNSVoKWFm3IMEghV4aDl3Xp/lDVpDfsn+NxZLg/qYZlYcPW3eRsVvZwdsKVPLvGxLFNCN0rYY2LnFDUEftExz3wrP+8D0zEotkIRSdKh6UkIzEpTOwsyx50vzSXwB0qFtb7CsHX9G5cTaZ93fzPrvL9XkgC81EzsTCYPXcZ3PQx/YpwZURJUp7k8OsaI2tI03t1G67bl62yooglFXCB+BsGeKimRxhVfknToB56R970DPitAzzsB6FJVyMlg/6XBom+qNNwDcl3iguBjPwlwVScR3zVQ2Nop0GWDJCxjJX6mpMXEXw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=os.amperecomputing.com; dmarc=pass action=none header.from=os.amperecomputing.com; dkim=pass header.d=os.amperecomputing.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=os.amperecomputing.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Df/XyA43DYdDjGBfCcgN8b3U54LTgkInDm9dCaMVI+I=; b=R+qUZF7Ipc3QSv9eS+zFqEjEZ2G1KTeFb82wP1+VWmCOAvGa8KLSKQni8gQNWteCHhh4GOLYlESOvNBUhijPgsT9NVHWLaVGFESsNDlda49hF79mNgmC1QEjOy9QskAwENEUzbiv7em3fWnOGKWN26OoG7aESXKG9nNQv9GnTTA= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=os.amperecomputing.com; Received: from LV2PR01MB7792.prod.exchangelabs.com (2603:10b6:408:14f::10) by SA1PR01MB6527.prod.exchangelabs.com (2603:10b6:806:187::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.25; Tue, 3 Sep 2024 16:45:37 +0000 Received: from LV2PR01MB7792.prod.exchangelabs.com ([fe80::2349:ebe6:2948:adb9]) by LV2PR01MB7792.prod.exchangelabs.com ([fe80::2349:ebe6:2948:adb9%6]) with mapi id 15.20.7918.019; Tue, 3 Sep 2024 16:45:36 +0000 From: D Scott Phillips To: Catalin M arinas , Mark Rutland , Will Deacon , Ard Biesheuvel , linux-arm-kernel@lists.infradead.org Cc: "Kirill A. Shutemov" , AKASHI Takahiro , Alison Schofield , Andrew Morton , Andrey Konovalov , Andy Shevchenko , Ankit Agrawal , Baoquan He , Dan Williams , Greg Kroah-Hartman , Wang Jinchao , linux-kernel@vger.kernel.org, patches@amperecomputing.com Subject: [PATCH v3] arm64: Expose the end of the linear map in PHYSMEM_END Date: Tue, 3 Sep 2024 09:45:32 -0700 Message-ID: <20240903164532.3874988-1-scott@os.amperecomputing.com> X-Mailer: git-send-email 2.46.0 X-ClientProxiedBy: CH2PR14CA0037.namprd14.prod.outlook.com (2603:10b6:610:56::17) To LV2PR01MB7792.prod.exchangelabs.com (2603:10b6:408:14f::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR01MB7792:EE_|SA1PR01MB6527:EE_ X-MS-Office365-Filtering-Correlation-Id: 58757440-4b8e-48f5-a170-08dccc37d5f2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|7416014|376014|1800799024|366016|38350700014; X-Microsoft-Antispam-Message-Info: DGL0wD6wOkbdhki1klL9HvJzD2BgUBAAflFUy0VV8gzb+X6SZix1/EfT+t7xtZG9gzfflvRw3yBZlGjyuy+fbapesZPXIYIKy4rCSc537lzedFBKdazJP294Yuk8DalvzUQUpNR4YSpav2YYVoXmuMreqS8GTszd+H+gH+VHXA4S5ya5OszsEIdpty8sUJDen0ScLiCi4o7E6lIb4aJBpD6kzsETt0B6QCLkBm9BNWHbmOG9mrCCIauGQtb3yP5z7nMhGGsRGlSxObUGrKVTKb9IGgVFLX8P87degb3hlpbMDsuPjkRPin9WozsohHscgFS2mM6m2t1Mru3JAI7eEZueQojW86LRy5C0O+zDXcxVrpPe67DBHJSuTNrO9Zsr3L1QXonMfnjmqJpVd5PXd312+4fkPY9Y0Hkb/8ZPFTLxAlr13dU1G41K+GJwbuODCDFLW4+yLANQSbzwihNAuiltlEoezx36i0mbahGPp0l4ukHpbAtJ8egynSW/fsOjVpfw4VBuHUzSZiMlovEh/XwRjbS3NrRgNuEb1Oon1n97ImkKl4nW5B/IW8kQRUaMJfvBTobHf1KD4ZD62SDka5/M9/nGxcv5J3dpULiggtmA8MKP7l/32/Vey1PUMx8CWVjV5bv6IpywVJ965YYsPRzjssmR9DiQqHxIIAuuUVqm3tWt2UQA9X2Dfdj16wcvGMcYAdCOYw8hjuDMgWEN/WyN8RNEsddSZ0yEwQ7NUnadrGVPtVuISwIk5EcojQzcJS50islOjCiL7XgZMiIHXPHqMQgxGDzSXiMRfPUBdLzdHR6Q2elgX3KwOnTF8zXDEAyEBPIE0dD0zQ8RjtIBDBMUcOOEH+7HRquCXuNXbcp3dlJ/kYHEXv+VopezqQOfoNNxq/wANilTxsuaSxyi1QFd6kFdkRVVzZb745YN43p2C8wTdCLuEtQgQ37r5RBVEdsBL9L0/7fNi5TBnOoBiECqVXe+uR8JOTaNZYNA7NReiG2bQ+ZKPQEZQPKBjAARDjp2vbfaZ98BpTIWREZdAZRncEsHNP4rWSH8XJ6ZtIrAlYzRzaos5XQ59fWwNw/dRuKbnUGz9vHWEd5TgebtnsHYw7nme8Fr2tVQdZ4DNVG0VxGc8d95YTf32fj94/4Z40P4oBxUdIk5qQsP7p1qCG5zcM5jGRyagCeMsEP1SZouwpq7B3JEkrapX6PbrWx8QV+Raw6akjEOPEd/rLziT2ZeVoaGkdMjVKV8C3HAJkmgFpLAmojxexWbZjh5xhznKmUoD592w2VBRhoi3htdWvbgDdq7YTtl0aYVr0ThxUxFrnKiAQeqTU3VvF+vvd2ZKvljNxY+AlW3w6O1x6fclceIW8tD3WfGcbqgigP7EC1txrXllrYMIr8IXumzseSDjYSvg2weBpBr0wGYadkqDQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:LV2PR01MB7792.prod.exchangelabs.com;PTR:;CAT:NONE;SFS:(13230040)(52116014)(7416014)(376014)(1800799024)(366016)(38350700014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: CjEso14nB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OfvoIu/FDRLrQdJzYnxqxgEzPQ/jYdjnjSimmnCUHMhw9HuuOorKUZlD1xN/pmS4tgHF2d4RWdvF8knpTjNadr3Pvs+BbY/grp+JoJq9OxhyPtF1GEFQW8MrjW79IaA374qK8MT5f5+U/yDdsRiJVe4ZIFPJI3hEfJNyTNZY1Gq7Rdst1SEknSef2cuuauZSNqGVZJRpWu9QVnlWu5iIROwo5bTFbk8QB+da8aOrbHGU4zxqbcjN9s0Pbhs413s2Lyi9s5PUqww3EXdFokBQc0kYA9XnduGj96kKJ0VgDils3vBCcwQa1KX0hnEF1iazQ3Tq4lnSeKI59hxGEmiHZSShW1Iyd4B93yuTQk6Sg8IoCrfxwHPMBLKqeDpyaLJ4m/Dvu5Ws7ogej/KDc+pOCYTuHX3PkI/rQmmLo4EWEzI92h/PwP9MsD824aEUc83dSLg0NgTcJzd1XOw/uDeqnSAeeXy2LRlobgtgTO7voFE4mDe1NBOk2pf5L/PnKXLJ218e4jlm8Ct/JMYflSc1cM5w9lBOi43/+3eFnBPbA3/W8= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: 58757440-4b8e-48f5-a170-08dccc37d5f2 X-MS-Exchange-CrossTenant-AuthSource: LV2PR01MB7792.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Sep 2024 16:45:36.9263 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3bc2b170-fd94-476d-b0ce-4229bdc904a7 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Y9E2bhCkI3vYjouGlDWmFyihn0oCWRkR58sRoIBuHyMjxzod8Rj8mfUT1owD9LtCntHNxU5tgZ6+WLeInnSAbCqVFnMTn2D8R+nQt9obr4Lo31luK8vBqm7lkylIIrD2 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR01MB6527 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240903_094544_291830_0F834A82 X-CRM114-Status: GOOD ( 14.48 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The memory hot-plug and resource management code needs to know the largest address which can fit in the linear map, so set PHYSMEM_END for that purpose. This fixes a crash[1] at boot when amdgpu tries to create DEVICE_PRIVATE_MEMORY and is given a physical address by the resource management code which is outside the range which can have a `struct page` The Fixes: commit listed below isn't actually broken, but the reorganization of vmemmap causes the improper DEVICE_PRIVATE_MEMORY address to go from a warning to a crash. [1]: Unable to handle kernel paging request at virtual address 000001ffa6000034 Mem abort info: ESR = 0x0000000096000044 EC = 0x25: DABT (current EL), IL = 32 bits SET = 0, FnV = 0 EA = 0, S1PTW = 0 FSC = 0x04: level 0 translation fault Data abort info: ISV = 0, ISS = 0x00000044, ISS2 = 0x00000000 CM = 0, WnR = 1, TnD = 0, TagAccess = 0 GCS = 0, Overlay = 0, DirtyBit = 0, Xs = 0 user pgtable: 4k pages, 48-bit VAs, pgdp=000008000287c000 [000001ffa6000034] pgd=0000000000000000, p4d=0000000000000000 Call trace: __init_zone_device_page.constprop.0+0x2c/0xa8 memmap_init_zone_device+0xf0/0x210 pagemap_range+0x1e0/0x410 memremap_pages+0x18c/0x2e0 devm_memremap_pages+0x30/0x90 kgd2kfd_init_zone_device+0xf0/0x200 [amdgpu] amdgpu_device_ip_init+0x674/0x888 [amdgpu] amdgpu_device_init+0x7a4/0xea0 [amdgpu] amdgpu_driver_load_kms+0x28/0x1c0 [amdgpu] amdgpu_pci_probe+0x1a0/0x560 [amdgpu] local_pci_probe+0x48/0xb8 work_for_cpu_fn+0x24/0x40 process_one_work+0x170/0x3e0 worker_thread+0x2ac/0x3e0 kthread+0xf4/0x108 ret_from_fork+0x10/0x20 Fixes: 32697ff38287 ("arm64: vmemmap: Avoid base2 order of struct page size to dimension region") Signed-off-by: D Scott Phillips Cc: stable@vger.kernel.org --- Link to v2: https://lore.kernel.org/all/20240709002757.2431399-1-scott@os.amperecomputing.com/ Changes since v1: - Change approach again to defining the newly created PHYSMEM_END in arch/arm64/include/asm/memory.h Link to v1: https://lore.kernel.org/all/20240703210707.1986816-1-scott@os.amperecomputing.com/ Changes since v1: - Change from fiddling the architecture's MAX_PHYSMEM_BITS to checking arch_get_mappable_range(). arch/arm64/include/asm/memory.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h index 54fb014eba05..0480c61dbb4f 100644 --- a/arch/arm64/include/asm/memory.h +++ b/arch/arm64/include/asm/memory.h @@ -110,6 +110,8 @@ #define PAGE_END (_PAGE_END(VA_BITS_MIN)) #endif /* CONFIG_KASAN */ +#define PHYSMEM_END __pa(PAGE_END - 1) + #define MIN_THREAD_SHIFT (14 + KASAN_THREAD_SHIFT) /*