MCPcopy Index your code
hub / github.com/KuangjuX/hypocaust

github.com/KuangjuX/hypocaust @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
223 symbols 504 edges 45 files 68 documented · 30%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Hypocaust

Note:
Currently developing the hardware-assisted virtualization project hypocaust-2

Overview

Hypocaust is an experimental S-mode trap and emulate type-1 hypervisor for RISC-V. It is currently targeted at QEMU's virt machine type. It can run on RustSBI currently. It can boot and run minikernel now.

Environment

  • QEMU 7.0.0
  • rust 1.66.0

Build

git clone https://github.com/KuangjuX/hypocaust.git
cd hypocaust
git submodule update --init

make qemu

Memory Region

  • DRAM Memory Region: 0x80000000 - 0x140000000 3GB
  • hypervisor: 128MB
  • Guest Kernel: 128MB

Hypervisor Memory Region

HVA Start HVA End HPA Start HPA End Memory Region
0x80000000 0x80200000 0x80000000 0x80200000 RustSBI
0x80200000 0xC0000000 0x80200000 0x88000000 hypervisor
0x88000000 0x8FFFFFFF 0x88000000 0x8FFFFFFF Guest Kernel 1
0x90000000 0x97FFFFFF 0x90000000 0x97FFFFFF Guest Kernel 2
0x98000000 0x9FFFFFFF 0x98000000 0x9FFFFFFF Guest Kernel 3
0x100000000 0x17FFFFFFF 0x100000000 0x17FFFFFFF Guest Kernel 1 Shadow Page Table

Resvered Memory Region

VA Start VA End Memory Region
0xFFFFFFFFFFFFF000 0xFFFFFFFFFFFFFFFF Trampoline
0xFFFFFFFFFFFFE000 0xFFFFFFFFFFFFEFFF Trap Context

Guest Kernel Memory Region

GVA GPA HVA Memory Region
0x80000000 - 0x87FFFFFF 0x80000000 - 0x87FFFFFF 0x88000000 - 0x8FFFFFFF Guest Kernel 1
0x80000000 - 0x87FFFFFF 0x80000000 - 0x87FFFFFF 0x90000000 - 0x97FFFFFF Guest Kernel 2
0x80000000 - 0x87FFFFFF 0x80000000 - 0x87FFFFFF 0x98000000 - 0x9FFFFFFF Guest Kernel 3

Supported Platforms

  • QEMU virt machine type

RoadMap

  • [x] Load guest kernel && Run guest kernel
  • [x] Trap and emulate of privileged instructions(CSR related and SFENCE>VMA)
  • [x] Shadow page tables
  • [x] Synchronize guest page table & shadow page table
  • [x] Foward Expections & Interrupts
  • [x] Timers
  • [ ] Serial IO emulate
  • [ ] Handle external interrupts
  • [ ] Expose and/or emulate peripherals
  • [ ] passthrough virtio block and networkd devices
  • [ ] multicore supported
  • [ ] multiguest supported

References

Questions

See also: - Synchronize satp & SPT

License

MIT License

Copyright (c) 2022 ChengXiang Qi

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Extension points exported contracts — how you extend this code

StepByOne (Interface)
(no doc) [2 implementers]
src/page_table/address.rs
PageDebug (Interface)
(no doc) [1 implementers]
src/debug/pagedebug.rs
FrameAllocator (Interface)
(no doc) [1 implementers]
src/hypervisor/hyp_alloc/frame_allocator.rs
Mutex (Interface)
(no doc)
src/sync/mutex.rs
PageTable (Interface)
(no doc) [1 implementers]
src/page_table/mod.rs

Core symbols most depended-on inside this repo

ppn
called by 32
src/page_table/pte.rs
is_valid
called by 19
src/page_table/pte.rs
push
called by 16
src/guest/pmap.rs
flags
called by 16
src/page_table/pte.rs
translate
called by 16
src/mm/memory_set.rs
get_pte_array
called by 15
src/page_table/address.rs
push
called by 14
src/mm/memory_set.rs
gpa2hpa
called by 11
src/guest/pmap.rs

Shape

Method 117
Function 61
Class 34
Enum 6
Interface 5

Languages

Rust100%

Modules by API surface

src/guest/pmap.rs24 symbols
src/page_table/address.rs23 symbols
src/mm/memory_set.rs23 symbols
src/page_table/sv39.rs16 symbols
src/page_table/pte.rs13 symbols
src/hypervisor/hyp_alloc/frame_allocator.rs13 symbols
src/guest/context.rs10 symbols
src/page_table/mod.rs8 symbols
src/hypervisor/trap/mod.rs8 symbols
src/hypervisor/mod.rs8 symbols
src/mm/memory_region.rs7 symbols
src/guest/mod.rs6 symbols

For agents

$ claude mcp add hypocaust \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact