[PATCH 1/9] powerpc/lib: Add helper to check if offset is within conditional branch range
Naveen N. Rao
naveen.n.rao at linux.vnet.ibm.com
Tue Oct 5 05:03:27 AEDT 2021
Hi Christophe,
Thanks for the reviews.
Christophe Leroy wrote:
>
>
> Le 01/10/2021 à 23:14, Naveen N. Rao a écrit :
>> Add a helper to check if a given offset is within the branch range for a
>> powerpc conditional branch instruction, and update some sites to use the
>> new helper.
>>
>> Signed-off-by: Naveen N. Rao <naveen.n.rao at linux.vnet.ibm.com>
>> ---
>> arch/powerpc/include/asm/code-patching.h | 1 +
>> arch/powerpc/lib/code-patching.c | 7 ++++++-
>> arch/powerpc/net/bpf_jit.h | 7 +------
>> 3 files changed, 8 insertions(+), 7 deletions(-)
>>
>> diff --git a/arch/powerpc/include/asm/code-patching.h b/arch/powerpc/include/asm/code-patching.h
>> index a95f63788c6b14..4ba834599c4d4c 100644
>> --- a/arch/powerpc/include/asm/code-patching.h
>> +++ b/arch/powerpc/include/asm/code-patching.h
>> @@ -23,6 +23,7 @@
>> #define BRANCH_ABSOLUTE 0x2
>>
>> bool is_offset_in_branch_range(long offset);
>> +bool is_offset_in_cond_branch_range(long offset);
>> int create_branch(struct ppc_inst *instr, const u32 *addr,
>> unsigned long target, int flags);
>> int create_cond_branch(struct ppc_inst *instr, const u32 *addr,
>> diff --git a/arch/powerpc/lib/code-patching.c b/arch/powerpc/lib/code-patching.c
>> index f9a3019e37b43c..e2342b9a1ab9c9 100644
>> --- a/arch/powerpc/lib/code-patching.c
>> +++ b/arch/powerpc/lib/code-patching.c
>> @@ -228,6 +228,11 @@ bool is_offset_in_branch_range(long offset)
>> return (offset >= -0x2000000 && offset <= 0x1fffffc && !(offset & 0x3));
>> }
>>
>> +bool is_offset_in_cond_branch_range(long offset)
>> +{
>> + return offset >= -0x8000 && offset <= 0x7FFF && !(offset & 0x3);
>> +}
>
> Would be better without capital letters in numbers, in extenso 0x7fff
> instead of 0x7FFF
Ack.
- Naveen
More information about the Linuxppc-dev
mailing list