Skip to content

Commit

Permalink
Adding missing fuses to libcaliptra and SW emulator (#1311)
Browse files Browse the repository at this point in the history
- adding lms_verify, lms_revocation, and soc_stepping_id fuses to libcaliptra
- adding soc_stepping_id fuse to SW emulator
  • Loading branch information
nquarton authored Feb 9, 2024
1 parent 8d07f16 commit d6182be
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 0 deletions.
3 changes: 3 additions & 0 deletions hw-model/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,9 @@ pub trait HwModel {
self.soc_ifc()
.fuse_lms_revocation()
.write(|_| fuses.fuse_lms_revocation);
self.soc_ifc()
.fuse_soc_stepping_id()
.write(|w| w.soc_stepping_id(fuses.soc_stepping_id.into()));

self.soc_ifc().cptra_fuse_wr_done().write(|w| w.done(true));
assert!(self.soc_ifc().cptra_fuse_wr_done().read().done());
Expand Down
3 changes: 3 additions & 0 deletions hw-model/types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ pub struct Fuses {
pub life_cycle: DeviceLifecycle,
pub lms_verify: bool,
pub fuse_lms_revocation: u32,
pub soc_stepping_id: u16,
}
impl Default for Fuses {
fn default() -> Self {
Expand All @@ -198,6 +199,7 @@ impl Default for Fuses {
life_cycle: Default::default(),
lms_verify: Default::default(),
fuse_lms_revocation: Default::default(),
soc_stepping_id: Default::default(),
}
}
}
Expand All @@ -220,6 +222,7 @@ impl std::fmt::Debug for Fuses {
.field("life_cycle", &self.life_cycle)
.field("lms_verify", &self.lms_verify)
.field("fuse_lms_revocation", &self.fuse_lms_revocation)
.field("soc_stepping_id", &self.soc_stepping_id)
.finish()
}
}
Expand Down
3 changes: 3 additions & 0 deletions libcaliptra/inc/caliptra_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ struct caliptra_fuses {
uint32_t idevid_cert_attr[24];
uint32_t idevid_manuf_hsm_id[4];
enum device_lifecycle life_cycle;
bool lms_verify;
uint32_t lms_revocation;
uint16_t soc_stepping_id;
};

// Request/Response fields
Expand Down
3 changes: 3 additions & 0 deletions libcaliptra/src/caliptra_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,9 @@ int caliptra_init_fuses(struct caliptra_fuses *fuses)
caliptra_fuse_array_write(GENERIC_AND_FUSE_REG_FUSE_IDEVID_CERT_ATTR_0, fuses->idevid_cert_attr, ARRAY_SIZE(fuses->idevid_cert_attr));
caliptra_fuse_array_write(GENERIC_AND_FUSE_REG_FUSE_IDEVID_MANUF_HSM_ID_0, fuses->idevid_manuf_hsm_id, ARRAY_SIZE(fuses->idevid_manuf_hsm_id));
caliptra_generic_and_fuse_write(GENERIC_AND_FUSE_REG_FUSE_LIFE_CYCLE, (uint32_t)fuses->life_cycle);
caliptra_generic_and_fuse_write(GENERIC_AND_FUSE_REG_FUSE_LMS_VERIFY, (uint32_t)fuses->lms_verify);
caliptra_generic_and_fuse_write(GENERIC_AND_FUSE_REG_FUSE_LMS_REVOCATION, fuses->lms_revocation);
caliptra_generic_and_fuse_write(GENERIC_AND_FUSE_REG_FUSE_SOC_STEPPING_ID, fuses->soc_stepping_id);

// Write to Caliptra Fuse Done
caliptra_write_u32(CALIPTRA_TOP_REG_GENERIC_AND_FUSE_REG_CPTRA_FUSE_WR_DONE, 1);
Expand Down
10 changes: 10 additions & 0 deletions sw-emulator/lib/periph/src/soc_reg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,12 @@ register_bitfields! [
RSVD OFFSET(1) NUMBITS(31) [],
],

/// SoC Stepping ID
SocSteppingId [
SOC_STEPPING_ID OFFSET(0) NUMBITS(16) [],
RSVD OFFSET(16) NUMBITS(16) [],
],

/// ErrorIntrT
ErrorIntrT [
ERROR_INTERNAL_STS OFFSET(0) NUMBITS(1) [],
Expand Down Expand Up @@ -546,6 +552,9 @@ struct SocRegistersImpl {
#[register(offset = 0x344)]
fuse_lms_revocation: u32,

#[register(offset = 0x348)]
fuse_soc_stepping_id: ReadWriteRegister<u32, SocSteppingId::Register>,

/// INTERNAL_OBF_KEY Register
internal_obf_key: [u32; 8],

Expand Down Expand Up @@ -706,6 +715,7 @@ impl SocRegistersImpl {
fuse_life_cycle: Default::default(),
fuse_lms_verify: ReadWriteRegister::new(0),
fuse_lms_revocation: Default::default(),
fuse_soc_stepping_id: ReadWriteRegister::new(0),
internal_obf_key: args.cptra_obf_key,
internal_iccm_lock: ReadWriteRegister::new(0),
internal_fw_update_reset: ReadWriteRegister::new(0),
Expand Down

0 comments on commit d6182be

Please sign in to comment.