Skip to contentSkip to conversation

ARM: nommu: R-class fixes

PATCH Superseded Vladimir Murzin 2 participants 9 messages Apr 28, 2016 – May 4, 2016 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

v2 cover ARM: nommu: R-class fixes

Small set of fixes discovered with R-class cores.

Jean-Philippe Brucker (2):
ARM: nommu: fix PMSAv7 setup
ARM: nommu: change memory reserve for the vectors

Vladimir Murzin (1):
ARM: domain: move {set,get}_domain under config guard

 arch/arm/include/asm/domain.h |   11 +++++++++++
 arch/arm/kernel/head-nommu.S  |    2 +-
 arch/arm/mm/nommu.c           |   15 ++++++++-------
 3 files changed, 20 insertions(+), 8 deletions(-)
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH v2 1/3 ARM: nommu: fix PMSAv7 setup

From: Jean-Philippe Brucker <[email protected]>

Commit 1c2f87c (ARM: 8025/1: Get rid of meminfo) broke the support for MPU on ARMv7-R. This patch adapts the code inside CONFIG_ARM_MPU to use memblocks appropriately.

MPU initialisation only uses the first memory region, and removes all subsequent ones. Because looping over all regions that need removal is inefficient, and memblock_remove already handles memory ranges, we can flatten the 'for_each_memblock' part.

---
 arch/arm/mm/nommu.c |   13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
arch/arm/mm/nommu.c +7 -6
index 1dd1093..4d113fc 100644
@@ -87,7 +87,6 @@ static unsigned long irbar_read(void)
 /* MPU initialisation functions */
 void __init sanity_check_meminfo_mpu(void)
 {
-	int i;
 	phys_addr_t phys_offset = PHYS_OFFSET;
 	phys_addr_t aligned_region_size, specified_mem_size, rounded_mem_size;
 	struct memblock_region *reg;
@@ -110,11 +109,13 @@ void __init sanity_check_meminfo_mpu(void)
 		} else {
 			/*
 			 * memblock auto merges contiguous blocks, remove
-			 * all blocks afterwards
+			 * all blocks afterwards in one go (we can't remove
+			 * blocks separately while iterating)
 			 */
 			pr_notice("Ignoring RAM after %pa, memory at %pa ignored\n",
-				  &mem_start, &reg->base);
-			memblock_remove(reg->base, reg->size);
+				  &mem_end, &reg->base);
+			memblock_remove(reg->base, 0 - reg->base);
+			break;
 		}
 	}
 
@@ -144,7 +145,7 @@ void __init sanity_check_meminfo_mpu(void)
 		pr_warn("Truncating memory from %pa to %pa (MPU region constraints)",
 				&specified_mem_size, &aligned_region_size);
 		memblock_remove(mem_start + aligned_region_size,
-				specified_mem_size - aligned_round_size);
+				specified_mem_size - aligned_region_size);
 
 		mem_end = mem_start + aligned_region_size;
 	}
