Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4751677pxj; Wed, 12 May 2021 12:24:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxsAraltApcS+ofVaoQKm8DmyqN40d9vwZTXCKAaYRy/VnyLLjVqEGAed7RdqYGl+L8tt6D X-Received: by 2002:a17:906:81b:: with SMTP id e27mr8846601ejd.118.1620847454336; Wed, 12 May 2021 12:24:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620847454; cv=none; d=google.com; s=arc-20160816; b=tWG6sW3ttIZ/52Ymorib35u/M8YX3UH+gxKJVocpOkxfeKVhH9D3JVvZ0TlXrj3qqf mtTCgTqRp8JI+TS7zD9YKSNRMGNe2rcwYHLiNZkCx/Kvu9cKh/HFcVMWylsnJ2yqZSHz 7S4qKyOWo3EEJ0ZvvkSS+dHSynIHqhRJx9Fvh+c4BAqroajg3laKn5scqxo7LcXo/hhN HKr+YsYncbNNAqcJxh+QEJxOfmQy01WLtEFujnqjolJK+FcFlzH1vSF524/9JTWFYppM iMo4KlQW7u9owDtnVFQYjvkLTp5fRNGCsi8NFmOP0fH5Kicoea5PdRP8kwJWIgYBITsu /9zA== 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=A04HKBmZP4S9db8kd0CUQvtbtO6iVtAcQipeLyJocGQ=; b=B05rhIZprMsGVK6xI9/Dg0ncdH3ikGx+dPO+e+SjE7vM7l+/IFMz4ryfSLEMSljOrM mBCfwrcBn/8ClsZjhz5TghGjWgXthKIje46jVwqzo+jrkjjm/ksEfoPw3pfXbWNl0ddw pFOmS5Q4hBZ3+eSaTziL/de7ECI0I9a5ldgvGC1dgX1l3LyC1aU95u46W/In0deysp71 82ynm7aVEIaBjMoskIVbfDsfxZykpK7JjIqVQf0bVrQMTIkMoHs7QCHzPOpksSbzfrAQ LeL6zMhWhAdN64N7vWj09AC6UnUJCcdqIhyczWe5INjugLM6NvUdmsqkMPGsqR3sRhJ7 Uf1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=cHlsr4zH; 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 f26si736005ejf.128.2021.05.12.12.23.50; Wed, 12 May 2021 12:24:14 -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=cHlsr4zH; 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 S1378721AbhELTRn (ORCPT + 99 others); Wed, 12 May 2021 15:17:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:39792 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236212AbhELQsI (ORCPT ); Wed, 12 May 2021 12:48:08 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 819F26157F; Wed, 12 May 2021 16:15:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620836138; bh=sTHMaoLvZNSxOJZyOV9rbfw+9EnDIBr1ENi9IKS6+oE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cHlsr4zHpD1l5CqZSAe8kaSClQ5vObJtHsgoHGiNfF3oeoLOlNJCzGU+Tk2Xi5kS7 L4E8W0F7irf3G7Lk8m3kzc1dHeS8mv6aJrQHgf9ZCxJ6/3hNoo7jdPvd7KRw5LywPU No24N/va/wxGaCPu9XxWchWHNbpJ358k0M/YZZr4= 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.12 625/677] powerpc/64: Fix the definition of the fixmap area Date: Wed, 12 May 2021 16:51:11 +0200 Message-Id: <20210512144858.124502531@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144837.204217980@linuxfoundation.org> References: <20210512144837.204217980@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 058601efbc8a..b703330459b8 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