Skip to content

openhcl_boot: Serial output in the boot shim in SNP #1378

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

Open
wants to merge 30 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
eec2758
.
romank-msft May 16, 2025
2f5d5a6
use unmeasured pages
romank-msft May 16, 2025
7bdec1c
openhcl_boot: serial output for SNP
romank-msft May 17, 2025
60417ba
port I/O
romank-msft May 19, 2025
12293dd
fix finding the non-[present pml4 entry
romank-msft May 19, 2025
dd8ad1f
mask cr3 appropriately
romank-msft May 19, 2025
5aebd33
shift page table entries correctly
romank-msft May 19, 2025
907627d
va < 0, non-measured pages, decrypting
romank-msft May 19, 2025
b41e40e
hv accepts ghcb calls
romank-msft May 20, 2025
c39da4a
don't allocate pages in IGVM
romank-msft May 20, 2025
660dba7
clippy, fix arm64
romank-msft May 20, 2025
45ec826
fixes
romank-msft May 20, 2025
6240043
fix comment about ident mapping
romank-msft May 20, 2025
58457f5
renames, refactoring
romank-msft May 20, 2025
6e6a4fa
restore previous ghcb at the right time
romank-msft May 20, 2025
c3053a8
proper name
romank-msft May 20, 2025
c86910d
fewer pointers and unsafe
romank-msft May 21, 2025
4f5bde7
fix the terminology
romank-msft May 21, 2025
1951a68
refactor
romank-msft May 21, 2025
d6ed709
nfc to match the comment
romank-msft May 21, 2025
be31cb0
guarantee page align
romank-msft May 21, 2025
450d8bd
no atomics
romank-msft May 21, 2025
dab1806
ghcb_mut is unsafe
romank-msft May 21, 2025
2d9f90d
don't stip and add back the same type
romank-msft May 21, 2025
9cf634a
atomic access to ghcb
romank-msft May 21, 2025
9566a27
register for hypercalls
romank-msft May 21, 2025
5dff74f
ghcb hypercalls (regular Hyper-V)
romank-msft May 22, 2025
3121952
setting and checking bitmaps centrally
romank-msft May 22, 2025
7a29da7
first set guest OS ID via the hvcall
romank-msft May 22, 2025
1648e44
temp remap at GPA 0 to let pvalidate succeed
romank-msft May 26, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4811,6 +4811,7 @@ version = "0.0.0"
dependencies = [
"aarch64defs",
"arrayvec",
"bitfield-struct 0.10.1",
"cfg-if",
"crc32fast",
"fdt",
Expand Down
1 change: 1 addition & 0 deletions openhcl/openhcl_boot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ rust-version.workspace = true

[dependencies]
aarch64defs.workspace = true
bitfield-struct.workspace = true
minimal_rt.workspace = true
underhill_confidentiality.workspace = true
host_fdt_parser.workspace = true
Expand Down
5 changes: 5 additions & 0 deletions openhcl/openhcl_boot/src/arch/aarch64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,17 @@ mod memory;
mod vp;
mod vsm;

use crate::host_params::shim_params::ShimParams;
pub use memory::physical_address_bits;
pub use memory::setup_vtl2_memory;
pub use memory::verify_imported_regions_hash;
pub use vp::setup_vtl2_vp;
pub use vsm::get_isolation_type;

pub fn initialize(_: &ShimParams) {}

pub fn uninitialize(_: &ShimParams) {}

// Entry point.
#[cfg(minimal_rt)]
core::arch::global_asm! {
Expand Down
18 changes: 9 additions & 9 deletions openhcl/openhcl_boot/src/arch/x86_64/address_space.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,21 @@ use zerocopy::Immutable;
use zerocopy::IntoBytes;
use zerocopy::KnownLayout;

const X64_PTE_PRESENT: u64 = 1;
const X64_PTE_READ_WRITE: u64 = 1 << 1;
const X64_PTE_ACCESSED: u64 = 1 << 5;
pub const X64_PTE_PRESENT: u64 = 1;
pub const X64_PTE_READ_WRITE: u64 = 1 << 1;
pub const X64_PTE_ACCESSED: u64 = 1 << 5;
const X64_PTE_DIRTY: u64 = 1 << 6;
const X64_PTE_LARGE_PAGE: u64 = 1 << 7;
const X64_PTE_CONFIDENTIAL: u64 = 1 << 51;
pub const X64_PTE_CONFIDENTIAL: u64 = 1 << 51;

const PAGE_TABLE_ENTRY_COUNT: usize = 512;
pub const PAGE_TABLE_ENTRY_COUNT: usize = 512;

const X64_PAGE_SHIFT: u64 = 12;
const X64_PTE_BITS: u64 = 9;
pub const X64_PAGE_SHIFT: u64 = 12;
pub const X64_PTE_BITS: u64 = 9;

#[derive(Debug, IntoBytes, Immutable, KnownLayout, FromBytes)]
#[repr(transparent)]
struct PageTableEntry {
pub struct PageTableEntry {
entry: u64,
}
#[derive(Debug, Copy, Clone)]
Expand Down Expand Up @@ -105,7 +105,7 @@ impl PageTableEntry {

#[repr(C)]
#[derive(Debug, IntoBytes, Immutable, KnownLayout, FromBytes)]
struct PageTable {
pub struct PageTable {
entries: [PageTableEntry; PAGE_TABLE_ENTRY_COUNT],
}

Expand Down
13 changes: 13 additions & 0 deletions openhcl/openhcl_boot/src/arch/x86_64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ mod vp;
mod vsm;

use crate::host_params::shim_params::IsolationType;
use crate::host_params::shim_params::ShimParams;
pub use memory::setup_vtl2_memory;
pub use memory::verify_imported_regions_hash;
use safe_intrinsics::cpuid;
Expand All @@ -39,6 +40,18 @@ pub fn physical_address_bits(isolation: IsolationType) -> u8 {
}
}

pub fn initialize(p: &ShimParams) {
if p.isolation_type == IsolationType::Snp {
snp::Ghcb::initialize();
}
}

pub fn uninitialize(p: &ShimParams) {
if p.isolation_type == IsolationType::Snp {
snp::Ghcb::uninitialize();
}
}

// Entry point.
#[cfg(minimal_rt)]
core::arch::global_asm! {
Expand Down
Loading