All of lore.kernel.org
 help / color / mirror / Atom feed
* New big-endian patch series against 3.12-rc4
@ 2013-10-08 22:34 Ben Dooks
  2013-10-08 22:34 ` [PATCH 01/23] ARM: fix ARCH_IXP4xx usage of ARCH_SUPPORTS_BIG_ENDIAN Ben Dooks
                   ` (26 more replies)
  0 siblings, 27 replies; 41+ messages in thread
From: Ben Dooks @ 2013-10-08 22:34 UTC (permalink / raw)
  To: linux-arm-kernel

This is a new series for big-endian on ARM re-based onto 3.12-rc4
and updated with new patches from Victor to fix regressions since 3.11.

I have not been able to test this further than building it as I do not
currently have access to any hardware, however there where no big issues
when re-basing. Thanks to Marc Zyngier for pointing out the need for a
rebase.

The branch is at:

  git://git.baserock.org/delta/linux baserock/bjdooks/3.12-rc4/core

Russell, if possible could this go into -next and then if everything
I can issue a pull request for it.

Changes since last:

- Updated to 3.12-rc4 to be closer to mainline
- Added Victor's patches for CCI and TC2 boot
- Added Victor's patch for ASID extraction
- Updated Victor's patch with fix for building on older kernels

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

* [PATCH 01/23] ARM: fix ARCH_IXP4xx usage of ARCH_SUPPORTS_BIG_ENDIAN
  2013-10-08 22:34 New big-endian patch series against 3.12-rc4 Ben Dooks
@ 2013-10-08 22:34 ` Ben Dooks
  2013-10-08 22:34 ` [PATCH 02/23] ARM: asm: Add ARM_BE8() assembly helper Ben Dooks
                   ` (25 subsequent siblings)
  26 siblings, 0 replies; 41+ messages in thread
From: Ben Dooks @ 2013-10-08 22:34 UTC (permalink / raw)
  To: linux-arm-kernel

The Kconfig for arch/arm/mach-ixp4xx has a local definition
of ARCH_SUPPORTS_BIG_ENDIAN which could be used elsewhere.
This means that if IXP4xx is selected and this symbol is
selected eleswhere then an warning is produced.

Clean the following error up by making the symbol be
selected by the main ARCH_IXP4XX definition and have a
common definition in arch/arm/mm/Kconfig

warning: (ARCH_xxx) selects ARCH_SUPPORTS_BIG_ENDIAN which has unmet direct dependencies (ARCH_IXP4XX)
warning: (ARCH_xxx) selects ARCH_SUPPORTS_BIG_ENDIAN which has unmet direct dependencies (ARCH_IXP4XX)

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
---
 arch/arm/Kconfig             | 1 +
 arch/arm/mach-ixp4xx/Kconfig | 4 ----
 arch/arm/mm/Kconfig          | 6 ++++++
 3 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 1ad6fb6..f048e14 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -481,6 +481,7 @@ config ARCH_IXP4XX
 	bool "IXP4xx-based"
 	depends on MMU
 	select ARCH_HAS_DMA_SET_COHERENT_MASK
+	select ARCH_SUPPORTS_BIG_ENDIAN
 	select ARCH_REQUIRE_GPIOLIB
 	select CLKSRC_MMIO
 	select CPU_XSCALE
diff --git a/arch/arm/mach-ixp4xx/Kconfig b/arch/arm/mach-ixp4xx/Kconfig
index 30e1ebe..c342dc4 100644
--- a/arch/arm/mach-ixp4xx/Kconfig
+++ b/arch/arm/mach-ixp4xx/Kconfig
@@ -1,9 +1,5 @@
 if ARCH_IXP4XX
 
-config ARCH_SUPPORTS_BIG_ENDIAN
-	bool
-	default y
-
 menu "Intel IXP4xx Implementation Options"
 
 comment "IXP4xx Platforms"
diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig
index cd2c88e..1f8fed9 100644
--- a/arch/arm/mm/Kconfig
+++ b/arch/arm/mm/Kconfig
@@ -952,3 +952,9 @@ config ARCH_HAS_BARRIERS
 	help
 	  This option allows the use of custom mandatory barriers
 	  included via the mach/barriers.h file.
+
+config ARCH_SUPPORTS_BIG_ENDIAN
+	bool
+	help
+	  This option specifies the architecture can support big endian
+	  operation.
-- 
1.8.4.rc3

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

* [PATCH 02/23] ARM: asm: Add ARM_BE8() assembly helper
  2013-10-08 22:34 New big-endian patch series against 3.12-rc4 Ben Dooks
  2013-10-08 22:34 ` [PATCH 01/23] ARM: fix ARCH_IXP4xx usage of ARCH_SUPPORTS_BIG_ENDIAN Ben Dooks
@ 2013-10-08 22:34 ` Ben Dooks
  2013-10-08 22:34 ` [PATCH 03/23] ARM: fixup_pv_table bug when CPU_ENDIAN_BE8 Ben Dooks
                   ` (24 subsequent siblings)
  26 siblings, 0 replies; 41+ messages in thread
From: Ben Dooks @ 2013-10-08 22:34 UTC (permalink / raw)
  To: linux-arm-kernel

Add ARM_BE8() helper to wrap any code conditional on being
compile when CONFIG_ARM_ENDIAN_BE8 is selected and convert
existing places where this is to use it.

Acked-by: Nicolas Pitre <nico@linaro.org>
Reviewed-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
---
 arch/arm/boot/compressed/head.S  | 8 ++------
 arch/arm/include/asm/assembler.h | 7 +++++++
 arch/arm/kernel/entry-armv.S     | 5 ++---
 arch/arm/kernel/entry-common.S   | 4 +---
 arch/arm/mm/abort-ev6.S          | 5 ++---
 arch/arm/mm/proc-v6.S            | 4 +---
 arch/arm/mm/proc-v7.S            | 4 +---
 7 files changed, 16 insertions(+), 21 deletions(-)

diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S
index 75189f1..c912c2a 100644
--- a/arch/arm/boot/compressed/head.S
+++ b/arch/arm/boot/compressed/head.S
@@ -699,9 +699,7 @@ __armv4_mmu_cache_on:
 		mrc	p15, 0, r0, c1, c0, 0	@ read control reg
 		orr	r0, r0, #0x5000		@ I-cache enable, RR cache replacement
 		orr	r0, r0, #0x0030
-#ifdef CONFIG_CPU_ENDIAN_BE8
-		orr	r0, r0, #1 << 25	@ big-endian page tables
-#endif
+ ARM_BE8(	orr	r0, r0, #1 << 25 )	@ big-endian page tables
 		bl	__common_mmu_cache_on
 		mov	r0, #0
 		mcr	p15, 0, r0, c8, c7, 0	@ flush I,D TLBs
@@ -728,9 +726,7 @@ __armv7_mmu_cache_on:
 		orr	r0, r0, #1 << 22	@ U (v6 unaligned access model)
 						@ (needed for ARM1176)
 #ifdef CONFIG_MMU
-#ifdef CONFIG_CPU_ENDIAN_BE8
-		orr	r0, r0, #1 << 25	@ big-endian page tables
-#endif
+ ARM_BE8(	orr	r0, r0, #1 << 25 )	@ big-endian page tables
 		mrcne   p15, 0, r6, c2, c0, 2   @ read ttb control reg
 		orrne	r0, r0, #1		@ MMU enabled
 		movne	r1, #0xfffffffd		@ domain 0 = client
diff --git a/arch/arm/include/asm/assembler.h b/arch/arm/include/asm/assembler.h
index fcc1b5b..5c22851 100644
--- a/arch/arm/include/asm/assembler.h
+++ b/arch/arm/include/asm/assembler.h
@@ -53,6 +53,13 @@
 #define put_byte_3      lsl #0
 #endif
 
+/* Select code for any configuration running in BE8 mode */
+#ifdef CONFIG_CPU_ENDIAN_BE8
+#define ARM_BE8(code...) code
+#else
+#define ARM_BE8(code...)
+#endif
+
 /*
  * Data preload for architectures that support it
  */
diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
index 9cbe70c..55090fb 100644
--- a/arch/arm/kernel/entry-armv.S
+++ b/arch/arm/kernel/entry-armv.S
@@ -416,9 +416,8 @@ __und_usr:
 	bne	__und_usr_thumb
 	sub	r4, r2, #4			@ ARM instr@LR - 4
 1:	ldrt	r0, [r4]
-#ifdef CONFIG_CPU_ENDIAN_BE8
-	rev	r0, r0				@ little endian instruction
-#endif
+ ARM_BE8(rev	r0, r0)				@ little endian instruction
+
 	@ r0 = 32-bit ARM instruction which caused the exception
 	@ r2 = PC value for the following instruction (:= regs->ARM_pc)
 	@ r4 = PC value for the faulting instruction
diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S
index bc6bd96..a2dcafd 100644
--- a/arch/arm/kernel/entry-common.S
+++ b/arch/arm/kernel/entry-common.S
@@ -393,9 +393,7 @@ ENTRY(vector_swi)
 #else
  USER(	ldr	r10, [lr, #-4]		)	@ get SWI instruction
 #endif
-#ifdef CONFIG_CPU_ENDIAN_BE8
-	rev	r10, r10			@ little endian instruction
-#endif
+ ARM_BE8(rev	r10, r10)			@ little endian instruction
 
 #elif defined(CONFIG_AEABI)
 
diff --git a/arch/arm/mm/abort-ev6.S b/arch/arm/mm/abort-ev6.S
index 8074199..3815a82 100644
--- a/arch/arm/mm/abort-ev6.S
+++ b/arch/arm/mm/abort-ev6.S
@@ -38,9 +38,8 @@ ENTRY(v6_early_abort)
 	bne	do_DataAbort
 	bic	r1, r1, #1 << 11		@ clear bit 11 of FSR
 	ldr	r3, [r4]			@ read aborted ARM instruction
-#ifdef CONFIG_CPU_ENDIAN_BE8
-	rev	r3, r3
-#endif
+ ARM_BE8(rev	r3, r3)
+
 	do_ldrd_abort tmp=ip, insn=r3
 	tst	r3, #1 << 20			@ L = 0 -> write
 	orreq	r1, r1, #1 << 11		@ yes.
diff --git a/arch/arm/mm/proc-v6.S b/arch/arm/mm/proc-v6.S
index 1128064..45dc29f 100644
--- a/arch/arm/mm/proc-v6.S
+++ b/arch/arm/mm/proc-v6.S
@@ -220,9 +220,7 @@ __v6_setup:
 #endif /* CONFIG_MMU */
 	adr	r5, v6_crval
 	ldmia	r5, {r5, r6}
-#ifdef CONFIG_CPU_ENDIAN_BE8
-	orr	r6, r6, #1 << 25		@ big-endian page tables
-#endif
+ ARM_BE8(orr	r6, r6, #1 << 25)		@ big-endian page tables
 	mrc	p15, 0, r0, c1, c0, 0		@ read control register
 	bic	r0, r0, r5			@ clear bits them
 	orr	r0, r0, r6			@ set them
diff --git a/arch/arm/mm/proc-v7.S b/arch/arm/mm/proc-v7.S
index c63d9bd..60920f6 100644
--- a/arch/arm/mm/proc-v7.S
+++ b/arch/arm/mm/proc-v7.S
@@ -367,9 +367,7 @@ __v7_setup:
 #endif
 	adr	r5, v7_crval
 	ldmia	r5, {r5, r6}
-#ifdef CONFIG_CPU_ENDIAN_BE8
-	orr	r6, r6, #1 << 25		@ big-endian page tables
-#endif
+ ARM_BE8(orr	r6, r6, #1 << 25)		@ big-endian page tables
 #ifdef CONFIG_SWP_EMULATE
 	orr     r5, r5, #(1 << 10)              @ set SW bit in "clear"
 	bic     r6, r6, #(1 << 10)              @ clear it in "mmuset"
-- 
1.8.4.rc3

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

* [PATCH 03/23] ARM: fixup_pv_table bug when CPU_ENDIAN_BE8
  2013-10-08 22:34 New big-endian patch series against 3.12-rc4 Ben Dooks
  2013-10-08 22:34 ` [PATCH 01/23] ARM: fix ARCH_IXP4xx usage of ARCH_SUPPORTS_BIG_ENDIAN Ben Dooks
  2013-10-08 22:34 ` [PATCH 02/23] ARM: asm: Add ARM_BE8() assembly helper Ben Dooks
@ 2013-10-08 22:34 ` Ben Dooks
  2013-10-08 22:34 ` [PATCH 04/23] ARM: set BE8 if LE in head code Ben Dooks
                   ` (23 subsequent siblings)
  26 siblings, 0 replies; 41+ messages in thread
From: Ben Dooks @ 2013-10-08 22:34 UTC (permalink / raw)
  To: linux-arm-kernel

The fixup_pv_table assumes that the instructions are in the same
endian configuration as the data, but when the CPU is running in
BE8 the instructions stay in little-endian format.

Make sure if CONFIG_CPU_ENDIAN_BE8 is set that we do all the
alterations to the instructions taking in to account the LDR/STR
will be swapping the data endian-ness.

Since the code is only modifying a byte, we avoid dual-swapping
the data, and just change the bits we clear and ORR in (in the
case where the code is not thumb2).

For thumb2, we add the necessary rev16 instructions to ensure that
the instructions are processed in the correct format, as it was
easier than re-writing the code to contain a mask and shift.

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
Reviewed-by: Dave Martin <Dave.Martin@arm.com>
Tested-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
---
 arch/arm/kernel/head.S | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
