Skip to content

[codex] Add SBI console input on RISC-V - #2584

Draft
Jonesxq wants to merge 3 commits into
hermit-os:mainfrom
Jonesxq:fix/issue-1838-sbi-console
Draft

[codex] Add SBI console input on RISC-V#2584
Jonesxq wants to merge 3 commits into
hermit-os:mainfrom
Jonesxq:fix/issue-1838-sbi-console

Conversation

@Jonesxq

@Jonesxq Jonesxq commented Jul 29, 2026

Copy link
Copy Markdown

Summary

  • replace per-byte RISC-V SBI console output with bulk console_write
  • add default RISC-V console input through console_read, including readiness caching and async stdin polling
  • enable the default RISC-V stdin CI test

Why

The default RISC-V console only supported output through console_write_byte and never read input, so stdin could not work. The SBI debug console extension provides bulk read and write operations that address both limitations.

The SBI API accepts physical addresses, so the console uses a page-aligned bounce buffer embedded in the serial device. Kernel data is identity-mapped on RISC-V; keeping the buffer local to the device also avoids page-table translation during early logging or while the page-table lock is held.

Impact

Default-console RISC-V guests can now receive stdin, and console output is sent in chunks instead of one SBI call per byte.

Validation

  • built the RISC-V kernel and hermit-builtins
  • ran repository-wide cargo xtask clippy across architectures and feature combinations
  • cargo fmt --all -- --check
  • git diff --check

Local QEMU stdin execution was not available because qemu-system-riscv64 is not installed. The RISC-V stdin CI job is enabled by this change.

Closes #1838

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Benchmark Results

Details
Benchmark Current: 8f19f39 Previous: 2e23902 Performance Ratio
startup_benchmark Build Time 81.38 s 80.34 s 1.01
startup_benchmark File Size 0.79 MB 0.80 MB 1.00
Startup Time - 1 core 0.75 s (±0.02 s) 0.75 s (±0.02 s) 1.00
Startup Time - 2 cores 0.77 s (±0.02 s) 0.74 s (±0.02 s) 1.05
Startup Time - 4 cores 0.76 s (±0.02 s) 0.74 s (±0.02 s) 1.03
multithreaded_benchmark Build Time 81.60 s 82.11 s 0.99
multithreaded_benchmark File Size 0.90 MB 0.86 MB 1.05
Multithreaded Pi Efficiency - 2 Threads 87.81 % (±4.42 %) 85.89 % (±6.61 %) 1.02
Multithreaded Pi Efficiency - 4 Threads 42.66 % (±2.30 %) 43.43 % (±2.56 %) 0.98
Multithreaded Pi Efficiency - 8 Threads 24.66 % (±1.64 %) 25.76 % (±1.53 %) 0.96
micro_benchmarks Build Time 80.17 s 80.40 s 1.00
micro_benchmarks File Size 0.90 MB 0.86 MB 1.05
Scheduling time - 1 thread 64.19 ticks (±2.42 ticks) 62.65 ticks (±4.06 ticks) 1.02
Scheduling time - 2 threads 36.00 ticks (±5.11 ticks) 34.08 ticks (±4.10 ticks) 1.06
Micro - Time for syscall (getpid) 4.42 ticks (±0.81 ticks) 3.45 ticks (±0.58 ticks) 1.28
Memcpy speed - (built_in) block size 4096 84686.73 MByte/s (±58599.22 MByte/s) 82448.38 MByte/s (±56997.13 MByte/s) 1.03
Memcpy speed - (built_in) block size 1048576 30399.98 MByte/s (±24479.96 MByte/s) 30585.98 MByte/s (±24707.84 MByte/s) 0.99
Memcpy speed - (built_in) block size 16777216 29306.61 MByte/s (±24085.90 MByte/s) 26340.06 MByte/s (±21720.96 MByte/s) 1.11
Memset speed - (built_in) block size 4096 84033.61 MByte/s (±58226.21 MByte/s) 82292.76 MByte/s (±56891.50 MByte/s) 1.02
Memset speed - (built_in) block size 1048576 31110.92 MByte/s (±24903.36 MByte/s) 31323.85 MByte/s (±25145.86 MByte/s) 0.99
Memset speed - (built_in) block size 16777216 30065.44 MByte/s (±24522.27 MByte/s) 27104.68 MByte/s (±22209.94 MByte/s) 1.11
Memcpy speed - (rust) block size 4096 74968.57 MByte/s (±52503.01 MByte/s) 74097.96 MByte/s (±51811.44 MByte/s) 1.01
Memcpy speed - (rust) block size 1048576 30276.51 MByte/s (±24480.06 MByte/s) 30361.60 MByte/s (±24602.37 MByte/s) 1.00
Memcpy speed - (rust) block size 16777216 29442.22 MByte/s (±24206.78 MByte/s) 27625.34 MByte/s (±22806.88 MByte/s) 1.07
Memset speed - (rust) block size 4096 75551.56 MByte/s (±52899.66 MByte/s) 74373.47 MByte/s (±51976.48 MByte/s) 1.02
Memset speed - (rust) block size 1048576 31023.57 MByte/s (±24919.37 MByte/s) 31110.89 MByte/s (±25033.24 MByte/s) 1.00
Memset speed - (rust) block size 16777216 30174.50 MByte/s (±24616.23 MByte/s) 28386.93 MByte/s (±23265.03 MByte/s) 1.06
alloc_benchmarks Build Time 77.71 s 74.76 s 1.04
alloc_benchmarks File Size 0.87 MB 0.87 MB 1.00
Allocations - Allocation success 91.31 % 91.31 % 1
Allocations - Deallocation success 100.00 % 100.00 % 1
Allocations - Pre-fail Allocations 61.44 % 61.44 % 1
Allocations - Average Allocation time 4287.14 Ticks (±105.93 Ticks) 5860.58 Ticks (±98.43 Ticks) 0.73
Allocations - Average Allocation time (no fail) 5058.75 Ticks (±104.51 Ticks) 6554.81 Ticks (±92.86 Ticks) 0.77
Allocations - Average Deallocation time 945.96 Ticks (±226.80 Ticks) 1805.01 Ticks (±250.35 Ticks) 0.52
mutex_benchmark Build Time 78.64 s 79.82 s 0.99
mutex_benchmark File Size 0.90 MB 0.86 MB 1.05
Mutex Stress Test Average Time per Iteration - 1 Threads 12.22 ns (±0.46 ns) 12.10 ns (±0.41 ns) 1.01
Mutex Stress Test Average Time per Iteration - 2 Threads 40.12 ns (±2.03 ns) 40.26 ns (±1.68 ns) 1.00

This comment was automatically generated by workflow using github-action-benchmark.

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.

SBI-based debug console is not read on RISC-V

1 participant