2022-12-09 09:58:15

by Tiezhu Yang

[permalink] [raw]
Subject: [PATCH v10 0/4] Add kprobe and kretprobe support for LoongArch

v10:
-- Remove sign_extend() based on the latest code
-- Rename insns_are_not_supported() to insns_not_supported()
-- Rename insns_are_not_simulated() to insns_not_simulated()
-- Set KPROBE_HIT_SSDONE if cur->post_handler is not NULL
-- Enable preemption for KPROBE_REENTER in kprobe_fault_handler()

v9:
-- Rename sign_extended() to sign_extend()
-- Modify kprobe_fault_handler() to handle all of kprobe_status

v8:
-- Put "regs->csr_prmd &= ~CSR_PRMD_PIE;" ahead to save one line
-- Add code comment of preempt_disable()
-- Put kprobe_page_fault() in __do_page_fault()
-- Modify the check condition of break insn in kprobe_breakpoint_handler()

v7:
-- Remove stop_machine_cpuslocked() related code

v6:
-- Add a new patch to redefine larch_insn_patch_text() with
stop_machine_cpuslocked()
-- Modify kprobe_breakpoint_handler() to consider the original
insn is break and return the correct value
-- Modify do_bp() to refresh bcode when original insn is break

v5:
-- Rebase on the latest code
-- Use stop_machine_cpuslocked() to modify insn to avoid CPU race

v4:
-- Remove kprobe_exceptions_notify() in kprobes.c
-- Call kprobe_breakpoint_handler() and kprobe_singlestep_handler()
in do_bp()

v3:
-- Rebase on the latest code
-- Check the alignment of PC in simu_branch() and simu_pc()
-- Add ibar in flush_insn_slot()
-- Rename kprobe_{pre,post}_handler() to {post_}kprobe_handler
-- Add preempt_disable() and preempt_enable_no_resched()
-- Remove r0 save/restore and do some minor changes
in kprobes_trampoline.S
-- Do not enable CONFIG_KPROBES by default

v2:
-- Split simu_branch() and simu_pc() into a single patch
-- Call kprobe_page_fault() in do_page_fault()
-- Add kprobes_trampoline.S for kretprobe

Tiezhu Yang (4):
LoongArch: Simulate branch and PC instructions
LoongArch: Add kprobe support
LoongArch: Add kretprobe support
samples/kprobes: Add LoongArch support

arch/loongarch/Kconfig | 2 +
arch/loongarch/include/asm/inst.h | 20 ++
arch/loongarch/include/asm/kprobes.h | 59 +++++
arch/loongarch/include/asm/ptrace.h | 1 +
arch/loongarch/kernel/Makefile | 2 +
arch/loongarch/kernel/inst.c | 123 ++++++++++
arch/loongarch/kernel/kprobes.c | 364 +++++++++++++++++++++++++++++
arch/loongarch/kernel/kprobes_trampoline.S | 96 ++++++++
arch/loongarch/kernel/traps.c | 13 +-
arch/loongarch/mm/fault.c | 3 +
samples/kprobes/kprobe_example.c | 8 +
11 files changed, 687 insertions(+), 4 deletions(-)
create mode 100644 arch/loongarch/include/asm/kprobes.h
create mode 100644 arch/loongarch/kernel/kprobes.c
create mode 100644 arch/loongarch/kernel/kprobes_trampoline.S

--
2.1.0


2022-12-09 10:18:27

by Huacai Chen

[permalink] [raw]
Subject: Re: [PATCH v10 0/4] Add kprobe and kretprobe support for LoongArch

Hi, Masami,

This series looks good to me now, but I'm not familiar with kprobes.
So, if you have any comments, please let me know.

And Jeff,

As we all know, you are an expert in this domain, so could you please
help me to test this series?

If there are no objections, I plan to merge this series in a few days.
But since the next merge window will be open soon, if there are any
problems, I will revert the patches to wait for the next cycle.

Thanks,
Huacai