index 2c7cc1e..9e5906c 100644
--- a/arch/arm/kernel/head.S
+++ b/arch/arm/kernel/head.S
@@ -582,8 +582,10 @@ __fixup_a_pv_table:
 	b	2f
 1:	add     r7, r3
 	ldrh	ip, [r7, #2]
+ARM_BE8(rev16	ip, ip)
 	and	ip, 0x8f00
 	orr	ip, r6	@ mask in offset bits 31-24
+ARM_BE8(rev16	ip, ip)
 	strh	ip, [r7, #2]
 2:	cmp	r4, r5
 	ldrcc	r7, [r4], #4	@ use branch for delay slot
@@ -592,8 +594,14 @@ __fixup_a_pv_table:
 #else
 	b	2f
 1:	ldr	ip, [r7, r3]
+#ifdef CONFIG_CPU_ENDIAN_BE8
+	@ in BE8, we load data in BE, but instructions still in LE
+	bic	ip, ip, #0xff000000
+	orr	ip, ip, r6, lsl#24
+#else
 	bic	ip, ip, #0x000000ff
 	orr	ip, ip, r6	@ mask in offset bits 31-24
+#endif
 	str	ip, [r7, r3]
 2:	cmp	r4, r5
 	ldrcc	r7, [r4], #4	@ use branch for delay slot
-- 
1.8.4.rc3

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

* [PATCH 04/23] ARM: set BE8 if LE in head code
  2013-10-08 22:34 New big-endian patch series against 3.12-rc4 Ben Dooks
                   ` (2 preceding siblings ...)
  2013-10-08 22:34 ` [PATCH 03/23] ARM: fixup_pv_table bug when CPU_ENDIAN_BE8 Ben Dooks
@ 2013-10-08 22:34 ` Ben Dooks
  2013-10-08 22:34 ` [PATCH 05/23] ARM: pl01x debug code endian fix Ben Dooks
                   ` (22 subsequent siblings)
  26 siblings, 0 replies; 41+ messages in thread
From: Ben Dooks @ 2013-10-08 22:34 UTC (permalink / raw)
  To: linux-arm-kernel

If we are booting in LE and compiled for BE8, then add code to
set the state to bE8. Since the instruction stream is always LE,
we do not need to do anything special to the instruction.

Also ensure that the secondary processors are started in the same mode.

Note, we do add about 20 bytes to the kernel image, but it seems easier
to do this than adding another configuration to change.

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
Reviewed-by: Dave Martin <Dave.Martin@arm.com>
Tested-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
---
 arch/arm/boot/compressed/head.S | 1 +
 arch/arm/kernel/head.S          | 4 ++++
 arch/arm/kernel/sleep.S         | 1 +
 3 files changed, 6 insertions(+)

diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S
index c912c2a..066b034 100644
--- a/arch/arm/boot/compressed/head.S
+++ b/arch/arm/boot/compressed/head.S
@@ -135,6 +135,7 @@ start:
 		.word	_edata			@ zImage end address
  THUMB(		.thumb			)
 1:
+ ARM_BE8(	setend	be )			@ go BE8 if compiled for BE8
 		mrs	r9, cpsr
 #ifdef CONFIG_ARM_VIRT_EXT
 		bl	__hyp_stub_install	@ get into SVC mode, reversibly
diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
index 9e5906c..a047acf 100644
--- a/arch/arm/kernel/head.S
+++ b/arch/arm/kernel/head.S
@@ -77,6 +77,7 @@
 
 	__HEAD
 ENTRY(stext)
+ ARM_BE8(setend	be )			@ ensure we are in BE8 mode
 
  THUMB(	adr	r9, BSYM(1f)	)	@ Kernel is always entered in ARM.
  THUMB(	bx	r9		)	@ If this is a Thumb-2 kernel,
@@ -352,6 +353,9 @@ ENTRY(secondary_startup)
 	 * the processor type - there is no need to check the machine type
 	 * as it has already been validated by the primary processor.
 	 */
+
+ ARM_BE8(setend	be)				@ ensure we are in BE8 mode
+
 #ifdef CONFIG_ARM_VIRT_EXT
 	bl	__hyp_stub_install_secondary
 #endif
diff --git a/arch/arm/kernel/sleep.S b/arch/arm/kernel/sleep.S
index db1536b..716343c 100644
--- a/arch/arm/kernel/sleep.S
+++ b/arch/arm/kernel/sleep.S
@@ -130,6 +130,7 @@ ENDPROC(cpu_resume_after_mmu)
 	.data
 	.align
 ENTRY(cpu_resume)
+ARM_BE8(setend be)			@ ensure we are in BE mode
 	mov	r1, #0
 	ALT_SMP(mrc p15, 0, r0, c0, c0, 5)
 	ALT_UP_B(1f)
-- 
1.8.4.rc3

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

* [PATCH 05/23] ARM: pl01x debug code endian fix
  2013-10-08 22:34 New big-endian patch series against 3.12-rc4 Ben Dooks
                   ` (3 preceding siblings ...)
  2013-10-08 22:34 ` [PATCH 04/23] ARM: set BE8 if LE in head code Ben Dooks
@ 2013-10-08 22:34 ` Ben Dooks
  2013-10-08 22:34 ` [PATCH 06/23] ARM: twd: data " Ben Dooks
                   ` (21 subsequent siblings)
  26 siblings, 0 replies; 41+ messages in thread
From: Ben Dooks @ 2013-10-08 22:34 UTC (permalink / raw)
  To: linux-arm-kernel

The PL01X debug code needs to take into account which endian mode the
processor is running in. If it is big-endian, ensure the data is swapped
appropriately.

Note, we could do this slightly more efficiently if we have an macro to
do the necessary swap for the bits used by test.

Reviewed-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
---
 arch/arm/include/debug/pl01x.S | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm/include/debug/pl01x.S b/arch/arm/include/debug/pl01x.S
index 37c6895b..92ef808 100644
--- a/arch/arm/include/debug/pl01x.S
+++ b/arch/arm/include/debug/pl01x.S
@@ -25,12 +25,14 @@
 
 		.macro	waituart,rd,rx
 1001:		ldr	\rd, [\rx, #UART01x_FR]
+ ARM_BE8(	rev	\rd, \rd )
 		tst	\rd, #UART01x_FR_TXFF
 		bne	1001b
 		.endm
 
 		.macro	busyuart,rd,rx
 1001:		ldr	\rd, [\rx, #UART01x_FR]
+ ARM_BE8(	rev	\rd, \rd )
 		tst	\rd, #UART01x_FR_BUSY
 		bne	1001b
 		.endm
-- 
1.8.4.rc3

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

* [PATCH 06/23] ARM: twd: data endian fix
  2013-10-08 22:34 New big-endian patch series against 3.12-rc4 Ben Dooks
                   ` (4 preceding siblings ...)
  2013-10-08 22:34 ` [PATCH 05/23] ARM: pl01x debug code endian fix Ben Dooks
@ 2013-10-08 22:34 ` Ben Dooks
  2013-10-08 22:34 ` [PATCH 07/23] ARM: smp_scu: data endian fixes Ben Dooks
                   ` (20 subsequent siblings)
  26 siblings, 0 replies; 41+ messages in thread
From: Ben Dooks @ 2013-10-08 22:34 UTC (permalink / raw)
  To: linux-arm-kernel

Ensure the twd driver uses the correct calls to access the hardware
to ensure that we do not end up with data in the wrong endian format.

Reviewed-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
---
 arch/arm/kernel/smp_twd.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/arch/arm/kernel/smp_twd.c b/arch/arm/kernel/smp_twd.c
index 2985c9f..6591e26 100644
--- a/arch/arm/kernel/smp_twd.c
+++ b/arch/arm/kernel/smp_twd.c
@@ -45,7 +45,7 @@ static void twd_set_mode(enum clock_event_mode mode,
 	case CLOCK_EVT_MODE_PERIODIC:
 		ctrl = TWD_TIMER_CONTROL_ENABLE | TWD_TIMER_CONTROL_IT_ENABLE
 			| TWD_TIMER_CONTROL_PERIODIC;
-		__raw_writel(DIV_ROUND_CLOSEST(twd_timer_rate, HZ),
+		writel_relaxed(DIV_ROUND_CLOSEST(twd_timer_rate, HZ),
 			twd_base + TWD_TIMER_LOAD);
 		break;
 	case CLOCK_EVT_MODE_ONESHOT:
@@ -58,18 +58,18 @@ static void twd_set_mode(enum clock_event_mode mode,
 		ctrl = 0;
 	}
 
-	__raw_writel(ctrl, twd_base + TWD_TIMER_CONTROL);
+	writel_relaxed(ctrl, twd_base + TWD_TIMER_CONTROL);
 }
 
 static int twd_set_next_event(unsigned long evt,
 			struct clock_event_device *unused)
 {
-	unsigned long ctrl = __raw_readl(twd_base + TWD_TIMER_CONTROL);
+	unsigned long ctrl = readl_relaxed(twd_base + TWD_TIMER_CONTROL);
 
 	ctrl |= TWD_TIMER_CONTROL_ENABLE;
 
-	__raw_writel(evt, twd_base + TWD_TIMER_COUNTER);
-	__raw_writel(ctrl, twd_base + TWD_TIMER_CONTROL);
+	writel_relaxed(evt, twd_base + TWD_TIMER_COUNTER);
+	writel_relaxed(ctrl, twd_base + TWD_TIMER_CONTROL);
 
 	return 0;
 }
@@ -82,8 +82,8 @@ static int twd_set_next_event(unsigned long evt,
  */
 static int twd_timer_ack(void)
 {
-	if (__raw_readl(twd_base + TWD_TIMER_INTSTAT)) {
-		__raw_writel(1, twd_base + TWD_TIMER_INTSTAT);
+	if (readl_relaxed(twd_base + TWD_TIMER_INTSTAT)) {
+		writel_relaxed(1, twd_base + TWD_TIMER_INTSTAT);
 		return 1;
 	}
 
@@ -211,15 +211,15 @@ static void twd_calibrate_rate(void)
 		waitjiffies += 5;
 
 				 /* enable, no interrupt or reload */
-		__raw_writel(0x1, twd_base + TWD_TIMER_CONTROL);
+		writel_relaxed(0x1, twd_base + TWD_TIMER_CONTROL);
 
 				 /* maximum value */
-		__raw_writel(0xFFFFFFFFU, twd_base + TWD_TIMER_COUNTER);
+		writel_relaxed(0xFFFFFFFFU, twd_base + TWD_TIMER_COUNTER);
 
 		while (get_jiffies_64() < waitjiffies)
 			udelay(10);
 
-		count = __raw_readl(twd_base + TWD_TIMER_COUNTER);
+		count = readl_relaxed(twd_base + TWD_TIMER_COUNTER);
 
 		twd_timer_rate = (0xFFFFFFFFU - count) * (HZ / 5);
 
@@ -277,7 +277,7 @@ static void twd_timer_setup(void)
 	 * bother with the below.
 	 */
 	if (per_cpu(percpu_setup_called, cpu)) {
-		__raw_writel(0, twd_base + TWD_TIMER_CONTROL);
+		writel_relaxed(0, twd_base + TWD_TIMER_CONTROL);
 		clockevents_register_device(clk);
 		enable_percpu_irq(clk->irq, 0);
 		return;
@@ -290,7 +290,7 @@ static void twd_timer_setup(void)
 	 * The following is done once per CPU the first time .setup() is
 	 * called.
 	 */
-	__raw_writel(0, twd_base + TWD_TIMER_CONTROL);
+	writel_relaxed(0, twd_base + TWD_TIMER_CONTROL);
 
 	clk->name = "local_timer";
 	clk->features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT |
-- 
1.8.4.rc3

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

* [PATCH 07/23] ARM: smp_scu: data endian fixes
  2013-10-08 22:34 New big-endian patch series against 3.12-rc4 Ben Dooks
                   ` (5 preceding siblings ...)
  2013-10-08 22:34 ` [PATCH 06/23] ARM: twd: data " Ben Dooks
@ 2013-10-08 22:34 ` Ben Dooks
  2013-10-08 22:34 ` [PATCH 08/23] ARM: highbank: enable big-endian Ben Dooks
                   ` (19 subsequent siblings)
  26 siblings, 0 replies; 41+ messages in thread
From: Ben Dooks @ 2013-10-08 22:34 UTC (permalink / raw)
  To: linux-arm-kernel

The smp_scu driver needs to use the relaxed readl/write accessors
to avoid any issues with the endian mode the processor core is in.

Reviewed-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
---
 arch/arm/kernel/smp_scu.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/arch/arm/kernel/smp_scu.c b/arch/arm/kernel/smp_scu.c
index 5bc1a63..1aafa0d 100644
--- a/arch/arm/kernel/smp_scu.c
+++ b/arch/arm/kernel/smp_scu.c
@@ -28,7 +28,7 @@
  */
 unsigned int __init scu_get_core_count(void __iomem *scu_base)
 {
-	unsigned int ncores = __raw_readl(scu_base + SCU_CONFIG);
+	unsigned int ncores = readl_relaxed(scu_base + SCU_CONFIG);
 	return (ncores & 0x03) + 1;
 }
 
@@ -42,19 +42,19 @@ void scu_enable(void __iomem *scu_base)
 #ifdef CONFIG_ARM_ERRATA_764369
 	/* Cortex-A9 only */
 	if ((read_cpuid_id() & 0xff0ffff0) == 0x410fc090) {
-		scu_ctrl = __raw_readl(scu_base + 0x30);
+		scu_ctrl = readl_relaxed(scu_base + 0x30);
 		if (!(scu_ctrl & 1))
-			__raw_writel(scu_ctrl | 0x1, scu_base + 0x30);
+			writel_relaxed(scu_ctrl | 0x1, scu_base + 0x30);
 	}
 #endif
 
-	scu_ctrl = __raw_readl(scu_base + SCU_CTRL);
+	scu_ctrl = readl_relaxed(scu_base + SCU_CTRL);
 	/* already enabled? */
 	if (scu_ctrl & 1)
 		return;
 
 	scu_ctrl |= 1;
-	__raw_writel(scu_ctrl, scu_base + SCU_CTRL);
+	writel_relaxed(scu_ctrl, scu_base + SCU_CTRL);
 
 	/*
 	 * Ensure that the data accessed by CPU0 before the SCU was
@@ -80,9 +80,9 @@ int scu_power_mode(void __iomem *scu_base, unsigned int mode)
 	if (mode > 3 || mode == 1 || cpu > 3)
 		return -EINVAL;
 
-	val = __raw_readb(scu_base + SCU_CPU_STATUS + cpu) & ~0x03;
+	val = readb_relaxed(scu_base + SCU_CPU_STATUS + cpu) & ~0x03;
 	val |= mode;
-	__raw_writeb(val, scu_base + SCU_CPU_STATUS + cpu);
+	writeb_relaxed(val, scu_base + SCU_CPU_STATUS + cpu);
 
 	return 0;
 }
-- 
1.8.4.rc3

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

* [PATCH 08/23] ARM: highbank: enable big-endian
  2013-10-08 22:34 New big-endian patch series against 3.12-rc4 Ben Dooks
                   ` (6 preceding siblings ...)
  2013-10-08 22:34 ` [PATCH 07/23] ARM: smp_scu: data endian fixes Ben Dooks
@ 2013-10-08 22:34 ` Ben Dooks
  2013-10-08 22:34 ` [PATCH 09/23] ARM: mvebu: support running big-endian Ben Dooks
                   ` (18 subsequent siblings)
  26 siblings, 0 replies; 41+ messages in thread
From: Ben Dooks @ 2013-10-08 22:34 UTC (permalink / raw)
  To: linux-arm-kernel

Apart from a xgmac driver issue, the highbank seems to work correctly in
big-endian mode. Allow the selection of big-endian in the system.

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
Acked-by: Rob Herring <rob.herring@calxeda.com>
---
 arch/arm/mach-highbank/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/mach-highbank/Kconfig b/arch/arm/mach-highbank/Kconfig
index 8e8437d..3c3bff7 100644
--- a/arch/arm/mach-highbank/Kconfig
+++ b/arch/arm/mach-highbank/Kconfig
@@ -4,6 +4,7 @@ config ARCH_HIGHBANK
 	select ARCH_HAS_CPUFREQ
 	select ARCH_HAS_HOLES_MEMORYMODEL
 	select ARCH_HAS_OPP
+	select ARCH_SUPPORTS_BIG_ENDIAN
 	select ARCH_WANT_OPTIONAL_GPIOLIB
 	select ARM_AMBA
 	select ARM_ERRATA_764369
-- 
1.8.4.rc3

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

* [PATCH 09/23] ARM: mvebu: support running big-endian
  2013-10-08 22:34 New big-endian patch series against 3.12-rc4 Ben Dooks
                   ` (7 preceding siblings ...)
  2013-10-08 22:34 ` [PATCH 08/23] ARM: highbank: enable big-endian Ben Dooks
@ 2013-10-08 22:34 ` Ben Dooks
  2013-10-08 22:34 ` [PATCH 10/23] ARM: vexpress: add big endian support Ben Dooks
                   ` (17 subsequent siblings)
  26 siblings, 0 replies; 41+ messages in thread
From: Ben Dooks @ 2013-10-08 22:34 UTC (permalink / raw)
  To: linux-arm-kernel

Add indication we can run these cores in BE mode, and ensure that the
secondary CPU is set to big-endian mode in the initialisation code as
the initial code runs little-endian.

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
Tested-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Jason Cooper <jason@lakedaemon.net>
---
 arch/arm/mach-mvebu/Kconfig        | 1 +
 arch/arm/mach-mvebu/coherency_ll.S | 3 +++
 arch/arm/mach-mvebu/headsmp.S      | 4 ++++
 3 files changed, 8 insertions(+)

diff --git a/arch/arm/mach-mvebu/Kconfig b/arch/arm/mach-mvebu/Kconfig
index 9eb63d7..5e269d7 100644
--- a/arch/arm/mach-mvebu/Kconfig
+++ b/arch/arm/mach-mvebu/Kconfig
@@ -1,5 +1,6 @@
 config ARCH_MVEBU
 	bool "Marvell SOCs with Device Tree support" if ARCH_MULTI_V7
+	select ARCH_SUPPORTS_BIG_ENDIAN
 	select CLKSRC_MMIO
 	select COMMON_CLK
 	select GENERIC_CLOCKEVENTS
diff --git a/arch/arm/mach-mvebu/coherency_ll.S b/arch/arm/mach-mvebu/coherency_ll.S
index 5476669..ee7598f 100644
--- a/arch/arm/mach-mvebu/coherency_ll.S
+++ b/arch/arm/mach-mvebu/coherency_ll.S
@@ -20,6 +20,8 @@
 #define ARMADA_XP_CFB_CTL_REG_OFFSET 0x0
 #define ARMADA_XP_CFB_CFG_REG_OFFSET 0x4
 
+#include <asm/assembler.h>
+
 	.text
 /*
  * r0: Coherency fabric base register address
@@ -29,6 +31,7 @@ ENTRY(ll_set_cpu_coherent)
 	/* Create bit by cpu index */
 	mov	r3, #(1 << 24)
 	lsl	r1, r3, r1
+ARM_BE8(rev	r1, r1)
 
 	/* Add CPU to SMP group - Atomic */
 	add	r3, r0, #ARMADA_XP_CFB_CTL_REG_OFFSET
diff --git a/arch/arm/mach-mvebu/headsmp.S b/arch/arm/mach-mvebu/headsmp.S
index 8a1b0c9..3dd80df4 100644
--- a/arch/arm/mach-mvebu/headsmp.S
+++ b/arch/arm/mach-mvebu/headsmp.S
@@ -21,12 +21,16 @@
 #include <linux/linkage.h>
 #include <linux/init.h>
 
+#include <asm/assembler.h>
+
 /*
  * Armada XP specific entry point for secondary CPUs.
  * We add the CPU to the coherency fabric and then jump to secondary
  * startup
  */
 ENTRY(armada_xp_secondary_startup)
+ ARM_BE8(setend	be )			@ go BE8 if entered LE
+
 	/* Get coherency fabric base physical address */
 	adr	r0, 1f
 	ldr	r1, [r0]
-- 
1.8.4.rc3

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

* [PATCH 10/23] ARM: vexpress: add big endian support
  2013-10-08 22:34 New big-endian patch series against 3.12-rc4 Ben Dooks
                   ` (8 preceding siblings ...)
  2013-10-08 22:34 ` [PATCH 09/23] ARM: mvebu: support running big-endian Ben Dooks
@ 2013-10-08 22:34 ` Ben Dooks
  2013-10-08 22:34 ` [PATCH 11/23] ARM: alignment: correctly decode instructions in BE8 mode Ben Dooks
                   ` (16 subsequent siblings)
  26 siblings, 0 replies; 41+ messages in thread
From: Ben Dooks @ 2013-10-08 22:34 UTC (permalink / raw)
  To: linux-arm-kernel

Add support for the versatile express systems to boot big-endian.

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
---
 arch/arm/mach-vexpress/Kconfig    | 1 +
 arch/arm/plat-versatile/headsmp.S | 2 ++
 2 files changed, 3 insertions(+)

diff --git a/arch/arm/mach-vexpress/Kconfig b/arch/arm/mach-vexpress/Kconfig
index 3657954..4fe8ebe 100644
--- a/arch/arm/mach-vexpress/Kconfig
+++ b/arch/arm/mach-vexpress/Kconfig
@@ -1,6 +1,7 @@
 config ARCH_VEXPRESS
 	bool "ARM Ltd. Versatile Express family" if ARCH_MULTI_V7
 	select ARCH_REQUIRE_GPIOLIB
+	select ARCH_SUPPORTS_BIG_ENDIAN
 	select ARM_AMBA
 	select ARM_GIC
 	select ARM_TIMER_SP804
diff --git a/arch/arm/plat-versatile/headsmp.S b/arch/arm/plat-versatile/headsmp.S
index 2677bc3..40f27e5 100644
--- a/arch/arm/plat-versatile/headsmp.S
+++ b/arch/arm/plat-versatile/headsmp.S
@@ -10,6 +10,7 @@
  */
 #include <linux/linkage.h>
 #include <linux/init.h>
+#include <asm/assembler.h>
 
 /*
  * Realview/Versatile Express specific entry point for secondary CPUs.
@@ -17,6 +18,7 @@
  * until we're ready for them to initialise.
  */
 ENTRY(versatile_secondary_startup)
+ ARM_BE8(setend	be)
 	mrc	p15, 0, r0, c0, c0, 5
 	bic	r0, #0xff000000
 	adr	r4, 1f
-- 
1.8.4.rc3

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

* [PATCH 11/23] ARM: alignment: correctly decode instructions in BE8 mode.
  2013-10-08 22:34 New big-endian patch series against 3.12-rc4 Ben Dooks
                   ` (9 preceding siblings ...)
  2013-10-08 22:34 ` [PATCH 10/23] ARM: vexpress: add big endian support Ben Dooks
@ 2013-10-08 22:34 ` Ben Dooks
  2013-10-08 22:34 ` [PATCH 12/23] ARM: traps: use <asm/opcodes.h> to get correct instruction order Ben Dooks
                   ` (15 subsequent siblings)
  26 siblings, 0 replies; 41+ messages in thread
From: Ben Dooks @ 2013-10-08 22:34 UTC (permalink / raw)
  To: linux-arm-kernel

If we are in BE8 mode, we must deal with the instruction stream being
in LE order when data is being loaded in BE order. Ensure the data is
swapped before processing to avoid thre following:

Change to using <asm/opcodes.h> to provide the necessary conversion
functions to change the byte ordering.

This stops the following warning messages from the kernel on a fault:

Unhandled fault: alignment exception (0x001) at 0xbfa09567
Alignment trap: not handling instruction 030091e8 at [<80333e8c>]

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
Reviewed-by: Dave Martin <Dave.Martin@arm.com>
Tested-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
---
 arch/arm/mm/alignment.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mm/alignment.c b/arch/arm/mm/alignment.c
index 6f4585b..9240364 100644
--- a/arch/arm/mm/alignment.c
+++ b/arch/arm/mm/alignment.c
@@ -25,6 +25,7 @@
 #include <asm/cp15.h>
 #include <asm/system_info.h>
 #include <asm/unaligned.h>
+#include <asm/opcodes.h>
 
 #include "fault.h"
 
@@ -762,21 +763,25 @@ do_alignment(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
 	if (thumb_mode(regs)) {
 		u16 *ptr = (u16 *)(instrptr & ~1);
 		fault = probe_kernel_address(ptr, tinstr);
+		tinstr = __mem_to_opcode_thumb16(tinstr);
 		if (!fault) {
 			if (cpu_architecture() >= CPU_ARCH_ARMv7 &&
 			    IS_T32(tinstr)) {
 				/* Thumb-2 32-bit */
 				u16 tinst2 = 0;
 				fault = probe_kernel_address(ptr + 1, tinst2);
-				instr = (tinstr << 16) | tinst2;
+				tinst2 = __mem_to_opcode_thumb16(tinst2);
+				instr = __opcode_thumb32_compose(tinstr, tinst2);
 				thumb2_32b = 1;
 			} else {
 				isize = 2;
 				instr = thumb2arm(tinstr);
 			}
 		}
-	} else
+	} else {
 		fault = probe_kernel_address(instrptr, instr);
+		instr = __mem_to_opcode_arm(instr);
+	}
 
 	if (fault) {
 		type = TYPE_FAULT;
-- 
1.8.4.rc3

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

* [PATCH 12/23] ARM: traps: use <asm/opcodes.h> to get correct instruction order
  2013-10-08 22:34 New big-endian patch series against 3.12-rc4 Ben Dooks
                   ` (10 preceding siblings ...)
  2013-10-08 22:34 ` [PATCH 11/23] ARM: alignment: correctly decode instructions in BE8 mode Ben Dooks
@ 2013-10-08 22:34 ` Ben Dooks
  2013-10-09 11:42   ` Will Deacon
  2013-10-08 22:34 ` [PATCH 13/23] ARM: module: correctly relocate instructions in BE8 Ben Dooks
                   ` (14 subsequent siblings)
  26 siblings, 1 reply; 41+ messages in thread
From: Ben Dooks @ 2013-10-08 22:34 UTC (permalink / raw)
  To: linux-arm-kernel

The trap handler needs to take into account the endian configuration of
the system when loading instructions. Use <asm/opcodes.h> to provide the
necessary conversion functions.

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
Tested-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
---
 arch/arm/kernel/traps.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
index 8fcda14..caf96da 100644
--- a/arch/arm/kernel/traps.c
+++ b/arch/arm/kernel/traps.c
@@ -34,6 +34,7 @@
 #include <asm/unwind.h>
 #include <asm/tls.h>
 #include <asm/system_misc.h>
+#include <asm/opcodes.h>
 
 static const char *handler[]= { "prefetch abort", "data abort", "address exception", "interrupt" };
 
@@ -402,25 +403,28 @@ asmlinkage void __exception do_undefinstr(struct pt_regs *regs)
 	if (processor_mode(regs) == SVC_MODE) {
 #ifdef CONFIG_THUMB2_KERNEL
 		if (thumb_mode(regs)) {
-			instr = ((u16 *)pc)[0];
+			instr = __mem_to_opcode_thumb16(((u16 *)pc)[0]);
 			if (is_wide_instruction(instr)) {
-				instr <<= 16;
-				instr |= ((u16 *)pc)[1];
+				u16 inst2;
+				inst2 = __mem_to_opcode_thumb16(((u16 *)pc)[1]);
+				instr = __opcode_thumb32_compose(instr, inst2);
 			}
 		} else
 #endif
-			instr = *(u32 *) pc;
+			instr = __mem_to_opcode_arm(*(u32 *) pc);
 	} else if (thumb_mode(regs)) {
 		if (get_user(instr, (u16 __user *)pc))
 			goto die_sig;
+		instr = __mem_to_opcode_thumb16(instr);
 		if (is_wide_instruction(instr)) {
 			unsigned int instr2;
 			if (get_user(instr2, (u16 __user *)pc+1))
 				goto die_sig;
-			instr <<= 16;
-			instr |= instr2;
+			instr2 = __mem_to_opcode_thumb16(instr2);
+			instr = __opcode_thumb32_compose(instr, instr2);
 		}
 	} else if (get_user(instr, (u32 __user *)pc)) {
+		instr = __mem_to_opcode_arm(instr);
 		goto die_sig;
 	}
 
-- 
1.8.4.rc3

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

* [PATCH 13/23] ARM: module: correctly relocate instructions in BE8
  2013-10-08 22:34 New big-endian patch series against 3.12-rc4 Ben Dooks
                   ` (11 preceding siblings ...)
  2013-10-08 22:34 ` [PATCH 12/23] ARM: traps: use <asm/opcodes.h> to get correct instruction order Ben Dooks
@ 2013-10-08 22:34 ` Ben Dooks
  2013-10-08 22:34 ` [PATCH 14/23] ARM: set --be8 when linking modules Ben Dooks
                   ` (13 subsequent siblings)
  26 siblings, 0 replies; 41+ messages in thread
From: Ben Dooks @ 2013-10-08 22:34 UTC (permalink / raw)
  To: linux-arm-kernel

When in BE8 mode, our instructions are not in the same ordering as the
data, so use <asm/opcodes.h> to take this into account.

Note, also requires modules to be built --be8

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
Reviewed-by: Dave Martin <Dave.Martin@arm.com>
---
 arch/arm/kernel/module.c | 57 +++++++++++++++++++++++++++++-------------------
 1 file changed, 34 insertions(+), 23 deletions(-)

diff --git a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c
index 084dc88..5fdb403 100644
--- a/arch/arm/kernel/module.c
+++ b/arch/arm/kernel/module.c
@@ -24,6 +24,7 @@
 #include <asm/sections.h>
 #include <asm/smp_plat.h>
 #include <asm/unwind.h>
+#include <asm/opcodes.h>
 
 #ifdef CONFIG_XIP_KERNEL
 /*
@@ -60,6 +61,7 @@ apply_relocate(Elf32_Shdr *sechdrs, const char *strtab, unsigned int symindex,
 		Elf32_Sym *sym;
 		const char *symname;
 		s32 offset;
+		u32 tmp;
 #ifdef CONFIG_THUMB2_KERNEL
 		u32 upper, lower, sign, j1, j2;
 #endif
@@ -95,7 +97,8 @@ apply_relocate(Elf32_Shdr *sechdrs, const char *strtab, unsigned int symindex,
 		case R_ARM_PC24:
 		case R_ARM_CALL:
 		case R_ARM_JUMP24:
-			offset = (*(u32 *)loc & 0x00ffffff) << 2;
+			offset = __mem_to_opcode_arm(*(u32 *)loc);
+			offset = (offset & 0x00ffffff) << 2;
 			if (offset & 0x02000000)
 				offset -= 0x04000000;
 
@@ -111,9 +114,10 @@ apply_relocate(Elf32_Shdr *sechdrs, const char *strtab, unsigned int symindex,
 			}
 
 			offset >>= 2;
+			offset &= 0x00ffffff;
 
-			*(u32 *)loc &= 0xff000000;
-			*(u32 *)loc |= offset & 0x00ffffff;
+			*(u32 *)loc &= __opcode_to_mem_arm(0xff000000);
+			*(u32 *)loc |= __opcode_to_mem_arm(offset);
 			break;
 
 	       case R_ARM_V4BX:
@@ -121,8 +125,8 @@ apply_relocate(Elf32_Shdr *sechdrs, const char *strtab, unsigned int symindex,
 			* other bits to re-code instruction as
 			* MOV PC,Rm.
 			*/
-		       *(u32 *)loc &= 0xf000000f;
-		       *(u32 *)loc |= 0x01a0f000;
+		       *(u32 *)loc &= __opcode_to_mem_arm(0xf000000f);
+		       *(u32 *)loc |= __opcode_to_mem_arm(0x01a0f000);
 		       break;
 
 		case R_ARM_PREL31:
@@ -132,7 +136,7 @@ apply_relocate(Elf32_Shdr *sechdrs, const char *strtab, unsigned int symindex,
 
 		case R_ARM_MOVW_ABS_NC:
 		case R_ARM_MOVT_ABS:
-			offset = *(u32 *)loc;
+			offset = tmp = __mem_to_opcode_arm(*(u32 *)loc);
 			offset = ((offset & 0xf0000) >> 4) | (offset & 0xfff);
 			offset = (offset ^ 0x8000) - 0x8000;
 
@@ -140,16 +144,18 @@ apply_relocate(Elf32_Shdr *sechdrs, const char *strtab, unsigned int symindex,
 			if (ELF32_R_TYPE(rel->r_info) == R_ARM_MOVT_ABS)
 				offset >>= 16;
 
-			*(u32 *)loc &= 0xfff0f000;
-			*(u32 *)loc |= ((offset & 0xf000) << 4) |
-					(offset & 0x0fff);
+			tmp &= 0xfff0f000;
+			tmp |= ((offset & 0xf000) << 4) |
+				(offset & 0x0fff);
+
+			*(u32 *)loc = __opcode_to_mem_arm(tmp);
 			break;
 
 #ifdef CONFIG_THUMB2_KERNEL
 		case R_ARM_THM_CALL:
 		case R_ARM_THM_JUMP24:
-			upper = *(u16 *)loc;
-			lower = *(u16 *)(loc + 2);
+			upper = __mem_to_opcode_thumb16(*(u16 *)loc);
+			lower = __mem_to_opcode_thumb16(*(u16 *)(loc + 2));
 
 			/*
 			 * 25 bit signed address range (Thumb-2 BL and B.W
@@ -198,17 +204,20 @@ apply_relocate(Elf32_Shdr *sechdrs, const char *strtab, unsigned int symindex,
 			sign = (offset >> 24) & 1;
 			j1 = sign ^ (~(offset >> 23) & 1);
 			j2 = sign ^ (~(offset >> 22) & 1);
-			*(u16 *)loc = (u16)((upper & 0xf800) | (sign << 10) |
+			upper = (u16)((upper & 0xf800) | (sign << 10) |
 					    ((offset >> 12) & 0x03ff));
-			*(u16 *)(loc + 2) = (u16)((lower & 0xd000) |
-						  (j1 << 13) | (j2 << 11) |
-						  ((offset >> 1) & 0x07ff));
+			lower = (u16)((lower & 0xd000) |
+				      (j1 << 13) | (j2 << 11) |
+				      ((offset >> 1) & 0x07ff));
+
+			*(u16 *)loc = __opcode_to_mem_thumb16(upper);
+			*(u16 *)(loc + 2) = __opcode_to_mem_thumb16(lower);
 			break;
 
 		case R_ARM_THM_MOVW_ABS_NC:
 		case R_ARM_THM_MOVT_ABS:
-			upper = *(u16 *)loc;
-			lower = *(u16 *)(loc + 2);
+			upper = __mem_to_opcode_thumb16(*(u16 *)loc);
+			lower = __mem_to_opcode_thumb16(*(u16 *)(loc + 2));
 
 			/*
 			 * MOVT/MOVW instructions encoding in Thumb-2:
@@ -229,12 +238,14 @@ apply_relocate(Elf32_Shdr *sechdrs, const char *strtab, unsigned int symindex,
 			if (ELF32_R_TYPE(rel->r_info) == R_ARM_THM_MOVT_ABS)
 				offset >>= 16;
 
-			*(u16 *)loc = (u16)((upper & 0xfbf0) |
-					    ((offset & 0xf000) >> 12) |
-					    ((offset & 0x0800) >> 1));
-			*(u16 *)(loc + 2) = (u16)((lower & 0x8f00) |
-						  ((offset & 0x0700) << 4) |
-						  (offset & 0x00ff));
+			upper = (u16)((upper & 0xfbf0) |
+				      ((offset & 0xf000) >> 12) |
+				      ((offset & 0x0800) >> 1));
+			lower = (u16)((lower & 0x8f00) |
+				      ((offset & 0x0700) << 4) |
+				      (offset & 0x00ff));
+			*(u16 *)loc = __opcode_to_mem_thumb16(upper);
+			*(u16 *)(loc + 2) = __opcode_to_mem_thumb16(lower);
 			break;
 #endif
 
-- 
1.8.4.rc3

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

* [PATCH 14/23] ARM: set --be8 when linking modules
  2013-10-08 22:34 New big-endian patch series against 3.12-rc4 Ben Dooks
                   ` (12 preceding siblings ...)
  2013-10-08 22:34 ` [PATCH 13/23] ARM: module: correctly relocate instructions in BE8 Ben Dooks
@ 2013-10-08 22:34 ` Ben Dooks
  2013-10-08 22:34 ` [PATCH 15/23] ARM: hardware: fix endian-ness in <hardware/coresight.h> Ben Dooks
                   ` (12 subsequent siblings)
  26 siblings, 0 replies; 41+ messages in thread
From: Ben Dooks @ 2013-10-08 22:34 UTC (permalink / raw)
  To: linux-arm-kernel

To avoid having to make every text section swap the instruction order
of all instructions, make sure modules are built also built with --be8
(as is the current kernel final link).

If we do not do this, we would end up having to swap all instructions
when loading a module, instead of just the instructions that we are
applying ELF relocations to.

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
Reviewed-by: Dave Martin <Dave.Martin@arm.com>
---
 arch/arm/Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index a37a50f..0069697 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -16,6 +16,7 @@ LDFLAGS		:=
 LDFLAGS_vmlinux	:=-p --no-undefined -X
 ifeq ($(CONFIG_CPU_ENDIAN_BE8),y)
 LDFLAGS_vmlinux	+= --be8
+LDFLAGS_MODULE	+= --be8
 endif
 
 OBJCOPYFLAGS	:=-O binary -R .comment -S
-- 
1.8.4.rc3

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

* [PATCH 15/23] ARM: hardware: fix endian-ness in <hardware/coresight.h>
  2013-10-08 22:34 New big-endian patch series against 3.12-rc4 Ben Dooks
                   ` (13 preceding siblings ...)
  2013-10-08 22:34 ` [PATCH 14/23] ARM: set --be8 when linking modules Ben Dooks
@ 2013-10-08 22:34 ` Ben Dooks
  2013-10-08 22:34 ` [PATCH 16/23] ARM: net: fix arm instruction endian-ness in bpf_jit_32.c Ben Dooks
                   ` (11 subsequent siblings)
  26 siblings, 0 replies; 41+ messages in thread
From: Ben Dooks @ 2013-10-08 22:34 UTC (permalink / raw)
  To: linux-arm-kernel

The <hardware/coresight.h> needs to take into account the endian-ness
of the processor when reading and writing data, so change to using
the readl/writel relaxed variants from the raw ones.

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
---
 arch/arm/include/asm/hardware/coresight.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/arm/include/asm/hardware/coresight.h b/arch/arm/include/asm/hardware/coresight.h
index 0cf7a6b..ad774f3 100644
--- a/arch/arm/include/asm/hardware/coresight.h
+++ b/arch/arm/include/asm/hardware/coresight.h
@@ -24,8 +24,8 @@
 #define TRACER_TIMEOUT 10000
 
 #define etm_writel(t, v, x) \
-	(__raw_writel((v), (t)->etm_regs + (x)))
-#define etm_readl(t, x) (__raw_readl((t)->etm_regs + (x)))
+	(writel_relaxed((v), (t)->etm_regs + (x)))
+#define etm_readl(t, x) (readl_relaxed((t)->etm_regs + (x)))
 
 /* CoreSight Management Registers */
 #define CSMR_LOCKACCESS 0xfb0
@@ -142,8 +142,8 @@
 #define ETBFF_TRIGFL		BIT(10)
 
 #define etb_writel(t, v, x) \
-	(__raw_writel((v), (t)->etb_regs + (x)))
-#define etb_readl(t, x) (__raw_readl((t)->etb_regs + (x)))
+	(writel_relaxed((v), (t)->etb_regs + (x)))
+#define etb_readl(t, x) (readl_relaxed((t)->etb_regs + (x)))
 
 #define etm_lock(t) do { etm_writel((t), 0, CSMR_LOCKACCESS); } while (0)
 #define etm_unlock(t) \
-- 
1.8.4.rc3

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

* [PATCH 16/23] ARM: net: fix arm instruction endian-ness in bpf_jit_32.c
  2013-10-08 22:34 New big-endian patch series against 3.12-rc4 Ben Dooks
                   ` (14 preceding siblings ...)
  2013-10-08 22:34 ` [PATCH 15/23] ARM: hardware: fix endian-ness in <hardware/coresight.h> Ben Dooks
@ 2013-10-08 22:34 ` Ben Dooks
  2013-10-08 22:34 ` [PATCH 17/23] ARM: Correct BUG() assembly to ensure it is endian-agnostic Ben Dooks
                   ` (10 subsequent siblings)
  26 siblings, 0 replies; 41+ messages in thread
From: Ben Dooks @ 2013-10-08 22:34 UTC (permalink / raw)
  To: linux-arm-kernel

Use <asm/opcodes.h> to correctly transform instruction byte ordering
into in-memory ordering.

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
Reviewed-by: Dave Martin <Dave.Martin@arm.com>
---
 arch/arm/net/bpf_jit_32.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/arch/arm/net/bpf_jit_32.c b/arch/arm/net/bpf_jit_32.c
index f50d223..510d923 100644
--- a/arch/arm/net/bpf_jit_32.c
+++ b/arch/arm/net/bpf_jit_32.c
@@ -19,6 +19,7 @@
 #include <linux/if_vlan.h>
 #include <asm/cacheflush.h>
 #include <asm/hwcap.h>
+#include <asm/opcodes.h>
 
 #include "bpf_jit_32.h"
 
@@ -113,8 +114,11 @@ static u32 jit_udiv(u32 dividend, u32 divisor)
 
 static inline void _emit(int cond, u32 inst, struct jit_ctx *ctx)
 {
+	inst |= (cond << 28);
+	inst = __opcode_to_mem_arm(inst);
+
 	if (ctx->target != NULL)
-		ctx->target[ctx->idx] = inst | (cond << 28);
+		ctx->target[ctx->idx] = inst;
 
 	ctx->idx++;
 }
-- 
1.8.4.rc3

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

* [PATCH 17/23] ARM: Correct BUG() assembly to ensure it is endian-agnostic
  2013-10-08 22:34 New big-endian patch series against 3.12-rc4 Ben Dooks
                   ` (15 preceding siblings ...)
  2013-10-08 22:34 ` [PATCH 16/23] ARM: net: fix arm instruction endian-ness in bpf_jit_32.c Ben Dooks
@ 2013-10-08 22:34 ` Ben Dooks
  2013-10-08 22:34 ` [PATCH 18/23] ARM: kdgb: use <asm/opcodes.h> for data to be assembled as intruction Ben Dooks
                   ` (9 subsequent siblings)
  26 siblings, 0 replies; 41+ messages in thread
From: Ben Dooks @ 2013-10-08 22:34 UTC (permalink / raw)
  To: linux-arm-kernel

Currently BUG() uses .word or .hword to create the necessary illegal
instructions. However if we are building BE8 then these get swapped
by the linker into different illegal instructions in the text. This
means that the BUG() macro does not get trapped properly.

Change to using <asm/opcodes.h> to provide the necessary ARM instruction
building as we cannot rely on gcc/gas having the `.inst` instructions
which where added to try and resolve this issue (reported by Dave Martin
<Dave.Martin@arm.com>).

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
Reviewed-by: Dave Martin <Dave.Martin@arm.com>
---
 arch/arm/include/asm/bug.h | 10 ++++++----
 arch/arm/kernel/traps.c    |  8 +++++---
 2 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/arch/arm/include/asm/bug.h b/arch/arm/include/asm/bug.h
index 7af5c6c..b274bde 100644
--- a/arch/arm/include/asm/bug.h
+++ b/arch/arm/include/asm/bug.h
@@ -2,6 +2,8 @@
 #define _ASMARM_BUG_H
 
 #include <linux/linkage.h>
+#include <linux/types.h>
+#include <asm/opcodes.h>
 
 #ifdef CONFIG_BUG
 
@@ -12,10 +14,10 @@
  */
 #ifdef CONFIG_THUMB2_KERNEL
 #define BUG_INSTR_VALUE 0xde02
-#define BUG_INSTR_TYPE ".hword "
+#define BUG_INSTR(__value) __inst_thumb16(__value)
 #else
 #define BUG_INSTR_VALUE 0xe7f001f2
-#define BUG_INSTR_TYPE ".word "
+#define BUG_INSTR(__value) __inst_arm(__value)
 #endif
 
 
@@ -33,7 +35,7 @@
 
 #define __BUG(__file, __line, __value)				\
 do {								\
-	asm volatile("1:\t" BUG_INSTR_TYPE #__value "\n"	\
+	asm volatile("1:\t" BUG_INSTR(__value) "\n"  \
 		".pushsection .rodata.str, \"aMS\", %progbits, 1\n" \
 		"2:\t.asciz " #__file "\n" 			\
 		".popsection\n" 				\
@@ -48,7 +50,7 @@ do {								\
 
 #define __BUG(__file, __line, __value)				\
 do {								\
-	asm volatile(BUG_INSTR_TYPE #__value);			\
+	asm volatile(BUG_INSTR(__value) "\n");			\
 	unreachable();						\
 } while (0)
 #endif  /* CONFIG_DEBUG_BUGVERBOSE */
diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
index caf96da..6125f25 100644
--- a/arch/arm/kernel/traps.c
+++ b/arch/arm/kernel/traps.c
@@ -342,15 +342,17 @@ void arm_notify_die(const char *str, struct pt_regs *regs,
 int is_valid_bugaddr(unsigned long pc)
 {
 #ifdef CONFIG_THUMB2_KERNEL
-	unsigned short bkpt;
+	u16 bkpt;
+	u16 insn = __opcode_to_mem_thumb16(BUG_INSTR_VALUE);
 #else
-	unsigned long bkpt;
+	u32 bkpt;
+	u32 insn = __opcode_to_mem_arm(BUG_INSTR_VALUE);
 #endif
 
 	if (probe_kernel_address((unsigned *)pc, bkpt))
 		return 0;
 
-	return bkpt == BUG_INSTR_VALUE;
+	return bkpt == insn;
 }
 
 #endif
-- 
1.8.4.rc3

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

* [PATCH 18/23] ARM: kdgb: use <asm/opcodes.h> for data to be assembled as intruction
  2013-10-08 22:34 New big-endian patch series against 3.12-rc4 Ben Dooks
                   ` (16 preceding siblings ...)
  2013-10-08 22:34 ` [PATCH 17/23] ARM: Correct BUG() assembly to ensure it is endian-agnostic Ben Dooks
@ 2013-10-08 22:34 ` Ben Dooks
  2013-10-08 22:34 ` [PATCH 19/23] ARM: atomic64: fix endian-ness in atomic.h Ben Dooks
                   ` (8 subsequent siblings)
  26 siblings, 0 replies; 41+ messages in thread
From: Ben Dooks @ 2013-10-08 22:34 UTC (permalink / raw)
  To: linux-arm-kernel

The arch_kgdb_breakpoint() function uses an inline assembly directive
to assemble a specific instruction using .word. This means the linker
will not treat is as an instruction, and therefore incorrectly swap
the endian-ness if running BE8.

As noted, this code means that kgdb is really only usable on arm32
kernels, and should be made dependant on not being a thumb2 kernel
until fixed. However this is not something to be added to this patch.

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
Reviewed-by: Dave Martin <Dave.Martin@arm.com>
---
 arch/arm/include/asm/kgdb.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/arm/include/asm/kgdb.h b/arch/arm/include/asm/kgdb.h
index 48066ce..0a9d5dd 100644
--- a/arch/arm/include/asm/kgdb.h
+++ b/arch/arm/include/asm/kgdb.h
@@ -11,6 +11,7 @@
 #define __ARM_KGDB_H__
 
 #include <linux/ptrace.h>
+#include <asm/opcodes.h>
 
 /*
  * GDB assumes that we're a user process being debugged, so
@@ -41,7 +42,7 @@
 
 static inline void arch_kgdb_breakpoint(void)
 {
-	asm(".word 0xe7ffdeff");
+	asm(__inst_arm(0xe7ffdeff));
 }
 
 extern void kgdb_handle_bus_error(void);
-- 
1.8.4.rc3

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

* [PATCH 19/23] ARM: atomic64: fix endian-ness in atomic.h
  2013-10-08 22:34 New big-endian patch series against 3.12-rc4 Ben Dooks
                   ` (17 preceding siblings ...)
  2013-10-08 22:34 ` [PATCH 18/23] ARM: kdgb: use <asm/opcodes.h> for data to be assembled as intruction Ben Dooks
@ 2013-10-08 22:34 ` Ben Dooks
  2013-10-08 22:34 ` [PATCH 20/23] ARM: signal: sigreturn_codes should be endian neutral to work in BE8 Ben Dooks
                   ` (7 subsequent siblings)
  26 siblings, 0 replies; 41+ messages in thread
From: Ben Dooks @ 2013-10-08 22:34 UTC (permalink / raw)
  To: linux-arm-kernel

From: Victor Kamensky <victor.kamensky@linaro.org>

Fix inline asm for atomic64_xxx functions in arm atomic.h. Instead of
%H operand specifiers code should use %Q for least significant part
of the value, and %R for the most significant part of the value. %H
always returns the higher of the two register numbers, and therefore
it is not endian neutral. %H should be used with ldrexd and strexd
instructions.

Signed-off-by: Victor Kamensky <victor.kamensky@linaro.org>
Acked-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
---
 arch/arm/include/asm/atomic.h | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/arch/arm/include/asm/atomic.h b/arch/arm/include/asm/atomic.h
index da1c77d..6447a0b 100644
--- a/arch/arm/include/asm/atomic.h
+++ b/arch/arm/include/asm/atomic.h
@@ -301,8 +301,8 @@ static inline void atomic64_add(u64 i, atomic64_t *v)
 
 	__asm__ __volatile__("@ atomic64_add\n"
 "1:	ldrexd	%0, %H0, [%3]\n"
-"	adds	%0, %0, %4\n"
-"	adc	%H0, %H0, %H4\n"
+"	adds	%Q0, %Q0, %Q4\n"
+"	adc	%R0, %R0, %R4\n"
 "	strexd	%1, %0, %H0, [%3]\n"
 "	teq	%1, #0\n"
 "	bne	1b"
@@ -320,8 +320,8 @@ static inline u64 atomic64_add_return(u64 i, atomic64_t *v)
 
 	__asm__ __volatile__("@ atomic64_add_return\n"
 "1:	ldrexd	%0, %H0, [%3]\n"
-"	adds	%0, %0, %4\n"
-"	adc	%H0, %H0, %H4\n"
+"	adds	%Q0, %Q0, %Q4\n"
+"	adc	%R0, %R0, %R4\n"
 "	strexd	%1, %0, %H0, [%3]\n"
 "	teq	%1, #0\n"
 "	bne	1b"
@@ -341,8 +341,8 @@ static inline void atomic64_sub(u64 i, atomic64_t *v)
 
 	__asm__ __volatile__("@ atomic64_sub\n"
 "1:	ldrexd	%0, %H0, [%3]\n"
-"	subs	%0, %0, %4\n"
-"	sbc	%H0, %H0, %H4\n"
+"	subs	%Q0, %Q0, %Q4\n"
+"	sbc	%R0, %R0, %R4\n"
 "	strexd	%1, %0, %H0, [%3]\n"
 "	teq	%1, #0\n"
 "	bne	1b"
@@ -360,8 +360,8 @@ static inline u64 atomic64_sub_return(u64 i, atomic64_t *v)
 
 	__asm__ __volatile__("@ atomic64_sub_return\n"
 "1:	ldrexd	%0, %H0, [%3]\n"
-"	subs	%0, %0, %4\n"
-"	sbc	%H0, %H0, %H4\n"
+"	subs	%Q0, %Q0, %Q4\n"
+"	sbc	%R0, %R0, %R4\n"
 "	strexd	%1, %0, %H0, [%3]\n"
 "	teq	%1, #0\n"
 "	bne	1b"
@@ -428,9 +428,9 @@ static inline u64 atomic64_dec_if_positive(atomic64_t *v)
 
 	__asm__ __volatile__("@ atomic64_dec_if_positive\n"
 "1:	ldrexd	%0, %H0, [%3]\n"
-"	subs	%0, %0, #1\n"
-"	sbc	%H0, %H0, #0\n"
-"	teq	%H0, #0\n"
+"	subs	%Q0, %Q0, #1\n"
+"	sbc	%R0, %R0, #0\n"
+"	teq	%R0, #0\n"
 "	bmi	2f\n"
 "	strexd	%1, %0, %H0, [%3]\n"
 "	teq	%1, #0\n"
@@ -459,8 +459,8 @@ static inline int atomic64_add_unless(atomic64_t *v, u64 a, u64 u)
 "	teqeq	%H0, %H5\n"
 "	moveq	%1, #0\n"
 "	beq	2f\n"
-"	adds	%0, %0, %6\n"
-"	adc	%H0, %H0, %H6\n"
+"	adds	%Q0, %Q0, %Q6\n"
+"	adc	%R0, %R0, %R6\n"
 "	strexd	%2, %0, %H0, [%4]\n"
 "	teq	%2, #0\n"
 "	bne	1b\n"
-- 
1.8.4.rc3

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

* [PATCH 20/23] ARM: signal: sigreturn_codes should be endian neutral to work in BE8
  2013-10-08 22:34 New big-endian patch series against 3.12-rc4 Ben Dooks
                   ` (18 preceding siblings ...)
  2013-10-08 22:34 ` [PATCH 19/23] ARM: atomic64: fix endian-ness in atomic.h Ben Dooks
@ 2013-10-08 22:34 ` Ben Dooks
  2013-11-05 21:18   ` Uwe Kleine-König
  2013-10-08 22:34 ` [PATCH 21/23] ARM: mcpm: fix big endian issue in mcpm startup code Ben Dooks
                   ` (6 subsequent siblings)
  26 siblings, 1 reply; 41+ messages in thread
From: Ben Dooks @ 2013-10-08 22:34 UTC (permalink / raw)
  To: linux-arm-kernel

From: Victor Kamensky <victor.kamensky@linaro.org>

In case of BE8 kernel data is in BE order whereas code stays in LE
order. Move sigreturn_codes to separate .S file and use proper
assembler mnemonics for these code snippets. In this case compiler
will take care of proper instructions byteswaps for BE8 case.
Change assumes that sufficiently Thumb-capable tools are used to
build kernel.

Problem was discovered during ltp testing of BE system: all rt_sig*
tests failed. Tested against the same tests in both BE and LE modes.

Signed-off-by: Victor Kamensky <victor.kamensky@linaro.org>
Reviewed-by: Dave Martin <Dave.Martin@arm.com>
Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
---
 arch/arm/kernel/Makefile          |  3 +-
 arch/arm/kernel/signal.c          | 24 +-----------
 arch/arm/kernel/sigreturn_codes.S | 80 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 83 insertions(+), 24 deletions(-)
 create mode 100644 arch/arm/kernel/sigreturn_codes.S

diff --git a/arch/arm/kernel/Makefile b/arch/arm/kernel/Makefile
index 5140df5f..39c9834 100644
--- a/arch/arm/kernel/Makefile
+++ b/arch/arm/kernel/Makefile
@@ -17,7 +17,8 @@ CFLAGS_REMOVE_return_address.o = -pg
 
 obj-y		:= elf.o entry-common.o irq.o opcodes.o \
 		   process.o ptrace.o return_address.o \
-		   setup.o signal.o stacktrace.o sys_arm.o time.o traps.o
+		   setup.o signal.o sigreturn_codes.o \
+		   stacktrace.o sys_arm.o time.o traps.o
 
 obj-$(CONFIG_ATAGS)		+= atags_parse.o
 obj-$(CONFIG_ATAGS_PROC)	+= atags_proc.o
diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c
index ab33042..64845fc 100644
--- a/arch/arm/kernel/signal.c
+++ b/arch/arm/kernel/signal.c
@@ -21,29 +21,7 @@
 #include <asm/unistd.h>
 #include <asm/vfp.h>
 
-/*
- * For ARM syscalls, we encode the syscall number into the instruction.
- */
-#define SWI_SYS_SIGRETURN	(0xef000000|(__NR_sigreturn)|(__NR_OABI_SYSCALL_BASE))
-#define SWI_SYS_RT_SIGRETURN	(0xef000000|(__NR_rt_sigreturn)|(__NR_OABI_SYSCALL_BASE))
-
-/*
- * With EABI, the syscall number has to be loaded into r7.
- */
-#define MOV_R7_NR_SIGRETURN	(0xe3a07000 | (__NR_sigreturn - __NR_SYSCALL_BASE))
-#define MOV_R7_NR_RT_SIGRETURN	(0xe3a07000 | (__NR_rt_sigreturn - __NR_SYSCALL_BASE))
-
-/*
- * For Thumb syscalls, we pass the syscall number via r7.  We therefore
- * need two 16-bit instructions.
- */
-#define SWI_THUMB_SIGRETURN	(0xdf00 << 16 | 0x2700 | (__NR_sigreturn - __NR_SYSCALL_BASE))
-#define SWI_THUMB_RT_SIGRETURN	(0xdf00 << 16 | 0x2700 | (__NR_rt_sigreturn - __NR_SYSCALL_BASE))
-
-static const unsigned long sigreturn_codes[7] = {
-	MOV_R7_NR_SIGRETURN,    SWI_SYS_SIGRETURN,    SWI_THUMB_SIGRETURN,
-	MOV_R7_NR_RT_SIGRETURN, SWI_SYS_RT_SIGRETURN, SWI_THUMB_RT_SIGRETURN,
-};
+extern const unsigned long sigreturn_codes[7];
 
 static unsigned long signal_return_offset;
 
diff --git a/arch/arm/kernel/sigreturn_codes.S b/arch/arm/kernel/sigreturn_codes.S
new file mode 100644
index 0000000..3c5d0f2
--- /dev/null
+++ b/arch/arm/kernel/sigreturn_codes.S
@@ -0,0 +1,80 @@
+/*
+ * sigreturn_codes.S - code sinpets for sigreturn syscalls
+ *
+ * Created by:	Victor Kamensky, 2013-08-13
+ * Copyright:	(C) 2013  Linaro Limited
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <asm/unistd.h>
+
+/*
+ * For ARM syscalls, we encode the syscall number into the instruction.
+ * With EABI, the syscall number has to be loaded into r7. As result
+ * ARM syscall sequence snippet will have move and svc in .arm encoding
+ *
+ * For Thumb syscalls, we pass the syscall number via r7.  We therefore
+ * need two 16-bit instructions in .thumb encoding
+ *
+ * Please note sigreturn_codes code are not executed in place. Instead
+ * they just copied by kernel into appropriate places. Code inside of
+ * arch/arm/kernel/signal.c is very sensitive to layout of these code
+ * snippets.
+ */
+
+#if __LINUX_ARM_ARCH__ <= 4
+	/*
+	 * Note we manually set minimally required arch that supports
+	 * required thumb opcodes for early arch versions. It is OK
+	 * for this file to be used in combination with other
+	 * lower arch variants, since these code snippets are only
+	 * used as input data.
+	 */
+	.arch armv4t
+#endif
+
+	.section .rodata
+	.global sigreturn_codes
+	.type	sigreturn_codes, #object
+
+	.arm
+
+sigreturn_codes:
+
+	/* ARM sigreturn syscall code snippet */
+	mov	r7, #(__NR_sigreturn - __NR_SYSCALL_BASE)
+	swi	#(__NR_sigreturn)|(__NR_OABI_SYSCALL_BASE)
+
+	/* Thumb sigreturn syscall code snippet */
+	.thumb
+	movs	r7, #(__NR_sigreturn - __NR_SYSCALL_BASE)
+	swi	#0
+
+	/* ARM sigreturn_rt syscall code snippet */
+	.arm
+	mov	r7, #(__NR_rt_sigreturn - __NR_SYSCALL_BASE)
+	swi	#(__NR_rt_sigreturn)|(__NR_OABI_SYSCALL_BASE)
+
+	/* Thumb sigreturn_rt syscall code snippet */
+	.thumb
+	movs	r7, #(__NR_rt_sigreturn - __NR_SYSCALL_BASE)
+	swi	#0
+
+	/*
+	 * Note on addtional space: setup_return in signal.c
+	 * algorithm uses two words copy regardless whether
+	 * it is thumb case or not, so we need additional
+	 * word after real last entry.
+	 */
+	.arm
+	.space	4
+
+	.size	sigreturn_codes, . - sigreturn_codes
-- 
1.8.4.rc3

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

* [PATCH 21/23] ARM: mcpm: fix big endian issue in mcpm startup code
  2013-10-08 22:34 New big-endian patch series against 3.12-rc4 Ben Dooks
                   ` (19 preceding siblings ...)
  2013-10-08 22:34 ` [PATCH 20/23] ARM: signal: sigreturn_codes should be endian neutral to work in BE8 Ben Dooks
@ 2013-10-08 22:34 ` Ben Dooks
  2013-10-08 22:34 ` [PATCH 22/23] ARM: cci: driver need big endian fixes in asm code Ben Dooks
                   ` (5 subsequent siblings)
  26 siblings, 0 replies; 41+ messages in thread
From: Ben Dooks @ 2013-10-08 22:34 UTC (permalink / raw)
  To: linux-arm-kernel

From: Victor Kamensky <victor.kamensky@linaro.org>

In big endian mode mcpm_entry_point is first function
that called on secondaries CPU. First it should switch
CPU into big endian code.

[ben.dooks at codethink.co.uk: merge fix patch from Victor into this]
Signed-off-by: Victor Kamensky <victor.kamensky@linaro.org>
Acked-by: Nicolas Pitre <nico@linaro.org>
Reviewed-by: Dave Martin <Dave.Martin@arm.com>
Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
---
 arch/arm/common/mcpm_head.S | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm/common/mcpm_head.S b/arch/arm/common/mcpm_head.S
index 39c96df..4f88f5e 100644
--- a/arch/arm/common/mcpm_head.S
+++ b/arch/arm/common/mcpm_head.S
@@ -15,6 +15,7 @@
 
 #include <linux/linkage.h>
 #include <asm/mcpm.h>
+#include <asm/assembler.h>
 
 #include "vlock.h"
 
@@ -47,6 +48,7 @@
 
 ENTRY(mcpm_entry_point)
 
+ ARM_BE8(setend        be)
  THUMB(	adr	r12, BSYM(1f)	)
  THUMB(	bx	r12		)
  THUMB(	.thumb			)
-- 
1.8.4.rc3

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

* [PATCH 22/23] ARM: cci: driver need big endian fixes in asm code
  2013-10-08 22:34 New big-endian patch series against 3.12-rc4 Ben Dooks
                   ` (20 preceding siblings ...)
  2013-10-08 22:34 ` [PATCH 21/23] ARM: mcpm: fix big endian issue in mcpm startup code Ben Dooks
@ 2013-10-08 22:34 ` Ben Dooks
  2013-10-09 14:35   ` Dave Martin
  2013-10-14 20:53   ` Ben Dooks
  2013-10-08 22:34 ` [PATCH 23/23] ARM: tlb: ASID macro should give 32bit result for BE correct operation Ben Dooks
                   ` (4 subsequent siblings)
  26 siblings, 2 replies; 41+ messages in thread
From: Ben Dooks @ 2013-10-08 22:34 UTC (permalink / raw)
  To: linux-arm-kernel

From: Victor Kamensky <victor.kamensky@linaro.org>

cci_enable_port_for_self written in asm and it works with h/w
registers that are in little endian format. When run in big
endian mode it needs byte swap before/after it writes/reads
to/from such registers

CC: Lorenzon Pieralisi <lorenzo.pieralisi@arm.com>
Signed-off-by: Victor Kamensky <victor.kamensky@linaro.org>
Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
---
 drivers/bus/arm-cci.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/bus/arm-cci.c b/drivers/bus/arm-cci.c
index 2009266..6db173e 100644
--- a/drivers/bus/arm-cci.c
+++ b/drivers/bus/arm-cci.c
@@ -281,6 +281,9 @@ asmlinkage void __naked cci_enable_port_for_self(void)
 	/* Enable the CCI port */
 "	ldr	r0, [r0, %[offsetof_port_phys]] \n"
 "	mov	r3, #"__stringify(CCI_ENABLE_REQ)" \n"
+#ifdef __ARMEB__
+"	rev	r3, r3 \n"
+#endif /* __ARMEB__ */
 "	str	r3, [r0, #"__stringify(CCI_PORT_CTRL)"] \n"
 
 	/* poll the status reg for completion */
@@ -288,6 +291,9 @@ asmlinkage void __naked cci_enable_port_for_self(void)
 "	ldr	r0, [r1] \n"
 "	ldr	r0, [r0, r1]		@ cci_ctrl_base \n"
 "4:	ldr	r1, [r0, #"__stringify(CCI_CTRL_STATUS)"] \n"
+#ifdef __ARMEB__
+"	rev	r1, r1 \n"
+#endif /* __ARMEB__ */
 "	tst	r1, #1 \n"
 "	bne	4b \n"
 
-- 
1.8.4.rc3

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

* [PATCH 23/23] ARM: tlb: ASID macro should give 32bit result for BE correct operation
  2013-10-08 22:34 New big-endian patch series against 3.12-rc4 Ben Dooks
                   ` (21 preceding siblings ...)
  2013-10-08 22:34 ` [PATCH 22/23] ARM: cci: driver need big endian fixes in asm code Ben Dooks
@ 2013-10-08 22:34 ` Ben Dooks
  2013-10-09  6:20 ` New big-endian patch series against 3.12-rc4 Victor Kamensky
                   ` (3 subsequent siblings)
  26 siblings, 0 replies; 41+ messages in thread
From: Ben Dooks @ 2013-10-08 22:34 UTC (permalink / raw)
  To: linux-arm-kernel

From: Victor Kamensky <victor.kamensky@linaro.org>

In order for ASID macro to be used as expression passed to
inline asm as 'r' operand it needs to give 32 bit unsigned result,
not unsigned 64bit expression.

Otherwise when 64bit ASID is passed to inline assembler statement
as 'r' operand (32bit) compiler behavior is not well specified.
For example when __flush_tlb_mm function compiled in big endian
case, and ASID is passed to tlb_op macro directly, 0 will be passed
as 'mcr	15, 0, r4, cr8, cr3, {2}' argument in r4, unless ASID
macro changed to produce 32 bit result.

Signed-off-by: Victor Kamensky <victor.kamensky@linaro.org>
Acked-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
---
 arch/arm/include/asm/mmu.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/include/asm/mmu.h b/arch/arm/include/asm/mmu.h
index 6f18da0..64fd151 100644
--- a/arch/arm/include/asm/mmu.h
+++ b/arch/arm/include/asm/mmu.h
@@ -16,7 +16,7 @@ typedef struct {
 #ifdef CONFIG_CPU_HAS_ASID
 #define ASID_BITS	8
 #define ASID_MASK	((~0ULL) << ASID_BITS)
-#define ASID(mm)	((mm)->context.id.counter & ~ASID_MASK)
+#define ASID(mm)	((unsigned int)((mm)->context.id.counter & ~ASID_MASK))
 #else
 #define ASID(mm)	(0)
 #endif
-- 
1.8.4.rc3

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

* New big-endian patch series against 3.12-rc4
  2013-10-08 22:34 New big-endian patch series against 3.12-rc4 Ben Dooks
                   ` (22 preceding siblings ...)
  2013-10-08 22:34 ` [PATCH 23/23] ARM: tlb: ASID macro should give 32bit result for BE correct operation Ben Dooks
@ 2013-10-09  6:20 ` Victor Kamensky
  2013-10-09  7:10   ` Ben Dooks
  2013-10-11 10:49 ` Marc Zyngier
                   ` (2 subsequent siblings)
  26 siblings, 1 reply; 41+ messages in thread
From: Victor Kamensky @ 2013-10-09  6:20 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Ben,

On 8 October 2013 15:34, Ben Dooks <ben.dooks@codethink.co.uk> wrote:
> This is a new series for big-endian on ARM re-based onto 3.12-rc4
> and updated with new patches from Victor to fix regressions since 3.11.
>
> I have not been able to test this further than building it as I do not
> currently have access to any hardware, however there where no big issues
> when re-basing. Thanks to Marc Zyngier for pointing out the need for a
> rebase.
>
> The branch is at:
>
>   git://git.baserock.org/delta/linux baserock/bjdooks/3.12-rc4/core

It is rather baserock/312-rc4/be/core isn't it?

I've tested baserock/312-rc4/be/core from
git://git.baserock.org/delta/linux on TC2. Both LE and BE images.
Done full LTP runs on both. LTP BE results match LE one.

Thanks,
Victor

> Russell, if possible could this go into -next and then if everything
> I can issue a pull request for it.
>
> Changes since last:
>
> - Updated to 3.12-rc4 to be closer to mainline
> - Added Victor's patches for CCI and TC2 boot
> - Added Victor's patch for ASID extraction
> - Updated Victor's patch with fix for building on older kernels
>

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

* New big-endian patch series against 3.12-rc4
  2013-10-09  6:20 ` New big-endian patch series against 3.12-rc4 Victor Kamensky
@ 2013-10-09  7:10   ` Ben Dooks
  0 siblings, 0 replies; 41+ messages in thread
From: Ben Dooks @ 2013-10-09  7:10 UTC (permalink / raw)
  To: linux-arm-kernel

On 09/10/13 08:20, Victor Kamensky wrote:
> Hi Ben,
>
> On 8 October 2013 15:34, Ben Dooks<ben.dooks@codethink.co.uk>  wrote:
>> This is a new series for big-endian on ARM re-based onto 3.12-rc4
>> and updated with new patches from Victor to fix regressions since 3.11.
>>
>> I have not been able to test this further than building it as I do not
>> currently have access to any hardware, however there where no big issues
>> when re-basing. Thanks to Marc Zyngier for pointing out the need for a
>> rebase.
>>
>> The branch is at:
>>
>>    git://git.baserock.org/delta/linux baserock/bjdooks/3.12-rc4/core
>
> It is rather baserock/312-rc4/be/core isn't it?
>
> I've tested baserock/312-rc4/be/core from
> git://git.baserock.org/delta/linux on TC2. Both LE and BE images.
> Done full LTP runs on both. LTP BE results match LE one.

Thanks, yes the path was wrong.

-- 
Ben Dooks				http://www.codethink.co.uk/
Senior Engineer				Codethink - Providing Genius

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

* [PATCH 12/23] ARM: traps: use <asm/opcodes.h> to get correct instruction order
  2013-10-08 22:34 ` [PATCH 12/23] ARM: traps: use <asm/opcodes.h> to get correct instruction order Ben Dooks
@ 2013-10-09 11:42   ` Will Deacon
  0 siblings, 0 replies; 41+ messages in thread
From: Will Deacon @ 2013-10-09 11:42 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Oct 08, 2013 at 11:34:28PM +0100, Ben Dooks wrote:
> The trap handler needs to take into account the endian configuration of
> the system when loading instructions. Use <asm/opcodes.h> to provide the
> necessary conversion functions.
> 
> Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
> Tested-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
> ---
>  arch/arm/kernel/traps.c | 16 ++++++++++------
>  1 file changed, 10 insertions(+), 6 deletions(-)

Reviewed-by: Will Deacon <will.deacon@arm.com>

Will

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

* [PATCH 22/23] ARM: cci: driver need big endian fixes in asm code
  2013-10-08 22:34 ` [PATCH 22/23] ARM: cci: driver need big endian fixes in asm code Ben Dooks
@ 2013-10-09 14:35   ` Dave Martin
  2013-10-14 20:53   ` Ben Dooks
  1 sibling, 0 replies; 41+ messages in thread
From: Dave Martin @ 2013-10-09 14:35 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Oct 09, 2013 at 12:34:38AM +0200, Ben Dooks wrote:
> From: Victor Kamensky <victor.kamensky@linaro.org>
> 
> cci_enable_port_for_self written in asm and it works with h/w
> registers that are in little endian format. When run in big
> endian mode it needs byte swap before/after it writes/reads
> to/from such registers

I had a play with an alternate way of doing this that may be a bit
cleaner, posted as a separate mini-series.  See:

ARM: Unify const-swabbing and conditional asm
http://lists.infradead.org/pipermail/linux-arm-kernel/2013-October/203479.html

Cheers
---Dave

> 
> CC: Lorenzon Pieralisi <lorenzo.pieralisi@arm.com>
> Signed-off-by: Victor Kamensky <victor.kamensky@linaro.org>
> Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
> ---
>  drivers/bus/arm-cci.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/bus/arm-cci.c b/drivers/bus/arm-cci.c
> index 2009266..6db173e 100644
> --- a/drivers/bus/arm-cci.c
> +++ b/drivers/bus/arm-cci.c
> @@ -281,6 +281,9 @@ asmlinkage void __naked cci_enable_port_for_self(void)
>  	/* Enable the CCI port */
>  "	ldr	r0, [r0, %[offsetof_port_phys]] \n"
>  "	mov	r3, #"__stringify(CCI_ENABLE_REQ)" \n"
> +#ifdef __ARMEB__
> +"	rev	r3, r3 \n"
> +#endif /* __ARMEB__ */
>  "	str	r3, [r0, #"__stringify(CCI_PORT_CTRL)"] \n"
>  
>  	/* poll the status reg for completion */
> @@ -288,6 +291,9 @@ asmlinkage void __naked cci_enable_port_for_self(void)
>  "	ldr	r0, [r1] \n"
>  "	ldr	r0, [r0, r1]		@ cci_ctrl_base \n"
>  "4:	ldr	r1, [r0, #"__stringify(CCI_CTRL_STATUS)"] \n"
> +#ifdef __ARMEB__
> +"	rev	r1, r1 \n"
> +#endif /* __ARMEB__ */
>  "	tst	r1, #1 \n"
>  "	bne	4b \n"
>  
> -- 
> 1.8.4.rc3
> 
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* New big-endian patch series against 3.12-rc4
  2013-10-08 22:34 New big-endian patch series against 3.12-rc4 Ben Dooks
                   ` (23 preceding siblings ...)
  2013-10-09  6:20 ` New big-endian patch series against 3.12-rc4 Victor Kamensky
@ 2013-10-11 10:49 ` Marc Zyngier
  2013-10-11 13:47 ` Thomas Petazzoni
  2013-10-17 12:07 ` Thomas Petazzoni
  26 siblings, 0 replies; 41+ messages in thread
From: Marc Zyngier @ 2013-10-11 10:49 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Ben,

On 08/10/13 23:34, Ben Dooks wrote:
> This is a new series for big-endian on ARM re-based onto 3.12-rc4
> and updated with new patches from Victor to fix regressions since 3.11.
> 
> I have not been able to test this further than building it as I do not
> currently have access to any hardware, however there where no big issues
> when re-basing. Thanks to Marc Zyngier for pointing out the need for a
> rebase.
> 
> The branch is at:
> 
>   git://git.baserock.org/delta/linux baserock/bjdooks/3.12-rc4/core
> 
> Russell, if possible could this go into -next and then if everything
> I can issue a pull request for it.
> 
> Changes since last:
> 
> - Updated to 3.12-rc4 to be closer to mainline
> - Added Victor's patches for CCI and TC2 boot
> - Added Victor's patch for ASID extraction
> - Updated Victor's patch with fix for building on older kernels

For what it is worth, I've just gave this series a run as a KVM/arm64
guest, running some Linaro OE userspace.

While this doesn't exercise any of the driver code (the guest is
entirely virtio based, and I have a separate patch series for this), the
core code looks solid enough.

I'm looking forward to seeing this series in next.

Thanks,

	M.
-- 
Jazz is not dead. It just smells funny...

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

* New big-endian patch series against 3.12-rc4
  2013-10-08 22:34 New big-endian patch series against 3.12-rc4 Ben Dooks
                   ` (24 preceding siblings ...)
  2013-10-11 10:49 ` Marc Zyngier
@ 2013-10-11 13:47 ` Thomas Petazzoni
  2013-10-17 12:07 ` Thomas Petazzoni
  26 siblings, 0 replies; 41+ messages in thread
From: Thomas Petazzoni @ 2013-10-11 13:47 UTC (permalink / raw)
  To: linux-arm-kernel

Hello,

On Wed,  9 Oct 2013 00:34:16 +0200, Ben Dooks wrote:
> This is a new series for big-endian on ARM re-based onto 3.12-rc4
> and updated with new patches from Victor to fix regressions since 3.11.
> 
> I have not been able to test this further than building it as I do not
> currently have access to any hardware, however there where no big issues
> when re-basing. Thanks to Marc Zyngier for pointing out the need for a
> rebase.
> 
> The branch is at:
> 
>   git://git.baserock.org/delta/linux baserock/bjdooks/3.12-rc4/core

I've tested this branch on Armada XP GP in the following configurations:

 * little-endian ARM
 * little-endian Thumb2
 * big-endian ARM
 * big-endian Thumb2

The four configurations booted successfully without any problem, and
devices appear to work as expected.

I'm all for getting this merged for 3.13. The code has been around for
a while, tested many times by various persons, reviewed by several ARM
people.

Thanks Ben for taking care of this series!

Best regards,

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

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

* [PATCH 22/23] ARM: cci: driver need big endian fixes in asm code
  2013-10-08 22:34 ` [PATCH 22/23] ARM: cci: driver need big endian fixes in asm code Ben Dooks
  2013-10-09 14:35   ` Dave Martin
@ 2013-10-14 20:53   ` Ben Dooks
  2013-10-15  1:40     ` Nicolas Pitre
  1 sibling, 1 reply; 41+ messages in thread
From: Ben Dooks @ 2013-10-14 20:53 UTC (permalink / raw)
  To: linux-arm-kernel

On 08/10/13 23:34, Ben Dooks wrote:
> From: Victor Kamensky<victor.kamensky@linaro.org>
>
> cci_enable_port_for_self written in asm and it works with h/w
> registers that are in little endian format. When run in big
> endian mode it needs byte swap before/after it writes/reads
> to/from such registers
>
> CC: Lorenzon Pieralisi<lorenzo.pieralisi@arm.com>
> Signed-off-by: Victor Kamensky<victor.kamensky@linaro.org>
> Signed-off-by: Ben Dooks<ben.dooks@codethink.co.uk>
> ---
>   drivers/bus/arm-cci.c | 6 ++++++
>   1 file changed, 6 insertions(+)
>
> diff --git a/drivers/bus/arm-cci.c b/drivers/bus/arm-cci.c
> index 2009266..6db173e 100644
> --- a/drivers/bus/arm-cci.c
> +++ b/drivers/bus/arm-cci.c
> @@ -281,6 +281,9 @@ asmlinkage void __naked cci_enable_port_for_self(void)
>   	/* Enable the CCI port */
>   "	ldr	r0, [r0, %[offsetof_port_phys]] \n"
>   "	mov	r3, #"__stringify(CCI_ENABLE_REQ)" \n"
> +#ifdef __ARMEB__
> +"	rev	r3, r3 \n"
> +#endif /* __ARMEB__ */
>   "	str	r3, [r0, #"__stringify(CCI_PORT_CTRL)"] \n"
>
>   	/* poll the status reg for completion */
> @@ -288,6 +291,9 @@ asmlinkage void __naked cci_enable_port_for_self(void)
>   "	ldr	r0, [r1] \n"
>   "	ldr	r0, [r0, r1]		@ cci_ctrl_base \n"
>   "4:	ldr	r1, [r0, #"__stringify(CCI_CTRL_STATUS)"] \n"
> +#ifdef __ARMEB__
> +"	rev	r1, r1 \n"
> +#endif /* __ARMEB__ */
>   "	tst	r1, #1 \n"
>   "	bne	4b \n"

I was just thinking if this would be a better way to change
the code:

diff --git a/drivers/bus/arm-cci.c b/drivers/bus/arm-cci.c
index 6db173e..2ad2511 100644
--- a/drivers/bus/arm-cci.c
+++ b/drivers/bus/arm-cci.c
@@ -280,10 +280,7 @@ asmlinkage void __naked cci_enable_port_for_self(void)

         /* Enable the CCI port */
  "      ldr     r0, [r0, %[offsetof_port_phys]] \n"
-"      mov     r3, #"__stringify(CCI_ENABLE_REQ)" \n"
-#ifdef __ARMEB__
-"      rev     r3, r3 \n"
-#endif /* __ARMEB__ */
+"      mov     r3, %[cci_enable_req]\n"
  "      str     r3, [r0, #"__stringify(CCI_PORT_CTRL)"] \n"

         /* poll the status reg for completion */
@@ -291,10 +288,7 @@ asmlinkage void __naked cci_enable_port_for_self(void)
  "      ldr     r0, [r1] \n"
  "      ldr     r0, [r0, r1]            @ cci_ctrl_base \n"
  "4:    ldr     r1, [r0, #"__stringify(CCI_CTRL_STATUS)"] \n"
-#ifdef __ARMEB__
-"      rev     r1, r1 \n"
-#endif /* __ARMEB__ */
-"      tst     r1, #1 \n"
+"      tst     r1, %[cci_control_status_bits] \n"
  "      bne     4b \n"

  "      mov     r0, #0 \n"
@@ -307,6 +301,8 @@ asmlinkage void __naked cci_enable_port_for_self(void)
  "7:    .word   cci_ctrl_phys - . \n"
         : :
         [sizeof_cpu_port] "i" (sizeof(cpu_port)),
+       [cci_enable_req] "i" cpu_to_le32(CCI_ENABLE_REQ),
+       [cci_control_status_bits] "i" cpu_to_le32(1),

so swap the data bits before passing them into the code
which could also remove some of the use of the __stringify()
calls in there too.

It seems to compile ok, but is not complete.


-- 
Ben Dooks				http://www.codethink.co.uk/
Senior Engineer				Codethink - Providing Genius

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

* [PATCH 22/23] ARM: cci: driver need big endian fixes in asm code
  2013-10-14 20:53   ` Ben Dooks
@ 2013-10-15  1:40     ` Nicolas Pitre
  2013-10-15  9:58       ` Ben Dooks
  0 siblings, 1 reply; 41+ messages in thread
From: Nicolas Pitre @ 2013-10-15  1:40 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, 14 Oct 2013, Ben Dooks wrote:

> On 08/10/13 23:34, Ben Dooks wrote:
> > From: Victor Kamensky<victor.kamensky@linaro.org>
> > 
> > cci_enable_port_for_self written in asm and it works with h/w
> > registers that are in little endian format. When run in big
> > endian mode it needs byte swap before/after it writes/reads
> > to/from such registers
> > 
> > CC: Lorenzon Pieralisi<lorenzo.pieralisi@arm.com>
> > Signed-off-by: Victor Kamensky<victor.kamensky@linaro.org>
> > Signed-off-by: Ben Dooks<ben.dooks@codethink.co.uk>
> > ---
> >   drivers/bus/arm-cci.c | 6 ++++++
> >   1 file changed, 6 insertions(+)
> > 
> > diff --git a/drivers/bus/arm-cci.c b/drivers/bus/arm-cci.c
> > index 2009266..6db173e 100644
> > --- a/drivers/bus/arm-cci.c
> > +++ b/drivers/bus/arm-cci.c
> > @@ -281,6 +281,9 @@ asmlinkage void __naked cci_enable_port_for_self(void)
> >   	/* Enable the CCI port */
> >   "	ldr	r0, [r0, %[offsetof_port_phys]] \n"
> >   "	mov	r3, #"__stringify(CCI_ENABLE_REQ)" \n"
> > +#ifdef __ARMEB__
> > +"	rev	r3, r3 \n"
> > +#endif /* __ARMEB__ */
> >   "	str	r3, [r0, #"__stringify(CCI_PORT_CTRL)"] \n"
> > 
> >   	/* poll the status reg for completion */
> > @@ -288,6 +291,9 @@ asmlinkage void __naked cci_enable_port_for_self(void)
> >   "	ldr	r0, [r1] \n"
> >   "	ldr	r0, [r0, r1]		@ cci_ctrl_base \n"
> >   "4:	ldr	r1, [r0, #"__stringify(CCI_CTRL_STATUS)"] \n"
> > +#ifdef __ARMEB__
> > +"	rev	r1, r1 \n"
> > +#endif /* __ARMEB__ */
> >   "	tst	r1, #1 \n"
> >   "	bne	4b \n"
> 
> I was just thinking if this would be a better way to change
> the code:
> 
> diff --git a/drivers/bus/arm-cci.c b/drivers/bus/arm-cci.c
> index 6db173e..2ad2511 100644
> --- a/drivers/bus/arm-cci.c
> +++ b/drivers/bus/arm-cci.c
> @@ -280,10 +280,7 @@ asmlinkage void __naked cci_enable_port_for_self(void)
> 
>         /* Enable the CCI port */
>  "      ldr     r0, [r0, %[offsetof_port_phys]] \n"
> -"      mov     r3, #"__stringify(CCI_ENABLE_REQ)" \n"
> -#ifdef __ARMEB__
> -"      rev     r3, r3 \n"
> -#endif /* __ARMEB__ */
> +"      mov     r3, %[cci_enable_req]\n"
>  "      str     r3, [r0, #"__stringify(CCI_PORT_CTRL)"] \n"
> 
>         /* poll the status reg for completion */
> @@ -291,10 +288,7 @@ asmlinkage void __naked cci_enable_port_for_self(void)
>  "      ldr     r0, [r1] \n"
>  "      ldr     r0, [r0, r1]            @ cci_ctrl_base \n"
>  "4:    ldr     r1, [r0, #"__stringify(CCI_CTRL_STATUS)"] \n"
> -#ifdef __ARMEB__
> -"      rev     r1, r1 \n"
> -#endif /* __ARMEB__ */
> -"      tst     r1, #1 \n"
> +"      tst     r1, %[cci_control_status_bits] \n"
>  "      bne     4b \n"
> 
>  "      mov     r0, #0 \n"
> @@ -307,6 +301,8 @@ asmlinkage void __naked cci_enable_port_for_self(void)
>  "7:    .word   cci_ctrl_phys - . \n"
>         : :
>         [sizeof_cpu_port] "i" (sizeof(cpu_port)),
> +       [cci_enable_req] "i" cpu_to_le32(CCI_ENABLE_REQ),
> +       [cci_control_status_bits] "i" cpu_to_le32(1),
> 
> so swap the data bits before passing them into the code
> which could also remove some of the use of the __stringify()
> calls in there too.
That certainly looks nicer to me.

> It seems to compile ok, but is not complete.

What do you mean?


Nicolas

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

* [PATCH 22/23] ARM: cci: driver need big endian fixes in asm code
  2013-10-15  1:40     ` Nicolas Pitre
@ 2013-10-15  9:58       ` Ben Dooks
  0 siblings, 0 replies; 41+ messages in thread
From: Ben Dooks @ 2013-10-15  9:58 UTC (permalink / raw)
  To: linux-arm-kernel

On 15/10/13 02:40, Nicolas Pitre wrote:
> On Mon, 14 Oct 2013, Ben Dooks wrote:
>
>> On 08/10/13 23:34, Ben Dooks wrote:
>>> From: Victor Kamensky<victor.kamensky@linaro.org>
>>>
>>> cci_enable_port_for_self written in asm and it works with h/w
>>> registers that are in little endian format. When run in big
>>> endian mode it needs byte swap before/after it writes/reads
>>> to/from such registers
>>>
>>> CC: Lorenzon Pieralisi<lorenzo.pieralisi@arm.com>
>>> Signed-off-by: Victor Kamensky<victor.kamensky@linaro.org>
>>> Signed-off-by: Ben Dooks<ben.dooks@codethink.co.uk>
>>> ---
>>>    drivers/bus/arm-cci.c | 6 ++++++
>>>    1 file changed, 6 insertions(+)
>>>
>>> diff --git a/drivers/bus/arm-cci.c b/drivers/bus/arm-cci.c
>>> index 2009266..6db173e 100644
>>> --- a/drivers/bus/arm-cci.c
>>> +++ b/drivers/bus/arm-cci.c
>>> @@ -281,6 +281,9 @@ asmlinkage void __naked cci_enable_port_for_self(void)
>>>    	/* Enable the CCI port */
>>>    "	ldr	r0, [r0, %[offsetof_port_phys]] \n"
>>>    "	mov	r3, #"__stringify(CCI_ENABLE_REQ)" \n"
>>> +#ifdef __ARMEB__
>>> +"	rev	r3, r3 \n"
>>> +#endif /* __ARMEB__ */
>>>    "	str	r3, [r0, #"__stringify(CCI_PORT_CTRL)"] \n"
>>>
>>>    	/* poll the status reg for completion */
>>> @@ -288,6 +291,9 @@ asmlinkage void __naked cci_enable_port_for_self(void)
>>>    "	ldr	r0, [r1] \n"
>>>    "	ldr	r0, [r0, r1]		@ cci_ctrl_base \n"
>>>    "4:	ldr	r1, [r0, #"__stringify(CCI_CTRL_STATUS)"] \n"
>>> +#ifdef __ARMEB__
>>> +"	rev	r1, r1 \n"
>>> +#endif /* __ARMEB__ */
>>>    "	tst	r1, #1 \n"
>>>    "	bne	4b \n"
>>
>> I was just thinking if this would be a better way to change
>> the code:
>>
>> diff --git a/drivers/bus/arm-cci.c b/drivers/bus/arm-cci.c
>> index 6db173e..2ad2511 100644
>> --- a/drivers/bus/arm-cci.c
>> +++ b/drivers/bus/arm-cci.c
>> @@ -280,10 +280,7 @@ asmlinkage void __naked cci_enable_port_for_self(void)
>>
>>          /* Enable the CCI port */
>>   "      ldr     r0, [r0, %[offsetof_port_phys]] \n"
>> -"      mov     r3, #"__stringify(CCI_ENABLE_REQ)" \n"
>> -#ifdef __ARMEB__
>> -"      rev     r3, r3 \n"
>> -#endif /* __ARMEB__ */
>> +"      mov     r3, %[cci_enable_req]\n"
>>   "      str     r3, [r0, #"__stringify(CCI_PORT_CTRL)"] \n"
>>
>>          /* poll the status reg for completion */
>> @@ -291,10 +288,7 @@ asmlinkage void __naked cci_enable_port_for_self(void)
>>   "      ldr     r0, [r1] \n"
>>   "      ldr     r0, [r0, r1]            @ cci_ctrl_base \n"
>>   "4:    ldr     r1, [r0, #"__stringify(CCI_CTRL_STATUS)"] \n"
>> -#ifdef __ARMEB__
>> -"      rev     r1, r1 \n"
>> -#endif /* __ARMEB__ */
>> -"      tst     r1, #1 \n"
>> +"      tst     r1, %[cci_control_status_bits] \n"
>>   "      bne     4b \n"
>>
>>   "      mov     r0, #0 \n"
>> @@ -307,6 +301,8 @@ asmlinkage void __naked cci_enable_port_for_self(void)
>>   "7:    .word   cci_ctrl_phys - . \n"
>>          : :
>>          [sizeof_cpu_port] "i" (sizeof(cpu_port)),
>> +       [cci_enable_req] "i" cpu_to_le32(CCI_ENABLE_REQ),
>> +       [cci_control_status_bits] "i" cpu_to_le32(1),
>>
>> so swap the data bits before passing them into the code
>> which could also remove some of the use of the __stringify()
>> calls in there too.
> That certainly looks nicer to me.
>
>> It seems to compile ok, but is not complete.
>
> What do you mean?

I didn't have time to check I caught all cases in this.

Victor, any chance you could have a look at this and re-do the patch?

-- 
Ben Dooks				http://www.codethink.co.uk/
Senior Engineer				Codethink - Providing Genius

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

* New big-endian patch series against 3.12-rc4
  2013-10-08 22:34 New big-endian patch series against 3.12-rc4 Ben Dooks
                   ` (25 preceding siblings ...)
  2013-10-11 13:47 ` Thomas Petazzoni
@ 2013-10-17 12:07 ` Thomas Petazzoni
  2013-10-17 12:15   ` Will Deacon
  26 siblings, 1 reply; 41+ messages in thread
From: Thomas Petazzoni @ 2013-10-17 12:07 UTC (permalink / raw)
  To: linux-arm-kernel

Ben,

On Wed,  9 Oct 2013 00:34:16 +0200, Ben Dooks wrote:

> Russell, if possible could this go into -next and then if everything
> I can issue a pull request for it.

Shall I suggest that you post the patches into Russell patch's system?

Your patch set has been around for a long while, has received Acked-by,
Reviewed-by and/or Tested-by from a number of different people,
including core ARM persons, so I believe it's time to push them through
Russell patch's system, to at least get some reaction from Russell,
since he has apparently completely ignored your pull requests until now.

Maybe Nicolas or Will can comment on the best way to make things move
forward with this patch set.

Thanks!

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

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

* New big-endian patch series against 3.12-rc4
  2013-10-17 12:07 ` Thomas Petazzoni
@ 2013-10-17 12:15   ` Will Deacon
  2013-10-17 12:20     ` Thomas Petazzoni
  0 siblings, 1 reply; 41+ messages in thread
From: Will Deacon @ 2013-10-17 12:15 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Oct 17, 2013 at 01:07:12PM +0100, Thomas Petazzoni wrote:
> On Wed,  9 Oct 2013 00:34:16 +0200, Ben Dooks wrote:
> 
> > Russell, if possible could this go into -next and then if everything
> > I can issue a pull request for it.
> 
> Shall I suggest that you post the patches into Russell patch's system?
> 
> Your patch set has been around for a long while, has received Acked-by,
> Reviewed-by and/or Tested-by from a number of different people,
> including core ARM persons, so I believe it's time to push them through
> Russell patch's system, to at least get some reaction from Russell,
> since he has apparently completely ignored your pull requests until now.
> 
> Maybe Nicolas or Will can comment on the best way to make things move
> forward with this patch set.

There are a good number of acks on this now, so I think a pull request to
rmk with the latest version based on something like -rc3 (since that's where
devel-stable is) would be the best thing to do. Then they can enjoy some
time in -next and we can iron out any conflicts that might crop up.

Will

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

* New big-endian patch series against 3.12-rc4
  2013-10-17 12:15   ` Will Deacon
@ 2013-10-17 12:20     ` Thomas Petazzoni
  2013-10-17 12:27       ` Will Deacon
  0 siblings, 1 reply; 41+ messages in thread
From: Thomas Petazzoni @ 2013-10-17 12:20 UTC (permalink / raw)
  To: linux-arm-kernel

Dear Will Deacon,

On Thu, 17 Oct 2013 13:15:30 +0100, Will Deacon wrote:

> > Maybe Nicolas or Will can comment on the best way to make things
> > move forward with this patch set.
> 
> There are a good number of acks on this now, so I think a pull
> request to rmk with the latest version based on something like -rc3
> (since that's where devel-stable is) would be the best thing to do.
> Then they can enjoy some time in -next and we can iron out any
> conflicts that might crop up.

Well, the e-mail I was replying to was already a pull request sent to
rmk, and there has been a number of other similar pull requests made by
Ben during the previous iterations, and there has never been any
reaction from rmk (as far as I can remember, of course).

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

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

* New big-endian patch series against 3.12-rc4
  2013-10-17 12:20     ` Thomas Petazzoni
@ 2013-10-17 12:27       ` Will Deacon
  2013-10-17 12:29         ` Thomas Petazzoni
  0 siblings, 1 reply; 41+ messages in thread
From: Will Deacon @ 2013-10-17 12:27 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Oct 17, 2013 at 01:20:53PM +0100, Thomas Petazzoni wrote:
> Dear Will Deacon,
> 
> On Thu, 17 Oct 2013 13:15:30 +0100, Will Deacon wrote:
> 
> > > Maybe Nicolas or Will can comment on the best way to make things
> > > move forward with this patch set.
> > 
> > There are a good number of acks on this now, so I think a pull
> > request to rmk with the latest version based on something like -rc3
> > (since that's where devel-stable is) would be the best thing to do.
> > Then they can enjoy some time in -next and we can iron out any
> > conflicts that might crop up.
> 
> Well, the e-mail I was replying to was already a pull request sent to
> rmk, and there has been a number of other similar pull requests made by
> Ben during the previous iterations, and there has never been any
> reaction from rmk (as far as I can remember, of course).

Hmm, the email doesn't have [GIT PULL] in the subject and I don't see
linux+pull at arm.linux.org.uk in the to/cc list, so maybe that explain why
it's not getting picked up!

Will

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

* New big-endian patch series against 3.12-rc4
  2013-10-17 12:27       ` Will Deacon
@ 2013-10-17 12:29         ` Thomas Petazzoni
  0 siblings, 0 replies; 41+ messages in thread
From: Thomas Petazzoni @ 2013-10-17 12:29 UTC (permalink / raw)
  To: linux-arm-kernel

Dear Will Deacon,

On Thu, 17 Oct 2013 13:27:58 +0100, Will Deacon wrote:

> > Well, the e-mail I was replying to was already a pull request sent
> > to rmk, and there has been a number of other similar pull requests
> > made by Ben during the previous iterations, and there has never
> > been any reaction from rmk (as far as I can remember, of course).
> 
> Hmm, the email doesn't have [GIT PULL] in the subject and I don't see
> linux+pull at arm.linux.org.uk in the to/cc list, so maybe that explain
> why it's not getting picked up!

Ok. So Ben, it'd be great if you could repost a pull request by
following those recommendations. If you need help, let me know, I can
probably dedicate a bit of time to help pushing the BE stuff if needed.

Best regards,

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

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

* [PATCH 20/23] ARM: signal: sigreturn_codes should be endian neutral to work in BE8
  2013-10-08 22:34 ` [PATCH 20/23] ARM: signal: sigreturn_codes should be endian neutral to work in BE8 Ben Dooks
@ 2013-11-05 21:18   ` Uwe Kleine-König
  2013-11-06  3:48     ` Victor Kamensky
  0 siblings, 1 reply; 41+ messages in thread
From: Uwe Kleine-König @ 2013-11-05 21:18 UTC (permalink / raw)
  To: linux-arm-kernel

Hello,

On Wed, Oct 09, 2013 at 12:34:36AM +0200, Ben Dooks wrote:
> From: Victor Kamensky <victor.kamensky@linaro.org>
> 
> In case of BE8 kernel data is in BE order whereas code stays in LE
> order. Move sigreturn_codes to separate .S file and use proper
> assembler mnemonics for these code snippets. In this case compiler
> will take care of proper instructions byteswaps for BE8 case.
> Change assumes that sufficiently Thumb-capable tools are used to
> build kernel.
> 
> Problem was discovered during ltp testing of BE system: all rt_sig*
> tests failed. Tested against the same tests in both BE and LE modes.
> 
> Signed-off-by: Victor Kamensky <victor.kamensky@linaro.org>
> Reviewed-by: Dave Martin <Dave.Martin@arm.com>
> Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
> ---
>  arch/arm/kernel/Makefile          |  3 +-
>  arch/arm/kernel/signal.c          | 24 +-----------
>  arch/arm/kernel/sigreturn_codes.S | 80 +++++++++++++++++++++++++++++++++++++++
>  3 files changed, 83 insertions(+), 24 deletions(-)
>  create mode 100644 arch/arm/kernel/sigreturn_codes.S
> 
> diff --git a/arch/arm/kernel/Makefile b/arch/arm/kernel/Makefile
> index 5140df5f..39c9834 100644
> --- a/arch/arm/kernel/Makefile
> +++ b/arch/arm/kernel/Makefile
> @@ -17,7 +17,8 @@ CFLAGS_REMOVE_return_address.o = -pg
>  
>  obj-y		:= elf.o entry-common.o irq.o opcodes.o \
>  		   process.o ptrace.o return_address.o \
> -		   setup.o signal.o stacktrace.o sys_arm.o time.o traps.o
> +		   setup.o signal.o sigreturn_codes.o \
> +		   stacktrace.o sys_arm.o time.o traps.o
>  
>  obj-$(CONFIG_ATAGS)		+= atags_parse.o
>  obj-$(CONFIG_ATAGS_PROC)	+= atags_proc.o
> diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c
> index ab33042..64845fc 100644
> --- a/arch/arm/kernel/signal.c
> +++ b/arch/arm/kernel/signal.c
> @@ -21,29 +21,7 @@
>  #include <asm/unistd.h>
>  #include <asm/vfp.h>
>  
> -/*
> - * For ARM syscalls, we encode the syscall number into the instruction.
> - */
> -#define SWI_SYS_SIGRETURN	(0xef000000|(__NR_sigreturn)|(__NR_OABI_SYSCALL_BASE))
> -#define SWI_SYS_RT_SIGRETURN	(0xef000000|(__NR_rt_sigreturn)|(__NR_OABI_SYSCALL_BASE))
> -
> -/*
> - * With EABI, the syscall number has to be loaded into r7.
> - */
> -#define MOV_R7_NR_SIGRETURN	(0xe3a07000 | (__NR_sigreturn - __NR_SYSCALL_BASE))
> -#define MOV_R7_NR_RT_SIGRETURN	(0xe3a07000 | (__NR_rt_sigreturn - __NR_SYSCALL_BASE))
> -
> -/*
> - * For Thumb syscalls, we pass the syscall number via r7.  We therefore
> - * need two 16-bit instructions.
> - */
> -#define SWI_THUMB_SIGRETURN	(0xdf00 << 16 | 0x2700 | (__NR_sigreturn - __NR_SYSCALL_BASE))
> -#define SWI_THUMB_RT_SIGRETURN	(0xdf00 << 16 | 0x2700 | (__NR_rt_sigreturn - __NR_SYSCALL_BASE))
> -
> -static const unsigned long sigreturn_codes[7] = {
> -	MOV_R7_NR_SIGRETURN,    SWI_SYS_SIGRETURN,    SWI_THUMB_SIGRETURN,
> -	MOV_R7_NR_RT_SIGRETURN, SWI_SYS_RT_SIGRETURN, SWI_THUMB_RT_SIGRETURN,
> -};
> +extern const unsigned long sigreturn_codes[7];
>  
>  static unsigned long signal_return_offset;
>  
> diff --git a/arch/arm/kernel/sigreturn_codes.S b/arch/arm/kernel/sigreturn_codes.S
> new file mode 100644
> index 0000000..3c5d0f2
> --- /dev/null
> +++ b/arch/arm/kernel/sigreturn_codes.S
> @@ -0,0 +1,80 @@
> +/*
> + * sigreturn_codes.S - code sinpets for sigreturn syscalls
> + *
> + * Created by:	Victor Kamensky, 2013-08-13
> + * Copyright:	(C) 2013  Linaro Limited
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + */
> +
> +#include <asm/unistd.h>
> +
> +/*
> + * For ARM syscalls, we encode the syscall number into the instruction.
> + * With EABI, the syscall number has to be loaded into r7. As result
> + * ARM syscall sequence snippet will have move and svc in .arm encoding
> + *
> + * For Thumb syscalls, we pass the syscall number via r7.  We therefore
> + * need two 16-bit instructions in .thumb encoding
> + *
> + * Please note sigreturn_codes code are not executed in place. Instead
> + * they just copied by kernel into appropriate places. Code inside of
> + * arch/arm/kernel/signal.c is very sensitive to layout of these code
> + * snippets.
> + */
> +
> +#if __LINUX_ARM_ARCH__ <= 4
> +	/*
> +	 * Note we manually set minimally required arch that supports
> +	 * required thumb opcodes for early arch versions. It is OK
> +	 * for this file to be used in combination with other
> +	 * lower arch variants, since these code snippets are only
> +	 * used as input data.
> +	 */
> +	.arch armv4t
> +#endif
> +
> +	.section .rodata
> +	.global sigreturn_codes
> +	.type	sigreturn_codes, #object
> +
> +	.arm
This breaks a ARMv7-M build, see
http://arm-soc.lixom.net/buildlogs/misc/next-20131105-1-g2b29c44/buildall.arm.efm32_defconfig.log.failed

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

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

* [PATCH 20/23] ARM: signal: sigreturn_codes should be endian neutral to work in BE8
  2013-11-05 21:18   ` Uwe Kleine-König
@ 2013-11-06  3:48     ` Victor Kamensky
  2013-11-06  8:46       ` Uwe Kleine-König
  0 siblings, 1 reply; 41+ messages in thread
From: Victor Kamensky @ 2013-11-06  3:48 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Uwe, and All,

On 5 November 2013 13:18, Uwe Kleine-K?nig
<u.kleine-koenig@pengutronix.de> wrote:

<snip>

>> +
>> +#if __LINUX_ARM_ARCH__ <= 4
>> +     /*
>> +      * Note we manually set minimally required arch that supports
>> +      * required thumb opcodes for early arch versions. It is OK
>> +      * for this file to be used in combination with other
>> +      * lower arch variants, since these code snippets are only
>> +      * used as input data.
>> +      */
>> +     .arch armv4t
>> +#endif
>> +
>> +     .section .rodata
>> +     .global sigreturn_codes
>> +     .type   sigreturn_codes, #object
>> +
>> +     .arm
> This breaks a ARMv7-M build, see
> http://arm-soc.lixom.net/buildlogs/misc/next-20131105-1-g2b29c44/buildall.arm.efm32_defconfig.log.failed

Could you please point to git tree and branch from which efm32_defconfig
was built - I could not find such in my tree.
I would like to be able to reproduce this failure.

This issue looks similar to

http://lists.infradead.org/pipermail/linux-arm-kernel/2013-September/197636.html
http://lists.infradead.org/pipermail/linux-arm-kernel/2013-September/197637.html

which is fixed as in left quoted patch above. but this time
is not thumb opcodes are problem, but rather arm opcodes.
However it seems to be more harder.

I have tried to enable arm opcodes with '.arch armv7a' directive. But
unlike above case of v4t and v7a. .o file with armv7a and armv7m are
not compatible and cannot be linked together even though
sigreturn_codes snipet used as data.

I see only way fix that is to come back to manually constructed
opcodes and use macros from <asm/opcodes.h> to deal with
endianity issues. Effectively it will back out my v3 version of patch
and apply v1 version as I posted here:

http://lists.infradead.org/pipermail/linux-arm-kernel/2013-August/191543.html

Adding bunch of ifdef into sigreturns_codes.S could be another
option, but IMHO it seems to be move in wrong direction. I would
rather see constructed opcodes.

Any other ideas?

Thanks,
Victor

> Best regards
> Uwe
>
> --
> Pengutronix e.K.                           | Uwe Kleine-K?nig            |
> Industrial Linux Solutions                 | http://www.pengutronix.de/  |

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

* [PATCH 20/23] ARM: signal: sigreturn_codes should be endian neutral to work in BE8
  2013-11-06  3:48     ` Victor Kamensky
@ 2013-11-06  8:46       ` Uwe Kleine-König
  0 siblings, 0 replies; 41+ messages in thread
From: Uwe Kleine-König @ 2013-11-06  8:46 UTC (permalink / raw)
  To: linux-arm-kernel

Hello Victor,

On Tue, Nov 05, 2013 at 07:48:42PM -0800, Victor Kamensky wrote:
> Hi Uwe, and All,
> 
> On 5 November 2013 13:18, Uwe Kleine-K?nig
> <u.kleine-koenig@pengutronix.de> wrote:
> 
> <snip>
> 
> >> +
> >> +#if __LINUX_ARM_ARCH__ <= 4
> >> +     /*
> >> +      * Note we manually set minimally required arch that supports
> >> +      * required thumb opcodes for early arch versions. It is OK
> >> +      * for this file to be used in combination with other
> >> +      * lower arch variants, since these code snippets are only
> >> +      * used as input data.
> >> +      */
> >> +     .arch armv4t
> >> +#endif
> >> +
> >> +     .section .rodata
> >> +     .global sigreturn_codes
> >> +     .type   sigreturn_codes, #object
> >> +
> >> +     .arm
> > This breaks a ARMv7-M build, see
> > http://arm-soc.lixom.net/buildlogs/misc/next-20131105-1-g2b29c44/buildall.arm.efm32_defconfig.log.failed
> 
> Could you please point to git tree and branch from which efm32_defconfig
> was built - I could not find such in my tree.
next-20131105 contains both, your patch and the efm32 support.
(i.e. git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
next/master)

The problem is, that armv7-M doesn't support ARM, only Thumb-2.
If you go the ifdef route, CONFIG_CPU_THUMBONLY is what you want to use.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

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

end of thread, other threads:[~2013-11-06  8:46 UTC | newest]

Thread overview: 41+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-08 22:34 New big-endian patch series against 3.12-rc4 Ben Dooks
2013-10-08 22:34 ` [PATCH 01/23] ARM: fix ARCH_IXP4xx usage of ARCH_SUPPORTS_BIG_ENDIAN Ben Dooks
2013-10-08 22:34 ` [PATCH 02/23] ARM: asm: Add ARM_BE8() assembly helper Ben Dooks
2013-10-08 22:34 ` [PATCH 03/23] ARM: fixup_pv_table bug when CPU_ENDIAN_BE8 Ben Dooks
2013-10-08 22:34 ` [PATCH 04/23] ARM: set BE8 if LE in head code Ben Dooks
2013-10-08 22:34 ` [PATCH 05/23] ARM: pl01x debug code endian fix Ben Dooks
2013-10-08 22:34 ` [PATCH 06/23] ARM: twd: data " Ben Dooks
2013-10-08 22:34 ` [PATCH 07/23] ARM: smp_scu: data endian fixes Ben Dooks
2013-10-08 22:34 ` [PATCH 08/23] ARM: highbank: enable big-endian Ben Dooks
2013-10-08 22:34 ` [PATCH 09/23] ARM: mvebu: support running big-endian Ben Dooks
2013-10-08 22:34 ` [PATCH 10/23] ARM: vexpress: add big endian support Ben Dooks
2013-10-08 22:34 ` [PATCH 11/23] ARM: alignment: correctly decode instructions in BE8 mode Ben Dooks
2013-10-08 22:34 ` [PATCH 12/23] ARM: traps: use <asm/opcodes.h> to get correct instruction order Ben Dooks
2013-10-09 11:42   ` Will Deacon
2013-10-08 22:34 ` [PATCH 13/23] ARM: module: correctly relocate instructions in BE8 Ben Dooks
2013-10-08 22:34 ` [PATCH 14/23] ARM: set --be8 when linking modules Ben Dooks
2013-10-08 22:34 ` [PATCH 15/23] ARM: hardware: fix endian-ness in <hardware/coresight.h> Ben Dooks
2013-10-08 22:34 ` [PATCH 16/23] ARM: net: fix arm instruction endian-ness in bpf_jit_32.c Ben Dooks
2013-10-08 22:34 ` [PATCH 17/23] ARM: Correct BUG() assembly to ensure it is endian-agnostic Ben Dooks
2013-10-08 22:34 ` [PATCH 18/23] ARM: kdgb: use <asm/opcodes.h> for data to be assembled as intruction Ben Dooks
2013-10-08 22:34 ` [PATCH 19/23] ARM: atomic64: fix endian-ness in atomic.h Ben Dooks
2013-10-08 22:34 ` [PATCH 20/23] ARM: signal: sigreturn_codes should be endian neutral to work in BE8 Ben Dooks
2013-11-05 21:18   ` Uwe Kleine-König
2013-11-06  3:48     ` Victor Kamensky
2013-11-06  8:46       ` Uwe Kleine-König
2013-10-08 22:34 ` [PATCH 21/23] ARM: mcpm: fix big endian issue in mcpm startup code Ben Dooks
2013-10-08 22:34 ` [PATCH 22/23] ARM: cci: driver need big endian fixes in asm code Ben Dooks
2013-10-09 14:35   ` Dave Martin
2013-10-14 20:53   ` Ben Dooks
2013-10-15  1:40     ` Nicolas Pitre
2013-10-15  9:58       ` Ben Dooks
2013-10-08 22:34 ` [PATCH 23/23] ARM: tlb: ASID macro should give 32bit result for BE correct operation Ben Dooks
2013-10-09  6:20 ` New big-endian patch series against 3.12-rc4 Victor Kamensky
2013-10-09  7:10   ` Ben Dooks
2013-10-11 10:49 ` Marc Zyngier
2013-10-11 13:47 ` Thomas Petazzoni
2013-10-17 12:07 ` Thomas Petazzoni
2013-10-17 12:15   ` Will Deacon
2013-10-17 12:20     ` Thomas Petazzoni
2013-10-17 12:27       ` Will Deacon
2013-10-17 12:29         ` Thomas Petazzoni

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.