[PATCH v4 0/4] openrisc: Support basic trace mechanism

ChenMiao posted 4 patches 4 weeks ago
There is a newer version of this series
.../core/jump-labels/arch-support.txt         |  2 +-
arch/openrisc/Kconfig                         |  2 +
arch/openrisc/configs/or1ksim_defconfig       | 19 ++---
arch/openrisc/configs/virt_defconfig          |  2 +-
arch/openrisc/include/asm/Kbuild              |  1 -
arch/openrisc/include/asm/fixmap.h            |  1 +
arch/openrisc/include/asm/insn-def.h          | 15 ++++
arch/openrisc/include/asm/jump_label.h        | 72 +++++++++++++++++
arch/openrisc/include/asm/text-patching.h     | 13 +++
arch/openrisc/kernel/Makefile                 |  2 +
arch/openrisc/kernel/jump_label.c             | 52 ++++++++++++
arch/openrisc/kernel/module.c                 |  4 +
arch/openrisc/kernel/patching.c               | 79 +++++++++++++++++++
arch/openrisc/kernel/setup.c                  |  2 +
arch/openrisc/mm/init.c                       |  6 +-
15 files changed, 256 insertions(+), 16 deletions(-)
create mode 100644 arch/openrisc/include/asm/insn-def.h
create mode 100644 arch/openrisc/include/asm/jump_label.h
create mode 100644 arch/openrisc/include/asm/text-patching.h
create mode 100644 arch/openrisc/kernel/jump_label.c
create mode 100644 arch/openrisc/kernel/patching.c
[PATCH v4 0/4] openrisc: Support basic trace mechanism
Posted by ChenMiao 4 weeks ago
From: chenmiao <chenmiao.ku@gmail.com>

Hello everyone,

This implements a basic text patching mechanism and a complete jump_label
implementation for OpenRISC. It should be noted that the jump_label have
passed testing.

1. Implement the patch_map interface and the patch_insn_write single insn
write API by providing FIX_TEXT_POKE0. And create a new insn-def.h to record
openrisc's instruction macro definition which only have OPENRISC_INSN_SIZE
now.

2. Support for the R_OR1K_32_PCREL relocation type is added for module insertion,
enabling subsequent jump_label selftest module insertion.

3. Regenerate defconfigs for or1ksim_defconfig and virt_defconfig.

4. Based on the previously implemented patch_insn_write, achieve a complete
jump_label implementation, directly supporting arch_jump_label_transform_queue.
And add a new macro OPENRISC_INSN_NOP in insn-def.h.

Link: https://lore.kernel.org/openrisc/20250805084926.4125564-1-chenmiao.ku@gmail.com/T/#u

Thanks,

Chen Miao

---
Changes in V4:
  - Added testing for jump_label
  - Split part of the jump_label patch content to form the third patch
  - Implemented R_OR1K_32_PCREL module support for jump_label testing

Changes in V3:
  - Removed the is_exit_text used, added some necessary comments.
  - Modify some macro like __ASSEMBLY__ to __ASSEMBLER__ and ensure the
    defconfig by make savedefconfig.

Changes in V2:
  - Add a new insn-def.h to record the insn macro.
  - Modify the patch_insn_write API from const void* to u32 insn.
  - Using the modified patch_insn_write API in 
    arch_jump_label_transform_queue.

chenmiao (4):
  openrisc: Add text patching API support
  openrisc: Add R_OR1K_32_PCREL relocation type module support
  openrisc: Regenerate defconfigs.
  openrisc: Add jump label support

 .../core/jump-labels/arch-support.txt         |  2 +-
 arch/openrisc/Kconfig                         |  2 +
 arch/openrisc/configs/or1ksim_defconfig       | 19 ++---
 arch/openrisc/configs/virt_defconfig          |  2 +-
 arch/openrisc/include/asm/Kbuild              |  1 -
 arch/openrisc/include/asm/fixmap.h            |  1 +
 arch/openrisc/include/asm/insn-def.h          | 15 ++++
 arch/openrisc/include/asm/jump_label.h        | 72 +++++++++++++++++
 arch/openrisc/include/asm/text-patching.h     | 13 +++
 arch/openrisc/kernel/Makefile                 |  2 +
 arch/openrisc/kernel/jump_label.c             | 52 ++++++++++++
 arch/openrisc/kernel/module.c                 |  4 +
 arch/openrisc/kernel/patching.c               | 79 +++++++++++++++++++
 arch/openrisc/kernel/setup.c                  |  2 +
 arch/openrisc/mm/init.c                       |  6 +-
 15 files changed, 256 insertions(+), 16 deletions(-)
 create mode 100644 arch/openrisc/include/asm/insn-def.h
 create mode 100644 arch/openrisc/include/asm/jump_label.h
 create mode 100644 arch/openrisc/include/asm/text-patching.h
 create mode 100644 arch/openrisc/kernel/jump_label.c
 create mode 100644 arch/openrisc/kernel/patching.c