On Fri, Dec 9, 2022 at 4:53 PM Tiezhu Yang <[email protected]> wrote:
>
> v10:
> -- Remove sign_extend() based on the latest code
> -- Rename insns_are_not_supported() to insns_not_supported()
> -- Rename insns_are_not_simulated() to insns_not_simulated()
> -- Set KPROBE_HIT_SSDONE if cur->post_handler is not NULL
> -- Enable preemption for KPROBE_REENTER in kprobe_fault_handler()
>
> v9:
> -- Rename sign_extended() to sign_extend()
> -- Modify kprobe_fault_handler() to handle all of kprobe_status
>
> v8:
> -- Put "regs->csr_prmd &= ~CSR_PRMD_PIE;" ahead to save one line
> -- Add code comment of preempt_disable()
> -- Put kprobe_page_fault() in __do_page_fault()
> -- Modify the check condition of break insn in kprobe_breakpoint_handler()
>
> v7:
> -- Remove stop_machine_cpuslocked() related code
>
> v6:
> -- Add a new patch to redefine larch_insn_patch_text() with
> stop_machine_cpuslocked()
> -- Modify kprobe_breakpoint_handler() to consider the original
> insn is break and return the correct value
> -- Modify do_bp() to refresh bcode when original insn is break
>
> v5:
> -- Rebase on the latest code
> -- Use stop_machine_cpuslocked() to modify insn to avoid CPU race
>
> v4:
> -- Remove kprobe_exceptions_notify() in kprobes.c
> -- Call kprobe_breakpoint_handler() and kprobe_singlestep_handler()
> in do_bp()
>
> v3:
> -- Rebase on the latest code
> -- Check the alignment of PC in simu_branch() and simu_pc()
> -- Add ibar in flush_insn_slot()
> -- Rename kprobe_{pre,post}_handler() to {post_}kprobe_handler
> -- Add preempt_disable() and preempt_enable_no_resched()
> -- Remove r0 save/restore and do some minor changes
> in kprobes_trampoline.S
> -- Do not enable CONFIG_KPROBES by default
>
> v2:
> -- Split simu_branch() and simu_pc() into a single patch
> -- Call kprobe_page_fault() in do_page_fault()
> -- Add kprobes_trampoline.S for kretprobe
>
> Tiezhu Yang (4):
> LoongArch: Simulate branch and PC instructions
> LoongArch: Add kprobe support
> LoongArch: Add kretprobe support
> samples/kprobes: Add LoongArch support
>
> arch/loongarch/Kconfig | 2 +
> arch/loongarch/include/asm/inst.h | 20 ++
> arch/loongarch/include/asm/kprobes.h | 59 +++++
> arch/loongarch/include/asm/ptrace.h | 1 +
> arch/loongarch/kernel/Makefile | 2 +
> arch/loongarch/kernel/inst.c | 123 ++++++++++
> arch/loongarch/kernel/kprobes.c | 364 +++++++++++++++++++++++++++++
> arch/loongarch/kernel/kprobes_trampoline.S | 96 ++++++++
> arch/loongarch/kernel/traps.c | 13 +-
> arch/loongarch/mm/fault.c | 3 +
> samples/kprobes/kprobe_example.c | 8 +
> 11 files changed, 687 insertions(+), 4 deletions(-)
> create mode 100644 arch/loongarch/include/asm/kprobes.h
> create mode 100644 arch/loongarch/kernel/kprobes.c
> create mode 100644 arch/loongarch/kernel/kprobes_trampoline.S
>
> --
> 2.1.0
>

2022-12-09 11:17:07

by WANG Xuerui

[permalink] [raw]
Subject: Re: [PATCH v10 0/4] Add kprobe and kretprobe support for LoongArch

On 2022/12/9 18:01, Huacai Chen wrote:
> Hi, Masami,
>
> This series looks good to me now, but I'm not familiar with kprobes.
> So, if you have any comments, please let me know.
>
> And Jeff,
>
> As we all know, you are an expert in this domain, so could you please
> help me to test this series?
>
> If there are no objections, I plan to merge this series in a few days.
> But since the next merge window will be open soon, if there are any
> problems, I will revert the patches to wait for the next cycle.

Sorry for jumping in so late, but due to the imminence of the merge
window, and Linus having *specifically* asked for readiness of all 6.2
material upfront due to holidays, IMHO it could be more prudent to wait
one more cycle. Especially considering some other people's code probably
already made the respective maintainers more cautious due to the compile
warnings, and hurried fixes to some other similarly hurried commits...

