From 46084bc253e1acdd6c47846e91fc20f4ab4f1fec Mon Sep 17 00:00:00 2001 From: Suzuki K Poulose Date: Fri, 9 Sep 2016 14:07:12 +0100 Subject: arm64: insn: Add helpers for adrp offsets Adds helpers for decoding/encoding the PC relative addresses for adrp. This will be used for handling dynamic patching of 'adrp' instructions in alternative code patching. Cc: Mark Rutland Cc: Will Deacon Cc: Catalin Marinas Cc: Marc Zyngier Signed-off-by: Suzuki K Poulose Signed-off-by: Will Deacon --- arch/arm64/kernel/insn.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'arch/arm64/kernel/insn.c') diff --git a/arch/arm64/kernel/insn.c b/arch/arm64/kernel/insn.c index 178488fc775f..6f2ac4fc66ca 100644 --- a/arch/arm64/kernel/insn.c +++ b/arch/arm64/kernel/insn.c @@ -1202,6 +1202,19 @@ u32 aarch64_set_branch_offset(u32 insn, s32 offset) BUG(); } +s32 aarch64_insn_adrp_get_offset(u32 insn) +{ + BUG_ON(!aarch64_insn_is_adrp(insn)); + return aarch64_insn_decode_immediate(AARCH64_INSN_IMM_ADR, insn) << 12; +} + +u32 aarch64_insn_adrp_set_offset(u32 insn, s32 offset) +{ + BUG_ON(!aarch64_insn_is_adrp(insn)); + return aarch64_insn_encode_immediate(AARCH64_INSN_IMM_ADR, insn, + offset >> 12); +} + /* * Extract the Op/CR data from a msr/mrs instruction. */ -- cgit v1.2.3