Skip to content

Commit fa191b7

Browse files
ardbiesheuvelRussell King (Oracle)
authored andcommitted
ARM: 9150/1: Fix PID_IN_CONTEXTIDR regression when THREAD_INFO_IN_TASK=y
The code that implements the rarely used PID_IN_CONTEXTIDR feature dereferences the 'task' field of struct thread_info directly, and this is no longer possible when THREAD_INFO_IN_TASK=y, as the 'task' field is omitted from the struct definition in that case. Instead, we should just cast the thread_info pointer to a task_struct pointer, given that the former is now the first member of the latter. So use a helper that abstracts this, and provide implementations for both cases. Reported by: Arnd Bergmann <[email protected]> Fixes: 18ed1c0 ("ARM: smp: Enable THREAD_INFO_IN_TASK") Signed-off-by: Ard Biesheuvel <[email protected]> Signed-off-by: Russell King (Oracle) <[email protected]>
1 parent 13a695a commit fa191b7

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

arch/arm/include/asm/thread_info.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,20 @@ struct thread_info {
7979

8080
#ifdef CONFIG_THREAD_INFO_IN_TASK
8181
#define INIT_THREAD_INFO_TASK(tsk)
82+
83+
static inline struct task_struct *thread_task(struct thread_info* ti)
84+
{
85+
return (struct task_struct *)ti;
86+
}
87+
8288
#else
8389
#define INIT_THREAD_INFO_TASK(tsk) .task = &(tsk),
8490

91+
static inline struct task_struct *thread_task(struct thread_info* ti)
92+
{
93+
return ti->task;
94+
}
95+
8596
/*
8697
* how to get the thread information struct from C
8798
*/

arch/arm/mm/context.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ static int contextidr_notifier(struct notifier_block *unused, unsigned long cmd,
109109
if (cmd != THREAD_NOTIFY_SWITCH)
110110
return NOTIFY_DONE;
111111

112-
pid = task_pid_nr(thread->task) << ASID_BITS;
112+
pid = task_pid_nr(thread_task(thread)) << ASID_BITS;
113113
asm volatile(
114114
" mrc p15, 0, %0, c13, c0, 1\n"
115115
" and %0, %0, %2\n"

0 commit comments

Comments
 (0)