--
WANG "xen0n" Xuerui

Linux/LoongArch mailing list: https://lore.kernel.org/loongarch/

2022-12-10 15:22:21

by Jeff Xie

[permalink] [raw]
Subject: Re: [PATCH v10 0/4] Add kprobe and kretprobe support for LoongArch

On Fri, Dec 9, 2022 at 6:01 PM Huacai Chen <[email protected]> wrote:
>
> Hi, Masami,
>
> This series looks good to me now, but I'm not familiar with kprobes.
> So, if you have any comments, please let me know.
>
> And Jeff,
>
> As we all know, you are an expert in this domain, so could you please
> help me to test this series?
>
> If there are no objections, I plan to merge this series in a few days.
> But since the next merge window will be open soon, if there are any
> problems, I will revert the patches to wait for the next cycle.

I can't use the kprobe function normally now, tested the function from
the branch: https://github.com/loongson/linux/commits/loongarch-next

steps:
1. Try to probe __memset_fast()

[root@loongarch ]# cat /proc/kallsyms | grep __memset_fast
90000000012c75f0 T __memset_fast

./samples/kprobes/kprobe_example.c
static char symbol[KSYM_NAME_LEN] = "__memset_fast";

2. Loading the kprobe_example.ko
[root@loongarch mnt]# insmod ./kprobe_example.ko

*** The system will keep hanging ***

dmesg-messages:
gef➤ lx-dmesg
[ 12.348047] handler_pre: <__memset_fast> p->addr =
0x(____ptrval____), era = 0x90000000012c75f0, estat = 0xc0000
[ 12.348512] handler_post: <__memset_fast> p->addr =
0x(____ptrval____), estat = 0xc0000
[ 12.348525] handler_post: <__memset_fast> p->addr =
0x(____ptrval____), estat = 0xc0000
[ 12.349248] handler_pre: <__memset_fast> p->addr =
0x(____ptrval____), era = 0x90000000012c75f0, estat = 0xc0000
[ 12.349259] handler_post: <__memset_fast> p->addr =
0x(____ptrval____), estat = 0xc0000

call trace:
gef➤ bt
#0 0x90000000012f45f8 in queued_spin_lock_slowpath
(lock=0x9000000001cc0018 <die_lock>, val=0x1) at
kernel/locking/qspinlock.c:383
#1 0x9000000000223b2c in die (str=str@entry=0x90000000017e3488 "Break
instruction in kernel code", regs=regs@entry=0x900000010fd735f0) at
arch/loongarch/kernel/traps.c:240
#2 0x90000000012e3968 in die_if_kernel (regs=<optimized out>,
str=<optimized out>) at ./arch/loongarch/include/asm/ptrace.h:131
#3 do_bp (regs=0x900000010fd735f0) at arch/loongarch/kernel/traps.c:485
#4 0x9000000001cb1924 in exception_handlers ()
Backtrace stopped: frame did not save the PC