-- 
2.45.2
Re: [PATCH v4 0/4] openrisc: Support basic trace mechanism
Posted by Stafford Horne 3 weeks, 6 days ago
On Thu, Sep 04, 2025 at 10:00:48AM +0000, ChenMiao wrote:
> From: chenmiao <chenmiao.ku@gmail.com>
> 
> Hello everyone,
> 
> This implements a basic text patching mechanism and a complete jump_label
> implementation for OpenRISC. It should be noted that the jump_label have
> passed testing.
> 
> 1. Implement the patch_map interface and the patch_insn_write single insn
> write API by providing FIX_TEXT_POKE0. And create a new insn-def.h to record
> openrisc's instruction macro definition which only have OPENRISC_INSN_SIZE
> now.
> 
> 2. Support for the R_OR1K_32_PCREL relocation type is added for module insertion,
> enabling subsequent jump_label selftest module insertion.
> 
> 3. Regenerate defconfigs for or1ksim_defconfig and virt_defconfig.
> 
> 4. Based on the previously implemented patch_insn_write, achieve a complete
> jump_label implementation, directly supporting arch_jump_label_transform_queue.
> And add a new macro OPENRISC_INSN_NOP in insn-def.h.

Thank, this is looking good.  I will queue this soon once the final items are
cleaned up.

> Link: https://lore.kernel.org/openrisc/20250805084926.4125564-1-chenmiao.ku@gmail.com/T/#u

> Thanks,
> 
> Chen Miao
> 
> ---
> Changes in V4:
>   - Added testing for jump_label
>   - Split part of the jump_label patch content to form the third patch
>   - Implemented R_OR1K_32_PCREL module support for jump_label testing
> 
> Changes in V3:
>   - Removed the is_exit_text used, added some necessary comments.
>   - Modify some macro like __ASSEMBLY__ to __ASSEMBLER__ and ensure the
>     defconfig by make savedefconfig.
> 
> Changes in V2:
>   - Add a new insn-def.h to record the insn macro.
>   - Modify the patch_insn_write API from const void* to u32 insn.
>   - Using the modified patch_insn_write API in 
>     arch_jump_label_transform_queue.
> 
> chenmiao (4):
>   openrisc: Add text patching API support
>   openrisc: Add R_OR1K_32_PCREL relocation type module support
>   openrisc: Regenerate defconfigs.
>   openrisc: Add jump label support
> 
>  .../core/jump-labels/arch-support.txt         |  2 +-
>  arch/openrisc/Kconfig                         |  2 +
>  arch/openrisc/configs/or1ksim_defconfig       | 19 ++---
>  arch/openrisc/configs/virt_defconfig          |  2 +-
>  arch/openrisc/include/asm/Kbuild              |  1 -
>  arch/openrisc/include/asm/fixmap.h            |  1 +
>  arch/openrisc/include/asm/insn-def.h          | 15 ++++
>  arch/openrisc/include/asm/jump_label.h        | 72 +++++++++++++++++
>  arch/openrisc/include/asm/text-patching.h     | 13 +++
>  arch/openrisc/kernel/Makefile                 |  2 +
>  arch/openrisc/kernel/jump_label.c             | 52 ++++++++++++
>  arch/openrisc/kernel/module.c                 |  4 +
>  arch/openrisc/kernel/patching.c               | 79 +++++++++++++++++++
>  arch/openrisc/kernel/setup.c                  |  2 +
>  arch/openrisc/mm/init.c                       |  6 +-
>  15 files changed, 256 insertions(+), 16 deletions(-)
>  create mode 100644 arch/openrisc/include/asm/insn-def.h
>  create mode 100644 arch/openrisc/include/asm/jump_label.h
>  create mode 100644 arch/openrisc/include/asm/text-patching.h
>  create mode 100644 arch/openrisc/kernel/jump_label.c
>  create mode 100644 arch/openrisc/kernel/patching.c
> 
> -- 
> 2.45.2
> 
>
Re: [PATCH v4 0/4] openrisc: Support basic trace mechanism
Posted by Chen Miao 3 weeks, 6 days ago
well, I'll send a new version later

