Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4696357pxj; Wed, 12 May 2021 11:06:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxrwn1itD+uhMUH0oJTRjvfnITLwjHvlh3UXVIOB72UQIjgV5C82KnAven62PpbtUzbTRnv X-Received: by 2002:a17:906:994f:: with SMTP id zm15mr39449707ejb.24.1620842789404; Wed, 12 May 2021 11:06:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620842789; cv=none; d=google.com; s=arc-20160816; b=toIA+rYkldCcgTobhh5Xa+7o3GcJWyRhK1xrID6TooNBKL+7a0nV/Wf/4/L+px5BmE Stppn2JI38MW7j0Lx21eq+/J/V90oIv1BRliOUKz1vbR2LOCf1V9D2aacz1Tl8mmGyZo /RiJdHe507zhKHjI8o1/OUvygiJ3ea7BIPVJCBE6+G9bABV0ClZ1U39bSy6UILr2bTgU JxyRD8MveDCgssb8Ut+qv5l+jKASFjjko3e0p5QCaJoo4LFzf8qkCvUp7/3xXzX1YD4P EHZuPhBQRgrKy/BRWH4gq59ncke+Irqg3iEBKfn/ZQtlOdCP0v/kp7m6kZDZy2zYW7ha BO0A== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=xHLo/wl91mW4/rczvBPhm6kasP+lwBiTocqty6w7iJs=; b=OXLbDWblJBwIUZcwyx4/Mj9JOrFjR8RjPQzNeZv+SeW+LCdVIOxXD1y2zPW1cCr04X j3dONIUT7Ez5PiZ/V/bG4/fmyUrt5B88t+Lvg1WNmCNH1XTja67QT2GOr5OuAMEWUeCo AbgfU1dc0fHUxQff8iN6LQi7StVANgtSes1gGxe12H5YSrT/+EaPrJzWV2rGLFM1WGRx W+Hs9+UsdyRMpcDHrfSbhkrEOVlR9wuyfqiGiFzVUviG+AWbwWml8s+28JOyXkIMdmyH NuLxwtih5oXsp1rXSgu+DXj/KEzmasK60+0gSJXttqs9OJvI9o9JUmyGXLWcmNTei+gB qOhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=oGXS50Pr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p13si285900edq.588.2021.05.12.11.06.05; Wed, 12 May 2021 11:06:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=oGXS50Pr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351158AbhELRxq (ORCPT + 99 others); Wed, 12 May 2021 13:53:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:42392 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237053AbhELQYL (ORCPT ); Wed, 12 May 2021 12:24:11 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4D9C461C9F; Wed, 12 May 2021 15:47:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620834463; bh=JzetIQQuZ5cB7MJY+zjMK3lz4KswqMMKVJmxRfMZMZY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oGXS50PrS74Yj38F4oEotVLl12n42Ay7+L+MV+XSsj9Cx5lWgfBcX6poMGWj6qL3X hUPBOuCiGuDQTUB1TKrvB74cNAUrzesbSpuzKG6XlHaAqYcCJfYhXYxQJNVBRdQlIx bV6H/gPuM2Tb0kjx+RaxHFWDXZRQSgqPjwU97aqI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christophe Leroy , Michael Ellerman , Sasha Levin Subject: [PATCH 5.11 553/601] powerpc/64: Fix the definition of the fixmap area Date: Wed, 12 May 2021 16:50:30 +0200 Message-Id: <20210512144846.068646624@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144827.811958675@linuxfoundation.org> References: <20210512144827.811958675@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Christophe Leroy [ Upstream commit 9ccba66d4d2aff9a3909aa77d57ea8b7cc166f3c ] At the time being, the fixmap area is defined at the top of the address space or just below KASAN. This definition is not valid for PPC64. For PPC64, use the top of the I/O space. Because of circular dependencies, it is not possible to include asm/fixmap.h in asm/book3s/64/pgtable.h , so define a fixed size AREA at the top of the I/O space for fixmap and ensure during build that the size is big enough. Fixes: 265c3491c4bc ("powerpc: Add support for GENERIC_EARLY_IOREMAP") Signed-off-by: Christophe Leroy Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/0d51620eacf036d683d1a3c41328f69adb601dc0.1618925560.git.christophe.leroy@csgroup.eu Signed-off-by: Sasha Levin --- arch/powerpc/include/asm/book3s/64/pgtable.h | 4 +++- arch/powerpc/include/asm/fixmap.h | 9 +++++++++ arch/powerpc/include/asm/nohash/64/pgtable.h | 5 ++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h b/arch/powerpc/include/asm/book3s/64/pgtable.h index a39886681629..3d6cfa3b0f40 100644 --- a/arch/powerpc/include/asm/book3s/64/pgtable.h +++ b/arch/powerpc/include/asm/book3s/64/pgtable.h @@ -7,6 +7,7 @@ #ifndef __ASSEMBLY__ #include #include +#include #endif /* @@ -323,7 +324,8 @@ extern unsigned long pci_io_base; #define PHB_IO_END (KERN_IO_START + FULL_IO_SIZE) #define IOREMAP_BASE (PHB_IO_END) #define IOREMAP_START (ioremap_bot) -#define IOREMAP_END (KERN_IO_END) +#define IOREMAP_END (KERN_IO_END - FIXADDR_SIZE) +#define FIXADDR_SIZE SZ_32M /* Advertise special mapping type for AGP */ #define HAVE_PAGE_AGP diff --git a/arch/powerpc/include/asm/fixmap.h b/arch/powerpc/include/asm/fixmap.h index 8d03c16a3663..947b5b9c4424 100644 --- a/arch/powerpc/include/asm/fixmap.h +++ b/arch/powerpc/include/asm/fixmap.h @@ -23,12 +23,17 @@ #include #endif +#ifdef CONFIG_PPC64 +#define FIXADDR_TOP (IOREMAP_END + FIXADDR_SIZE) +#else +#define FIXADDR_SIZE 0 #ifdef CONFIG_KASAN #include #define FIXADDR_TOP (KASAN_SHADOW_START - PAGE_SIZE) #else #define FIXADDR_TOP ((unsigned long)(-PAGE_SIZE)) #endif +#endif /* * Here we define all the compile-time 'special' virtual @@ -50,6 +55,7 @@ */ enum fixed_addresses { FIX_HOLE, +#ifdef CONFIG_PPC32 /* reserve the top 128K for early debugging purposes */ FIX_EARLY_DEBUG_TOP = FIX_HOLE, FIX_EARLY_DEBUG_BASE = FIX_EARLY_DEBUG_TOP+(ALIGN(SZ_128K, PAGE_SIZE)/PAGE_SIZE)-1, @@ -72,6 +78,7 @@ enum fixed_addresses { FIX_IMMR_SIZE, #endif /* FIX_PCIE_MCFG, */ +#endif /* CONFIG_PPC32 */ __end_of_permanent_fixed_addresses, #define NR_FIX_BTMAPS (SZ_256K / PAGE_SIZE) @@ -98,6 +105,8 @@ enum fixed_addresses { static inline void __set_fixmap(enum fixed_addresses idx, phys_addr_t phys, pgprot_t flags) { + BUILD_BUG_ON(IS_ENABLED(CONFIG_PPC64) && __FIXADDR_SIZE > FIXADDR_SIZE); + if (__builtin_constant_p(idx)) BUILD_BUG_ON(idx >= __end_of_fixed_addresses); else if (WARN_ON(idx >= __end_of_fixed_addresses)) diff --git a/arch/powerpc/include/asm/nohash/64/pgtable.h b/arch/powerpc/include/asm/nohash/64/pgtable.h index 6cb8aa357191..57cd3892bfe0 100644 --- a/arch/powerpc/include/asm/nohash/64/pgtable.h +++ b/arch/powerpc/include/asm/nohash/64/pgtable.h @@ -6,6 +6,8 @@ * the ppc64 non-hashed page table. */ +#include + #include #include #include @@ -54,7 +56,8 @@ #define PHB_IO_END (KERN_IO_START + FULL_IO_SIZE) #define IOREMAP_BASE (PHB_IO_END) #define IOREMAP_START (ioremap_bot) -#define IOREMAP_END (KERN_VIRT_START + KERN_VIRT_SIZE) +#define IOREMAP_END (KERN_VIRT_START + KERN_VIRT_SIZE - FIXADDR_SIZE) +#define FIXADDR_SIZE SZ_32M /* -- 2.30.2