forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ARM: 7659/1: mm: make mm->context.id an atomic64_t variable
mm->context.id is updated under asid_lock when a new ASID is allocated to an mm_struct. However, it is also read without the lock when a task is being scheduled and checking whether or not the current ASID generation is up-to-date. If two threads of the same process are being scheduled in parallel and the bottom bits of the generation in their mm->context.id match the current generation (that is, the mm_struct has not been used for ~2^24 rollovers) then the non-atomic, lockless access to mm->context.id may yield the incorrect ASID. This patch fixes this issue by making mm->context.id and atomic64_t, ensuring that the generation is always read consistently. For code that only requires access to the ASID bits (e.g. TLB flushing by mm), then the value is accessed directly, which GCC converts to an ldrb. Cc: <[email protected]> # 3.8 Reviewed-by: Catalin Marinas <[email protected]> Signed-off-by: Will Deacon <[email protected]> Signed-off-by: Russell King <[email protected]>
- Loading branch information
Showing
4 changed files
with
19 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,15 +5,15 @@ | |
|
||
typedef struct { | ||
#ifdef CONFIG_CPU_HAS_ASID | ||
u64 id; | ||
atomic64_t id; | ||
#endif | ||
unsigned int vmalloc_seq; | ||
unsigned int vmalloc_seq; | ||
} mm_context_t; | ||
|
||
#ifdef CONFIG_CPU_HAS_ASID | ||
#define ASID_BITS 8 | ||
#define ASID_MASK ((~0ULL) << ASID_BITS) | ||
#define ASID(mm) ((mm)->context.id & ~ASID_MASK) | ||
#define ASID(mm) ((mm)->context.id.counter & ~ASID_MASK) | ||
#else | ||
#define ASID(mm) (0) | ||
#endif | ||
|
@@ -26,7 +26,7 @@ typedef struct { | |
* modified for 2.6 by Hyok S. Choi <[email protected]> | ||
*/ | ||
typedef struct { | ||
unsigned long end_brk; | ||
unsigned long end_brk; | ||
} mm_context_t; | ||
|
||
#endif | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters