Sign in
Sign up
Explore
Enterprise
Education
Search
Help
Terms of use
About Us
Explore
Enterprise
Education
Gitee Premium
Gitee AI
AI teammates
Sign in
Sign up
Fetch the repository succeeded.
description of repo status
Open Source
>
Other
>
Operation System
&&
Donate
Please sign in before you donate.
Cancel
Sign in
Scan WeChat QR to Pay
Cancel
Complete
Prompt
Switch to Alipay.
OK
Cancel
Watch
Unwatch
Watching
Releases Only
Ignoring
458
Star
1.7K
Fork
1.9K
GVP
openEuler
/
kernel
Closed
Code
Issues
1271
Pull Requests
991
Wiki
Insights
Pipelines
Service
Quality Analysis
Jenkins for Gitee
Tencent CloudBase
Tencent Cloud Serverless
悬镜安全
Aliyun SAE
Codeblitz
SBOM
Don’t show this again
Update failed. Please try again later!
Remove this flag
Content Risk Flag
This task is identified by
as the content contains sensitive information such as code security bugs, privacy leaks, etc., so it is only accessible to contributors of this repository.
[OLK-5.10] sw64:修复_mcount记录位置与ftrace相关的错误
Done
#I645P4
Task
guzitao
member
Opened this issue
2022-12-01 17:05
【问题描述】 申威平台使用gcc -pg对需要跟踪的函数起始位置插入_mcount时,插入的时5条指令(其中第3条ldih指令其实是多余的,可以只用4条指令实现)。由于_mcount是全局符号,需要ldgp,然后通过gp得到_mcount的地址,再执行call指令。原来的recordmcount工具参照mips实现,但是没有考虑申威编译器生成指令的特点,记录的mcount位置是第4条ldl指令的位置,根据ftrace的语义,需要记录的是插入mcount的函数入口位置,这就会导致后面基于ftrace的热补丁实现出问题。 GCC编译器还有个问题,如果被跟踪的函数本身需要访问全局符号,gcc生成的指令序列开头就是两条ldgp指令。如果不需要访问全局符号,则没有。对于前者而言,mcount的两条lgdp其实是必须的,因为不只访问mcount符号需要,访问后面的符号也需要。因此动态ftrace在替换指令时,不能将5条指令全部替换,二是需要保留前两条ldgp。 【修复方法】 recordmcount工具对offset做调整,记录正确的地址。 在ftrace的实现需要相应微调,ftrace_make_call和ftrace_make_nop需要在rec->ip加上两条ldgp指令,再修改指令。
【问题描述】 申威平台使用gcc -pg对需要跟踪的函数起始位置插入_mcount时,插入的时5条指令(其中第3条ldih指令其实是多余的,可以只用4条指令实现)。由于_mcount是全局符号,需要ldgp,然后通过gp得到_mcount的地址,再执行call指令。原来的recordmcount工具参照mips实现,但是没有考虑申威编译器生成指令的特点,记录的mcount位置是第4条ldl指令的位置,根据ftrace的语义,需要记录的是插入mcount的函数入口位置,这就会导致后面基于ftrace的热补丁实现出问题。 GCC编译器还有个问题,如果被跟踪的函数本身需要访问全局符号,gcc生成的指令序列开头就是两条ldgp指令。如果不需要访问全局符号,则没有。对于前者而言,mcount的两条lgdp其实是必须的,因为不只访问mcount符号需要,访问后面的符号也需要。因此动态ftrace在替换指令时,不能将5条指令全部替换,二是需要保留前两条ldgp。 【修复方法】 recordmcount工具对offset做调整,记录正确的地址。 在ftrace的实现需要相应微调,ftrace_make_call和ftrace_make_nop需要在rec->ip加上两条ldgp指令,再修改指令。
Comments (
1
)
Sign in
to comment
Status
Done
Backlog
Doing
Done
Declined
Assignees
Not set
Labels
sig/Kernel
Not set
Projects
Unprojected
Unprojected
Pull Requests
None yet
None yet
Successfully merging a pull request will close this issue.
Branches
No related branch
Branches (
-
)
Tags (
-
)
Planed to start   -   Planed to end
-
Top level
Not Top
Top Level: High
Top Level: Medium
Top Level: Low
Priority
Not specified
Serious
Main
Secondary
Unimportant
Duration
(hours)
参与者(2)
C
1
https://gitee.com/openeuler/kernel.git
git@gitee.com:openeuler/kernel.git
openeuler
kernel
kernel
Going to Help Center
Search
Git 命令在线学习
如何在 Gitee 导入 GitHub 仓库
Git 仓库基础操作
企业版和社区版功能对比
SSH 公钥设置
如何处理代码冲突
仓库体积过大,如何减小?
如何找回被删除的仓库数据
Gitee 产品配额说明
GitHub仓库快速导入Gitee及同步更新
什么是 Release(发行版)
将 PHP 项目自动发布到 packagist.org
Comment
Repository Report
Back to the top
Login prompt
This operation requires login to the code cloud account. Please log in before operating.
Go to login
No account. Register