__kimg_to_phys (which is used by virt_to_phys) assumes that the top byte of the address is 0xff, which isn't always the case with KHWASAN enabled. The solution is to reset the tag in __kimg_to_phys. __lm_to_phys doesn't require any fixups, as it zeroes out the top byte with the current implementation. Signed-off-by: Andrey Konovalov <andreyknvl@xxxxxxxxxx> --- arch/arm64/include/asm/memory.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h index febd54ff3354..c13b89257352 100644 --- a/arch/arm64/include/asm/memory.h +++ b/arch/arm64/include/asm/memory.h @@ -98,6 +98,10 @@ #define KASAN_THREAD_SHIFT 0 #endif +#ifdef CONFIG_KASAN_TAGS +#define KASAN_PTR_TAG_MASK (UL(0xff) << 56) +#endif + #define MIN_THREAD_SHIFT (14 + KASAN_THREAD_SHIFT) /* @@ -231,7 +235,12 @@ static inline unsigned long kaslr_offset(void) #define __is_lm_address(addr) (!!((addr) & BIT(VA_BITS - 1))) #define __lm_to_phys(addr) (((addr) & ~PAGE_OFFSET) + PHYS_OFFSET) + +#ifdef CONFIG_KASAN_TAGS +#define __kimg_to_phys(addr) (((addr) | KASAN_PTR_TAG_MASK) - kimage_voffset) +#else #define __kimg_to_phys(addr) ((addr) - kimage_voffset) +#endif #define __virt_to_phys_nodebug(x) ({ \ phys_addr_t __x = (phys_addr_t)(x); \ -- 2.17.0.rc0.231.g781580f067-goog _______________________________________________ kvmarm mailing list kvmarm@xxxxxxxxxxxxxxxxxxxxx https://lists.cs.columbia.edu/mailman/listinfo/kvmarm