-
Notifications
You must be signed in to change notification settings - Fork 804
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[hmac, rtl] Increase coverage through minor RTL restructure #25766
[hmac, rtl] Increase coverage through minor RTL restructure #25766
Conversation
hw/ip/hmac/rtl/hmac_core.sv
Outdated
end else begin // SHA384 || SHA512 | ||
sha_msg_len = message_length_i + BlockSizeSHA512in64; | ||
end | ||
end else begin // `SelOPadMsg` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with this, but (again) it's probably worth sticking an assertion at the bottom that says the comment is always true :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having added the assertion (looking at the new failing tests), I see now that the value of digest_size_i
may not be SHA2_256
, SHA2_384
, or SHA2_512
when hmac_en_i
is 1. It can also take the value SHA2_NONE
. Checking with @martin-velay.
To breathe some life into this, how about this strategy: We only change one of the conditional always_comb begin: assign_sha_message_length
sha_msg_len = '0;
if (!hmac_en_i) begin
sha_msg_len = message_length_i;
// HASH = (o_pad || HASH_INTERMEDIATE (i_pad || msg))
// message length for HASH_INTERMEDIATE = block size (i_pad) + message length
end else if (sel_msglen == SelIPadMsg) begin
if (digest_size_i == SHA2_256) begin
sha_msg_len = message_length_i + BlockSizeSHA256in64;
end else if ((digest_size_i == SHA2_384) || (digest_size_i == SHA2_512)) begin
sha_msg_len = message_length_i + BlockSizeSHA512in64;
end else begin
sha_msg_len = '0; // <== THIS LINE/BRANCH IS COVERED
end
end else begin // `SelOPadMsg`
// message length for HASH = block size (o_pad) + HASH_INTERMEDIATE digest length
if (digest_size_i == SHA2_256) begin
sha_msg_len = BlockSizeSHA256in64 + 64'd256;
end else if (digest_size_i == SHA2_384) begin
sha_msg_len = BlockSizeSHA512in64 + 64'd384;
end else begin // SHA512
sha_msg_len = BlockSizeSHA512in64 + 64'd512;
end
end
end Keep the changes alongside assertions in With this we have 100% line coverage. What's left are two exclusion agreed upon in #24692 for missing else branches in |
83e03aa
to
8ebbf11
Compare
8ebbf11
to
b9211c0
Compare
Can someone take a look at this? There is one unrelated test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the update @andrea-caforio. This looks mostly good but I have some comments regarding indentation and some of the assertions.
Also, what do you mean by:
the unreachability exclusions for the default FSM states
when talking about what's left? Can you elaborate on this please?
hw/ip/hmac/rtl/hmac_core.sv
Outdated
end else begin | ||
sha_msg_len = '0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is really necessary as this is the default assignment (See line 208). Can you please confirm?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tricky thing here is the fact that it is possible that digest_size_i == SHA2_NONE
when hmac_en_i && sel_msglen == SelIPadMsg
, which is incompatible with the assertion for the other branch sel_msglen == SelOPadMsg
where digest_size_i == SHA2_NONE
is an impossible value.
It's a rare occurrence but I've encountered it in some of the tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah now I understand. Thanks for explaining.
Can you please add a comment for that and correct the indentation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Thank you for the review @vogelpi. What I'm referring to here are uncovered branches with respect to the default FSM states. There are three of them:
All other FSM default states branches have been excluded in the |
Thanks this is now clear. For other and hardened modules/FSMs we trigger those default statements by injecting errors into the sparsely encoded FSM states. We don't do this here because the HMAC FSMs are not hardened. All clear now. |
In light of the V3 signoff, this commits adapts certain RTL parts that induced uncoverable coverage holes. There are two types of changes: 1. Removal of dangling else branches that are impossible to cover. 2. Removal of uncoverable FSM default state assignments. Both changes have no functional impact and are only cosmetic in nature in order to attain the demanded coverage thresholds. See lowRISC#24692, for a detailed discussion of these changes. Signed-off-by: Andrea Caforio <andrea.caforio@lowrisc.org>
b9211c0
to
785e853
Compare
CHANGE AUTHORIZED: hw/ip/hmac/rtl/hmac_core.sv This PR doesn't contain functional changes but modifies the RTL to close unreachable coverage holes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks @andrea-caforio for implementing the additional changes.
CHANGE AUTHORIZED: hw/ip/hmac/rtl/hmac_core.sv This PR doesn't change functional behaviour, but rephrases some if/else blocks and default values to avoid functional coverage holes. This seems safe. |
I am merging this, the failing CW310 ROM Test e2e_bootstrap_rma_fpga_cw310_rom_with_fake_keys is known to be flaky. |
In light of the V3 signoff, this commits adapts certain RTL parts that induced uncoverable coverage holes. There are two types of changes:
Both changes have no functional impact and are only cosmetic in nature in order to attain the demanded coverage thresholds. See #24692, for a detailed discussion of these changes.