> Thanks,
> Huacai
>
> On Fri, Dec 9, 2022 at 4:53 PM Tiezhu Yang <[email protected]> wrote:
> >
> > v10:
> > -- Remove sign_extend() based on the latest code
> > -- Rename insns_are_not_supported() to insns_not_supported()
> > -- Rename insns_are_not_simulated() to insns_not_simulated()
> > -- Set KPROBE_HIT_SSDONE if cur->post_handler is not NULL
> > -- Enable preemption for KPROBE_REENTER in kprobe_fault_handler()
> >
> > v9:
> > -- Rename sign_extended() to sign_extend()
> > -- Modify kprobe_fault_handler() to handle all of kprobe_status
> >
> > v8:
> > -- Put "regs->csr_prmd &= ~CSR_PRMD_PIE;" ahead to save one line
> > -- Add code comment of preempt_disable()
> > -- Put kprobe_page_fault() in __do_page_fault()
> > -- Modify the check condition of break insn in kprobe_breakpoint_handler()
> >
> > v7:
> > -- Remove stop_machine_cpuslocked() related code
> >
> > v6:
> > -- Add a new patch to redefine larch_insn_patch_text() with
> > stop_machine_cpuslocked()
> > -- Modify kprobe_breakpoint_handler() to consider the original
> > insn is break and return the correct value
> > -- Modify do_bp() to refresh bcode when original insn is break
> >
> > v5:
> > -- Rebase on the latest code
> > -- Use stop_machine_cpuslocked() to modify insn to avoid CPU race
> >
> > v4:
> > -- Remove kprobe_exceptions_notify() in kprobes.c
> > -- Call kprobe_breakpoint_handler() and kprobe_singlestep_handler()
> > in do_bp()
> >
> > v3:
> > -- Rebase on the latest code
> > -- Check the alignment of PC in simu_branch() and simu_pc()
> > -- Add ibar in flush_insn_slot()
> > -- Rename kprobe_{pre,post}_handler() to {post_}kprobe_handler
> > -- Add preempt_disable() and preempt_enable_no_resched()
> > -- Remove r0 save/restore and do some minor changes
> > in kprobes_trampoline.S
> > -- Do not enable CONFIG_KPROBES by default
> >
> > v2:
> > -- Split simu_branch() and simu_pc() into a single patch
> > -- Call kprobe_page_fault() in do_page_fault()
> > -- Add kprobes_trampoline.S for kretprobe
> >
> > Tiezhu Yang (4):
> > LoongArch: Simulate branch and PC instructions
> > LoongArch: Add kprobe support
> > LoongArch: Add kretprobe support
> > samples/kprobes: Add LoongArch support
> >
> > arch/loongarch/Kconfig | 2 +
> > arch/loongarch/include/asm/inst.h | 20 ++
> > arch/loongarch/include/asm/kprobes.h | 59 +++++
> > arch/loongarch/include/asm/ptrace.h | 1 +
> > arch/loongarch/kernel/Makefile | 2 +
> > arch/loongarch/kernel/inst.c | 123 ++++++++++
> > arch/loongarch/kernel/kprobes.c | 364 +++++++++++++++++++++++++++++
> > arch/loongarch/kernel/kprobes_trampoline.S | 96 ++++++++
> > arch/loongarch/kernel/traps.c | 13 +-
> > arch/loongarch/mm/fault.c | 3 +
> > samples/kprobes/kprobe_example.c | 8 +
> > 11 files changed, 687 insertions(+), 4 deletions(-)
> > create mode 100644 arch/loongarch/include/asm/kprobes.h
> > create mode 100644 arch/loongarch/kernel/kprobes.c
> > create mode 100644 arch/loongarch/kernel/kprobes_trampoline.S
> >
> > --
> > 2.1.0
> >



--
Thanks,
JeffXie

2022-12-12 08:53:18

by Hengqi Chen

[permalink] [raw]
Subject: Re: [PATCH v10 0/4] Add kprobe and kretprobe support for LoongArch

Hi, Tiezhu:

I tested this patchset from BPF side, failed with EINVAL:

$ cat /sys/kernel/tracing/error_log
[ 262.299093] trace_kprobe: error: Failed to register probe event
Command: p:kprobes/libbpf_4609_inet_bind_0x0_0 inet_bind+0x0
^
--
Hengqi

