Skip to contentSkip to conversation

arm: Hook up SYNC_CORE functionality for sys_membarrier()

PATCH New Will Deacon 2 participants 4 messages Jun 19, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm: Hook up SYNC_CORE functionality for sys_membarrier()

Exception return implies context synchronization, so we can hook up the SYNC_CORE option to sys_membarrier() simply by selecting the Kconfig option, just like we've done for arm64 already.

Cc Mathieu Desnoyers <[email protected]>
Cc Orion Hodson <[email protected]>
---
 arch/arm/Kconfig | 1 +
 1 file changed, 1 insertion(+)
arch/arm/Kconfig +1 -0
index 54eeb8d00bc6..b0ac18547370 100644
@@ -9,6 +9,7 @@ config ARM
 	select ARCH_HAS_ELF_RANDOMIZE
 	select ARCH_HAS_FORTIFY_SOURCE
 	select ARCH_HAS_KCOV
+	select ARCH_HAS_MEMBARRIER_SYNC_CORE
 	select ARCH_HAS_PTE_SPECIAL if ARM_LPAE
 	select ARCH_HAS_PHYS_TO_DMA
 	select ARCH_HAS_SET_MEMORY
Signature · 1 line
2.1.4
#1 lore raw

PATCH 1/1 arm: Hook up SYNC_CORE functionality for sys_membarrier()

Quoted 16 lines · Will Deacon will.deacon at arm.com

Exception return implies context synchronization, so we can hook up the SYNC_CORE option to sys_membarrier() simply by selecting the Kconfig option, just like we've done for arm64 already.

Cc Mathieu Desnoyers <[email protected]>
Cc Orion Hodson <[email protected]>

---
arch/arm/Kconfig | 1 +

1 file changed, 1 insertion(+)
arch/arm/Kconfig +0 -0
index 54eeb8d00bc6..b0ac18547370 100644

arch/arm/Kconfig config ARM · line 12

Quoted 4 lines
arch/arm/Kconfig +1 -0
@@ -9,6 +9,7 @@ config ARM
 	select ARCH_HAS_ELF_RANDOMIZE
 	select ARCH_HAS_FORTIFY_SOURCE
 	select ARCH_HAS_KCOV
+	select ARCH_HAS_MEMBARRIER_SYNC_CORE

In addition to this, we added this comment in arch/arm64/kernel/entry.S:

+ /*

+        * ARCH_HAS_MEMBARRIER_SYNC_CORE rely on eret context synchronization
+        * when returning from IPI handler, and when returning to user-space.
+        */

So I would expect a similar comment in arch/arm/kernel/entry-header.S, within svc_exit and svc_exit_via_fiq:

/*
* ARCH_HAS_MEMBARRIER_SYNC_CORE rely on [insn] context synchronization
* when returning from IPI handler, and when returning to user-space. */

Which instruction exactly is responsible for context synchronization on arm32 ?

Thanks,

Mathieu

Quoted 5 lines
arch/arm/Kconfig +0 -1
 	select ARCH_HAS_PTE_SPECIAL if ARM_LPAE
 	select ARCH_HAS_PHYS_TO_DMA
 	select ARCH_HAS_SET_MEMORY
--

2.1.4

Signature · 3 lines
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com
#2 lore raw

PATCH 1/1 arm: Hook up SYNC_CORE functionality for sys_membarrier()

Hi Mathieu,

Quoted 30 lines · Mathieu Desnoyers
Quoted 16 lines · Will Deacon will.deacon at arm.com

Exception return implies context synchronization, so we can hook up the SYNC_CORE option to sys_membarrier() simply by selecting the Kconfig option, just like we've done for arm64 already.

Cc Mathieu Desnoyers <[email protected]>
Cc Orion Hodson <[email protected]>

---
arch/arm/Kconfig | 1 +

1 file changed, 1 insertion(+)
arch/arm/Kconfig +0 -0
index 54eeb8d00bc6..b0ac18547370 100644

arch/arm/Kconfig config ARM · line 12

