Skip to contentSkip to conversation

arm64: patching: Use uintptr_t in aarch64_insn_patch_text_nosync()

PATCH New Thorsten Blum 1 participant 1 message Nov 4 arm64

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm64: patching: Use uintptr_t in aarch64_insn_patch_text_nosync()

Use uintptr_t for tp instead of casting it multiple times and pass addr directly to aarch64_insn_write().

---
 arch/arm64/kernel/patching.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
arch/arm64/kernel/patching.c +4 -5
index 09f019c6547a..24333419a8f1 100644
@@ -178,17 +178,16 @@ noinstr void *aarch64_insn_set(void *dst, u32 insn, size_t len)
 
 int __kprobes aarch64_insn_patch_text_nosync(void *addr, u32 insn)
 {
-	u32 *tp = addr;
+	uintptr_t tp = (uintptr_t)addr;
 	int ret;
 
 	/* A64 instructions must be word aligned */
-	if ((uintptr_t)tp & 0x3)
+	if (tp & 0x3)
 		return -EINVAL;
 
-	ret = aarch64_insn_write(tp, insn);
+	ret = aarch64_insn_write(addr, insn);
 	if (ret == 0)
-		caches_clean_inval_pou((uintptr_t)tp,
-				     (uintptr_t)tp + AARCH64_INSN_SIZE);
+		caches_clean_inval_pou(tp, tp + AARCH64_INSN_SIZE);
 
 	return ret;
 }