linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCHv2 0/2] PCI_IOBASE fixes
@ 2015-01-22 18:20 Mark Rutland
  2015-01-22 18:20 ` [PATCHv2 1/2] arm64: Fix overlapping VA allocations Mark Rutland
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Mark Rutland @ 2015-01-22 18:20 UTC (permalink / raw)
  To: linux-arm-kernel

Mark Brown reported [1] build failures in the page table dump code, due
to lack of an explicit include for PCI_IOBASE.

While looking into that I spotted that the VA space allocated for PCI I/O
overlaps with the fixmap allocation, and that in a couple of places we assume
that the I/O space is 16MiB while the allocated VA space (and associated
IO_SPACE_LIMIT) cover 32MiB.

The first patch fixes the VA space allocation, preventing overlap, and
introduces common definitions for the I/O space layout, preventing futurre
issues if the I/O space layout is modified.

The second patch adds the missing explicit includes for the remaining
definitions used in the dump code, and has been updated from the
previous posting [2] to take the effects of patch 1 into account.

I've built and boot tested a v3.19-rc4 defconfig with these patches
applied.

Since v1 [3]:
* Restore I/O space to 16MiB, per Catalin's request.
* Add PCI_IO_SIZE along with comment to ensure the I/O space size is
  consistent through all uses.
* Reorder mem_init entries for consistency.

Thanks,
Mark.

[1] http://lists.infradead.org/pipermail/linux-arm-kernel/2015-January/315228.html
[2] http://lists.infradead.org/pipermail/linux-arm-kernel/2015-January/315326.html
[3] http://lists.infradead.org/pipermail/linux-arm-kernel/2015-January/315443.html

Mark Rutland (2):
  arm64: Fix overlapping VA allocations
  arm64: mm: dump: add missing includes

 arch/arm64/include/asm/io.h     |  5 +++--
 arch/arm64/include/asm/memory.h | 10 +++++++++-
 arch/arm64/mm/dump.c            |  8 ++++++--
 arch/arm64/mm/init.c            |  5 +++--
 4 files changed, 21 insertions(+), 7 deletions(-)

-- 
1.9.1

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCHv2 1/2] arm64: Fix overlapping VA allocations
  2015-01-22 18:20 [PATCHv2 0/2] PCI_IOBASE fixes Mark Rutland
@ 2015-01-22 18:20 ` Mark Rutland
  2015-01-22 18:20 ` [PATCHv2 2/2] arm64: mm: dump: add missing includes Mark Rutland
  2015-01-23 14:18 ` [PATCHv2 0/2] PCI_IOBASE fixes Catalin Marinas
  2 siblings, 0 replies; 4+ messages in thread
From: Mark Rutland @ 2015-01-22 18:20 UTC (permalink / raw)
  To: linux-arm-kernel

PCI IO space was intended to be 16MiB, at 32MiB below MODULES_VADDR, but
commit d1e6dc91b532d3d3 ("arm64: Add architectural support for PCI")
extended this to cover the full 32MiB. The final 8KiB of this 32MiB is
also allocated for the fixmap, allowing for potential clashes between
the two.

This change was masked by assumptions in mem_init and the page table
dumping code, which assumed the I/O space to be 16MiB long through
seaparte hard-coded definitions.

This patch changes the definition of the PCI I/O space allocation to
live in asm/memory.h, along with the other VA space allocations. As the
fixmap allocation depends on the number of fixmap entries, this is moved
below the PCI I/O space allocation. Both the fixmap and PCI I/O space
are guarded with 2MB of padding. Sites assuming the I/O space was 16MiB
are moved over use new PCI_IO_{START,END} definitions, which will keep
in sync with the size of the IO space (now restored to 16MiB).

As a useful side effect, the use of the new PCI_IO_{START,END}
definitions prevents a build issue in the dumping code due to a (now
redundant) missing include of io.h for PCI_IOBASE.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Laura Abbott <lauraa@codeaurora.org>
Cc: Liviu Dudau <liviu.dudau@arm.com>
Cc: Steve Capper <steve.capper@linaro.org>
Cc: Will Deacon <will.deacon@arm.com>
---
 arch/arm64/include/asm/io.h     |  5 +++--
 arch/arm64/include/asm/memory.h | 10 +++++++++-
 arch/arm64/mm/dump.c            |  4 ++--
 arch/arm64/mm/init.c            |  5 +++--
 4 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/arch/arm64/include/asm/io.h b/arch/arm64/include/asm/io.h
