Skip to content

Add VDSO functionality under the riscv64 architecture. #10219

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ScuDays
Copy link

@ScuDays ScuDays commented Apr 23, 2025

拉取/合并请求描述:(PR description)

[

为什么提交这份PR (why to submit this PR)

你的解决方案是什么 (what is your solution)

请提供验证的bsp和config (provide the config and bsp)

  • BSP:
  • .config:
  • action:

]

当前拉取/合并请求的状态 Intent for your PR

必须选择一项 Choose one (Mandatory):

  • 本拉取/合并请求是一个草稿版本 This PR is for a code-review and is intended to get feedback
  • 本拉取/合并请求是一个成熟版本 This PR is mature, and ready to be integrated into the repo

代码质量 Code Quality:

我在这个拉取/合并请求中已经考虑了 As part of this pull request, I've considered the following:

  • 已经仔细查看过代码改动的对比 Already check the difference between PR and old code
  • 代码风格正确,包括缩进空格,命名及其他风格 Style guide is adhered to, including spacing, naming and other styles
  • 没有垃圾代码,代码尽量精简,不包含#if 0代码,不包含已经被注释了的代码 All redundant code is removed and cleaned up
  • 所有变更均有原因及合理的,并且不会影响到其他软件组件代码或BSP All modifications are justified and not affect other components or BSP
  • 对难懂代码均提供对应的注释 I've commented appropriately where code is tricky
  • 代码是高质量的 Code in this PR is of high quality
  • 已经使用formatting 等源码格式化工具确保格式符合RT-Thread代码规范 This PR complies with RT-Thread code specification
  • 如果是新增bsp, 已经添加ci检查到.github/workflows/bsp_buildings.yml 详细请参考链接BSP自查

@ScuDays ScuDays requested a review from BernardXiong as a code owner April 23, 2025 02:40
@CLAassistant
Copy link

CLAassistant commented Apr 23, 2025

CLA assistant check
All committers have signed the CLA.

@github-actions github-actions bot added BSP RT-Smart RT-Thread Smart related PR or issues component: lwp Component labels Apr 23, 2025
user_path = os.path.dirname(vdso_usr)
user_path = os.path.dirname(user_path)
user_path = os.path.dirname(user_path)
rt_root_path = os.path.abspath(os.path.join(vdso_usr, "../../../../../../")) # 获取根目录绝对路径
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

移除中文注释吧

Copy link
Contributor

@unicornx unicornx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我对 rtt 上 vdso 的设计不是很熟,简单 review 一下,提了几个问题请回答一下。

另外我想问一下目前 rtt 的 vdso 是不是只支持了 clock_gettime 这一个系统调用?

另外这个 pr 是怎么测试的,请描述一下。测试结果如何?

@@ -21,15 +21,17 @@ list = os.listdir(cwd)
src = Glob('kernel/*.c')
src +=Glob('kernel/*.S')

if not os.path.exists(cwd + "/user/vdso.lds"):
Preprocessing("user/vdso.lds.S", ".lds", CPPPATH=[cwd])
print(rtconfig.CPP)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

删掉多余的打印

Preprocessing("user/vdso.lds.S", ".lds", CPPPATH=[cwd])
print(rtconfig.CPP)
if not os.path.exists(cwd + "/user" + "/arch" +"/" + rtconfig.ARCH + "/vdso.lds"):
print("/user" + "/arch/"+ rtconfig.ARCH + "/vdso.lds.S")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

删掉多余的打印

@@ -33,6 +34,7 @@
OBJCPY = PREFIX + 'objcopy'

DEVICE = ' -mcmodel=medany -march=rv64imafdc -mabi=lp64 '
CPPFLAGS= ' -E -P -x assembler-with-cpp'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

请问这个文件中加这个 CPPFLAGS 和 CPP 的目的是什么?

而且这个 pr 为啥会涉及对 bsp 的改动?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已删除。

unsigned char st_info;
unsigned char st_other;
Elf64_Half st_shndx;
Elf64_Half st_shndx;
} Elf64_sym;