On 2022/12/9 16:52, Tiezhu Yang wrote:
> v10:
> -- Remove sign_extend() based on the latest code
> -- Rename insns_are_not_supported() to insns_not_supported()
> -- Rename insns_are_not_simulated() to insns_not_simulated()
> -- Set KPROBE_HIT_SSDONE if cur->post_handler is not NULL
> -- Enable preemption for KPROBE_REENTER in kprobe_fault_handler()
>
> v9:
> -- Rename sign_extended() to sign_extend()
> -- Modify kprobe_fault_handler() to handle all of kprobe_status
>
> v8:
> -- Put "regs->csr_prmd &= ~CSR_PRMD_PIE;" ahead to save one line
> -- Add code comment of preempt_disable()
> -- Put kprobe_page_fault() in __do_page_fault()
> -- Modify the check condition of break insn in kprobe_breakpoint_handler()
>
> v7:
> -- Remove stop_machine_cpuslocked() related code
>
> v6:
> -- Add a new patch to redefine larch_insn_patch_text() with
> stop_machine_cpuslocked()
> -- Modify kprobe_breakpoint_handler() to consider the original
> insn is break and return the correct value
> -- Modify do_bp() to refresh bcode when original insn is break
>
> v5:
> -- Rebase on the latest code
> -- Use stop_machine_cpuslocked() to modify insn to avoid CPU race
>
> v4:
> -- Remove kprobe_exceptions_notify() in kprobes.c
> -- Call kprobe_breakpoint_handler() and kprobe_singlestep_handler()
> in do_bp()
>
> v3:
> -- Rebase on the latest code
> -- Check the alignment of PC in simu_branch() and simu_pc()
> -- Add ibar in flush_insn_slot()
> -- Rename kprobe_{pre,post}_handler() to {post_}kprobe_handler
> -- Add preempt_disable() and preempt_enable_no_resched()
> -- Remove r0 save/restore and do some minor changes
> in kprobes_trampoline.S
> -- Do not enable CONFIG_KPROBES by default
>
> v2:
> -- Split simu_branch() and simu_pc() into a single patch
> -- Call kprobe_page_fault() in do_page_fault()
> -- Add kprobes_trampoline.S for kretprobe
>
> Tiezhu Yang (4):
> LoongArch: Simulate branch and PC instructions
> LoongArch: Add kprobe support
> LoongArch: Add kretprobe support
> samples/kprobes: Add LoongArch support
>
> arch/loongarch/Kconfig | 2 +
> arch/loongarch/include/asm/inst.h | 20 ++
> arch/loongarch/include/asm/kprobes.h | 59 +++++
> arch/loongarch/include/asm/ptrace.h | 1 +
> arch/loongarch/kernel/Makefile | 2 +
> arch/loongarch/kernel/inst.c | 123 ++++++++++
> arch/loongarch/kernel/kprobes.c | 364 +++++++++++++++++++++++++++++
> arch/loongarch/kernel/kprobes_trampoline.S | 96 ++++++++
> arch/loongarch/kernel/traps.c | 13 +-
> arch/loongarch/mm/fault.c | 3 +
> samples/kprobes/kprobe_example.c | 8 +
> 11 files changed, 687 insertions(+), 4 deletions(-)
> create mode 100644 arch/loongarch/include/asm/kprobes.h
> create mode 100644 arch/loongarch/kernel/kprobes.c
> create mode 100644 arch/loongarch/kernel/kprobes_trampoline.S
>

2022-12-12 09:52:31

by Qing Zhang

[permalink] [raw]
Subject: Re: [PATCH v10 0/4] Add kprobe and kretprobe support for LoongArch

Hi, Hengqi

On 2022/12/12 下午4:41, Hengqi Chen wrote:
> Hi, Tiezhu:
>
> I tested this patchset from BPF side, failed with EINVAL:
>
> $ cat /sys/kernel/tracing/error_log
> [ 262.299093] trace_kprobe: error: Failed to register probe event
> Command: p:kprobes/libbpf_4609_inet_bind_0x0_0 inet_bind+0x0
>
This is because KPROBE_ON_FTRACE is not yet supported. Trace Event
cannot be used now.
We will support it soon, if you want to test it by install
kprobe_example.ko as jeff did.