index 949c406..540f7c0 100644
--- a/arch/arm64/include/asm/io.h
+++ b/arch/arm64/include/asm/io.h
@@ -26,6 +26,7 @@
 
 #include <asm/byteorder.h>
 #include <asm/barrier.h>
+#include <asm/memory.h>
 #include <asm/pgtable.h>
 #include <asm/early_ioremap.h>
 #include <asm/alternative.h>
@@ -145,8 +146,8 @@ static inline u64 __raw_readq(const volatile void __iomem *addr)
  *  I/O port access primitives.
  */
 #define arch_has_dev_port()	(1)
-#define IO_SPACE_LIMIT		(SZ_32M - 1)
-#define PCI_IOBASE		((void __iomem *)(MODULES_VADDR - SZ_32M))
+#define IO_SPACE_LIMIT		(PCI_IO_SIZE - 1)
+#define PCI_IOBASE		((void __iomem *)PCI_IO_START)
 
 /*
  * String version of I/O memory access operations.
diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h
index 6486b2b..f800d45 100644
--- a/arch/arm64/include/asm/memory.h
+++ b/arch/arm64/include/asm/memory.h
@@ -33,6 +33,12 @@
 #define UL(x) _AC(x, UL)
 
 /*
+ * Size of the PCI I/O space. This must remain a power of two so that
+ * IO_SPACE_LIMIT acts as a mask for the low bits of I/O addresses.
+ */
+#define PCI_IO_SIZE		SZ_16M
+
+/*
  * PAGE_OFFSET - the virtual address of the start of the kernel image (top
  *		 (VA_BITS - 1))
  * VA_BITS - the maximum number of bits for virtual addresses.
@@ -45,7 +51,9 @@
 #define PAGE_OFFSET		(UL(0xffffffffffffffff) << (VA_BITS - 1))
 #define MODULES_END		(PAGE_OFFSET)
 #define MODULES_VADDR		(MODULES_END - SZ_64M)
-#define FIXADDR_TOP		(MODULES_VADDR - SZ_2M - PAGE_SIZE)
+#define PCI_IO_END		(MODULES_VADDR - SZ_2M)
+#define PCI_IO_START		(PCI_IO_END - PCI_IO_SIZE)
+#define FIXADDR_TOP		(PCI_IO_START - SZ_2M)
 #define TASK_SIZE_64		(UL(1) << VA_BITS)
 
 #ifdef CONFIG_COMPAT
diff --git a/arch/arm64/mm/dump.c b/arch/arm64/mm/dump.c
index cf33f33..203a6cf 100644
--- a/arch/arm64/mm/dump.c
+++ b/arch/arm64/mm/dump.c
@@ -52,8 +52,8 @@ static struct addr_marker address_markers[] = {
 	{ 0,			"vmemmap start" },
 	{ 0,			"vmemmap end" },
 #endif
-	{ (unsigned long) PCI_IOBASE,		"PCI I/O start" },
-	{ (unsigned long) PCI_IOBASE + SZ_16M,	"PCI I/O end" },
+	{ PCI_IO_START,		"PCI I/O start" },
+	{ PCI_IO_END,		"PCI I/O end" },
 	{ FIXADDR_START,	"Fixmap start" },
 	{ FIXADDR_TOP,		"Fixmap end" },
 	{ MODULES_VADDR,	"Modules start" },
diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
index bac492c..7e9f12e 100644
--- a/arch/arm64/mm/init.c
+++ b/arch/arm64/mm/init.c
@@ -35,6 +35,7 @@
 #include <linux/efi.h>
 
 #include <asm/fixmap.h>
+#include <asm/memory.h>
 #include <asm/sections.h>
 #include <asm/setup.h>
 #include <asm/sizes.h>
@@ -277,8 +278,8 @@ void __init mem_init(void)
 		  "    vmemmap : 0x%16lx - 0x%16lx   (%6ld GB maximum)\n"
 		  "              0x%16lx - 0x%16lx   (%6ld MB actual)\n"
 #endif
-		  "    PCI I/O : 0x%16lx - 0x%16lx   (%6ld MB)\n"
 		  "    fixed   : 0x%16lx - 0x%16lx   (%6ld KB)\n"
+		  "    PCI I/O : 0x%16lx - 0x%16lx   (%6ld MB)\n"
 		  "    modules : 0x%16lx - 0x%16lx   (%6ld MB)\n"
 		  "    memory  : 0x%16lx - 0x%16lx   (%6ld MB)\n"
 		  "      .init : 0x%p" " - 0x%p" "   (%6ld KB)\n"
@@ -291,8 +292,8 @@ void __init mem_init(void)
 		  MLM((unsigned long)virt_to_page(PAGE_OFFSET),
 		      (unsigned long)virt_to_page(high_memory)),
 #endif
-		  MLM((unsigned long)PCI_IOBASE, (unsigned long)PCI_IOBASE + SZ_16M),
 		  MLK(FIXADDR_START, FIXADDR_TOP),
+		  MLM(PCI_IO_START, PCI_IO_END),
 		  MLM(MODULES_VADDR, MODULES_END),
 		  MLM(PAGE_OFFSET, (unsigned long)high_memory),
 		  MLK_ROUNDUP(__init_begin, __init_end),
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCHv2 2/2] arm64: mm: dump: add missing includes
  2015-01-22 18:20 [PATCHv2 0/2] PCI_IOBASE fixes Mark Rutland
  2015-01-22 18:20 ` [PATCHv2 1/2] arm64: Fix overlapping VA allocations Mark Rutland
@ 2015-01-22 18:20 ` Mark Rutland
  2015-01-23 14:18 ` [PATCHv2 0/2] PCI_IOBASE fixes Catalin Marinas
  2 siblings, 0 replies; 4+ messages in thread
From: Mark Rutland @ 2015-01-22 18:20 UTC (permalink / raw)
  To: linux-arm-kernel

The arm64 dump code is currently relying on some definitions which are
pulled in via transitive dependencies. It seems we have implicit
dependencies on the following definitions:

* MODULES_VADDR         (asm/memory.h)
* MODULES_END           (asm/memory.h)
* PAGE_OFFSET           (asm/memory.h)
* PTE_*                 (asm/pgtable-hwdef.h)
* ENOMEM                (linux/errno.h)
* device_initcall       (linux/init.h)

This patch ensures we explicitly include the relevant headers for the
above items, fixing the observed build issue and hopefully preventing
future issues as headers are refactored.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Reported-by: Mark Brown <broonie@kernel.org>
Acked-by: Steve Capper <steve.capper@linaro.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Laura Abbott <lauraa@codeaurora.org>
Cc: Will Deacon <will.deacon@arm.com>
---
 arch/arm64/mm/dump.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/arm64/mm/dump.c b/arch/arm64/mm/dump.c
index 203a6cf..48a4a2f 100644
--- a/arch/arm64/mm/dump.c
+++ b/arch/arm64/mm/dump.c
@@ -14,13 +14,17 @@
  * of the License.
  */
 #include <linux/debugfs.h>