Stafford Horne <shorne@gmail.com> 于2025年9月6日周六 01:16写道:
>
> On Thu, Sep 04, 2025 at 10:00:48AM +0000, ChenMiao wrote:
> > From: chenmiao <chenmiao.ku@gmail.com>
> >
> > Hello everyone,
> >
> > This implements a basic text patching mechanism and a complete jump_label
> > implementation for OpenRISC. It should be noted that the jump_label have
> > passed testing.
> >
> > 1. Implement the patch_map interface and the patch_insn_write single insn
> > write API by providing FIX_TEXT_POKE0. And create a new insn-def.h to record
> > openrisc's instruction macro definition which only have OPENRISC_INSN_SIZE
> > now.
> >
> > 2. Support for the R_OR1K_32_PCREL relocation type is added for module insertion,
> > enabling subsequent jump_label selftest module insertion.
> >
> > 3. Regenerate defconfigs for or1ksim_defconfig and virt_defconfig.
> >
> > 4. Based on the previously implemented patch_insn_write, achieve a complete
> > jump_label implementation, directly supporting arch_jump_label_transform_queue.
> > And add a new macro OPENRISC_INSN_NOP in insn-def.h.
>
> Thank, this is looking good.  I will queue this soon once the final items are
> cleaned up.
>
> > Link: https://lore.kernel.org/openrisc/20250805084926.4125564-1-chenmiao.ku@gmail.com/T/#u
>
> > Thanks,
> >
> > Chen Miao
> >
> > ---
> > Changes in V4:
> >   - Added testing for jump_label
> >   - Split part of the jump_label patch content to form the third patch
> >   - Implemented R_OR1K_32_PCREL module support for jump_label testing
> >
> > Changes in V3:
> >   - Removed the is_exit_text used, added some necessary comments.
> >   - Modify some macro like __ASSEMBLY__ to __ASSEMBLER__ and ensure the
> >     defconfig by make savedefconfig.
> >
> > Changes in V2:
> >   - Add a new insn-def.h to record the insn macro.
> >   - Modify the patch_insn_write API from const void* to u32 insn.
> >   - Using the modified patch_insn_write API in
> >     arch_jump_label_transform_queue.
> >
> > chenmiao (4):
> >   openrisc: Add text patching API support
> >   openrisc: Add R_OR1K_32_PCREL relocation type module support
> >   openrisc: Regenerate defconfigs.
> >   openrisc: Add jump label support
> >
> >  .../core/jump-labels/arch-support.txt         |  2 +-
> >  arch/openrisc/Kconfig                         |  2 +
> >  arch/openrisc/configs/or1ksim_defconfig       | 19 ++---
> >  arch/openrisc/configs/virt_defconfig          |  2 +-
> >  arch/openrisc/include/asm/Kbuild              |  1 -
> >  arch/openrisc/include/asm/fixmap.h            |  1 +
> >  arch/openrisc/include/asm/insn-def.h          | 15 ++++
> >  arch/openrisc/include/asm/jump_label.h        | 72 +++++++++++++++++
> >  arch/openrisc/include/asm/text-patching.h     | 13 +++
> >  arch/openrisc/kernel/Makefile                 |  2 +
> >  arch/openrisc/kernel/jump_label.c             | 52 ++++++++++++
> >  arch/openrisc/kernel/module.c                 |  4 +
> >  arch/openrisc/kernel/patching.c               | 79 +++++++++++++++++++
> >  arch/openrisc/kernel/setup.c                  |  2 +
> >  arch/openrisc/mm/init.c                       |  6 +-
> >  15 files changed, 256 insertions(+), 16 deletions(-)
> >  create mode 100644 arch/openrisc/include/asm/insn-def.h
> >  create mode 100644 arch/openrisc/include/asm/jump_label.h
> >  create mode 100644 arch/openrisc/include/asm/text-patching.h
> >  create mode 100644 arch/openrisc/kernel/jump_label.c
> >  create mode 100644 arch/openrisc/kernel/patching.c
> >
> > --
> > 2.45.2
> >
> >