Thanks
-Qing ^
> --
> Hengqi
>
> On 2022/12/9 16:52, Tiezhu Yang wrote:
>> v10:
>> -- Remove sign_extend() based on the latest code
>> -- Rename insns_are_not_supported() to insns_not_supported()
>> -- Rename insns_are_not_simulated() to insns_not_simulated()
>> -- Set KPROBE_HIT_SSDONE if cur->post_handler is not NULL
>> -- Enable preemption for KPROBE_REENTER in kprobe_fault_handler()
>>
>> v9:
>> -- Rename sign_extended() to sign_extend()
>> -- Modify kprobe_fault_handler() to handle all of kprobe_status
>>
>> v8:
>> -- Put "regs->csr_prmd &= ~CSR_PRMD_PIE;" ahead to save one line
>> -- Add code comment of preempt_disable()
>> -- Put kprobe_page_fault() in __do_page_fault()
>> -- Modify the check condition of break insn in kprobe_breakpoint_handler()
>>
>> v7:
>> -- Remove stop_machine_cpuslocked() related code
>>
>> v6:
>> -- Add a new patch to redefine larch_insn_patch_text() with
>> stop_machine_cpuslocked()
>> -- Modify kprobe_breakpoint_handler() to consider the original
>> insn is break and return the correct value
>> -- Modify do_bp() to refresh bcode when original insn is break
>>
>> v5:
>> -- Rebase on the latest code
>> -- Use stop_machine_cpuslocked() to modify insn to avoid CPU race
>>
>> v4:
>> -- Remove kprobe_exceptions_notify() in kprobes.c
>> -- Call kprobe_breakpoint_handler() and kprobe_singlestep_handler()
>> in do_bp()
>>
>> v3:
>> -- Rebase on the latest code
>> -- Check the alignment of PC in simu_branch() and simu_pc()
>> -- Add ibar in flush_insn_slot()
>> -- Rename kprobe_{pre,post}_handler() to {post_}kprobe_handler
>> -- Add preempt_disable() and preempt_enable_no_resched()
>> -- Remove r0 save/restore and do some minor changes
>> in kprobes_trampoline.S
>> -- Do not enable CONFIG_KPROBES by default
>>
>> v2:
>> -- Split simu_branch() and simu_pc() into a single patch
>> -- Call kprobe_page_fault() in do_page_fault()
>> -- Add kprobes_trampoline.S for kretprobe
>>
>> Tiezhu Yang (4):
>> LoongArch: Simulate branch and PC instructions
>> LoongArch: Add kprobe support
>> LoongArch: Add kretprobe support
>> samples/kprobes: Add LoongArch support
>>
>> arch/loongarch/Kconfig | 2 +
>> arch/loongarch/include/asm/inst.h | 20 ++
>> arch/loongarch/include/asm/kprobes.h | 59 +++++
>> arch/loongarch/include/asm/ptrace.h | 1 +
>> arch/loongarch/kernel/Makefile | 2 +
>> arch/loongarch/kernel/inst.c | 123 ++++++++++
>> arch/loongarch/kernel/kprobes.c | 364 +++++++++++++++++++++++++++++
>> arch/loongarch/kernel/kprobes_trampoline.S | 96 ++++++++
>> arch/loongarch/kernel/traps.c | 13 +-
>> arch/loongarch/mm/fault.c | 3 +
>> samples/kprobes/kprobe_example.c | 8 +
>> 11 files changed, 687 insertions(+), 4 deletions(-)
>> create mode 100644 arch/loongarch/include/asm/kprobes.h
>> create mode 100644 arch/loongarch/kernel/kprobes.c
>> create mode 100644 arch/loongarch/kernel/kprobes_trampoline.S
>>

2022-12-13 03:33:38

by Masami Hiramatsu

[permalink] [raw]
Subject: Re: [PATCH v10 0/4] Add kprobe and kretprobe support for LoongArch

On Fri, 9 Dec 2022 18:01:44 +0800
Huacai Chen <[email protected]> wrote:

> Hi, Masami,
>
> This series looks good to me now, but I'm not familiar with kprobes.
> So, if you have any comments, please let me know.

Sorry I missed this series. Let me add some comments.
BTW, I don't have any board to run the loongarch, so I'll make
comments just about style issues.

Thanks,