#ifdef ARCH_MM_MMU
void arch_elf_reloc(rt_aspace_t aspace, void *text_start, void *rel_dyn_start, size_t rel_dyn_size, void *got_start, size_t got_size, Elf64_sym *dynsym)
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

arch_elf_reloc 这个函数在哪里被调用的,没发现调用的地方?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个reloc.c文件是原本就有的,这个pr里面只修改了这个文件的位置,这个函数arch_elf_reloc 具体的调用我也不太清楚。

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

建议研究一下,即使不在这个 pr 里改,或许是个另外的问题,可以提 issue,在另外的 pr 里改。

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

好的

{
int ret;
if (init_ret_flag != RT_EOK) return -RT_ERROR;
/* ret = __setup_additional_pages(VDSO_ABI_AA64, lwp); */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

删除这行

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

有个疑问,这个文件和 components/lwp/arch/aarch64/common/vdso.c 几乎一摸一样,是否可以考虑合并?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

查看了一下确实可以进行合并。最新的commit中已经进行了合并。


rt_weak inline uint64_t __arch_get_hw_frq()
{
return 10000000;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个值写死了,合适吗?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个使用了rt_weak弱符号标记,根据对应平台实现这个函数就会覆盖这个实现,risc-v里面好像没有可以获取主频的寄存器,所以这里就写死了。

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个文件删除是没有用了吗?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

后续移除xmake了

@BernardXiong
Copy link
Member

我对 rtt 上 vdso 的设计不是很熟,简单 review 一下,提了几个问题请回答一下。

另外我想问一下目前 rtt 的 vdso 是不是只支持了 clock_gettime 这一个系统调用?

另外这个 pr 是怎么测试的,请描述一下。测试结果如何?

应该是之前这个接口用于做用户态性能测试,这个时候不用通过内核系统调用方式走,不会损失精度延迟

@ScuDays ScuDays force-pushed the master branch 2 times, most recently from 5bab842 to 0693ee3 Compare April 27, 2025 03:12
@supperthomas supperthomas requested a review from Copilot April 27, 2025 03:32
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds VDSO functionality for the riscv64 architecture. Key changes include introducing new header and source files implementing VDSO syscalls and timekeeping functions for RISC-V, updating build configuration (SConstruct and SConscript) to support the new architecture, and adding common VDSO data and initialization routines.

Reviewed Changes

Copilot reviewed 11 out of 14 changed files in this pull request and generated no comments.

Show a summary per file
File Description
components/lwp/vdso/user/arch/risc-v/vdso_sys.h New header with inline functions and macros for timekeeping and hardware counter access
components/lwp/vdso/user/arch/risc-v/vdso_sys.c New source file implementing VDSO clock_gettime functions
components/lwp/vdso/user/arch/risc-v/SConstruct Build script updates for RISC-V VDSO shared library generation
components/lwp/vdso/user/arch/aarch64/SConstruct Adjustments in include paths to align with new directory structure
components/lwp/vdso/SConscript Update to include riscv support in addition to aarch64
components/lwp/arch/risc-v/common/vdso_data.c VDSO data update routine for the riscv64 platform
components/lwp/arch/risc-v/common/vdso.c VDSO ELF validation and additional pages setup for VDSO
Files not reviewed (3)
  • components/lwp/vdso/Kconfig: Language not supported
  • components/lwp/vdso/user/arch/risc-v/vdso.lds.S: Language not supported
  • components/lwp/vdso/user/xmake.lua: Language not supported
Comments suppressed due to low confidence (1)

components/lwp/vdso/user/arch/risc-v/vdso_sys.c:48

  • The function __arch_get_hw_counter is defined without parameters in vdso_sys.h, but it is invoked with arguments here; update the call to match its signature or modify the function definition as needed.
cycles = __arch_get_hw_counter(vd->clock_mode, vd);

@supperthomas
Copy link
Member

image
image
CI问题看下

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BSP component: lwp Component RT-Smart RT-Thread Smart related PR or issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants