Skip to content

Commit 4a10297

Browse files
authored
Merge branch 'main-2.x' into vmhatre/default-mldsa
2 parents 6dfb7fb + 4391ce1 commit 4a10297

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+3209
-451
lines changed

common/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pub use pcr::{PcrLogEntry, PcrLogEntryId, RT_FW_CURRENT_PCR, RT_FW_JOURNEY_PCR};
4141
pub const FMC_ORG: u32 = 0x40000000;
4242
pub const FMC_SIZE: u32 = 21 * 1024;
4343
pub const RUNTIME_ORG: u32 = FMC_ORG + FMC_SIZE;
44-
pub const RUNTIME_SIZE: u32 = 99 * 1024;
44+
pub const RUNTIME_SIZE: u32 = 100 * 1024;
4545

4646
pub use memory_layout::{DATA_ORG, FHT_ORG, FHT_SIZE, MAN1_ORG};
4747
pub use wdt::{restart_wdt, start_wdt, stop_wdt, WdtTimeout};

drivers/src/csrng.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,13 +341,13 @@ fn send_command(csrng: &mut CsrngReg, command: Command) -> CaliptraResult<()> {
341341
let reg = csrng.regs().sw_cmd_sts().read();
342342

343343
// Order matters. Check for errors first.
344-
if reg.cmd_sts() || u32::from(csrng.regs().err_code().read()) != 0 {
344+
if reg.cmd_sts() != 0 || u32::from(csrng.regs().err_code().read()) != 0 {
345345
// TODO: Somehow convey additional error information found in
346346
// the ERR_CODE register.
347347
return Err(err);
348348
}
349349

350-
if reg.cmd_rdy() {
350+
if reg.cmd_rdy() && reg.cmd_ack() {
351351
return Ok(());
352352
}
353353
}

drivers/src/mailbox.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub struct Mailbox {
3939
mbox: MboxCsr,
4040
}
4141

42-
const MAX_MAILBOX_LEN: u32 = 128 * 1024;
42+
const MAX_MAILBOX_LEN: u32 = 256 * 1024;
4343

4444
impl Mailbox {
4545
pub fn new(mbox: MboxCsr) -> Self {

drivers/src/memory_layout.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use crate::Mldsa87PubKey;
2525
// Memory Addresses
2626
//
2727
pub const ROM_ORG: u32 = 0x00000000;
28-
pub const MBOX_ORG: u32 = 0x30000000;
28+
pub const MBOX_ORG: u32 = 0x30040000;
2929
pub const ICCM_ORG: u32 = 0x40000000;
3030
pub const DCCM_ORG: u32 = 0x50000000;
3131
pub const ROM_DATA_ORG: u32 = 0x50000000;
@@ -68,8 +68,8 @@ pub const LAST_REGION_END: u32 = NSTACK_ORG + NSTACK_SIZE;
6868
//
6969
pub const ROM_RELAXATION_PADDING: u32 = 4 * 1024;
7070
pub const ROM_SIZE: u32 = 96 * 1024;
71-
pub const MBOX_SIZE: u32 = 128 * 1024;
72-
pub const ICCM_SIZE: u32 = 128 * 1024;
71+
pub const MBOX_SIZE: u32 = 256 * 1024;
72+
pub const ICCM_SIZE: u32 = 256 * 1024;
7373
pub const DCCM_SIZE: u32 = 256 * 1024;
7474
pub const ROM_DATA_SIZE: u32 = 996;
7575
pub const MAN1_SIZE: u32 = 17 * 1024;

drivers/src/sha2_512_384.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ impl Sha2_512_384 {
231231
wait::until(|| status_reg.read().ready());
232232

233233
if status_reg.read().valid() {
234-
Ok(reg.gen_pcr_hash_digest().read().into())
234+
Ok(reg.gen_pcr_hash_digest().truncate::<12>().read().into())
235235
} else {
236236
Err(CaliptraError::DRIVER_SHA384_INVALID_STATE_ERR)
237237
}

drivers/src/sha2_512_384acc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use caliptra_registers::sha512_acc::regs::ExecuteWriteVal;
2121
use caliptra_registers::sha512_acc::Sha512AccCsr;
2222

2323
/// Maximum mailbox capacity in Bytes.
24-
const MAX_MAILBOX_CAPACITY_BYTES: u32 = 128 << 10;
24+
const MAX_MAILBOX_CAPACITY_BYTES: u32 = 256 << 10;
2525

2626
pub type Sha384Digest<'a> = &'a mut Array4x12;
2727
pub type Sha512Digest<'a> = &'a mut Array4x16;

drivers/test-fw/src/bin/sha2_512_384acc_tests.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use caliptra_registers::sha512_acc::Sha512AccCsr;
2424
use caliptra_test_harness::test_suite;
2525
use core::slice;
2626

27-
const MAX_MAILBOX_CAPACITY_BYTES: usize = 128 << 10;
27+
const MAX_MAILBOX_CAPACITY_BYTES: usize = 256 << 10;
2828
const SHA384_HASH_SIZE: usize = 48;
2929
const SHA512_HASH_SIZE: usize = 64;
3030

@@ -303,17 +303,17 @@ fn test_digest_max_mailbox_size() {
303303
let mut sha_acc = unsafe { Sha2_512_384Acc::new(Sha512AccCsr::new()) };
304304

305305
let expected: [u8; SHA384_HASH_SIZE] = [
306-
0xca, 0xd1, 0x95, 0xe7, 0xc3, 0xf2, 0xb2, 0x50, 0xb3, 0x5a, 0xc7, 0x8b, 0x17, 0xb7, 0xc2,
307-
0xf2, 0x29, 0xe1, 0x34, 0xb8, 0x61, 0xf2, 0xd0, 0xbe, 0x15, 0xb7, 0xd9, 0x54, 0x69, 0x71,
308-
0xf8, 0x5e, 0xc0, 0x40, 0x69, 0x3e, 0x5a, 0x22, 0x21, 0x88, 0x79, 0x77, 0xfd, 0xea, 0x6f,
309-
0x89, 0xef, 0xee,
306+
0x9B, 0xF0, 0x66, 0xF5, 0x2C, 0xD8, 0x58, 0x8B, 0x21, 0x31, 0xD1, 0xD2, 0xDA, 0x24, 0xB2,
307+
0xAD, 0xAC, 0xB8, 0xAD, 0x3E, 0xFC, 0x36, 0xF3, 0xCB, 0x77, 0x97, 0x72, 0xC1, 0x93, 0xA0,
308+
0xB1, 0x40, 0xB1, 0x20, 0xBD, 0x13, 0xDF, 0xCB, 0x3E, 0x5E, 0x8C, 0x66, 0xB6, 0x85, 0x26,
309+
0xD5, 0x31, 0x50,
310310
];
311311
let expected_512: [u8; SHA512_HASH_SIZE] = [
312-
0x4e, 0xd8, 0x3e, 0x40, 0xc9, 0xcf, 0x32, 0xac, 0x2c, 0x59, 0x12, 0x5a, 0x01, 0x17, 0x0b,
313-
0xc9, 0x7f, 0x20, 0x55, 0x09, 0x52, 0xc8, 0xca, 0x20, 0xff, 0xe1, 0xb2, 0xa5, 0x9d, 0x1b,
314-
0x1e, 0xd9, 0xc8, 0x42, 0x6c, 0x51, 0x5f, 0x76, 0x29, 0xd1, 0xbb, 0x5e, 0x4c, 0xdc, 0x53,
315-
0xdd, 0x70, 0xff, 0xcf, 0x67, 0x20, 0x3d, 0x59, 0xe7, 0x0a, 0x55, 0x94, 0x92, 0xe5, 0xff,
316-
0x0e, 0x71, 0x22, 0x78,
312+
0x9D, 0xD0, 0xC3, 0x01, 0x67, 0xFB, 0xEA, 0xF6, 0x8D, 0xFB, 0xBA, 0xD8, 0xE1, 0xAF, 0x55,
313+
0x2A, 0x7A, 0x1F, 0xCA, 0xE1, 0x20, 0xB6, 0xE0, 0x4F, 0x1B, 0x41, 0xFA, 0x76, 0xC7, 0x6D,
314+
0x5A, 0x78, 0x92, 0x2F, 0xF8, 0x28, 0xF5, 0xCF, 0xFD, 0x8C, 0x02, 0x96, 0x5C, 0xDE, 0x57,
315+
0xD6, 0x3D, 0xCB, 0xFB, 0x4C, 0x47, 0x9B, 0x3C, 0xB4, 0x9C, 0x9D, 0x81, 0x07, 0xA7, 0xD5,
316+
0x24, 0x4E, 0x9D, 0x03,
317317
];
318318

319319
{

error/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,10 @@ impl CaliptraError {
312312
CaliptraError::new_const(0x000b0057);
313313
pub const IMAGE_VERIFIER_ERR_MLDSA_TYPE_CONVERSION_FAILED: CaliptraError =
314314
CaliptraError::new_const(0x000b0058);
315+
pub const IMAGE_VERIFIER_ERR_VENDOR_ECC_PUB_KEY_DIGEST_MISMATCH: CaliptraError =
316+
CaliptraError::new_const(0x000b0059);
317+
pub const IMAGE_VERIFIER_ERR_VENDOR_PQC_PUB_KEY_DIGEST_MISMATCH: CaliptraError =
318+
CaliptraError::new_const(0x000b005a);
315319

316320
/// Driver Error: LMS
317321
pub const DRIVER_LMS_INVALID_LMS_ALGO_TYPE: CaliptraError =

hw-model/c-binding/examples/api/caliptra_api.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ int caliptra_init_fuses(struct caliptra_model *model, struct caliptra_fuses *fus
3131
caliptra_fuse_array_write(model, GENERIC_AND_FUSE_REG_FUSE_IDEVID_MANUF_HSM_ID_0, fuses->idevid_manuf_hsm_id, CALIPTRA_ARRAY_SIZE(fuses->idevid_manuf_hsm_id));
3232

3333
// Write to Caliptra Fuse Done
34-
caliptra_model_axi_write_u32(model, CALIPTRA_TOP_REG_GENERIC_AND_FUSE_REG_CPTRA_FUSE_WR_DONE, 1);
34+
caliptra_model_axi_write_u32(model, EXTERNAL_PERIPH_BASE + CALIPTRA_TOP_REG_GENERIC_AND_FUSE_REG_CPTRA_FUSE_WR_DONE, 1);
3535

3636
// It shouldn`t be longer ready for fuses
3737
if (caliptra_model_ready_for_fuses(model))
@@ -48,7 +48,7 @@ int caliptra_bootfsm_go(struct caliptra_model *model)
4848
}
4949

5050
// Write BOOTFSM_GO Register
51-
caliptra_model_axi_write_u32(model, CALIPTRA_TOP_REG_GENERIC_AND_FUSE_REG_CPTRA_BOOTFSM_GO, 1);
51+
caliptra_model_axi_write_u32(model, EXTERNAL_PERIPH_BASE + CALIPTRA_TOP_REG_GENERIC_AND_FUSE_REG_CPTRA_BOOTFSM_GO, 1);
5252

5353
return 0;
5454
}

hw-model/c-binding/examples/api/caliptra_fuses.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@
1515
extern "C" {
1616
#endif
1717

18+
#define EXTERNAL_PERIPH_BASE 0x30000000
19+
1820
static inline void caliptra_fuse_write(caliptra_model *model, uint32_t offset, uint32_t data)
1921
{
20-
caliptra_model_axi_write_u32(model, (offset + CALIPTRA_TOP_REG_GENERIC_AND_FUSE_REG_BASE_ADDR), data);
22+
caliptra_model_axi_write_u32(model, EXTERNAL_PERIPH_BASE + (offset + CALIPTRA_TOP_REG_GENERIC_AND_FUSE_REG_BASE_ADDR), data);
2123
}
2224

2325
static inline void caliptra_fuse_array_write(caliptra_model *model, uint32_t offset, uint32_t *data, size_t size)

hw-model/c-binding/examples/api/caliptra_mbox.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,17 @@
99
extern "C" {
1010
#endif
1111

12+
#define EXTERNAL_PERIPH_BASE 0x30000000
13+
1214
static inline void caliptra_mbox_write(caliptra_model *model, uint32_t offset, uint32_t data)
1315
{
14-
caliptra_model_axi_write_u32(model, (offset + CALIPTRA_TOP_REG_MBOX_CSR_BASE_ADDR), data);
16+
caliptra_model_axi_write_u32(model, EXTERNAL_PERIPH_BASE + (offset + CALIPTRA_TOP_REG_MBOX_CSR_BASE_ADDR), data);
1517
}
1618

1719
static inline uint32_t caliptra_mbox_read(caliptra_model *model, uint32_t offset)
1820
{
1921
uint32_t data;
20-
caliptra_model_axi_read_u32(model, (offset + CALIPTRA_TOP_REG_MBOX_CSR_BASE_ADDR), &data);
22+
caliptra_model_axi_read_u32(model, EXTERNAL_PERIPH_BASE + (offset + CALIPTRA_TOP_REG_MBOX_CSR_BASE_ADDR), &data);
2123
return data;
2224
}
2325

hw-model/tests/model_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ fn test_uninitialized_iccm_read() {
237237
);
238238

239239
const ICCM_ADDR: u32 = 0x4000_0000;
240-
const ICCM_SIZE: u32 = 128 * 1024;
240+
const ICCM_SIZE: u32 = 256 * 1024;
241241

242242
model.soc_ifc().cptra_rsvd_reg().at(0).write(|_| ICCM_ADDR);
243243
model.soc_ifc().cptra_rsvd_reg().at(1).write(|_| ICCM_SIZE);

0 commit comments

Comments
 (0)