@@ -261,7 +262,7 @@ void __init mpu_setup(void)
 		return;
 
 	region_err = mpu_setup_region(MPU_RAM_REGION, PHYS_OFFSET,
-					ilog2(meminfo.bank[0].size),
+					ilog2(memblock.memory.regions[0].size),
 					MPU_AP_PL1RW_PL0RW | MPU_RGN_NORMAL);
 	if (region_err) {
 		panic("MPU region initialization failure! %d", region_err);
Signature · 1 line
1.7.9.5
#2 lore raw

PATCH v2 2/3 ARM: nommu: change memory reserve for the vectors

In reply to Vladimir Murzin

From: Jean-Philippe Brucker <[email protected]>

Commit 19accfd3 (ARM: move vector stubs) moved the vector stubs in an additional page above the base vector one. This change wasn't taken into account by the nommu memreserve.
This patch ensures that the kernel won't overwrite any vector stub on nommu.

[changed the MPU side too]
---
 arch/arm/kernel/head-nommu.S |    2 +-
 arch/arm/mm/nommu.c          |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
arch/arm/kernel/head-nommu.S +1 -1
index 9b8c5a1..fb1a69e 100644
@@ -236,7 +236,7 @@ ENTRY(__setup_mpu)
 	mov	r0, #CONFIG_VECTORS_BASE	@ Cover from VECTORS_BASE
 	ldr	r5,=(MPU_AP_PL1RW_PL0NA | MPU_RGN_NORMAL)
 	/* Writing N to bits 5:1 (RSR_SZ) --> region size 2^N+1 */
-	mov	r6, #(((PAGE_SHIFT - 1) << MPU_RSR_SZ) | 1 << MPU_RSR_EN)
+	mov	r6, #(((2 * PAGE_SHIFT - 1) << MPU_RSR_SZ) | 1 << MPU_RSR_EN)
 
 	setup_region r0, r5, r6, MPU_DATA_SIDE	@ VECTORS_BASE, PL0 NA, enabled
 	beq	3f				@ Memory-map not unified
arch/arm/mm/nommu.c +1 -1
index 4d113fc..d5805e4 100644
@@ -286,7 +286,7 @@ void __init arm_mm_memblock_reserve(void)
 	 * some architectures which the DRAM is the exception vector to trap,
 	 * alloc_page breaks with error, although it is not NULL, but "0."
 	 */
-	memblock_reserve(CONFIG_VECTORS_BASE, PAGE_SIZE);
+	memblock_reserve(CONFIG_VECTORS_BASE, 2 * PAGE_SIZE);
 #else /* ifndef CONFIG_CPU_V7M */
 	/*
 	 * There is no dedicated vector page on V7-M. So nothing needs to be
Signature · 1 line
1.7.9.5
#3 lore raw

PATCH v2 3/3 ARM: domain: move {set,get}_domain under config guard

In reply to Vladimir Murzin

Recursive undefined instrcution falut is seen with R-class taking an exception. The reson for that is __show_regs() tries to get domain information, but domains is not available on !MMU cores, like R/M class.

Fix it by puting {set,get}_domain functions under CONFIG_CPU_CP15_MMU guard and providing stubs for the case where domains is not supported.

---
Changelog:
v1 -> v2
- use CPU_CP15_MMU and don't disable SW PAN (per Russell)

arch/arm/include/asm/domain.h | 11 +++++++++++

 1 file changed, 11 insertions(+)
arch/arm/include/asm/domain.h +11 -0
index fc8ba16..99d9f63 100644
@@ -84,6 +84,7 @@
 
 #ifndef __ASSEMBLY__
 
+#ifdef CONFIG_CPU_CP15_MMU
 static inline unsigned int get_domain(void)
 {
 	unsigned int domain;
@@ -103,6 +104,16 @@ static inline void set_domain(unsigned val)
 	  : : "r" (val) : "memory");
 	isb();
 }
+#else
+static inline unsigned int get_domain(void)
+{
+	return 0;
+}
+
+static inline void set_domain(unsigned val)
+{
+}
+#endif
 
 #ifdef CONFIG_CPU_USE_DOMAINS
 #define modify_domain(dom,type)					\
Signature · 1 line
1.7.9.5
#4 lore raw

v2 cover ARM: nommu: R-class fixes

In reply to Vladimir Murzin
Quoted 6 lines · Vladimir Murzin

Small set of fixes discovered with R-class cores.

Jean-Philippe Brucker (2):
ARM: nommu: fix PMSAv7 setup
ARM: nommu: change memory reserve for the vectors

Quoted 8 lines

Vladimir Murzin (1):
ARM: domain: move {set,get}_domain under config guard

 arch/arm/include/asm/domain.h |   11 +++++++++++
 arch/arm/kernel/head-nommu.S  |    2 +-
 arch/arm/mm/nommu.c           |   15 ++++++++-------
 3 files changed, 20 insertions(+), 8 deletions(-)

Russell, any objection to get it into patch tracker?

Thanks
Vladimir

#5 lore raw

v2 cover ARM: nommu: R-class fixes

Quoted 10 lines · Vladimir Murzin
Quoted 9 lines · Vladimir Murzin

Small set of fixes discovered with R-class cores.

Jean-Philippe Brucker (2):
ARM: nommu: fix PMSAv7 setup
ARM: nommu: change memory reserve for the vectors

Vladimir Murzin (1):
ARM: domain: move {set,get}_domain under config guard

Quoted 7 lines
Quoted 5 lines
 arch/arm/include/asm/domain.h |   11 +++++++++++
 arch/arm/kernel/head-nommu.S  |    2 +-
 arch/arm/mm/nommu.c           |   15 ++++++++-------
 3 files changed, 20 insertions(+), 8 deletions(-)

Russell, any objection to get it into patch tracker?

I've not had any chance to look at them yet - last weekend, I was away from Thursday through until late Tuesday, then I spent most of Wednesday and Thursday catching up. Friday I was able to look at some stuff, and then I've spent the bank holiday weekend digging out laurels in the front garden. I've only just today got back to looking at some kernel stuff.

So really, I've only had two days in the last week and a half to look at anything.

Please wait a little while longer. Thanks.

Signature · 3 lines
RMK's Patch system: http://www.arm.linux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
#6 lore raw

v2 cover ARM: nommu: R-class fixes

Quoted 25 lines · Russell King - ARM Linux
Quoted 10 lines · Vladimir Murzin
Quoted 9 lines · Vladimir Murzin

Small set of fixes discovered with R-class cores.

Jean-Philippe Brucker (2):
ARM: nommu: fix PMSAv7 setup
ARM: nommu: change memory reserve for the vectors

Vladimir Murzin (1):
ARM: domain: move {set,get}_domain under config guard

Quoted 7 lines
Quoted 5 lines
 arch/arm/include/asm/domain.h |   11 +++++++++++
 arch/arm/kernel/head-nommu.S  |    2 +-
 arch/arm/mm/nommu.c           |   15 ++++++++-------
 3 files changed, 20 insertions(+), 8 deletions(-)

Russell, any objection to get it into patch tracker?

I've not had any chance to look at them yet - last weekend, I was away from Thursday through until late Tuesday, then I spent most of Wednesday and Thursday catching up. Friday I was able to look at some stuff, and then I've spent the bank holiday weekend digging out laurels in the front garden. I've only just today got back to looking at some kernel stuff.

Quoted 4 lines

So really, I've only had two days in the last week and a half to look at anything.

Please wait a little while longer. Thanks.

Thanks for prompt reply! I wasn't aware you've been off, patches can wait.

Cheers
Vladimir

#7 lore raw

v2 cover ARM: nommu: R-class fixes

Quoted 26 lines · Vladimir Murzin
Quoted 25 lines · Russell King - ARM Linux
Quoted 10 lines · Vladimir Murzin
Quoted 9 lines · Vladimir Murzin

Small set of fixes discovered with R-class cores.

Jean-Philippe Brucker (2):
ARM: nommu: fix PMSAv7 setup
ARM: nommu: change memory reserve for the vectors

Vladimir Murzin (1):
ARM: domain: move {set,get}_domain under config guard

Quoted 7 lines
Quoted 5 lines
 arch/arm/include/asm/domain.h |   11 +++++++++++
 arch/arm/kernel/head-nommu.S  |    2 +-
 arch/arm/mm/nommu.c           |   15 ++++++++-------
 3 files changed, 20 insertions(+), 8 deletions(-)

Russell, any objection to get it into patch tracker?

I've not had any chance to look at them yet - last weekend, I was away from Thursday through until late Tuesday, then I spent most of Wednesday and Thursday catching up. Friday I was able to look at some stuff, and then I've spent the bank holiday weekend digging out laurels in the front garden. I've only just today got back to looking at some kernel stuff.

Quoted 6 lines
Quoted 4 lines

So really, I've only had two days in the last week and a half to look at anything.

Please wait a little while longer. Thanks.

Thanks for prompt reply! I wasn't aware you've been off, patches can wait.

Thanks for waiting, I've now looked through them and they look fine to me.

Please put them in the patch system, thanks.

Signature · 3 lines
RMK's Patch system: http://www.arm.linux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
#8 lore raw

v2 cover ARM: nommu: R-class fixes

Quoted 30 lines · Russell King - ARM Linux
Quoted 29 lines · Vladimir Murzin
Quoted 28 lines · Russell King - ARM Linux
Quoted 10 lines · Vladimir Murzin
Quoted 9 lines · Vladimir Murzin

Small set of fixes discovered with R-class cores.

Jean-Philippe Brucker (2):
ARM: nommu: fix PMSAv7 setup
ARM: nommu: change memory reserve for the vectors

Vladimir Murzin (1):
ARM: domain: move {set,get}_domain under config guard

Quoted 7 lines
Quoted 5 lines
 arch/arm/include/asm/domain.h |   11 +++++++++++
 arch/arm/kernel/head-nommu.S  |    2 +-
 arch/arm/mm/nommu.c           |   15 ++++++++-------
 3 files changed, 20 insertions(+), 8 deletions(-)

Russell, any objection to get it into patch tracker?

I've not had any chance to look at them yet - last weekend, I was away from Thursday through until late Tuesday, then I spent most of Wednesday and Thursday catching up. Friday I was able to look at some stuff, and then I've spent the bank holiday weekend digging out laurels in the front garden. I've only just today got back to looking at some kernel stuff.

So really, I've only had two days in the last week and a half to look at anything.

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

Please wait a little while longer. Thanks.

Thanks for prompt reply! I wasn't aware you've been off, patches can wait.

Thanks for waiting, I've now looked through them and they look fine to me.

Please put them in the patch system, thanks.

Thanks for your time! Patches in the patch system now.

Cheers
Vladimir