>
> And Jeff,
>
> As we all know, you are an expert in this domain, so could you please
> help me to test this series?
>
> If there are no objections, I plan to merge this series in a few days.
> But since the next merge window will be open soon, if there are any
> problems, I will revert the patches to wait for the next cycle.
>
> Thanks,
> Huacai
>
> On Fri, Dec 9, 2022 at 4:53 PM Tiezhu Yang <[email protected]> wrote:
> >
> > v10:
> > -- Remove sign_extend() based on the latest code
> > -- Rename insns_are_not_supported() to insns_not_supported()
> > -- Rename insns_are_not_simulated() to insns_not_simulated()
> > -- Set KPROBE_HIT_SSDONE if cur->post_handler is not NULL
> > -- Enable preemption for KPROBE_REENTER in kprobe_fault_handler()
> >
> > v9:
> > -- Rename sign_extended() to sign_extend()
> > -- Modify kprobe_fault_handler() to handle all of kprobe_status
> >
> > v8:
> > -- Put "regs->csr_prmd &= ~CSR_PRMD_PIE;" ahead to save one line
> > -- Add code comment of preempt_disable()
> > -- Put kprobe_page_fault() in __do_page_fault()
> > -- Modify the check condition of break insn in kprobe_breakpoint_handler()
> >
> > v7:
> > -- Remove stop_machine_cpuslocked() related code
> >
> > v6:
> > -- Add a new patch to redefine larch_insn_patch_text() with
> > stop_machine_cpuslocked()
> > -- Modify kprobe_breakpoint_handler() to consider the original
> > insn is break and return the correct value
> > -- Modify do_bp() to refresh bcode when original insn is break
> >
> > v5:
> > -- Rebase on the latest code
> > -- Use stop_machine_cpuslocked() to modify insn to avoid CPU race
> >
> > v4:
> > -- Remove kprobe_exceptions_notify() in kprobes.c
> > -- Call kprobe_breakpoint_handler() and kprobe_singlestep_handler()
> > in do_bp()
> >
> > v3:
> > -- Rebase on the latest code
> > -- Check the alignment of PC in simu_branch() and simu_pc()
> > -- Add ibar in flush_insn_slot()
> > -- Rename kprobe_{pre,post}_handler() to {post_}kprobe_handler
> > -- Add preempt_disable() and preempt_enable_no_resched()
> > -- Remove r0 save/restore and do some minor changes
> > in kprobes_trampoline.S
> > -- Do not enable CONFIG_KPROBES by default
> >
> > v2:
> > -- Split simu_branch() and simu_pc() into a single patch
> > -- Call kprobe_page_fault() in do_page_fault()
> > -- Add kprobes_trampoline.S for kretprobe
> >
> > Tiezhu Yang (4):
> > LoongArch: Simulate branch and PC instructions
> > LoongArch: Add kprobe support
> > LoongArch: Add kretprobe support
> > samples/kprobes: Add LoongArch support
> >
> > arch/loongarch/Kconfig | 2 +
> > arch/loongarch/include/asm/inst.h | 20 ++
> > arch/loongarch/include/asm/kprobes.h | 59 +++++
> > arch/loongarch/include/asm/ptrace.h | 1 +
> > arch/loongarch/kernel/Makefile | 2 +
> > arch/loongarch/kernel/inst.c | 123 ++++++++++
> > arch/loongarch/kernel/kprobes.c | 364 +++++++++++++++++++++++++++++
> > arch/loongarch/kernel/kprobes_trampoline.S | 96 ++++++++
> > arch/loongarch/kernel/traps.c | 13 +-
> > arch/loongarch/mm/fault.c | 3 +
> > samples/kprobes/kprobe_example.c | 8 +
> > 11 files changed, 687 insertions(+), 4 deletions(-)
> > create mode 100644 arch/loongarch/include/asm/kprobes.h
> > create mode 100644 arch/loongarch/kernel/kprobes.c
> > create mode 100644 arch/loongarch/kernel/kprobes_trampoline.S
> >
> > --
> > 2.1.0
> >


--
Masami Hiramatsu (Google) <[email protected]>

2022-12-17 03:00:44

by Huacai Chen

[permalink] [raw]
Subject: Re: [PATCH v10 0/4] Add kprobe and kretprobe support for LoongArch

Hi, Masami,

On Tue, Dec 13, 2022 at 11:10 AM Masami Hiramatsu <[email protected]> wrote:
>
> On Fri, 9 Dec 2022 18:01:44 +0800
> Huacai Chen <[email protected]> wrote:
>
> > Hi, Masami,
> >
> > This series looks good to me now, but I'm not familiar with kprobes.
> > So, if you have any comments, please let me know.
>
> Sorry I missed this series. Let me add some comments.
> BTW, I don't have any board to run the loongarch, so I'll make
> comments just about style issues.
You needn't say sorry, and you can use qemu to run loongarch if needed.

