Skip to content

[dpe] Make SVN in DeriveContext optional#3963

Open
zhalvorsen wants to merge 1 commit into
chipsalliance:caliptra-1.xfrom
zhalvorsen:push-lrnxnkxwqtks
Open

[dpe] Make SVN in DeriveContext optional#3963
zhalvorsen wants to merge 1 commit into
chipsalliance:caliptra-1.xfrom
zhalvorsen:push-lrnxnkxwqtks

Conversation

@zhalvorsen

Copy link
Copy Markdown
Collaborator

DPE added an SVN field to DeriveContext. To avoid making a breaking change to Caliptra integrators, this will append a default SVN value (0) to the command if it is not present.

This also adds a test to make sure it is handled correctly.

@zhalvorsen zhalvorsen linked an issue Jul 10, 2026 that may be closed by this pull request
DPE added an SVN field to `DeriveContext`. To avoid making a breaking
change to Caliptra integrators, this will append a default SVN value
(`0`) to the command if it is not present.

This also adds a test to make sure it is handled correctly.
Comment thread runtime/src/invoke_dpe.rs

if is_derive_context_cmd && is_missing_svn && has_space_for_svn {
cmd.data[cmd_size..cmd_size + size_of::<u32>()].fill(0);
cmd.data_size += size_of::<u32>() as u32;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about parsing what we know about the command and serializing a new one; I think it makes the code a bit easier to read / maintainable, but a much more verbose.

Comment on lines +558 to +561
// Strip the last 4 bytes (svn u32 field) to simulate caller without SVN
let dpe_cmd_buf_no_svn = &dpe_cmd_buf[..dpe_cmd_buf.len() - 4];
cmd_data[cmd_hdr_buf.len()..cmd_hdr_buf.len() + dpe_cmd_buf_no_svn.len()]
.copy_from_slice(dpe_cmd_buf_no_svn);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively could re-define the older version of the command struct, rather than manipulating the serialized form

Comment thread runtime/src/invoke_dpe.rs

let is_derive_context_cmd = hdr.cmd_id == Command::DERIVE_CONTEXT;
let is_missing_svn = cmd_size == expected_no_svn_len;
let has_space_for_svn = cmd_size + size_of::<u32>() <= cmd.data.len();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check here would mean the message still has to be provided with additional space, which would require a change from integrators right?

One thing we could do is detect if a DeriveContext command is being executed and allocate a full buffer then copy over the slice and parse from the new buffer. It would give us a default value of SVN, and not require an integrator change, though that seems a bit brittle to me.

Another option, would be to provide the ability for the DPE library to handle both provided and non-provided svns, likely by providing a way to deserialize either?

This does raise a good point of how we wish to handle DPE command versioning though.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suppose we add another set of invoke dpe commands? That helps make the breaking change explicit and gives us a way to translate the previous API in an obvious way.

There is some boiler plate for a new command like this but hopefully it doesn't result in too much code space, since we can just translate the command and call the updated API

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I decided to mock up handling it in the DPE library. I think I like it more, but it does break the mold a little bit. What do you guys think chipsalliance/caliptra-dpe#613?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer handling the translation in caliptra since it's strictly an issue with the caliptra API, and not necessarily the DPE API

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make SVN in DPE's DeriveContext optional.

3 participants