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
3 changes: 3 additions & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6715,11 +6715,14 @@ version = "0.0.0"
dependencies = [
"anyhow",
"base64 0.22.1",
"firmware_uefi_custom_vars",
"hyperv_uefi_custom_vars_json",
"inspect",
"mesh_protobuf",
"paste",
"serde",
"serde_json",
"uefi_specs",
]

[[package]]
Expand Down
3 changes: 3 additions & 0 deletions openhcl/product_policy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ mesh_protobuf.workspace = true
paste.workspace = true

anyhow.workspace = true
hyperv_uefi_custom_vars_json.workspace = true
firmware_uefi_custom_vars.workspace = true
uefi_specs.workspace = true
base64 = { workspace = true, optional = true, features = ["alloc"] }
inspect = { workspace = true, optional = true }
serde = { workspace = true, optional = true, features = ["alloc", "derive"] }
Expand Down
39 changes: 32 additions & 7 deletions openhcl/product_policy/src/cwcow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,24 @@ use alloc::vec::Vec;
#[mesh(package = "openhcl.product_policy")]
/// Cwcow policy
pub struct CwcowPolicy {
/// Reserved: require an ephemeral VMGS. Not enforced at runtime yet.
/// Require an ephemeral VMGS guest state lifetime.
#[mesh(1)]
pub require_ephemeral_vmgs: bool,

/// Require secure boot is enabled.
#[mesh(2)]
pub require_secure_boot: bool,

/// Reserved: require PK/KEK/db/dbx variables. Not enforced at runtime yet.
/// Require PK/KEK/db/dbx variables to be self-contained.
#[mesh(3)]
pub require_secure_boot_vars: bool,

/// Reserved: require `BootConfigurationDataHash`. Not enforced at runtime yet.
/// Require `BootConfigurationDataHash`.
#[mesh(4)]
pub require_bcd_integrity: bool,

/// Custom UEFI JSON bytes (base64 in manifest JSON). Required in
/// manifests and asserted non-empty at build time when secure boot
/// plus secure-boot-vars or BCD-integrity are set;
/// Custom UEFI JSON bytes (base64 in manifest JSON); mandatory when
/// secure boot plus secure-boot-vars or BCD-integrity are set.
#[mesh(5)]
#[cfg_attr(
feature = "manifest",
Expand All @@ -42,7 +41,7 @@ pub struct CwcowPolicy {
#[cfg_attr(feature = "inspect", inspect(with = "Vec::<u8>::len"))]
pub custom_uefi_json: Vec<u8>,

/// Reserved: require Secure AVIC. Not enforced at runtime yet.
/// Require Secure AVIC to be enabled.
#[mesh(6)]
pub require_secure_avic: bool,
}
Expand All @@ -51,6 +50,32 @@ impl crate::uefi_security_policy::UefiSecurityPolicyParams for CwcowPolicy {
fn require_secure_boot(&self) -> bool {
self.require_secure_boot
}

fn require_secure_boot_vars(&self) -> bool {
self.require_secure_boot_vars
}

fn require_bcd_integrity(&self) -> bool {
self.require_bcd_integrity
}

fn custom_uefi_json(&self) -> &[u8] {
&self.custom_uefi_json
}

fn require_ephemeral_vmgs(&self) -> bool {
self.require_ephemeral_vmgs
}
}

impl crate::uefi_security_policy::UefiSecurityPolicy for CwcowPolicy {}

impl CwcowPolicy {
/// Enforce that Secure AVIC is enabled if required by the policy.
pub fn enforce_secure_avic(&self, on: bool) -> anyhow::Result<()> {
if self.require_secure_avic && !on {
anyhow::bail!("product policy requires Secure AVIC to be enabled");
}
Ok(())
}
}
27 changes: 21 additions & 6 deletions openhcl/product_policy/src/sivm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,24 @@ use crate::uefi_security_policy::UefiSecurityPolicy;
#[cfg_attr(feature = "inspect", derive(inspect::Inspect))]
#[mesh(package = "openhcl.product_policy")]
pub struct SivmPolicy {
/// Reserved: require an ephemeral VMGS. Not enforced at runtime yet.
/// Require an ephemeral VMGS guest state lifetime.
#[mesh(1)]
pub require_ephemeral_vmgs: bool,

/// Require secure boot is enabled.
#[mesh(2)]
pub require_secure_boot: bool,

/// Reserved: require PK/KEK/db/dbx variables. Not enforced at runtime yet.
/// Require PK/KEK/db/dbx variables to be self-contained.
#[mesh(3)]
pub require_secure_boot_vars: bool,

/// Reserved: require `BootConfigurationDataHash`. Not enforced at runtime yet.
/// Require `BootConfigurationDataHash`.
#[mesh(4)]
pub require_bcd_integrity: bool,

/// Custom UEFI JSON bytes (base64 in manifest JSON). Required in
/// manifests and asserted non-empty at build time when secure boot
/// plus secure-boot-vars or BCD-integrity are set;
/// Custom UEFI JSON bytes (base64 in manifest JSON); mandatory when
/// secure boot plus secure-boot-vars or BCD-integrity are set.
#[mesh(5)]
#[cfg_attr(
feature = "manifest",
Expand All @@ -53,6 +52,22 @@ impl crate::uefi_security_policy::UefiSecurityPolicyParams for SivmPolicy {
fn require_secure_boot(&self) -> bool {
self.require_secure_boot
}

fn require_secure_boot_vars(&self) -> bool {
self.require_secure_boot_vars
}

fn require_bcd_integrity(&self) -> bool {
self.require_bcd_integrity
}

fn custom_uefi_json(&self) -> &[u8] {
&self.custom_uefi_json
}

fn require_ephemeral_vmgs(&self) -> bool {
self.require_ephemeral_vmgs
}
}

impl UefiSecurityPolicy for SivmPolicy {}
Loading
Loading