[PATCH v5 3/9] riscv/kprobe: Prepare the skeleton to prepare optimized kprobe
liaochang (A)
liaochang1 at huawei.com
Wed Jan 4 00:34:35 PST 2023
在 2023/1/3 2:03, Björn Töpel 写道:
> Chen Guokai <chenguokai17 at mails.ucas.ac.cn> writes:
>
>> From: Liao Chang <liaochang1 at huawei.com>
>
>> arch/riscv/kernel/probes/opt.c | 107 ++++++++++++++++++++++++++++++++-
>>
>> diff --git a/arch/riscv/kernel/probes/opt.c b/arch/riscv/kernel/probes/opt.c
>> index 56c8a227c857..a4271e6033ba 100644
>> --- a/arch/riscv/kernel/probes/opt.c
>> +++ b/arch/riscv/kernel/probes/opt.c
>
>> @@ -24,7 +72,64 @@ int arch_check_optimized_kprobe(struct optimized_kprobe *op)
>> int arch_prepare_optimized_kprobe(struct optimized_kprobe *op,
>> struct kprobe *orig)
>> {
>> - return 0;
>> + long rel;
>> + int rd, ra, ret;
>> + kprobe_opcode_t *code = NULL, *slot = NULL;
>> +
>> + if (!can_optimize((unsigned long)orig->addr, op))
>> + return -EILSEQ;
>> +
>> + code = kzalloc(MAX_OPTINSN_SIZE, GFP_KERNEL);
>> + slot = get_optinsn_slot();
>> + if (!code || !slot) {
>> + ret = -ENOMEM;
>> + goto on_error;
>> + }
>> +
>> + /*
>> + * Verify if the address gap is within 4GB range, because this uses
>> + * a auipc+jalr pair.
>
> Try to be consistent. You're mixing "AUIPC/JALR" with "auipc+jalr".
OK,i will use AUIPC/JALR in all commit messages and comments of this series.
>
>> + */
>> + rel = (unsigned long)slot - (unsigned long)orig->addr;
>> + if (!in_auipc_jalr_range(rel)) {
>> + /*
>> + * Different from x86, we free code buf directly instead
>> of
>
> Reword for readers that are not familiar with x86.
OK, BTW, i think the code following tag on_error is fairly self-explanatoty,
perhaps this comment is no need anymore.
>
>
> Björn
--
BR,
Liao, Chang
More information about the linux-riscv
mailing list