Skip to contentSkip to conversation

Updated Cortex-M3 series

PATCH Superseded Uwe Kleine-König 7 participants 20 messages Aug 3, 2012 – Oct 17, 2012

Subsystems (2)

v6 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

v6 cover Updated Cortex-M3 series

Hello,

the only changes compared to v5 (sent starting with Message-id:
1341512035-8173-1-git-send-email-u.kleine-koenig at pengutronix.de) are that several debug pr_infos were dropped that I missed to remove before. Thanks to Will Deacon for pointing out that problem. Furthermore I rebased (trivially) to v3.5.

Best regards
Uwe

Catalin Marinas (1):
Cortex-M3: Add base support for Cortex-M3

Uwe Kleine-K?nig (2):
ARM: make cr_alignment read-only #ifndef CONFIG_CPU_CP15
Cortex-M3: Add support for exception handling

 arch/arm/include/asm/assembler.h   |   13 ++-
 arch/arm/include/asm/cp15.h        |   11 ++-
 arch/arm/include/asm/cputype.h     |    3 +
 arch/arm/include/asm/glue-cache.h  |   24 ++++++
 arch/arm/include/asm/glue-df.h     |    8 ++
 arch/arm/include/asm/glue-proc.h   |    9 ++
 arch/arm/include/asm/irqflags.h    |   22 +++--
 arch/arm/include/asm/processor.h   |    7 ++
 arch/arm/include/asm/ptrace.h      |   44 ++++++++--
 arch/arm/include/asm/system_info.h |    1 +
 arch/arm/kernel/asm-offsets.c      |    3 +
 arch/arm/kernel/entry-common.S     |    4 +
 arch/arm/kernel/entry-header.S     |  148 +++++++++++++++++++++++++++++++++
 arch/arm/kernel/entry-v7m.S        |  134 ++++++++++++++++++++++++++++++
 arch/arm/kernel/head-common.S      |    9 +-
 arch/arm/kernel/head-nommu.S       |    9 +-
 arch/arm/kernel/process.c          |    8 ++
 arch/arm/kernel/ptrace.c           |    3 +
 arch/arm/kernel/setup.c            |   13 ++-
 arch/arm/kernel/traps.c            |    2 +
 arch/arm/mm/alignment.c            |    2 +
 arch/arm/mm/mmu.c                  |   17 ++++
 arch/arm/mm/nommu.c                |    2 +
 arch/arm/mm/proc-v7m.S             |  161 ++++++++++++++++++++++++++++++++++++
 24 files changed, 635 insertions(+), 22 deletions(-)
 create mode 100644 arch/arm/kernel/entry-v7m.S
 create mode 100644 arch/arm/mm/proc-v7m.S
Signature · 1 line
1.7.10.4
#1 lore raw

PATCH v6 1/3 ARM: make cr_alignment read-only #ifndef CONFIG_CPU_CP15

This makes cr_alignment a constant 0 to break code that tries to modify the value as it's likely that it's built on wrong assumption when CONFIG_CPU_CP15 isn't defined. For code that is only reading the value 0 is more or less a fine value to report.

Forwarded: id:1333573807-23709-1-git-send-email-u.kleine-koenig at pengutronix.de

---
 arch/arm/include/asm/cp15.h   |   11 ++++++++++-
 arch/arm/kernel/head-common.S |    9 +++++++--
 arch/arm/mm/alignment.c       |    2 ++
 arch/arm/mm/mmu.c             |   17 +++++++++++++++++
 4 files changed, 36 insertions(+), 3 deletions(-)
arch/arm/include/asm/cp15.h +10 -1
index 5ef4d80..d814435 100644
@@ -42,6 +42,8 @@
 #define vectors_high()	(0)
 #endif
 
+#ifdef CONFIG_CPU_CP15
+
 extern unsigned long cr_no_alignment;	/* defined in entry-armv.S */
 extern unsigned long cr_alignment;	/* defined in entry-armv.S */
 
@@ -82,6 +84,13 @@ static inline void set_copro_access(unsigned int val)
 	isb();
 }
 
-#endif
+#else /* ifdef CONFIG_CPU_CP15 */
+
+#define cr_no_alignment	UL(0)
+#define cr_alignment	UL(0)
+
+#endif /* ifdef CONFIG_CPU_CP15 / else */
+
+#endif /* ifndef __ASSEMBLY__ */
 
 #endif
arch/arm/kernel/head-common.S +7 -2
index 854bd22..2f560c5 100644
@@ -98,8 +98,9 @@ __mmap_switched:
 	str	r9, [r4]			@ Save processor ID
 	str	r1, [r5]			@ Save machine type
 	str	r2, [r6]			@ Save atags pointer
-	bic	r4, r0, #CR_A			@ Clear 'A' bit
-	stmia	r7, {r0, r4}			@ Save control register values
+	cmp	r7, #0
+	bicne	r4, r0, #CR_A			@ Clear 'A' bit
+	stmneia	r7, {r0, r4}			@ Save control register values
 	b	start_kernel
 ENDPROC(__mmap_switched)
 
@@ -113,7 +114,11 @@ __mmap_switched_data:
 	.long	processor_id			@ r4
 	.long	__machine_arch_type		@ r5
 	.long	__atags_pointer			@ r6
+#ifdef CONFIG_CPU_CP15
 	.long	cr_alignment			@ r7
+#else
+	.long	0
+#endif
 	.long	init_thread_union + THREAD_START_SP @ sp
 	.size	__mmap_switched_data, . - __mmap_switched_data
 
arch/arm/mm/alignment.c +2 -0
index 9107231..7df07d1 100644
@@ -962,12 +962,14 @@ static int __init alignment_init(void)
 		return -ENOMEM;
 #endif
 
