Skip to content

[libcpu] rv64: support for ARCH_REMAP_KERNEL#9067

Merged
BernardXiong merged 5 commits intoRT-Thread:masterfrom
polarvid:shell/rv64-kspace
Jun 18, 2024
Merged

[libcpu] rv64: support for ARCH_REMAP_KERNEL#9067
BernardXiong merged 5 commits intoRT-Thread:masterfrom
polarvid:shell/rv64-kspace

Conversation

@polarvid
Copy link
Copy Markdown
Contributor

@polarvid polarvid commented Jun 17, 2024

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

[

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

Introduce support for the ARCH_REMAP_KERNEL configuration, which isolates kernel space in high virtual address regions. This feature is necessary to enhance memory protection and management by segregating user and kernel spaces more effectively.

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

Changes:

  • Updated conditional macros to check for ARCH_REMAP_KERNEL instead of ARCH_KERNEL_IN_HIGH_VA in board initialization files to reflect the new configuration option.
  • Modified qemu-virt64-riscv Kconfig and SConstruct files to include and utilize ARCH_REMAP_KERNEL.
  • Created a new linker script link_smart.lds for smart linking in qemu-virt64-riscv.
  • Updated rtconfig.py to use a more flexible execution path setup.
  • Enhanced user address space definitions in lwp_arch.h to support the new virtual address mappings.
  • Adjusted kernel memory initialization and mapping logic in c906/mmu.c and virt64/mmu.c to account for high virtual address regions.
  • Added Kconfig option to enable ARCH_REMAP_KERNEL for RISCV64 architectures.
  • Enhanced memory setup functions to support new mapping scheme, including updates to early page table setup and address relocation logic.

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

  • BSP: milkv duo, qemu riscv64
  • .config:
  • action:

milkv duo

image

QEMU rv64 on RT-Smart

image

QEMU rv64 on RT-Thread

image

]

当前拉取/合并请求的状态 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

@polarvid polarvid changed the title [libcpu] support for ARCH_REMAP_KERNEL [libcpu] rv64: support for ARCH_REMAP_KERNEL Jun 17, 2024
These changes introduce support for the ARCH_REMAP_KERNEL configuration,
which isolates kernel space in high virtual address regions. This feature
is necessary to enhance memory protection and management by segregating
user and kernel spaces more effectively.

Changes:
- Updated conditional macros to check for ARCH_REMAP_KERNEL instead of
  ARCH_KERNEL_IN_HIGH_VA in board initialization files to reflect the new
  configuration option.
- Modified qemu-virt64-riscv Kconfig and SConstruct files to include and
  utilize ARCH_REMAP_KERNEL.
- Created a new linker script `link_smart.lds` for smart linking in qemu-virt64-riscv.
- Updated rtconfig.py to use a more flexible execution path setup.
- Enhanced user address space definitions in `lwp_arch.h` to support the
  new virtual address mappings.
- Adjusted kernel memory initialization and mapping logic in `c906/mmu.c`
  and `virt64/mmu.c` to account for high virtual address regions.
- Added Kconfig option to enable ARCH_REMAP_KERNEL for RISCV64 architectures.
- Enhanced memory setup functions to support new mapping scheme, including
  updates to early page table setup and address relocation logic.

These modifications ensure that the system can utilize high memory
addresses for the kernel, improving memory isolation and system stability.

Signed-off-by: Shell <smokewood@qq.com>
@polarvid polarvid force-pushed the shell/rv64-kspace branch from 66cde3b to 97d3512 Compare June 17, 2024 06:06
@polarvid polarvid force-pushed the shell/rv64-kspace branch from efbdee8 to ce720a3 Compare June 17, 2024 08:00
@polarvid polarvid marked this pull request as ready for review June 17, 2024 09:48
@BernardXiong BernardXiong merged commit 65c9947 into RT-Thread:master Jun 18, 2024
messigogogo pushed a commit to messigogogo/rt-thread that referenced this pull request Jul 22, 2024
* [libcpu] support for ARCH_REMAP_KERNEL

These changes introduce support for the ARCH_REMAP_KERNEL configuration,
which isolates kernel space in high virtual address regions. This feature
is necessary to enhance memory protection and management by segregating
user and kernel spaces more effectively.

Changes:
- Updated conditional macros to check for ARCH_REMAP_KERNEL instead of
  ARCH_KERNEL_IN_HIGH_VA in board initialization files to reflect the new
  configuration option.
- Modified qemu-virt64-riscv Kconfig and SConstruct files to include and
  utilize ARCH_REMAP_KERNEL.
- Created a new linker script `link_smart.lds` for smart linking in qemu-virt64-riscv.
- Updated rtconfig.py to use a more flexible execution path setup.
- Enhanced user address space definitions in `lwp_arch.h` to support the
  new virtual address mappings.
- Adjusted kernel memory initialization and mapping logic in `c906/mmu.c`
  and `virt64/mmu.c` to account for high virtual address regions.
- Added Kconfig option to enable ARCH_REMAP_KERNEL for RISCV64 architectures.
- Enhanced memory setup functions to support new mapping scheme, including
  updates to early page table setup and address relocation logic.

These modifications ensure that the system can utilize high memory
addresses for the kernel, improving memory isolation and system stability.

Signed-off-by: Shell <smokewood@qq.com>

* fixup: CI run failed

* bsp: default config without using smart

* fixup: static checks

* restore rt_hw_mmu_kernel_map_init for D1

---------

Signed-off-by: Shell <smokewood@qq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants