Skip to content

Commit 9c23f84

Browse files
xairytorvalds
authored andcommitted
arm64: move untagged_addr macro from uaccess.h to memory.h
Move the untagged_addr() macro from arch/arm64/include/asm/uaccess.h to arch/arm64/include/asm/memory.h to be later reused by KASAN. Also make the untagged_addr() macro accept all kinds of address types (void *, unsigned long, etc.). This allows not to specify type casts in each place where the macro is used. This is done by using __typeof__. Link: http://lkml.kernel.org/r/2e9ef8d2ed594106eca514b268365b5419113f6a.1544099024.git.andreyknvl@google.com Signed-off-by: Andrey Konovalov <andreyknvl@google.com> Acked-by: Mark Rutland <mark.rutland@arm.com> Acked-by: Will Deacon <will.deacon@arm.com> Cc: Andrey Ryabinin <aryabinin@virtuozzo.com> Cc: Christoph Lameter <cl@linux.com> Cc: Dmitry Vyukov <dvyukov@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 080eb83 commit 9c23f84

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

arch/arm64/include/asm/memory.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,14 @@ extern u64 vabits_user;
218218
*/
219219
#define PHYS_PFN_OFFSET (PHYS_OFFSET >> PAGE_SHIFT)
220220

221+
/*
222+
* When dealing with data aborts, watchpoints, or instruction traps we may end
223+
* up with a tagged userland pointer. Clear the tag to get a sane pointer to
224+
* pass on to access_ok(), for instance.
225+
*/
226+
#define untagged_addr(addr) \
227+
((__typeof__(addr))sign_extend64((u64)(addr), 55))
228+
221229
/*
222230
* Physical vs virtual RAM address space conversion. These are
223231
* private definitions which should NOT be used outside memory.h

arch/arm64/include/asm/uaccess.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,6 @@ static inline unsigned long __range_ok(const void __user *addr, unsigned long si
9595
return ret;
9696
}
9797

98-
/*
99-
* When dealing with data aborts, watchpoints, or instruction traps we may end
100-
* up with a tagged userland pointer. Clear the tag to get a sane pointer to
101-
* pass on to access_ok(), for instance.
102-
*/
103-
#define untagged_addr(addr) sign_extend64(addr, 55)
104-
10598
#define access_ok(type, addr, size) __range_ok(addr, size)
10699
#define user_addr_max get_fs
107100

0 commit comments

Comments
 (0)