+#ifdef CONFIG_CPU_CP15
 	if (cpu_is_v6_unaligned()) {
 		cr_alignment &= ~CR_A;
 		cr_no_alignment &= ~CR_A;
 		set_cr(cr_alignment);
 		ai_usermode = safe_usermode(ai_usermode, false);
 	}
+#endif
 
 	hook_fault_code(FAULT_CODE_ALIGNMENT, do_alignment, SIGBUS, BUS_ADRALN,
 			"alignment exception");
arch/arm/mm/mmu.c +17 -0
index cf4528d..7a390f2 100644
@@ -96,6 +96,7 @@ static struct cachepolicy cache_policies[] __initdata = {
 	}
 };
 
+#ifdef CONFIG_CPU_CP15
 /*
  * These are useful for identifying cache coherency
  * problems by allowing the cache or the cache and
@@ -194,6 +195,22 @@ void adjust_cr(unsigned long mask, unsigned long set)
 }
 #endif
 
+#else
+
+static int __init early_cachepolicy(char *p)
+{
+	pr_warning("cachepolicy kernel parameter not supported without cp15\n");
+}
+early_param("cachepolicy", early_cachepolicy);
+
+static int __init noalign_setup(char *__unused)
+{
+	pr_warning("noalign kernel parameter not supported without cp15\n");
+}
+__setup("noalign", noalign_setup);
+
+#endif
+
 #define PROT_PTE_DEVICE		L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY|L_PTE_XN
 #define PROT_SECT_DEVICE	PMD_TYPE_SECT|PMD_SECT_AP_WRITE
 
Signature · 1 line
1.7.10.4
#2 lore raw

PATCH v6 2/3 Cortex-M3: Add base support for Cortex-M3

In reply to Uwe Kleine-König

From: Catalin Marinas <[email protected]>

This patch adds the base support for the Cortex-M3 processor (ARMv7-M architecture). It consists of the corresponding arch/arm/mm/ files and various #ifdef's around the kernel. Exception handling is implemented by a subsequent patch.

[ukleinek: squash in some changes originating from commit

b5717ba (Cortex-M3: Add support for the Microcontroller Prototyping System)

from the v2.6.33-arm1 patch stack, port to post 3.4, drop zImage support, drop reorganisation of pt_regs, assert CONFIG_V7M doesn't leak into installed headers and a few cosmetic changes]

---
Changes since v4, id:1333573807-23709-2-git-send-email-u.kleine-koenig at pengutronix.de
- simplify irq enable/disable ops as suggested by Russell
- don't leak kernel config symbols into userspace headers and add some comments

---
 arch/arm/include/asm/assembler.h   |   13 ++-
 arch/arm/include/asm/cputype.h     |    3 +
 arch/arm/include/asm/glue-cache.h  |   24 ++++++
 arch/arm/include/asm/glue-df.h     |    8 ++
 arch/arm/include/asm/glue-proc.h   |    9 ++
 arch/arm/include/asm/irqflags.h    |   22 +++--
 arch/arm/include/asm/processor.h   |    7 ++
 arch/arm/include/asm/ptrace.h      |   44 ++++++++--
 arch/arm/include/asm/system_info.h |    1 +
 arch/arm/kernel/asm-offsets.c      |    3 +
 arch/arm/kernel/head-nommu.S       |    9 +-
 arch/arm/kernel/setup.c            |   13 ++-
 arch/arm/kernel/traps.c            |    2 +
 arch/arm/mm/nommu.c                |    2 +
 arch/arm/mm/proc-v7m.S             |  161 ++++++++++++++++++++++++++++++++++++
 15 files changed, 302 insertions(+), 19 deletions(-)
 create mode 100644 arch/arm/mm/proc-v7m.S
arch/arm/include/asm/assembler.h +12 -1
index 03fb936..705d108 100644
@@ -135,7 +135,11 @@
  * assumes FIQs are enabled, and that the processor is in SVC mode.
  */
 	.macro	save_and_disable_irqs, oldcpsr
+#ifdef CONFIG_CPU_V7M
+	mrs	\oldcpsr, primask
+#else
 	mrs	\oldcpsr, cpsr
+#endif
 	disable_irq
 	.endm
 
@@ -149,7 +153,11 @@
  * guarantee that this will preserve the flags.
  */
 	.macro	restore_irqs_notrace, oldcpsr
+#ifdef CONFIG_CPU_V7M
+	msr	primask, \oldcpsr
+#else
 	msr	cpsr_c, \oldcpsr
+#endif
 	.endm
 
 	.macro restore_irqs, oldcpsr
@@ -228,7 +236,10 @@
 #endif
 	.endm
 
-#ifdef CONFIG_THUMB2_KERNEL
+#if defined(CONFIG_CPU_V7M)
+	.macro	setmode, mode, reg
+	.endm
+#elif defined(CONFIG_THUMB2_KERNEL)
 	.macro	setmode, mode, reg
 	mov	\reg, #\mode
 	msr	cpsr_c, \reg
arch/arm/include/asm/cputype.h +3 -0
index cb47d28..5bd8cb6 100644
@@ -46,6 +46,9 @@ extern unsigned int processor_id;
 		    : "cc");						\
 		__val;							\
 	})
+#elif defined(CONFIG_CPU_V7M)
+#define read_cpuid(reg) (*(unsigned int *)0xe000ed00)
+#define read_cpuid_ext(reg) 0
 #else
 #define read_cpuid(reg) (processor_id)
 #define read_cpuid_ext(reg) 0
arch/arm/include/asm/glue-cache.h +24 -0
index 7e30874..a02fd01 100644
@@ -125,10 +125,34 @@
 //# endif
 #endif
 