Huacai
>
> Thanks,
>
> >
> > And Jeff,
> >
> > As we all know, you are an expert in this domain, so could you please
> > help me to test this series?
> >
> > If there are no objections, I plan to merge this series in a few days.
> > But since the next merge window will be open soon, if there are any
> > problems, I will revert the patches to wait for the next cycle.
> >
> > Thanks,
> > Huacai
> >
> > On Fri, Dec 9, 2022 at 4:53 PM Tiezhu Yang <[email protected]> wrote:
> > >
> > > v10:
> > > -- Remove sign_extend() based on the latest code
> > > -- Rename insns_are_not_supported() to insns_not_supported()
> > > -- Rename insns_are_not_simulated() to insns_not_simulated()
> > > -- Set KPROBE_HIT_SSDONE if cur->post_handler is not NULL
> > > -- Enable preemption for KPROBE_REENTER in kprobe_fault_handler()
> > >
> > > v9:
> > > -- Rename sign_extended() to sign_extend()
> > > -- Modify kprobe_fault_handler() to handle all of kprobe_status
> > >
> > > v8:
> > > -- Put "regs->csr_prmd &= ~CSR_PRMD_PIE;" ahead to save one line
> > > -- Add code comment of preempt_disable()
> > > -- Put kprobe_page_fault() in __do_page_fault()
> > > -- Modify the check condition of break insn in kprobe_breakpoint_handler()
> > >
> > > v7:
> > > -- Remove stop_machine_cpuslocked() related code
> > >
> > > v6:
> > > -- Add a new patch to redefine larch_insn_patch_text() with
> > > stop_machine_cpuslocked()
> > > -- Modify kprobe_breakpoint_handler() to consider the original
> > > insn is break and return the correct value
> > > -- Modify do_bp() to refresh bcode when original insn is break
> > >
> > > v5:
> > > -- Rebase on the latest code
> > > -- Use stop_machine_cpuslocked() to modify insn to avoid CPU race
> > >
> > > v4:
> > > -- Remove kprobe_exceptions_notify() in kprobes.c
> > > -- Call kprobe_breakpoint_handler() and kprobe_singlestep_handler()
> > > in do_bp()
> > >
> > > v3:
> > > -- Rebase on the latest code
> > > -- Check the alignment of PC in simu_branch() and simu_pc()
> > > -- Add ibar in flush_insn_slot()
> > > -- Rename kprobe_{pre,post}_handler() to {post_}kprobe_handler
> > > -- Add preempt_disable() and preempt_enable_no_resched()
> > > -- Remove r0 save/restore and do some minor changes
> > > in kprobes_trampoline.S
> > > -- Do not enable CONFIG_KPROBES by default
> > >
> > > v2:
> > > -- Split simu_branch() and simu_pc() into a single patch
> > > -- Call kprobe_page_fault() in do_page_fault()
> > > -- Add kprobes_trampoline.S for kretprobe
> > >
> > > Tiezhu Yang (4):
> > > LoongArch: Simulate branch and PC instructions
> > > LoongArch: Add kprobe support
> > > LoongArch: Add kretprobe support
> > > samples/kprobes: Add LoongArch support
> > >
> > > arch/loongarch/Kconfig | 2 +
> > > arch/loongarch/include/asm/inst.h | 20 ++
> > > arch/loongarch/include/asm/kprobes.h | 59 +++++
> > > arch/loongarch/include/asm/ptrace.h | 1 +
> > > arch/loongarch/kernel/Makefile | 2 +
> > > arch/loongarch/kernel/inst.c | 123 ++++++++++
> > > arch/loongarch/kernel/kprobes.c | 364 +++++++++++++++++++++++++++++
> > > arch/loongarch/kernel/kprobes_trampoline.S | 96 ++++++++
> > > arch/loongarch/kernel/traps.c | 13 +-
> > > arch/loongarch/mm/fault.c | 3 +
> > > samples/kprobes/kprobe_example.c | 8 +
> > > 11 files changed, 687 insertions(+), 4 deletions(-)
> > > create mode 100644 arch/loongarch/include/asm/kprobes.h
> > > create mode 100644 arch/loongarch/kernel/kprobes.c
> > > create mode 100644 arch/loongarch/kernel/kprobes_trampoline.S
> > >
> > > --
> > > 2.1.0
> > >
>
>
> --
> Masami Hiramatsu (Google) <[email protected]>