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

Add support for the ibex-super-system #40

Open
wants to merge 2 commits into
base: rivos/main
Choose a base branch
from

Conversation

beezow
Copy link
Collaborator

@beezow beezow commented Oct 3, 2022

Adds chip and demo apps for the ibex super system. This is needed for testing on the FPGA.

@beezow
Copy link
Collaborator Author

beezow commented Oct 3, 2022

I should have made this as a draft. It still needs some cleanup and requires #41.

@beezow beezow mentioned this pull request Oct 3, 2022
@beezow beezow marked this pull request as draft October 3, 2022 22:52
@beezow beezow added good first issue Good for newcomers enhancement New feature or request labels Oct 24, 2022
@beezow beezow force-pushed the dev/drew/ibex_super_system branch 2 times, most recently from 00d6de7 to 4cff3e1 Compare November 15, 2022 22:35
@beezow beezow marked this pull request as ready for review November 15, 2022 22:46
@beezow beezow requested a review from a team as a code owner November 15, 2022 22:46
@beezow
Copy link
Collaborator Author

beezow commented Nov 15, 2022

The test suite is not included as it will not pass. When running the unaligned instruction test, it will hang the core.

FawazTirmizi
FawazTirmizi previously approved these changes Nov 15, 2022
@furquan-rivos
Copy link
Collaborator

The test suite is not included as it will not pass. When running the unaligned instruction test, it will hang the core.

Why is that? Shouldn't it be caught by the M-mode kernel and not result in a hang?

@beezow
Copy link
Collaborator Author

beezow commented Nov 15, 2022

The test suite is not included as it will not pass. When running the unaligned instruction test, it will hang the core.

Why is that? Shouldn't it be caught by the M-mode kernel and not result in a hang?

The exception never gets thrown. Jumping to the aligned address on either side generates an illegal instruction, but the unaligned case just hangs. Attempting to r/w from the same address also generates the correct exceptions.

chips/ibex-super-system/chip.toml Show resolved Hide resolved
chips/ibex-super-system/openocd.cfg Show resolved Hide resolved
chips/ibex-super-system/openocd.gdb Show resolved Hide resolved
app/demo-ibex-super-system/Cargo.toml Outdated Show resolved Hide resolved

#[entry]
fn main() -> ! {
const CYCLES_PER_MS: u32 = 0x60_0000;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Where does this value come from?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I just made it up, any values much smaller and it interrupts so fast the core cannot do anything. I tried to calculate the correct value based on the FPGA clock, but that was absurdly slow. I think I was missing something about what clock frequency the FPGA was actually running at.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Probably add a comment or a bug to follow-up on this if you plan to push this in as is?

@furquan-rivos
Copy link
Collaborator

The test suite is not included as it will not pass. When running the unaligned instruction test, it will hang the core.

Why is that? Shouldn't it be caught by the M-mode kernel and not result in a hang?

The exception never gets thrown. Jumping to the aligned address on either side generates an illegal instruction, but the unaligned case just hangs. Attempting to r/w from the same address also generates the correct exceptions.

Is that a known bug with the system? As per the priv spec, this should throw an "instruction address misaligned" exception. What test is this exactly that fails?

Also, does this help:

diff --git a/sys/kern/src/arch/riscv32.rs b/sys/kern/src/arch/riscv32.rs
index ebe22e99..b68d405d 100644
--- a/sys/kern/src/arch/riscv32.rs
+++ b/sys/kern/src/arch/riscv32.rs
@@ -571,6 +571,9 @@ fn trap_handler(task: &mut task::Task) {
         Trap::Exception(Exception::IllegalInstruction) => unsafe {
             handle_fault(task, FaultInfo::IllegalInstruction);
         },
+        Trap::Exception(Exception::InstructionMisaligned) => unsafe {
+            handle_fault(task, FaultInfo::IllegalInstruction);
+        },
         Trap::Exception(Exception::LoadFault)
         | Trap::Exception(Exception::StoreFault) => unsafe {
             handle_fault(

This chip will be useful for FPGA testing
@beezow beezow force-pushed the dev/drew/ibex_super_system branch from fcab4c7 to f05b38c Compare November 16, 2022 00:26
@beezow
Copy link
Collaborator Author

beezow commented Nov 16, 2022

The test suite is not included as it will not pass. When running the unaligned instruction test, it will hang the core.

Why is that? Shouldn't it be caught by the M-mode kernel and not result in a hang?

The exception never gets thrown. Jumping to the aligned address on either side generates an illegal instruction, but the unaligned case just hangs. Attempting to r/w from the same address also generates the correct exceptions.

Is that a known bug with the system? As per the priv spec, this should throw an "instruction address misaligned" exception. What test is this exactly that fails?

Also, does this help:

diff --git a/sys/kern/src/arch/riscv32.rs b/sys/kern/src/arch/riscv32.rs
index ebe22e99..b68d405d 100644
--- a/sys/kern/src/arch/riscv32.rs
+++ b/sys/kern/src/arch/riscv32.rs
@@ -571,6 +571,9 @@ fn trap_handler(task: &mut task::Task) {
         Trap::Exception(Exception::IllegalInstruction) => unsafe {
             handle_fault(task, FaultInfo::IllegalInstruction);
         },
+        Trap::Exception(Exception::InstructionMisaligned) => unsafe {
+            handle_fault(task, FaultInfo::IllegalInstruction);
+        },
         Trap::Exception(Exception::LoadFault)
         | Trap::Exception(Exception::StoreFault) => unsafe {
             handle_fault(

That will not help, the trap handler never gets called. Even re flashing hubris does not help (which initiates a reset), I have to fully power cycle the FPGA. The actual test cause is test_fault_nullexec within test-suite, but that translates to a badexec within the test-runner, which attempts to execute at address 0x1. I am adding some details to https://rivosinc.atlassian.net/browse/SW-205

This is useful for verifing hubris functionality on actual hardware.
@beezow beezow force-pushed the dev/drew/ibex_super_system branch from f05b38c to 5c78e8d Compare November 16, 2022 02:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants