Page MenuHomeFreeBSD

dtrace: add LoongArch support
Needs ReviewPublic

Authored by zhaoxiaoqiang007_gmail.com on Tue, Sep 22, 2:26 PM.
Tags
None
Referenced Files
F173612382: D59900.diff
Sun, Sep 27, 4:40 AM
F173560533: D59900.diff
Sat, Sep 26, 8:46 PM
Unknown Object (File)
Fri, Sep 25, 9:46 AM
Unknown Object (File)
Thu, Sep 24, 5:40 PM
Unknown Object (File)
Thu, Sep 24, 5:22 PM
Unknown Object (File)
Thu, Sep 24, 4:46 PM
Unknown Object (File)
Thu, Sep 24, 4:34 PM
Unknown Object (File)
Wed, Sep 23, 8:41 AM

Details

Reviewers
gnn
jkoshy
Summary

Add the libdtrace ISA backend and the kernel fasttrap
ISA code for LoongArch.

Signed-off-by: Xiaoqiang Zhao <zhaoxiaoqiang007@gmail.com>

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 77180
Build 74063: arc lint + arc unit

Event Timeline

shipujin.t_gmail.com added inline comments.
cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c
231–234

32-bit-related code is suggested to be removed.

1149

Correcting pcaddu12i to pcaddu18i is right, and the added distinction between bl/b and pcaddu18i + jirl is consistent with the subsequent handling of R_LARCH_B26 / R_LARCH_CALL36.

Suggested change to:

* LoongArch uses bl/b for short calls/jumps and pcaddu18i + jirl for
* long calls.  Calls are converted into a no-op whereas tail calls
* become a return.

In LLVM's LoongArchExpandPseudoInsts.cpp, expandFunctionCALL():

// CALL:  pcaddu18i $ra, %call36(func)
//        jirl      $ra, $ra, 0
// TAIL:  pcaddu18i $t8, %call36(func)
//        jirl      $r0, $t8, 0
1152

These are needed to identify and classify the instructions that R_LARCH_B26 relocations refer to.
add the branch-instruction encodings:

#define	DT_OP_BL		0x54000000  /* bl */
#define	DT_OP_B			0x50000000  b */
#define	DT_OP_PCADDU18I		0x1e000000  /* pcaddu18i */
#define	DT_OP_JIRL		0x4c000000  /* jirl */
#define	DT_OP_IS_JIRL(op)	(((op) & 0xfc000000) == 0x4c000000)

dt_modtext() is still a stub implementation internally, and the handling logic for R_LARCH_B26 / R_LARCH_CALL36 still needs to be filled in later.

All opcodes come from LLVM TableGen definitions.

/* LoongArch/LoongArchInstrInfo.td */
def B : Br_I26<0x50000000>;                                 /* line 848 */
def BL : FmtI26<0x54000000, ...>;                           /* line 851 */
def JIRL : Fmt2RI<0x4c000000, ...>;                       /* line 853 */
def PCADDU18I : ALU_1RI20<0x1e000000, simm20_pcaddu18i>;    /* line 958 */
1171

Sync the same change:

	if (GELF_R_TYPE(rela->r_info) != R_LARCH_B26 &&
	    GELF_R_TYPE(rela->r_info) != R_LARCH_CALL36 &&
	    GELF_R_TYPE(rela->r_info) != R_LARCH_NONE)
1325–1326

Remove these lines.
FreeBSD LoongArch is LP64 only; there is no 32-bit LoongArch port. Handling it in the ELFCLASS32 branch is misleading and inconsistent with upstream FreeBSD's deprecation of 32-bit platforms.