Skip to content
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

riscv64: replace deprecated legacy extensions to SBI 2.0 extensions #1088

Merged
merged 1 commit into from
Apr 17, 2024

Conversation

luojia65
Copy link
Contributor

@luojia65 luojia65 commented Mar 3, 2024

The SBI legacy extensions are deprecated 4 years ago ( riscv-non-isa/riscv-sbi-doc@705e955 ). We replace it using functions from SBI 2.0 extensions. Specifically:

  • the legacy console_putchar is replaced into console_write_byte in SBI DBCN extension;
  • legacy shutdown is replaced to system_reset in SBI SRST extension with ColdReboot and NoReason as parameters;
  • legacy set_timer is replaced with SBI TIME set_timer;
  • legacy send_ipi is replaced to SBI IPI extension. The code implemented in file processor.rs creates a HartMask with only one hart_id selected as an IPI target.

By updating to SBI 2.0, this commit supports to send IPI to hart IDs greater than 63 (on 64-bit devices). The current code encodes hart_id parameter in bit-vector like 1 << hart_id, which will cause the bit to be shifted out from usize range when hart_id >= 64. SBI 2.0 fixed this problem by adding a hart_mask_base parameter, allowing us to specify any hart ID within usize range when is provided as an SBI IPI hart mask.

@mkroening mkroening self-requested a review March 3, 2024 15:01
@mkroening mkroening self-assigned this Mar 3, 2024
Copy link
Member

@mkroening mkroening left a comment

Choose a reason for hiding this comment

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

This might be an issue with QEMU again, but we are experiencing crashes in CI. 🤔

Copy link
Member

@mkroening mkroening left a comment

Choose a reason for hiding this comment

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

I updated the loader and OpenSBI.

We are having reboots, though.

src/arch/riscv64/kernel/processor.rs Outdated Show resolved Hide resolved
The SBI legacy extensions are deprecated 4 years ago ( riscv-non-isa/riscv-sbi-doc@705e955 ).
We replace it using functions from SBI 2.0 extensions. Specifically:
- the legacy console_putchar is replaced into console_write_byte in SBI DBCN extension;
- legacy shutdown is replaced to system_reset in SBI SRST extension with ColdReboot and NoReason as parameters;
- legacy set_timer is replaced with SBI TIME set_timer;
- legacy send_ipi is replaced to SBI IPI extension. The code implemented in file processor.rs creates a HartMask with only one hart_id selected as an IPI target.

Signed-off-by: Zhouqi Jiang <[email protected]>
Copy link
Member

@mkroening mkroening left a comment

Choose a reason for hiding this comment

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

Thanks a lot! And thanks for being patient! :)

@mkroening mkroening added this pull request to the merge queue Apr 17, 2024
Merged via the queue into hermit-os:main with commit 6952f40 Apr 17, 2024
13 checks passed
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