Skip to content

feat/PCIe: verify the base address of PCI devices#2457

Open
zyuiop wants to merge 2 commits into
hermit-os:mainfrom
zyuiop:feat/pcie-verify-address
Open

feat/PCIe: verify the base address of PCI devices#2457
zyuiop wants to merge 2 commits into
hermit-os:mainfrom
zyuiop:feat/pcie-verify-address

Conversation

@zyuiop

@zyuiop zyuiop commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

This ensures that a malicious hypervisor will not provide PCI devices that map to system memory

@mkroening mkroening self-assigned this Jun 1, 2026

@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: fe42a4a Previous: 30cb3f9 Performance Ratio
startup_benchmark Build Time 80.77 s 78.59 s 1.03
startup_benchmark File Size 0.76 MB 0.76 MB 1.01
Startup Time - 1 core 0.76 s (±0.01 s) 0.73 s (±0.02 s) 1.04
Startup Time - 2 cores 0.76 s (±0.03 s) 0.75 s (±0.02 s) 1.01
Startup Time - 4 cores 0.75 s (±0.02 s) 0.76 s (±0.02 s) 1.00
multithreaded_benchmark Build Time 81.29 s 80.39 s 1.01
multithreaded_benchmark File Size 0.86 MB 0.82 MB 1.06
Multithreaded Pi Efficiency - 2 Threads 90.21 % (±7.65 %) 89.59 % (±5.95 %) 1.01
Multithreaded Pi Efficiency - 4 Threads 43.84 % (±2.63 %) 43.86 % (±2.44 %) 1.00
Multithreaded Pi Efficiency - 8 Threads 25.94 % (±1.27 %) 25.65 % (±1.39 %) 1.01
micro_benchmarks Build Time 82.87 s 87.27 s 0.95
micro_benchmarks File Size 0.87 MB 0.82 MB 1.06
Scheduling time - 1 thread 64.87 ticks (±2.06 ticks) 64.58 ticks (±2.95 ticks) 1.00
Scheduling time - 2 threads 37.30 ticks (±4.47 ticks) 35.27 ticks (±2.44 ticks) 1.06
Micro - Time for syscall (getpid) 2.83 ticks (±0.25 ticks) 2.72 ticks (±0.18 ticks) 1.04
Memcpy speed - (built_in) block size 4096 86593.76 MByte/s (±59674.46 MByte/s) 84336.36 MByte/s (±58124.47 MByte/s) 1.03
Memcpy speed - (built_in) block size 1048576 30829.60 MByte/s (±24922.40 MByte/s) 30954.90 MByte/s (±25149.11 MByte/s) 1.00
Memcpy speed - (built_in) block size 16777216 29920.90 MByte/s (±24643.32 MByte/s) 27618.34 MByte/s (±22854.11 MByte/s) 1.08
Memset speed - (built_in) block size 4096 86908.05 MByte/s (±59878.23 MByte/s) 84961.36 MByte/s (±58506.83 MByte/s) 1.02
Memset speed - (built_in) block size 1048576 31574.01 MByte/s (±25348.59 MByte/s) 31697.81 MByte/s (±25573.78 MByte/s) 1.00
Memset speed - (built_in) block size 16777216 30691.13 MByte/s (±25079.90 MByte/s) 28408.60 MByte/s (±23353.48 MByte/s) 1.08
Memcpy speed - (rust) block size 4096 76411.31 MByte/s (±53221.33 MByte/s) 74740.31 MByte/s (±52172.06 MByte/s) 1.02
Memcpy speed - (rust) block size 1048576 30758.96 MByte/s (±24893.83 MByte/s) 30989.85 MByte/s (±25131.37 MByte/s) 0.99
Memcpy speed - (rust) block size 16777216 29933.38 MByte/s (±24647.12 MByte/s) 27766.19 MByte/s (±22932.85 MByte/s) 1.08
Memset speed - (rust) block size 4096 76907.00 MByte/s (±53570.50 MByte/s) 75196.89 MByte/s (±52449.92 MByte/s) 1.02
Memset speed - (rust) block size 1048576 31500.78 MByte/s (±25322.18 MByte/s) 31748.80 MByte/s (±25574.00 MByte/s) 0.99
Memset speed - (rust) block size 16777216 30681.86 MByte/s (±25062.56 MByte/s) 28552.59 MByte/s (±23427.10 MByte/s) 1.07
alloc_benchmarks Build Time 81.36 s 81.63 s 1.00
alloc_benchmarks File Size 0.84 MB 0.84 MB 1.01
Allocations - Allocation success 100.00 % 100.00 % 1
Allocations - Deallocation success 100.00 % 100.00 % 1
Allocations - Pre-fail Allocations 100.00 % 100.00 % 1
Allocations - Average Allocation time 5366.07 Ticks (±96.57 Ticks) 5722.73 Ticks (±63.96 Ticks) 0.94
Allocations - Average Allocation time (no fail) 5366.07 Ticks (±96.57 Ticks) 5722.73 Ticks (±63.96 Ticks) 0.94
Allocations - Average Deallocation time 666.03 Ticks (±111.08 Ticks) 1530.42 Ticks (±212.44 Ticks) 0.44
mutex_benchmark Build Time 81.69 s 80.99 s 1.01
mutex_benchmark File Size 0.87 MB 0.82 MB 1.06
Mutex Stress Test Average Time per Iteration - 1 Threads 12.02 ns (±0.24 ns) 12.10 ns (±0.36 ns) 0.99
Mutex Stress Test Average Time per Iteration - 2 Threads 14.76 ns (±0.43 ns) 17.00 ns (±3.01 ns) 0.87

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

@zyuiop zyuiop force-pushed the feat/pcie-verify-address branch 2 times, most recently from 78eb5f1 to 01026fa Compare June 5, 2026 12:51
@zyuiop zyuiop force-pushed the feat/pcie-verify-address branch from 01026fa to 603f9dd Compare June 5, 2026 12:56

@mkroening mkroening left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks, this looks good to me. :)

Just one suggestion.

Comment thread src/arch/x86_64/kernel/pci.rs Outdated
Comment on lines +209 to +211
(pci_start >= region_start && pci_start <= region_end) // PCI region starts within the memory region
|| (pci_end >= region_start && pci_end <= region_end) // PCI region ends within the memory region
|| (pci_start <= region_start && pci_end >= region_end) // PCI region contains the memory region

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can't this be simplified?

Suggested change
(pci_start >= region_start && pci_start <= region_end) // PCI region starts within the memory region
|| (pci_end >= region_start && pci_end <= region_end) // PCI region ends within the memory region
|| (pci_start <= region_start && pci_end >= region_end) // PCI region contains the memory region
pci_start > region_end && pci_end < region_start

At least that is how I did it in PageRange::overlaps.

@zyuiop zyuiop Jun 17, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Isn't it more pci_start < region_end && pci_end > region_start ?

I ended up using range intersections, which I think make the intent clearer

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You are right; I mistyped. Would you be okay with that? I'd like to avoid new nightly features if possible. :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Okay, I was supposing this may be the case :)
Pushing a new version

@zyuiop zyuiop force-pushed the feat/pcie-verify-address branch 2 times, most recently from 9f7cf2c to b156af3 Compare June 17, 2026 10:44
@zyuiop zyuiop force-pushed the feat/pcie-verify-address branch from b156af3 to fe42a4a Compare June 17, 2026 10:44
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