Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5808,10 +5808,12 @@ version = "0.0.0"
dependencies = [
"anyhow",
"futures",
"guid",
"hcl",
"hvdef",
"inspect",
"memory_range",
"pal_async",
"parking_lot",
"sev_guest_device",
"tdisp",
Expand Down
2 changes: 1 addition & 1 deletion Guide/src/dev_guide/getting_started/build_openhcl.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ Some examples of potentially useful customization include:
`x64-cvm` recipe:

```bash
cargo xflowey build-igvm x64-cvm --override-manifest vm/loader/manifests/openhcl-x64-cvm-sivm-dev.toml
cargo xflowey build-igvm x64-cvm --override-manifest vm/loader/manifests/openhcl-x64-sivm-dev.toml
```

- `--custom-openvmm-hcl`: Specify a pre-built `openvmm_hcl` binary. This is
Expand Down
18 changes: 9 additions & 9 deletions Guide/src/reference/architecture/openhcl/product_policy.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ it only if the manifest sets `static_command_line` to false and OpenHCL trusts
the host: the guest isn't isolated, or the image's measured command line enables
confidential debugging. Otherwise only the measured command line sets it.

`allow_unattested_devices` lets the relay offer devices that can't be attested
with TDISP, for hosts that don't support it. It defaults to `false`; only the
SIVM policy sets it, as a temporary solution until TDISP support comes online
for SIVMs. With it set, OpenHCL sends the host no TDISP command and checks no
TDI report, so nothing attests the device's identity or configuration, and
the device's BARs stay shared with the host.

The catalog defines each device once, with any of `vendor_id`, `device_id`,
`revision_id`, `base_class`, `sub_class`, and `prog_if`. A field that is left
out matches any value, but an allowed device must set at least one:
Expand Down Expand Up @@ -112,12 +119,5 @@ When the relay runs, it offers the guest only the allowed devices:

## In-tree images

The policies are inline in `vm/loader/manifests/*.toml`. They share the catalog
in `vm/loader/manifests/policies/devices.toml`:

| Manifests | Product | Device policy |
|---|---|---|
| `openhcl-x64-cvm-{dev,release}.toml` | `azure` | NVMe, MANA, and the Azure Integrated HSM; `default_on` |
| `openhcl-x64-{dev,release}.toml`, `openhcl-x64-direct-{dev,release}.toml`, `openhcl-aarch64-{dev,release}.toml` | `azure` | The same devices; `default_off` |
| `openhcl-x64-cvm-sivm-{dev,release}.toml` | `sivm` | A GPU; `must_be_on` |
| `openhcl-x64-test-sivm.toml` | `sivm` | None |
The policies are inline in `vm/loader/manifests/*.toml`, and share the catalog
in `vm/loader/manifests/policies/devices.toml`.
35 changes: 33 additions & 2 deletions openhcl/hcl/src/ioctl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -804,13 +804,14 @@ impl MshvHvcall {
}
}

/// Accepts VTL 0 pages with no host visibility.
/// Accepts VTL 0 pages with the given host visibility.
///
/// [`HypercallCode::HvCallAcceptGpaPages`] must be allowed.
pub fn accept_gpa_pages(
&self,
range: MemoryRange,
memory_type: hvdef::hypercall::AcceptMemoryType,
host_visibility: HostVisibilityType,
) -> Result<(), AcceptPagesError> {
const MAX_INPUT_ELEMENTS: usize = (HV_PAGE_SIZE as usize
- size_of::<hvdef::hypercall::AcceptGpaPages>())
Expand All @@ -827,7 +828,7 @@ impl MshvHvcall {
partition_id: HV_PARTITION_ID_SELF,
page_attributes: hvdef::hypercall::AcceptPagesAttributes::new()
.with_memory_type(memory_type.0)
.with_host_visibility(HostVisibilityType::PRIVATE)
.with_host_visibility(host_visibility)
.with_vtl_set(0), // vtl protections cannot be applied for VTL 0 memory
vtl_permission_set: hvdef::hypercall::VtlPermissionSet {
vtl_permission_from_1: [0; hvdef::hypercall::HV_VTL_PERMISSION_SET_SIZE],
Expand Down Expand Up @@ -1426,6 +1427,36 @@ impl MshvHvcall {
Err(status.result().unwrap_err())
}
}

/// Asks the vTSM (virtual TSM) to authorize, or with `authorize` false to
/// unauthorize, DMA for the device the host assigned with
/// `logical_device_id`, on a VBS-isolated partition. The hypervisor denies
/// DMA from every device assigned to the partition until it's authorized.
///
/// [`HypercallCode::HvCallVbsVmCallAuthorizeDeviceIo`] must be allowed.
pub fn authorize_device_io(
&self,
logical_device_id: u64,
authorize: bool,
) -> Result<(), HvError> {
let input = hvdef::hypercall::VbsVmCallAuthorizeDeviceIo {
logical_device_id,
authorize: authorize.into(),
reserved: [0; 7],
};

// SAFETY: The input is the correct type for this hypercall, which has
// no output.
unsafe {
self.hvcall(
HypercallCode::HvCallVbsVmCallAuthorizeDeviceIo,
&input,
&mut (),
)
.expect("submitting hypercall should not fail")
.result()
}
}
}

/// The HCL device and collection of fds.
Expand Down
6 changes: 5 additions & 1 deletion openhcl/openhcl_tdisp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ rust-version.workspace = true
edition.workspace = true

[dependencies]
guid.workspace = true
hvdef.workspace = true
inspect.workspace = true
memory_range.workspace = true
Expand All @@ -20,11 +21,14 @@ anyhow.workspace = true
futures.workspace = true
tracing.workspace = true

# Both validators talk to /dev/mshv_vtl, and SEV-TIO also to /dev/sev-guest.
# The platform validators talk to mshv, and SEV-TIO also to /dev/sev-guest.
[target.'cfg(target_os = "linux")'.dependencies]
hcl.workspace = true
sev_guest_device.workspace = true
tracelimit.workspace = true

[dev-dependencies]
pal_async.workspace = true

[lints]
workspace = true
Loading
Loading