Skip to content

Commit 3afe907

Browse files
committed
Merge tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux
Pull arm64 fixes from Catalin Marinas: "Fix the arm64 linear map range detection for tagged addresses and replace the bitwise operations with subtract (virt_addr_valid(), __is_lm_address(), __lm_to_phys())" * tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux: arm64: Use simpler arithmetics for the linear map macros arm64: Do not pass tagged addresses to __is_lm_address()
2 parents dbc15d2 + 22cd5ed commit 3afe907

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

arch/arm64/include/asm/memory.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,9 @@ static inline const void *__tag_set(const void *addr, u8 tag)
251251
* lives in the [PAGE_OFFSET, PAGE_END) interval at the bottom of the
252252
* kernel's TTBR1 address range.
253253
*/
254-
#define __is_lm_address(addr) (((u64)(addr) ^ PAGE_OFFSET) < (PAGE_END - PAGE_OFFSET))
254+
#define __is_lm_address(addr) (((u64)(addr) - PAGE_OFFSET) < (PAGE_END - PAGE_OFFSET))
255255

256-
#define __lm_to_phys(addr) (((addr) & ~PAGE_OFFSET) + PHYS_OFFSET)
256+
#define __lm_to_phys(addr) (((addr) - PAGE_OFFSET) + PHYS_OFFSET)
257257
#define __kimg_to_phys(addr) ((addr) - kimage_voffset)
258258

259259
#define __virt_to_phys_nodebug(x) ({ \
@@ -332,7 +332,7 @@ static inline void *phys_to_virt(phys_addr_t x)
332332
#endif /* !CONFIG_SPARSEMEM_VMEMMAP || CONFIG_DEBUG_VIRTUAL */
333333

334334
#define virt_addr_valid(addr) ({ \
335-
__typeof__(addr) __addr = addr; \
335+
__typeof__(addr) __addr = __tag_reset(addr); \
336336
__is_lm_address(__addr) && pfn_valid(virt_to_pfn(__addr)); \
337337
})
338338

arch/arm64/mm/physaddr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
phys_addr_t __virt_to_phys(unsigned long x)
1111
{
12-
WARN(!__is_lm_address(x),
12+
WARN(!__is_lm_address(__tag_reset(x)),
1313
"virt_to_phys used for non-linear address: %pK (%pS)\n",
1414
(void *)x,
1515
(void *)x);

0 commit comments

Comments
 (0)