+#include <linux/errno.h>
 #include <linux/fs.h>
+#include <linux/init.h>
 #include <linux/mm.h>
 #include <linux/sched.h>
 #include <linux/seq_file.h>
 
 #include <asm/fixmap.h>
+#include <asm/memory.h>
 #include <asm/pgtable.h>
+#include <asm/pgtable-hwdef.h>
 
 #define LOWEST_ADDR	(UL(0xffffffffffffffff) << VA_BITS)
 
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCHv2 0/2] PCI_IOBASE fixes
  2015-01-22 18:20 [PATCHv2 0/2] PCI_IOBASE fixes Mark Rutland
  2015-01-22 18:20 ` [PATCHv2 1/2] arm64: Fix overlapping VA allocations Mark Rutland
  2015-01-22 18:20 ` [PATCHv2 2/2] arm64: mm: dump: add missing includes Mark Rutland
@ 2015-01-23 14:18 ` Catalin Marinas
  2 siblings, 0 replies; 4+ messages in thread
From: Catalin Marinas @ 2015-01-23 14:18 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Jan 22, 2015 at 06:20:34PM +0000, Mark Rutland wrote:
> Mark Rutland (2):
>   arm64: Fix overlapping VA allocations
>   arm64: mm: dump: add missing includes

Applied. Thanks.

-- 
Catalin

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-01-23 14:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-22 18:20 [PATCHv2 0/2] PCI_IOBASE fixes Mark Rutland
2015-01-22 18:20 ` [PATCHv2 1/2] arm64: Fix overlapping VA allocations Mark Rutland
2015-01-22 18:20 ` [PATCHv2 2/2] arm64: mm: dump: add missing includes Mark Rutland
2015-01-23 14:18 ` [PATCHv2 0/2] PCI_IOBASE fixes Catalin Marinas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).