Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4634471pxj; Wed, 12 May 2021 09:42:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxu3xzqDn9YRkqY1PkP1XMaOOHis3bLoQ7uCo8v8JE2UpYdINGHoYE0clJ0YSeKMRntz++w X-Received: by 2002:aca:c685:: with SMTP id w127mr8063032oif.89.1620837752307; Wed, 12 May 2021 09:42:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620837752; cv=none; d=google.com; s=arc-20160816; b=Ggcdj9NJrxoB+UFoCpebKlbX7As5KgTwFw6tgjzV4muT/XmLaikvTBdHBZlzjSm4UC KrRxE7tNqtTUdm7BPLDXWj4YCbx9Ic5LxHyGPerdU02atYtAPxvrJWXUIYIbZKr2aJuW VMhD9HXT2mw5JqdFmBTgkX09RYPEIVhwEmwg1e1tgG9dspvjrXG2D6uTiUF7Sw+gPo/m dQxKAUirV6xeo9UPujDv8oEK/xpcYL3vqGqc9+I9c8BBgixPE5ah0W1rvLptjEdgYwgM g+GUn5UOZVE8g0UUry/CWnoHBkvIiBMdZzGvnKcVlot1QmEnegLzIQmhjW3xyKVBexZK U09w== 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=mBsJ2VxBzgJ/s2h8qotlpKx64S0zIJ5//jS7Oo49k/g=; b=Dzuc7Dj5ruxg2hpIYsbNBRRxhgmTyZvn3ruec7QtlYFinfTffOj328k7vF0ZiK5B3q xKpDC9AH9QuL3RGUhic9lEMV8oG4NS8r3aXMuhpqI8VqVXUKioaexKcxdvW0YEfeIzYd kTQtGn0iX3QoOKgLoKmzv+1Ay+hvICNvnxi4SAVRgW1UAeGANSHcBiAe1cxS9zC15SZX yFeKKbv0zffiU8IIsfDKagVo+x9HEvl5FYd9AtThlXvV2kSWN1OTRydey1mB2Ep55PpY 7h3E76sfGczaPDvzynhvyXl4hvsNnkMiZG6yhuDqMsyCQBbttj95ZKgu+JQleG0mur0/ t8TQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="h6Bv/czM"; 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 f25si403146otp.132.2021.05.12.09.42.18; Wed, 12 May 2021 09:42:32 -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="h6Bv/czM"; 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 S239499AbhELQjQ (ORCPT + 99 others); Wed, 12 May 2021 12:39:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:41370 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236856AbhELPq6 (ORCPT ); Wed, 12 May 2021 11:46:58 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id CACB361CA0; Wed, 12 May 2021 15:23:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620833026; bh=VWdJTN/Km3OLHhXMnWhpMvYjCJ+uMEEai+vb8bsOLqI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=h6Bv/czM9FWIBgqBS9KWTBxvWXM51AoOcn8wqqVIxpi+8CMJbilGQwycFxmqemRT3 JN1mHfmTB6MPBtPtcSREaaf+5zMbaob95qLpGEkWo/YuHXrUyjPy44x7Z7GWNgA+tO c2CiaAfUgiF+YvQSK/49qDeFyY5qBMKgbKo/WFCc= 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.10 485/530] powerpc/64: Fix the definition of the fixmap area Date: Wed, 12 May 2021 16:49:55 +0200 Message-Id: <20210512144835.700383095@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144819.664462530@linuxfoundation.org> References: <20210512144819.664462530@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 cd3feeac6e87..4a3dca0271f1 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 6bfc87915d5d..591b2f4deed5 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