From: Maninder Singh <maninder1.s@samsung.com>
To: linux@armlinux.org.uk, ndesaulniers@google.com,
caij2003@gmail.com, tglx@linutronix.de, bigeasy@linutronix.de,
maz@kernel.org, valentin.schneider@arm.com,
vincent.whitchurch@axis.com, nhuck@google.com,
akpm@linux-foundation.org, 0x7f454c46@gmail.com, will@kernel.org
Cc: a.sahrawat@samsung.com, v.narang@samsung.com,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org,
Maninder Singh <maninder1.s@samsung.com>
Subject: [PATCH 1/3] arm: introduce self pointer in thread info
Date: Thu, 8 Oct 2020 12:45:31 +0530 [thread overview]
Message-ID: <1602141333-17822-2-git-send-email-maninder1.s@samsung.com> (raw)
In-Reply-To: <1602141333-17822-1-git-send-email-maninder1.s@samsung.com>
self pointer to thread info is added in thread info.
It is base change required for IRQ stack on ARM.
both stacks will have pointer to thread_info at bottom.
Co-developed-by: Vaneet Narang <v.narang@samsung.com>
Signed-off-by: Vaneet Narang <v.narang@samsung.com>
Signed-off-by: Maninder Singh <maninder1.s@samsung.com>
---
arch/arm/Kconfig | 10 ++++++++++
arch/arm/include/asm/assembler.h | 3 +++
arch/arm/include/asm/thread_info.h | 27 +++++++++++++++++++++++++++
include/linux/thread_info.h | 4 ++++
kernel/fork.c | 1 +
5 files changed, 45 insertions(+)
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index fe2f17eb2..434442f 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1667,6 +1667,16 @@ config STACKPROTECTOR_PER_TASK
Enable this option to switch to a different method that uses a
different canary value for each task.
+config IRQ_STACK
+ bool "use separate stacks for Interrupts"
+ default n
+ depends on FRAME_POINTER && !CC_IS_CLANG
+ help
+ Select this option to use separate stacks for Interrupt handling code.
+ It will add latency in fetching thread info of one more derefer operation
+ and add latency in Interrupt serve at time as for each Interrupt, thread_info
+ pointer needs to be stored at bottom of interrupt stack.
+
endmenu
menu "Boot options"
diff --git a/arch/arm/include/asm/assembler.h b/arch/arm/include/asm/assembler.h
index fce52eed..8512bdc 100644
--- a/arch/arm/include/asm/assembler.h
+++ b/arch/arm/include/asm/assembler.h
@@ -207,6 +207,9 @@
THUMB( mov \rd, sp )
THUMB( lsr \rd, \rd, #THREAD_SIZE_ORDER + PAGE_SHIFT )
mov \rd, \rd, lsl #THREAD_SIZE_ORDER + PAGE_SHIFT
+#ifdef CONFIG_IRQ_STACK
+ ldr \rd, [\rd]
+#endif
.endm
/*
diff --git a/arch/arm/include/asm/thread_info.h b/arch/arm/include/asm/thread_info.h
index 536b6b9..a4d5f76 100644
--- a/arch/arm/include/asm/thread_info.h
+++ b/arch/arm/include/asm/thread_info.h
@@ -44,6 +44,9 @@ struct cpu_context_save {
* __switch_to() assumes cpu_context follows immediately after cpu_domain.
*/
struct thread_info {
+#ifdef CONFIG_IRQ_STACK
+ void *tinfo_ptr; /* pointer to self thread_info */
+#endif
unsigned long flags; /* low level flags */
int preempt_count; /* 0 => preemptable, <0 => bug */
mm_segment_t addr_limit; /* address limit */
@@ -67,14 +70,33 @@ struct thread_info {
#endif
};
+
+#ifdef CONFIG_IRQ_STACK
+#define INIT_THREAD_SELF_PTR \
+ .tinfo_ptr = &init_thread_union.thread_info,
+#else
+#define INIT_THREAD_SELF_PTR
+#endif
+
#define INIT_THREAD_INFO(tsk) \
{ \
+ INIT_THREAD_SELF_PTR \
.task = &tsk, \
.flags = 0, \
.preempt_count = INIT_PREEMPT_COUNT, \
.addr_limit = KERNEL_DS, \
}
+
+#ifdef CONFIG_IRQ_STACK
+#define TASK_THREAD_SELF_POINTER(tsk) \
+{ \
+ struct thread_info *ti = task_thread_info(tsk); \
+ \
+ ti->tinfo_ptr = ti; \
+}
+#endif
+
/*
* how to get the thread information struct from C
*/
@@ -82,8 +104,13 @@ struct thread_info {
static inline struct thread_info *current_thread_info(void)
{
+#ifdef CONFIG_IRQ_STACK
+ return (struct thread_info *)
+ (*((unsigned long *)(current_stack_pointer & ~(THREAD_SIZE - 1))));
+#else
return (struct thread_info *)
(current_stack_pointer & ~(THREAD_SIZE - 1));
+#endif
}
#define thread_saved_pc(tsk) \
diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
index e93e249..ddf7b43 100644
--- a/include/linux/thread_info.h
+++ b/include/linux/thread_info.h
@@ -43,6 +43,10 @@ enum {
#define THREAD_ALIGN THREAD_SIZE
#endif
+#ifndef TASK_THREAD_SELF_POINTER
+#define TASK_THREAD_SELF_POINTER(tsk)
+#endif
+
#define THREADINFO_GFP (GFP_KERNEL_ACCOUNT | __GFP_ZERO)
/*
diff --git a/kernel/fork.c b/kernel/fork.c
index 7ef3eb3..d53f5eb 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -901,6 +901,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig, int node)
#endif
setup_thread_stack(tsk, orig);
+ TASK_THREAD_SELF_POINTER(tsk);
clear_user_return_notifier(tsk);
clear_tsk_need_resched(tsk);
set_task_stack_end_magic(tsk);
--
1.9.1
next prev parent reply other threads:[~2020-10-08 7:18 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20201008071628epcas5p24d196a6023a47a3b0bfa7b7f231ec811@epcas5p2.samsung.com>
2020-10-08 7:15 ` [PATCH 0/3] IRQ stack support for ARM Maninder Singh
[not found] ` <CGME20201008071633epcas5p20f5c533ac67ab235997e7e4a8ad3022b@epcas5p2.samsung.com>
2020-10-08 7:15 ` Maninder Singh [this message]
[not found] ` <CGME20201008071639epcas5p465f13d992a25936ba63436baf1fb6f83@epcas5p4.samsung.com>
2020-10-08 7:15 ` [PATCH 2/3] arm: introduce IRQ stacks Maninder Singh
[not found] ` <CAK8P3a2RYeNiTy9QmwFVKtFifXxWc9XfAT6ThPoSH9wGYsKGpA@mail.gmail.com>
2020-10-21 12:42 ` Arnd Bergmann
2020-10-21 12:45 ` Russell King - ARM Linux admin
2020-10-21 12:55 ` Arnd Bergmann
2020-10-21 12:57 ` Russell King - ARM Linux admin
2020-10-21 15:59 ` Arnd Bergmann
2020-11-09 14:45 ` Tony Lindgren
2020-11-09 19:10 ` Arnd Bergmann
2020-11-10 9:19 ` Tony Lindgren
2020-11-10 10:04 ` Arnd Bergmann
2020-11-10 12:04 ` Tony Lindgren
2020-11-10 13:35 ` Arnd Bergmann
2020-11-11 6:56 ` Tony Lindgren
[not found] ` <CGME20201008071639epcas5p465f13d992a25936ba63436baf1fb6f83@epcms5p7>
2020-10-21 13:46 ` Vaneet Narang
[not found] ` <CGME20201008071644epcas5p1f5c220b5f58fd4251695af147325b7c4@epcas5p1.samsung.com>
2020-10-08 7:15 ` [PATCH 3/3] arm: Modify stack trace and dump for use with irq stack Maninder Singh
2020-10-08 7:53 ` [PATCH 0/3] IRQ stack support for ARM Sebastian Andrzej Siewior
2020-10-08 8:30 ` Russell King - ARM Linux admin
2020-10-15 20:59 ` Nick Desaulniers
2020-10-15 21:16 ` Florian Fainelli
[not found] ` <CAK8P3a0h=D8_Kn_fpHbsik_jf4to2jayxj7K7B7=HaNFzKqNnw@mail.gmail.com>
2020-10-21 11:58 ` Arnd Bergmann
2020-10-21 12:34 ` Russell King - ARM Linux admin
2020-10-21 12:46 ` Arnd Bergmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1602141333-17822-2-git-send-email-maninder1.s@samsung.com \
--to=maninder1.s@samsung.com \
--cc=0x7f454c46@gmail.com \
--cc=a.sahrawat@samsung.com \
--cc=akpm@linux-foundation.org \
--cc=bigeasy@linutronix.de \
--cc=caij2003@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=maz@kernel.org \
--cc=ndesaulniers@google.com \
--cc=nhuck@google.com \
--cc=tglx@linutronix.de \
--cc=v.narang@samsung.com \
--cc=valentin.schneider@arm.com \
--cc=vincent.whitchurch@axis.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®