+#if defined(CONFIG_CPU_V7M)
+# ifdef _CACHE
+#  error "Multi-cache not supported on ARMv7-M"
+# else
+#  define _CACHE nop
+# endif
+#endif
+
 #if !defined(_CACHE) && !defined(MULTI_CACHE)
 #error Unknown cache maintenance model
 #endif
 
+#ifndef __ASSEMBLER__
+static inline void nop_flush_icache_all(void) { }
+static inline void nop_flush_kern_cache_all(void) { }
+static inline void nop_flush_user_cache_all(void) { }
+static inline void nop_flush_user_cache_range(unsigned long a, unsigned long b, unsigned int c) { }
+
+static inline void nop_coherent_kern_range(unsigned long a, unsigned long b) { }
+static inline int nop_coherent_user_range(unsigned long a, unsigned long b) { return 0; }
+static inline void nop_flush_kern_dcache_area(void *a, size_t s) { }
+
+static inline void nop_dma_flush_range(const void *a, const void *b) { }
+
+static inline void nop_dma_map_area(const void *s, size_t l, int f) { }
+static inline void nop_dma_unmap_area(const void *s, size_t l, int f) { }
+#endif
+
 #ifndef MULTI_CACHE
 #define __cpuc_flush_icache_all		__glue(_CACHE,_flush_icache_all)
 #define __cpuc_flush_kern_all		__glue(_CACHE,_flush_kern_cache_all)
arch/arm/include/asm/glue-df.h +8 -0
index 8cacbcd..1f2339c 100644
@@ -95,6 +95,14 @@
 # endif
 #endif
 
+#ifdef CONFIG_CPU_ABRT_NOMMU
+# ifdef CPU_DABORT_HANDLER
+#  define MULTI_DABORT 1
+# else
+#  define CPU_DABORT_HANDLER nommu_early_abort
+# endif
+#endif
+
 #ifndef CPU_DABORT_HANDLER
 #error Unknown data abort handler type
 #endif
arch/arm/include/asm/glue-proc.h +9 -0
index ac1dd54..f2f39bc 100644
@@ -230,6 +230,15 @@
 # endif
 #endif
 
+#ifdef CONFIG_CPU_V7M
+# ifdef CPU_NAME
+#  undef  MULTI_CPU
+#  define MULTI_CPU
+# else
+#  define CPU_NAME cpu_v7m
+# endif
+#endif
+
 #ifndef MULTI_CPU
 #define cpu_proc_init			__glue(CPU_NAME,_proc_init)
 #define cpu_proc_fin			__glue(CPU_NAME,_proc_fin)
arch/arm/include/asm/irqflags.h +16 -6
index 1e6cca5..3b763d6 100644
@@ -8,6 +8,16 @@
 /*
  * CPU interrupt mask handling.
  */
+#ifdef CONFIG_CPU_V7M
+#define IRQMASK_REG_NAME_R "primask"
+#define IRQMASK_REG_NAME_W "primask"
+#define IRQMASK_I_BIT	1
+#else
+#define IRQMASK_REG_NAME_R "cpsr"
+#define IRQMASK_REG_NAME_W "cpsr_c"
+#define IRQMASK_I_BIT	PSR_I_BIT
+#endif
+
 #if __LINUX_ARM_ARCH__ >= 6
 
 static inline unsigned long arch_local_irq_save(void)
@@ -15,7 +25,7 @@ static inline unsigned long arch_local_irq_save(void)
 	unsigned long flags;
 
 	asm volatile(
-		"	mrs	%0, cpsr	@ arch_local_irq_save\n"
+		"	mrs	%0, " IRQMASK_REG_NAME_R "	@ arch_local_irq_save\n"
 		"	cpsid	i"
 		: "=r" (flags) : : "memory", "cc");
 	return flags;
@@ -129,7 +139,7 @@ static inline unsigned long arch_local_save_flags(void)
 {
 	unsigned long flags;
 	asm volatile(
-		"	mrs	%0, cpsr	@ local_save_flags"
+		"	mrs	%0, " IRQMASK_REG_NAME_R "	@ local_save_flags"
 		: "=r" (flags) : : "memory", "cc");
 	return flags;
 }
