From 7a8faebb09cc161698c3ed455de814f59444ba11 Mon Sep 17 00:00:00 2001 From: Carl Lundin Date: Tue, 11 Feb 2025 14:42:50 -0800 Subject: [PATCH] Update to zerocopy 0.8.17 Also updates DPE submodule to pull in the same zerocopy. Zerocopy's derive macro for KnownLayout has changed. Compiling DPE in caliptra-sw fails because public interfaces are leaking these private types. The solution is to mark them as a public field. There may be another workaround, but since these types are being serialized to and from raw bytes, it makes sense that these private fields should be visible to callers. --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- api/src/mailbox.rs | 6 +++--- dpe | 2 +- drivers/src/pcr_reset.rs | 2 +- image/gen/src/generator.rs | 4 ++-- image/types/src/lib.rs | 6 +++--- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a4addd4844..5091883901 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2972,18 +2972,18 @@ dependencies = [ [[package]] name = "zerocopy" -version = "0.8.8" +version = "0.8.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a4e33e6dce36f2adba29746927f8e848ba70989fdb61c772773bbdda8b5d6a7" +checksum = "aa91407dacce3a68c56de03abe2760159582b846c6a4acd2f456618087f12713" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.8.8" +version = "0.8.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3cd137b4cc21bde6ecce3bbbb3350130872cda0be2c6888874279ea76e17d4c1" +checksum = "06718a168365cad3d5ff0bb133aad346959a2074bd4a85c121255a11304a8626" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index e5912f5701..78ddcecc73 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -184,7 +184,7 @@ ureg-schema = { path = "ureg/lib/schema" } ureg-systemrdl = { path = "ureg/lib/systemrdl" } wycheproof = "0.5.1" x509-parser = "0.15.0" -zerocopy = { version = "0.8.8", features = ["derive"] } +zerocopy = { version = "0.8.17", features = ["derive"] } serial_test = "2.0.0" nix = "0.26.2" libc = "0.2" diff --git a/api/src/mailbox.rs b/api/src/mailbox.rs index 1a5750ac8f..0250ca133d 100644 --- a/api/src/mailbox.rs +++ b/api/src/mailbox.rs @@ -472,7 +472,7 @@ pub struct GetIdevInfoResp { #[repr(C)] #[derive(Default, Debug, IntoBytes, FromBytes, Immutable, KnownLayout, PartialEq, Eq)] pub struct GetLdevCertReq { - header: MailboxReqHeader, + pub header: MailboxReqHeader, } impl Request for GetLdevCertReq { @@ -506,7 +506,7 @@ impl Default for GetLdevCertResp { #[repr(C)] #[derive(Default, Debug, IntoBytes, FromBytes, Immutable, KnownLayout, PartialEq, Eq)] pub struct GetRtAliasCertReq { - header: MailboxReqHeader, + pub header: MailboxReqHeader, } impl Request for GetRtAliasCertReq { const ID: CommandId = CommandId::GET_RT_ALIAS_CERT; @@ -734,7 +734,7 @@ impl Default for InvokeDpeResp { #[repr(C)] #[derive(Debug, Default, IntoBytes, FromBytes, Immutable, KnownLayout, PartialEq, Eq)] pub struct GetFmcAliasCertReq { - header: MailboxReqHeader, + pub header: MailboxReqHeader, } impl Request for GetFmcAliasCertReq { const ID: CommandId = CommandId::GET_FMC_ALIAS_CERT; diff --git a/dpe b/dpe index 7679315983..49422d391c 160000 --- a/dpe +++ b/dpe @@ -1 +1 @@ -Subproject commit 76793159830d29f5388ed7563679da62bb6126cf +Subproject commit 49422d391cbae851591fda6f8851e088df7cab96 diff --git a/drivers/src/pcr_reset.rs b/drivers/src/pcr_reset.rs index 8b5c4fbb00..62d915dc96 100644 --- a/drivers/src/pcr_reset.rs +++ b/drivers/src/pcr_reset.rs @@ -19,7 +19,7 @@ use zeroize::Zeroize; #[repr(C, align(4))] #[derive(IntoBytes, FromBytes, Immutable, KnownLayout, Zeroize)] pub struct PcrResetCounter { - counter: [u32; PcrBank::ALL_PCR_IDS.len()], + pub counter: [u32; PcrBank::ALL_PCR_IDS.len()], } impl Default for PcrResetCounter { diff --git a/image/gen/src/generator.rs b/image/gen/src/generator.rs index 6a75bc2376..0393716594 100644 --- a/image/gen/src/generator.rs +++ b/image/gen/src/generator.rs @@ -245,12 +245,12 @@ impl ImageGenerator { where E: ImageGenratorExecutable, { - let r#type = ImageTocEntryType::Executable; + let image_type = ImageTocEntryType::Executable; let digest = self.crypto.sha384_digest(image.content())?; let entry = ImageTocEntry { id: id.into(), - r#type: r#type.into(), + image_type: image_type.into(), revision: *image.rev(), version: image.version(), svn: image.svn(), diff --git a/image/types/src/lib.rs b/image/types/src/lib.rs index 2ef81bed63..6674f39eca 100644 --- a/image/types/src/lib.rs +++ b/image/types/src/lib.rs @@ -304,7 +304,7 @@ pub struct VendorSignedData { /// Vendor End Date [ASN1 Time Format] For FMC alias certificate. pub vendor_not_after: [u8; 15], - reserved: [u8; 10], + pub reserved: [u8; 10], } #[repr(C)] @@ -320,7 +320,7 @@ pub struct OwnerSignedData { /// Owner epoch, used to diversify stable SVN keys. pub epoch: [u8; 2], - reserved: [u8; 8], + pub reserved: [u8; 8], } /// Caliptra Image header @@ -396,7 +396,7 @@ pub struct ImageTocEntry { pub id: u32, /// Type - pub r#type: u32, + pub image_type: u32, /// Commit revision pub revision: ImageRevision,