Skip to contentSkip to conversation

arm64/ipipe: Add support for userspace return notifier

PATCH In review Jan Kiszka 2 participants 4 messages Oct 8, 2019 – Oct 9, 2019 arm64

lore
Share & tools
lore

Jan Kiszka

author
#0 lore raw

PATCH 1/1 arm64/ipipe: Add support for userspace return notifier

From: Jan Kiszka <[email protected]>

This adds the arm64-specific bits to implement the userspace return notifier.

---
 arch/arm64/kernel/entry.S | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
arch/arm64/kernel/entry.S +15 -0
index 805d89c0711d..8ebd72125afb 100644
@@ -954,8 +954,23 @@ finish_ret_to_user:
 	enable_step_tsk x1, x2
 #ifdef CONFIG_GCC_PLUGIN_STACKLEAK
 	bl	stackleak_erase
+#endif
+#ifdef CONFIG_IPIPE
+	ldr	x0, [tsk, #TSK_TI_IPIPE]
+	tst	x0, #_TIP_USERINTRET
+	b.ne	call_user_intret_notifier
+exit_head:
 #endif
 	kernel_exit 0
+#ifdef CONFIG_IPIPE
+call_user_intret_notifier:
+	enable_daif
+	bl     	__ipipe_notify_user_intreturn
+	disable_daif
+	cmp    	x0, #0
+	b.ne    exit_head
+	b	ret_to_user_noirq
+#endif
 ENDPROC(ret_to_user)
 
 /*
Signature · 6 lines
2.16.4


-- 
Siemens AG, Corporate Technology, CT RDA IOT SES-DE
Corporate Competence Center Embedded Linux
#1 lore raw
Quoted 6 lines · EDT Jan Kiszka

From: Jan Kiszka <[email protected]>

This adds the arm64-specific bits to implement the userspace return notifier.

arch/arm64/kernel/entry.S finish_ret_to_user: · line 962

Quoted 9 lines
arch/arm64/kernel/entry.S +6 -0
@@ -954,8 +954,23 @@ finish_ret_to_user:
 	enable_step_tsk x1, x2
 #ifdef CONFIG_GCC_PLUGIN_STACKLEAK
 	bl	stackleak_erase
+#endif
+#ifdef CONFIG_IPIPE
+	ldr	x0, [tsk, #TSK_TI_IPIPE]
+	tst	x0, #_TIP_USERINTRET
+	b.ne	call_user_intret_notifier
+exit_head:

Shouldn't exit_head: be a few lines up where work is checked? In other patches, it seems _TIF_WORK_MASK is checked again after ipipe_notify_user_intreturn returns 0.

Quoted 14 lines
arch/arm64/kernel/entry.S +9 -0
 #endif
 	kernel_exit 0
+#ifdef CONFIG_IPIPE
+call_user_intret_notifier:
+	enable_daif
+	bl     	__ipipe_notify_user_intreturn
+	disable_daif
+	cmp    	x0, #0
+	b.ne    exit_head
+	b	ret_to_user_noirq
+#endif
 ENDPROC(ret_to_user)
 
 /*
author
#2 lore raw
Quoted 6 lines · steven.seeger flightsystems.net
Quoted 5 lines · EDT Jan Kiszka

From: Jan Kiszka <[email protected]>

This adds the arm64-specific bits to implement the userspace return notifier.

Quoted 14 lines

arch/arm64/kernel/entry.S finish_ret_to_user: · line 962

Quoted 10 lines
arch/arm64/kernel/entry.S +6 -0
@@ -954,8 +954,23 @@ finish_ret_to_user:
 	enable_step_tsk x1, x2
 #ifdef CONFIG_GCC_PLUGIN_STACKLEAK
 	bl	stackleak_erase
+#endif
+#ifdef CONFIG_IPIPE
+	ldr	x0, [tsk, #TSK_TI_IPIPE]
+	tst	x0, #_TIP_USERINTRET
+	b.ne	call_user_intret_notifier
+exit_head:

Shouldn't exit_head: be a few lines up where work is checked? In other patches, it seems _TIF_WORK_MASK is checked again after ipipe_notify_user_intreturn returns 0.

It is if you look below:

Quoted 11 lines

arch/arm64/kernel/entry.S finish_ret_to_user: · line 972

Quoted 11 lines
arch/arm64/kernel/entry.S +8 -0
 #endif
 	kernel_exit 0
+#ifdef CONFIG_IPIPE
+call_user_intret_notifier:
+	enable_daif
+	bl     	__ipipe_notify_user_intreturn
+	disable_daif
+	cmp    	x0, #0
+	b.ne    exit_head
+	b	ret_to_user_noirq

When __ipipe_notify_user_intreturn returns 0, we go back to ret_to_user_noirq, and that checks again. I think I inverted the jump ordering here, compared to ARM.

Jan

Quoted 7 lines
Quoted 4 lines
arch/arm64/kernel/entry.S +1 -0
+#endif
 ENDPROC(ret_to_user)
 
 /*
Signature · 2 lines
Siemens AG, Corporate Technology, CT RDA IOT SES-DE
Corporate Competence Center Embedded Linux
#3 lore raw
Quoted 3 lines · EDT Jan Kiszka

When __ipipe_notify_user_intreturn returns 0, we go back to ret_to_user_noirq, and that checks again. I think I inverted the jump ordering here, compared to ARM.

That makes sense. I think when I reviewed your patch I assumed that ret_to_user_noirq was the direct exit path. That was actually the first time I ever looked at that file ;)

Steven