Quoted 4 lines
arch/arm/Kconfig +1 -0
@@ -9,6 +9,7 @@ config ARM
 	select ARCH_HAS_ELF_RANDOMIZE
 	select ARCH_HAS_FORTIFY_SOURCE
 	select ARCH_HAS_KCOV
+	select ARCH_HAS_MEMBARRIER_SYNC_CORE

In addition to this, we added this comment in arch/arm64/kernel/entry.S:

(quoted diff) +4 -0
+       /*
+        * ARCH_HAS_MEMBARRIER_SYNC_CORE rely on eret context synchronization
+        * when returning from IPI handler, and when returning to user-space.
+        */
Quoted 7 lines

So I would expect a similar comment in arch/arm/kernel/entry-header.S, within svc_exit and svc_exit_via_fiq:

/*
* ARCH_HAS_MEMBARRIER_SYNC_CORE rely on [insn] context synchronization
* when returning from IPI handler, and when returning to user-space. */

Bah, you know I hate that comment ;) I should update arch-support.txt, though. Diff below.

Quoted 2 lines

Which instruction exactly is responsible for context synchronization on arm32 ?

It's the act of doing an exception return, so there are multiple instruction sequences to do that on 32-bit arm.

Will

--->8

Documentation/features/sched/membarrier-sync-core/arch-support.txt +4 -4
index dbdf62907703..c7858dd1ea8f 100644
@@ -5,10 +5,10 @@
 #
 # Architecture requirements
 #
-# * arm64
+# * arm/arm64
 #
-# Rely on eret context synchronization when returning from IPI handler, and
-# when returning to user-space.
+# Rely on implicit context synchronization as a result of exception return
+# when returning from IPI handler, and when returning to user-space.
 #
 # * x86
 #
@@ -31,7 +31,7 @@
     -----------------------
     |       alpha: | TODO |
     |         arc: | TODO |
-    |         arm: | TODO |
+    |         arm: |  ok  |
     |       arm64: |  ok  |
     |         c6x: | TODO |
     |       h8300: | TODO |
#3 lore raw

PATCH 1/1 arm: Hook up SYNC_CORE functionality for sys_membarrier()

Quoted 36 lines · Will Deacon will.deacon at arm.com

Hi Mathieu,

Quoted 33 lines · Mathieu Desnoyers
Quoted 16 lines · Will Deacon will.deacon at arm.com

Exception return implies context synchronization, so we can hook up the SYNC_CORE option to sys_membarrier() simply by selecting the Kconfig option, just like we've done for arm64 already.

Cc Mathieu Desnoyers <[email protected]>
Cc Orion Hodson <[email protected]>

---
arch/arm/Kconfig | 1 +

1 file changed, 1 insertion(+)
arch/arm/Kconfig +0 -0
index 54eeb8d00bc6..b0ac18547370 100644

arch/arm/Kconfig config ARM · line 12

Quoted 4 lines
arch/arm/Kconfig +1 -0
@@ -9,6 +9,7 @@ config ARM
 	select ARCH_HAS_ELF_RANDOMIZE
 	select ARCH_HAS_FORTIFY_SOURCE
 	select ARCH_HAS_KCOV
+	select ARCH_HAS_MEMBARRIER_SYNC_CORE

In addition to this, we added this comment in arch/arm64/kernel/entry.S:

(quoted diff) +4 -0
+       /*
+        * ARCH_HAS_MEMBARRIER_SYNC_CORE rely on eret context synchronization
+        * when returning from IPI handler, and when returning to user-space.
+        */

So I would expect a similar comment in arch/arm/kernel/entry-header.S, within svc_exit and svc_exit_via_fiq:

Quoted 7 lines
Quoted 4 lines

/*
* ARCH_HAS_MEMBARRIER_SYNC_CORE rely on [insn] context synchronization
* when returning from IPI handler, and when returning to user-space. */

Bah, you know I hate that comment ;) I should update arch-support.txt, though. Diff below.

It works for me with this update, thanks!

Mathieu

Signature · 3 lines
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com