Skip to content
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

[aes/dv] Randomly drive invalid AES operation values #24623

Merged
merged 4 commits into from
Sep 25, 2024

Conversation

vogelpi
Copy link
Contributor

@vogelpi vogelpi commented Sep 23, 2024

This PR contains a couple of commits to enable closing a small coverage hole.

The main commit is the last one. It properly randomizes the operation values. Previously, the operation field of the main control register was only written with valid one-hot encoded values but not with invalid values leading to a small DV coverage hole.

This resolves #20941.

@vogelpi vogelpi requested a review from a team as a code owner September 23, 2024 10:32
@vogelpi vogelpi requested review from matutem, rswarbrick and martin-velay and removed request for a team and matutem September 23, 2024 10:32
@vogelpi
Copy link
Contributor Author

vogelpi commented Sep 23, 2024

Thanks @martin-velay for your help with debugging this :-)

Copy link
Contributor

@rswarbrick rswarbrick left a comment

Choose a reason for hiding this comment

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

Lots of nitty comments/questions but they needn't really gate this PR.

// [1]: reseed error
// [2]: mode error
// [3]: key_len
cfg_error_type_t config_error_type_en = 4'b1111;
Copy link
Contributor

Choose a reason for hiding this comment

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

This needn't gate the PR, but can't you do this with something like ... = '{op = 1'b1, rsd_rate = 1'b1, ...}; ? It might be a bit easier to read and wouldn't need the comment either.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea! I've implemented the change for lines / types touches in this PR.

solve has_config_error before cfg_error_type;
if (has_config_error) {
cfg_error_type inside {[1:15]};
config_error_type_en[0] == 0 -> cfg_error_type[0] == 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can't this be expressed with names? So something like config_error_type_en.op == 0 -> cfg_error_type.op == 0?

Even more tersely, I think you can do something like !(cfg_error_type & ~config_error_type_en), but that's probably getting ridiculously hard to understand...

FOLLOW-UP: Ah! I've just seen the lines this came from! I think I stand by my comments, but they needn't gate this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I went with the first proposal to be consistent and improve readability.

end else begin
this.aes_operation = 2'b01; // resovle to AES-ENC
`uvm_info(`gfn,
$sformatf("\n\t ---| Illegal operation value detected, resolving to default AES-ENC"),
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: I think you probably want "... detected. Resolving ..." to fix the grammar.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, thanks!

Copy link
Contributor

@martin-velay martin-velay left a comment

Choose a reason for hiding this comment

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

Your changes are looking good, this PR can be approved according to me.

Note: the DV seems to be complicated to debug because of some bad practices, particularly regarding the sequence items which are gathering more information than it should. These objects should be broken up into multiple sequence items in the future. And also using enumerated values for some variables might help.

$sformatf("\n\t ---| Illegal key length value detected, resolving to default AES-256"),
UVM_MEDIUM)
end
if (item.reseed_rate inside {3'b001, 3'b010, 3'b100}) begin
Copy link
Contributor

Choose a reason for hiding this comment

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

That's not really related to this PR, but in general I think it would be better to move to enumerated values. This would make reading easier. But it's not blocking for this PR of course.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I totally agree! I've changed this now for lines / member variables touches in this PR.

return str;
endfunction // conver2string

function string cfg_error_string();
Copy link
Contributor

Choose a reason for hiding this comment

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

As the sequence item is not properly split originally, I agree with your change. But FYI, this convert2string function is defined by the UVM. That's convenient when you want to debug a sequence from anybody, you know that you can call this and print all the relevant info in a relevant format. In the future, we should break down the sequence items into sub-items and eventually gathering them into another sequence item.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree with you. Thanks for providing some background on this Martin.

Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
Previously, the reseed rate wasn't correctly passed, resulting in
confusing debug statements during configuration error tests.

Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
This commit properly randomizes the operation values to fix a coverage
hole. Previously, the operation field of the main control register
was only written with valid one-hot encoded values but not with invalid
values leading to a small DV coverage hole.

This resolves lowRISC#20941.

Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
Previously, the basic convert2string() function called in different
contexts (scoreboard, base sequence, etc.) would print information that
is not available / meaningful in the scoreboard context such as the
configuration error data and distributions. This commits splits the
original function into multiple functions to enable controlling what to
print in which context.

Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
@vogelpi
Copy link
Contributor Author

vogelpi commented Sep 25, 2024

Thanks @martin-velay and @rswarbrick for your review and the suggestions! I've implemented most of your feedback (see discussions). If you're happy with the changes, please feel free to approve & merge this @rswarbrick .

Copy link
Contributor

@rswarbrick rswarbrick left a comment

Choose a reason for hiding this comment

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

This looks good to me. A couple of (rather nitty) tweaks that might be worth doing, but I'm happy either way.

Comment on lines +93 to +96
// [0]: op_error
// [1]: reseed error
// [2]: mode error
// [3]: key_len
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: I don't think you need the comment about the indices any more?

Similarly for cfg_error_type below.

@@ -7,7 +7,7 @@ class aes_seq_item extends uvm_sequence_item;
`uvm_object_utils(aes_seq_item)

aes_item_type_e item_type;
aes_op_e operation;
bit [1:0] operation;
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: I know that this is unchanged with this commit, but the indentation looks a bit weird with the previous line. Maybe we should either be dropping a space on line 9 or adding some more spaces before "operation"?

@vogelpi
Copy link
Contributor Author

vogelpi commented Sep 25, 2024

Thanks @rswarbrick for your approval. I am merging this now as I need to move on.

@vogelpi vogelpi merged commit 1cb1c3d into lowRISC:master Sep 25, 2024
38 checks passed
@vogelpi vogelpi added the ManuallyCherryPick:earlgrey_1.0.0 This PR should be cherry-picked to the earlgrey_1.0.0 branch (no automation, manual coordination). label Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ManuallyCherryPick:earlgrey_1.0.0 This PR should be cherry-picked to the earlgrey_1.0.0 branch (no automation, manual coordination).
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[aes,dv] Randomly drive invalid operation values to fix coverage hole
3 participants