@@ -140,7 +150,7 @@ static inline unsigned long arch_local_save_flags(void)
 static inline void arch_local_irq_restore(unsigned long flags)
 {
 	asm volatile(
-		"	msr	cpsr_c, %0	@ local_irq_restore"
+		"	msr	" IRQMASK_REG_NAME_W ", %0	@ local_irq_restore"
 		:
 		: "r" (flags)
 		: "memory", "cc");
@@ -148,8 +158,8 @@ static inline void arch_local_irq_restore(unsigned long flags)
 
 static inline int arch_irqs_disabled_flags(unsigned long flags)
 {
-	return flags & PSR_I_BIT;
+	return flags & IRQMASK_I_BIT;
 }
 
-#endif
-#endif
+#endif /* ifdef __KERNEL__ */
+#endif /* ifndef __ASM_ARM_IRQFLAGS_H */
arch/arm/include/asm/processor.h +7 -0
index 99afa74..dc82aa0 100644
@@ -49,7 +49,14 @@ struct thread_struct {
 #ifdef CONFIG_MMU
 #define nommu_start_thread(regs) do { } while (0)
 #else
+#ifndef CONFIG_CPU_V7M
 #define nommu_start_thread(regs) regs->ARM_r10 = current->mm->start_data
+#else
+#define nommu_start_thread(regs) do {					\
+	regs->ARM_r10 = current->mm->start_data;			\
+	regs->ARM_EXC_RET = 0xfffffffdL;				\
+} while (0)
+#endif
 #endif
 
 #define start_thread(regs,pc,sp)					\
arch/arm/include/asm/ptrace.h +36 -8

88 lines not on this page · raw message

arch/arm/include/asm/system_info.h +1 -0
index dfd386d..720ea03 100644
@@ -11,6 +11,7 @@
 #define CPU_ARCH_ARMv5TEJ	7
 #define CPU_ARCH_ARMv6		8
 #define CPU_ARCH_ARMv7		9
+#define CPU_ARCH_ARMv7M		10
 
 #ifndef __ASSEMBLY__
 
arch/arm/kernel/asm-offsets.c +3 -0
index 1429d89..6f6b5b6 100644
@@ -91,6 +91,9 @@ int main(void)
   DEFINE(S_PC,			offsetof(struct pt_regs, ARM_pc));
   DEFINE(S_PSR,			offsetof(struct pt_regs, ARM_cpsr));
   DEFINE(S_OLD_R0,		offsetof(struct pt_regs, ARM_ORIG_r0));
+#ifdef CONFIG_CPU_V7M
+  DEFINE(S_EXC_RET,		offsetof(struct pt_regs, ARM_EXC_RET));
+#endif
   DEFINE(S_FRAME_SIZE,		sizeof(struct pt_regs));
   BLANK();
 #ifdef CONFIG_CACHE_L2X0
arch/arm/kernel/head-nommu.S +6 -3
index 278cfc1..c391c05 100644
@@ -44,10 +44,13 @@ ENTRY(stext)
 
 	setmode	PSR_F_BIT | PSR_I_BIT | SVC_MODE, r9 @ ensure svc mode
 						@ and irqs disabled
-#ifndef CONFIG_CPU_CP15
-	ldr	r9, =CONFIG_PROCESSOR_ID
-#else
+#if defined(CONFIG_CPU_CP15)
 	mrc	p15, 0, r9, c0, c0		@ get processor id
+#elif defined(CONFIG_CPU_V7M)
+	ldr	r9, =0xe000ed00			@ CPUID register address
+	ldr	r9, [r9]
+#else
+	ldr	r9, =CONFIG_PROCESSOR_ID
 #endif
 	bl	__lookup_processor_type		@ r5=procinfo r9=cpuid
 	movs	r10, r5				@ invalid processor (r5=0)?
arch/arm/kernel/setup.c +12 -1
index e15d83b..e80ccab 100644
@@ -135,7 +135,9 @@ struct stack {
 	u32 und[3];
 } ____cacheline_aligned;
 
+#ifndef CONFIG_CPU_V7M
 static struct stack stacks[NR_CPUS];
+#endif
 
 char elf_platform[ELF_PLATFORM_SIZE];
 EXPORT_SYMBOL(elf_platform);
@@ -215,7 +217,7 @@ static const char *proc_arch[] = {
 	"5TEJ",
 	"6TEJ",
 	"7",
-	"?(11)",
+	"7M",
 	"?(12)",
 	"?(13)",
 	"?(14)",
@@ -224,6 +226,12 @@ static const char *proc_arch[] = {
 	"?(17)",
 };
 
+#ifdef CONFIG_CPU_V7M
+static int __get_cpu_architecture(void)
+{
+	return CPU_ARCH_ARMv7M;
+}
+#else
 static int __get_cpu_architecture(void)
 {
 	int cpu_arch;
@@ -256,6 +264,7 @@ static int __get_cpu_architecture(void)
 
 	return cpu_arch;
 }
+#endif
 
 int __pure cpu_architecture(void)
 {
@@ -383,6 +392,7 @@ static void __init feat_v6_fixup(void)
  */
 void cpu_init(void)
 {
+#ifndef CONFIG_CPU_V7M
 	unsigned int cpu = smp_processor_id();
 	struct stack *stk = &stacks[cpu];
 
@@ -427,6 +437,7 @@ void cpu_init(void)
 	      "I" (offsetof(struct stack, und[0])),
 	      PLC (PSR_F_BIT | PSR_I_BIT | SVC_MODE)
 	    : "r14");
+#endif
 }
 
 int __cpu_logical_map[NR_CPUS];
arch/arm/kernel/traps.c +2 -0
index 3647170..7c62282 100644
@@ -792,6 +792,7 @@ static void __init kuser_get_tls_init(unsigned long vectors)
 
 void __init early_trap_init(void *vectors_base)
 {
+#ifndef CONFIG_CPU_V7M
 	unsigned long vectors = (unsigned long)vectors_base;
 	extern char __stubs_start[], __stubs_end[];
 	extern char __vectors_start[], __vectors_end[];
@@ -825,4 +826,5 @@ void __init early_trap_init(void *vectors_base)
 
 	flush_icache_range(vectors, vectors + PAGE_SIZE);
 	modify_domain(DOMAIN_USER, DOMAIN_CLIENT);
+#endif
 }
arch/arm/mm/nommu.c +2 -0
index d51225f..4bc8ae5 100644
@@ -20,12 +20,14 @@
 
 void __init arm_mm_memblock_reserve(void)
 {
+#ifndef CONFIG_CPU_V7M
 	/*
 	 * Register the exception vector page.
 	 * 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);
+#endif
 }
 
 void __init sanity_check_meminfo(void)
arch/arm/mm/proc-v7m.S new file +161 -0

161 lines not on this page · raw message

Signature · 1 line
1.7.10.4
#3 lore raw

PATCH v6 3/3 Cortex-M3: Add support for exception handling

In reply to Uwe Kleine-König

This patch implements the exception handling for the ARMv7-M architecture (pretty different from the A or R profiles).

It bases on work done earlier by Catalin for 2.6.33 but was nearly completely rewritten to use a pt_regs layout compatible to the A profile.

Forwarded: id:1333573807-23709-3-git-send-email-u.kleine-koenig at pengutronix.de

---
 arch/arm/kernel/entry-common.S |    4 ++
 arch/arm/kernel/entry-header.S |  148 ++++++++++++++++++++++++++++++++++++++++
 arch/arm/kernel/entry-v7m.S    |  134 ++++++++++++++++++++++++++++++++++++
 arch/arm/kernel/process.c      |    8 +++
 arch/arm/kernel/ptrace.c       |    3 +
 5 files changed, 297 insertions(+)
 create mode 100644 arch/arm/kernel/entry-v7m.S
arch/arm/kernel/entry-common.S +4 -0
index 4afed88..62c4db6 100644
@@ -341,6 +341,9 @@ ENDPROC(ftrace_stub)
 
 	.align	5
 ENTRY(vector_swi)
+#ifdef CONFIG_CPU_V7M
+	v7m_exception_entry
+#else
 	sub	sp, sp, #S_FRAME_SIZE
 	stmia	sp, {r0 - r12}			@ Calling r0 - r12
  ARM(	add	r8, sp, #S_PC		)
@@ -351,6 +354,7 @@ ENTRY(vector_swi)
 	str	lr, [sp, #S_PC]			@ Save calling PC
 	str	r8, [sp, #S_PSR]		@ Save CPSR
 	str	r0, [sp, #S_OLD_R0]		@ Save OLD_R0
+#endif
 	zero_fp
 
 	/*
arch/arm/kernel/entry-header.S +148 -0

166 lines not on this page · raw message

arch/arm/kernel/entry-v7m.S new file +134 -0

134 lines not on this page · raw message

arch/arm/kernel/process.c +8 -0
index 19c95ea6..204bbd0 100644
@@ -434,7 +434,11 @@ asm(	".pushsection .text\n"
 #ifdef CONFIG_TRACE_IRQFLAGS
 "	bl	trace_hardirqs_on\n"
 #endif
+#ifdef CONFIG_CPU_V7M
+"	msr	primask, r7\n"
+#else
 "	msr	cpsr_c, r7\n"
+#endif
 "	mov	r0, r4\n"
 "	mov	lr, r6\n"
 "	mov	pc, r5\n"
@@ -473,6 +477,10 @@ pid_t kernel_thread(int (*fn)(void *), void *arg, unsigned long flags)
 	regs.ARM_r7 = SVC_MODE | PSR_ENDSTATE | PSR_ISETSTATE;
 	regs.ARM_pc = (unsigned long)kernel_thread_helper;
 	regs.ARM_cpsr = regs.ARM_r7 | PSR_I_BIT;
+#if defined CONFIG_CPU_V7M
+	/* Return to Handler mode */
+	regs.ARM_EXC_RET = 0xfffffff1L;
+#endif
 
 	return do_fork(flags|CLONE_VM|CLONE_UNTRACED, 0, &regs, 0, NULL, NULL);
 }
arch/arm/kernel/ptrace.c +3 -0
index 14e3826..1f11ba2 100644
@@ -83,6 +83,9 @@ static const struct pt_regs_offset regoffset_table[] = {
 	REG_OFFSET_NAME(pc),
 	REG_OFFSET_NAME(cpsr),
 	REG_OFFSET_NAME(ORIG_r0),
+#ifdef CONFIG_CPU_V7M
+	REG_OFFSET_NAME(EXC_RET),
+#endif
 	REG_OFFSET_END,
 };
 
Signature · 1 line
1.7.10.4
#4 lore raw

v6 cover Updated Cortex-M3 series

In reply to Uwe Kleine-König
Quoted 7 lines · Uwe Kleine-K?nig

Hello,

the only changes compared to v5 (sent starting with Message-id:
1341512035-8173-1-git-send-email-u.kleine-koenig at pengutronix.de) are that several debug pr_infos were dropped that I missed to remove before. Thanks to Will Deacon for pointing out that problem. Furthermore I rebased (trivially) to v3.5.

No objections to the code from my side, but I'd like to understand the big picture here. You introduce a new CPU_V7M configuration symbol in the code, but there is no Kconfig change that introduces that symbol. Is that another change that is still coming?

None of the code seems to be specific to Cortex-M3 rather than the ARMv7M architecture. Does that mean it is expected to run unmodifed on both M3 and M4, and possibly future ARMv-7M cores?

Is it possible to build a NOMMU kernel that runs on both ARMv7-A amd ARMv7-M, in other words is ARMv7-M compatible with ARMv7-A (or ARMv7-R for that matter) if you don't use the MMU?

How does this relate to the ARMv6-M (Cortex-M0/M0+/M1) support that has been floating around [1]? Can we support both in the same kernel?

Arnd

[1] http://developer.petalogix.com/git/gitweb.cgi?p=linux-2.6.x-cortexm1.git;a=summary

#5 lore raw

v6 cover Updated Cortex-M3 series

Hello,

Quoted 9 lines · Arnd Bergmann
Quoted 7 lines · Uwe Kleine-K?nig

Hello,

the only changes compared to v5 (sent starting with Message-id:
1341512035-8173-1-git-send-email-u.kleine-koenig at pengutronix.de) are that several debug pr_infos were dropped that I missed to remove before. Thanks to Will Deacon for pointing out that problem. Furthermore I rebased (trivially) to v3.5.

Quoted 4 lines

No objections to the code from my side, but I'd like to understand the big picture here. You introduce a new CPU_V7M configuration symbol in the code, but there is no Kconfig change that introduces that symbol. Is that another change that is still coming?

I need to rework irq support which is up to now a seperate driver (nvic) but it should be possible to integrate it into the gic driver. With this patch I intend to send the Kconfig and Makefile stuff to make the code actually do something.

Quoted 3 lines

None of the code seems to be specific to Cortex-M3 rather than the ARMv7M architecture. Does that mean it is expected to run unmodifed on both M3 and M4, and possibly future ARMv-7M cores?

I'd expect to have M4 working out of the box. But as I don't have an M4 I cannot tell for sure.

Quoted 3 lines

Is it possible to build a NOMMU kernel that runs on both ARMv7-A amd ARMv7-M, in other words is ARMv7-M compatible with ARMv7-A (or ARMv7-R for that matter) if you don't use the MMU?

the instructions to enable and disable irqs are different, so we'd need another indirection at least there. Also the whole exception model is different. So I'd say it's too different to target for a common kernel for the A, R and M profiles.

Quoted 3 lines

How does this relate to the ARMv6-M (Cortex-M0/M0+/M1) support that has been floating around [1]? Can we support both in the same kernel?

I don't know M0/M1 but from a quick look at the tree you pointed out I'd say they look reasonably similar.

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
#6 lore raw

v6 cover Updated Cortex-M3 series

Hi Uwe,

Quoted 9 lines · Uwe Kleine-K?nig
Quoted 3 lines · Arnd Bergmann

Is it possible to build a NOMMU kernel that runs on both ARMv7-A amd ARMv7-M, in other words is ARMv7-M compatible with ARMv7-A (or ARMv7-R for that matter) if you don't use the MMU?

the instructions to enable and disable irqs are different, so we'd need another indirection at least there. Also the whole exception model is different. So I'd say it's too different to target for a common kernel for the A, R and M profiles.

We are using standard Linux kernel (v3.3) with MMU disabled on a Cortex R4 system.

--
regards
Shiraz

#7 lore raw

v6 cover Updated Cortex-M3 series

Hello,

Quoted 6 lines · Shiraz Hashim
Quoted 5 lines · Uwe Kleine-K?nig
Quoted 3 lines · Arnd Bergmann

Is it possible to build a NOMMU kernel that runs on both ARMv7-A amd ARMv7-M, in other words is ARMv7-M compatible with ARMv7-A (or ARMv7-R for that matter) if you don't use the MMU?

Quoted 7 lines
Quoted 4 lines

the instructions to enable and disable irqs are different, so we'd need another indirection at least there. Also the whole exception model is different. So I'd say it's too different to target for a common kernel for the A, R and M profiles.

We are using standard Linux kernel (v3.3) with MMU disabled on a Cortex R4 system.

Yeah, I expected A and R to be similar enough. It's the difference between (A+R) and M that makes a common kernel for all three profiles hard.

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
#8 lore raw

v6 cover Updated Cortex-M3 series

In reply to Uwe Kleine-König

On 03/08/12 15:50, Uwe Kleine-K?nig wrote:

...

Quoted 7 lines
Quoted 4 lines

How does this relate to the ARMv6-M (Cortex-M0/M0+/M1) support that has been floating around [1]? Can we support both in the same kernel?

I don't know M0/M1 but from a quick look at the tree you pointed out I'd say they look reasonably similar.

I'm not so sure - M0/M0+/M1 don't use Thumb-2, they're a slightly extended version of Thumb-1, which we don't support in the kernel...

For the curious, here are the relevant bits from the ARM ARMs

Quoted 1 line

From the ARM (v6-M) ARM A4.1 - about the instruction set:

"ARMv6-M supports the Thumb instruction set including a small number of 32-bit instructions introduced with Thumb-2 technology, see 32-bit Thumb instruction encoding on page A5-91. The 16-bit instruction support is equivalent to the Thumb instruction set support in ARMv6 prior to the introduction of Thumb-2 technology."

Whereas for V7-M, it says:
"supports a large number of 32-bit instructions that Thumb-2 technology introduced into the Thumb instruction set. Much of the functionality available is identical to the ARM instruction set supported alongside the Thumb instruction set in ARMv6T2 and other ARMv7 profiles"

Jonny

#9 lore raw

v6 cover Updated Cortex-M3 series

In reply to Uwe Kleine-König

Hello Russell,

Quoted 5 lines · Uwe Kleine-K?nig

the only changes compared to v5 (sent starting with Message-id:
1341512035-8173-1-git-send-email-u.kleine-koenig at pengutronix.de) are that several debug pr_infos were dropped that I missed to remove before. Thanks to Will Deacon for pointing out that problem. Furthermore I rebased (trivially) to v3.5.

Any feedback from your side? It would be great to get this in for 3.7 with some time in next before.

Thanks
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
#10 lore raw

v6 cover Updated Cortex-M3 series

Hello,

Quoted 8 lines · Uwe Kleine-K?nig
Quoted 5 lines · Uwe Kleine-K?nig

the only changes compared to v5 (sent starting with Message-id:
1341512035-8173-1-git-send-email-u.kleine-koenig at pengutronix.de) are that several debug pr_infos were dropped that I missed to remove before. Thanks to Will Deacon for pointing out that problem. Furthermore I rebased (trivially) to v3.5.

Any feedback from your side? It would be great to get this in for 3.7 with some time in next before.

What must happen to get some feed back? Is it worth to assert the stuff still works with 3.6-rc6?

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
#11 lore raw

v6 cover Updated Cortex-M3 series

Hi Uwe,

Quoted 9 lines · Uwe Kleine-K?nig

Hello,

Quoted 6 lines · Uwe Kleine-K?nig
Quoted 5 lines · Uwe Kleine-K?nig

the only changes compared to v5 (sent starting with Message-id:
1341512035-8173-1-git-send-email-u.kleine-koenig at pengutronix.de) are that several debug pr_infos were dropped that I missed to remove before. Thanks to Will Deacon for pointing out that problem. Furthermore I rebased (trivially) to v3.5.

Quoted 4 lines
Quoted 2 lines

Any feedback from your side? It would be great to get this in for 3.7 with some time in next before.

What must happen to get some feed back? Is it worth to assert the stuff still works with 3.6-rc6?

I hope to have a chance to look at these towards the end of the week...

Looking at the patch series at a very superficial level, I wonder why you've chosen not to include any Kconfig/NVIC support at this stage, especially as you've posted some before and there appears to be something (presumably) working in your efm32 branch...

It would be a shame to spend time on merging the basic support if there are issues that mean the interrupt support won't follow.

Jonny

#12 lore raw

v6 cover Updated Cortex-M3 series

Hello,

Quoted 15 lines · Jonathan Austin
Quoted 11 lines · Uwe Kleine-K?nig
Quoted 8 lines · Uwe Kleine-K?nig
Quoted 5 lines · Uwe Kleine-K?nig

the only changes compared to v5 (sent starting with Message-id:
1341512035-8173-1-git-send-email-u.kleine-koenig at pengutronix.de) are that several debug pr_infos were dropped that I missed to remove before. Thanks to Will Deacon for pointing out that problem. Furthermore I rebased (trivially) to v3.5.

Any feedback from your side? It would be great to get this in for 3.7 with some time in next before.

What must happen to get some feed back? Is it worth to assert the stuff still works with 3.6-rc6?

I hope to have a chance to look at these towards the end of the week...

Quoted 7 lines

Looking at the patch series at a very superficial level, I wonder why you've chosen not to include any Kconfig/NVIC support at this stage, especially as you've posted some before and there appears to be something (presumably) working in your efm32 branch...

It would be a shame to spend time on merging the basic support if there are issues that mean the interrupt support won't follow.

I plan to expand common/gic.c for interrupt support. Currently I don't do much though because getting feedback and the changes into mainline is quite hard and I don't want to spend time now and hear later that I did it wrong or something. So I put my efforts on hold and only ping from time to time. :-(

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
#13 lore raw

v6 cover Updated Cortex-M3 series

Hi Uwe,

Quoted 6 lines · Uwe Kleine-K?nig
Quoted 5 lines · Jonathan Austin

Looking at the patch series at a very superficial level, I wonder why you've chosen not to include any Kconfig/NVIC support at this stage, especially as you've posted some before and there appears to be something (presumably) working in your efm32 branch...

Quoted 7 lines
Quoted 2 lines

It would be a shame to spend time on merging the basic support if there are issues that mean the interrupt support won't follow.

I plan to expand common/gic.c for interrupt support. Currently I don't do much though because getting feedback and the changes into mainline is quite hard and I don't want to spend time now and hear later that I did it wrong or something. So I put my efforts on hold and only ping from time to time. :-(

My personal view is that merging the code without support for interrupts is fairly pointless, so the nvic code should certainly be included. I wouldn't worry too much about merging it with gic.c initially. That can come later, especially as we'll need to prise the gic into drivers/ at some point (it should be shared with arm64).

I think one reason for the lack of feedback is the inability for people to run this code themselves. I believe Jonny was trying to get started with an FPGA / simulation, but some hardware would be great if there's any available...

Cheers,

Will

#14 lore raw

v6 cover Updated Cortex-M3 series

Hi Will,

Quoted 15 lines · Will Deacon
Quoted 6 lines · Uwe Kleine-K?nig
Quoted 5 lines · Jonathan Austin

Looking at the patch series at a very superficial level, I wonder why you've chosen not to include any Kconfig/NVIC support at this stage, especially as you've posted some before and there appears to be something (presumably) working in your efm32 branch...

Quoted 7 lines
Quoted 2 lines

It would be a shame to spend time on merging the basic support if there are issues that mean the interrupt support won't follow.

I plan to expand common/gic.c for interrupt support. Currently I don't do much though because getting feedback and the changes into mainline is quite hard and I don't want to spend time now and hear later that I did it wrong or something. So I put my efforts on hold and only ping from time to time. :-(

Quoted 3 lines

My personal view is that merging the code without support for interrupts is fairly pointless, so the nvic code should certainly be included. I wouldn't worry too much about merging it with gic.c initially. That can come

That would be ok for me, too.

Quoted 6 lines

later, especially as we'll need to prise the gic into drivers/ at some point (it should be shared with arm64).

I think one reason for the lack of feedback is the inability for people to run this code themselves. I believe Jonny was trying to get started with an FPGA / simulation, but some hardware would be great if there's any available...

I think you can order the efm32 devboard[1] via the usual channels. I don't know if Energymicro has interest to give out some boards into the community at an reduced price. I will ask.

Best regards
Uwe

[1] http://www.energymicro.com/tools/efm32-giant-gecko-development-kit

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
#15 lore raw

v6 cover Updated Cortex-M3 series

Hello,

Quoted 16 lines · Uwe Kleine-K?nig
Quoted 15 lines · Will Deacon
Quoted 13 lines · Uwe Kleine-K?nig
Quoted 7 lines · Jonathan Austin

Looking at the patch series at a very superficial level, I wonder why you've chosen not to include any Kconfig/NVIC support at this stage, especially as you've posted some before and there appears to be something (presumably) working in your efm32 branch...

It would be a shame to spend time on merging the basic support if there are issues that mean the interrupt support won't follow.

I plan to expand common/gic.c for interrupt support. Currently I don't do much though because getting feedback and the changes into mainline is quite hard and I don't want to spend time now and hear later that I did it wrong or something. So I put my efforts on hold and only ping from time to time. :-(

Quoted 4 lines
Quoted 3 lines

My personal view is that merging the code without support for interrupts is fairly pointless, so the nvic code should certainly be included. I wouldn't worry too much about merging it with gic.c initially. That can come

That would be ok for me, too.

I thought about that again, and I think merging with hacked irq support isn't good. Note that even when the irq support goes in you still need several patches to support an M3 platform. So one more patch in the private queue doesn't hurt IMHO.

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
#16 lore raw

new branch for linux-next [Was: [PATCH v6 0/3] Updated Cortex-M3 series]

In reply to Uwe Kleine-König

Hello Stephen,

I already tried several times to get feedback from Russell King (as you probably know he's the ARM maintainer and busy most of the time) for my series to support Cortex-M3 machines. As I think the outcome will probably (at least) be that it should be included in next for some time first (as for example Arnd Bergmann already suggested), can you please add

	git://git.pengutronix.de/git/ukl/linux-2.6.git for-next

to your tree? I'd suggest adding it after arm and arm-soc. I intend to use this branch later for efm32 support (which depends on the Cortex-M3 stuff).

Currently the branch is still empty, but I intend to fill it with what I consider to be applyable after I did some more testing. (Mainly to assert it still does what it did when I developed it on an older base.)

@Russell: I hope this is OK for you. If not, I'm sure you'll protest.

Thanks
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
#17 lore raw

new branch for linux-next [Was: [PATCH v6 0/3] Updated Cortex-M3 series]

Quoted 15 lines · Uwe Kleine-K?nig

Hello Stephen,

I already tried several times to get feedback from Russell King (as you probably know he's the ARM maintainer and busy most of the time) for my series to support Cortex-M3 machines. As I think the outcome will probably (at least) be that it should be included in next for some time first (as for example Arnd Bergmann already suggested), can you please add

	git://git.pengutronix.de/git/ukl/linux-2.6.git for-next

to your tree? I'd suggest adding it after arm and arm-soc. I intend to use this branch later for efm32 support (which depends on the Cortex-M3 stuff).

Quoted 5 lines

Currently the branch is still empty, but I intend to fill it with what I consider to be applyable after I did some more testing. (Mainly to assert it still does what it did when I developed it on an older base.)

@Russell: I hope this is OK for you. If not, I'm sure you'll protest.

Well, I think the patches are mostly fine but I do think more eyes are needed on them first. I heard today that some people will be looking at your Cortex M3 stuff, and hopefully that should move things forward.

#18 lore raw

new branch for linux-next [Was: [PATCH v6 0/3] Updated Cortex-M3 series]

Hi Uwe,

Quoted 20 lines · On Mon, 8 Oct 2012 16:47:00 +0100 Russell King - ARM Linux…
Quoted 18 lines · Uwe Kleine-K?nig

I already tried several times to get feedback from Russell King (as you probably know he's the ARM maintainer and busy most of the time) for my series to support Cortex-M3 machines. As I think the outcome will probably (at least) be that it should be included in next for some time first (as for example Arnd Bergmann already suggested), can you please add

	git://git.pengutronix.de/git/ukl/linux-2.6.git for-next

to your tree? I'd suggest adding it after arm and arm-soc. I intend to use this branch later for efm32 support (which depends on the Cortex-M3 stuff).

Currently the branch is still empty, but I intend to fill it with what I consider to be applyable after I did some more testing. (Mainly to assert it still does what it did when I developed it on an older base.)

Quoted 5 lines
Quoted 1 line

@Russell: I hope this is OK for you. If not, I'm sure you'll protest.

Well, I think the patches are mostly fine but I do think more eyes are needed on them first. I heard today that some people will be looking at your Cortex M3 stuff, and hopefully that should move things forward.

I generally don't add new trees to linux-next during the merge window, so, if you don't hear from me that I have added it, please remind me about this after Linus releases v3.7-rc1.

Signature · 9 lines
Cheers,
Stephen Rothwell                    sfr at canb.auug.org.au
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20121012/290f4d2b/attachment.sig>
#19 lore raw

new branch for linux-next [Was: [PATCH v6 0/3] Updated Cortex-M3 series]

In reply to Uwe Kleine-König

Hi Uwe,

Quoted 14 lines · On Mon, 8 Oct 2012 17:43:25 +0200 Uwe Kleine-K?nig…

I already tried several times to get feedback from Russell King (as you probably know he's the ARM maintainer and busy most of the time) for my series to support Cortex-M3 machines. As I think the outcome will probably (at least) be that it should be included in next for some time first (as for example Arnd Bergmann already suggested), can you please add

	git://git.pengutronix.de/git/ukl/linux-2.6.git for-next

to your tree? I'd suggest adding it after arm and arm-soc. I intend to use this branch later for efm32 support (which depends on the Cortex-M3 stuff).

Quoted 5 lines

Currently the branch is still empty, but I intend to fill it with what I consider to be applyable after I did some more testing. (Mainly to assert it still does what it did when I developed it on an older base.)

@Russell: I hope this is OK for you. If not, I'm sure you'll protest.

Added from today.

Thanks for adding your subsystem tree as a participant of linux-next. As you may know, this is not a judgment of your code. The purpose of linux-next is for integration testing and to lower the impact of conflicts between subsystems in the next merge window.

You will need to ensure that the patches/commits in your tree/series have been:
* submitted under GPL v2 (or later) and include the Contributor's Signed-off-by,
* posted to the relevant mailing list,
* reviewed by you (or another maintainer of your subsystem tree),
* successfully unit tested, and
* destined for the current or next Linux merge window.

Basically, this should be just what you would send to Linus (or ask him to fetch). It is allowed to be rebased if you deem it necessary.

Signature · 22 lines
Cheers,
Stephen Rothwell 
sfr at canb.auug.org.au

Legal Stuff:
By participating in linux-next, your subsystem tree contributions are
public and will be included in the linux-next trees.  You may be sent
e-mail messages indicating errors or other issues when the
patches/commits from your subsystem tree are merged and tested in
linux-next.  These messages may also be cross-posted to the linux-next
mailing list, the linux-kernel mailing list, etc.  The linux-next tree
project and IBM (my employer) make no warranties regarding the linux-next
project, the testing procedures, the results, the e-mails, etc.  If you
don't agree to these ground rules, let me know and I'll remove your tree
from participation in linux-next.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20121016/e15a9a13/attachment.sig>