opentitan icon indicating copy to clipboard operation
opentitan copied to clipboard

[keymgr] last strb is 0 when LC turns off keymgr

Open weicaiyang opened this issue 5 years ago • 12 comments

@tjaychen usually strb is never 0 when the valid is high. We also have assertion to check that and I think KMAC TB probably never test the case that strb is valid with value 0.

When LC turns off keymgr in the middle of an operation, we will see the last strb is set to 0. Screen Shot 2021-08-24 at 10 54 44 AM

Since this interacts with KMAC, we probably can't test this corner scenario in chip-level. If we do want to have this case in the keymgr side, we may need to test it at KMAC block-level TB as well.

cc @eunchan @udinator

weicaiyang avatar Aug 24 '21 18:08 weicaiyang

hmm interesting, so this is happening because LC disables the transaction. i think the right behavior from keymgr side is to set the mask to all 1's, since during this condition, we should be sending decoy_data anyways.

@weicaiyang , can you confirm that is the case?

tjaychen avatar Aug 25 '21 20:08 tjaychen

hmm interesting, so this is happening because LC disables the transaction. i think the right behavior from keymgr side is to set the mask to all 1's, since during this condition, we should be sending decoy_data anyways.

@weicaiyang , can you confirm that is the case?

we did send decoy_data after LC disable the transaction, but strb is 0 as adv_en_i, id_en_i and gen_en_i are all 0.

      StTxLast: begin
        valid = 1'b1;
        last = 1'b1;

        if (adv_en_i) begin
          strb = AdvByteMask;
        end else if (id_en_i) begin
          strb = IdByteMask;
        end else if (gen_en_i) begin
          strb = GenByteMask;
        end

Screen Shot 2021-08-25 at 1 34 19 PM

weicaiyang avatar Aug 25 '21 20:08 weicaiyang

yeah sounds good. I think in that case i can default to all 1's. Let me just make sure the condition to send decoy data is the same as the one that sends all 1's.

On Wed, Aug 25, 2021 at 1:35 PM weicaiyang @.***> wrote:

hmm interesting, so this is happening because LC disables the transaction. i think the right behavior from keymgr side is to set the mask to all 1's, since during this condition, we should be sending decoy_data anyways.

@weicaiyang https://github.com/weicaiyang , can you confirm that is the case?

we did send decoy_data after LC disable the transaction, but strb is 0 as adv_en_i, id_en_i and gen_en_i are all 0.

  StTxLast: begin
    valid = 1'b1;
    last = 1'b1;

    if (adv_en_i) begin
      strb = AdvByteMask;
    end else if (id_en_i) begin
      strb = IdByteMask;
    end else if (gen_en_i) begin
      strb = GenByteMask;
    end

[image: Screen Shot 2021-08-25 at 1 34 19 PM] https://user-images.githubusercontent.com/49293026/130860730-abb6e504-7b39-4d31-a104-50557dfaaefb.png

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/lowRISC/opentitan/issues/7902#issuecomment-905855210, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAH2RSUON77XMJ7ETITDDITT6VH2JANCNFSM5CXLS5EA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email .

tjaychen avatar Aug 25 '21 20:08 tjaychen

yeah sounds good. I think in that case i can default to all 1's. Let me just make sure the condition to send decoy data is the same as the one that sends all 1's.

that sounds great.

weicaiyang avatar Aug 25 '21 20:08 weicaiyang

Thanks for bringing this up @weicaiyang.

My understanding of the KMAC App interface protocol is that the strb is never allowed to be zero when valid is high.

If @tjaychen's update to default to all 1's for the mask in this scenario somehow doesn't work out, should we update the protocol to support this? I believe it will require a few updates to the kmac_app_agent as well.

udinator avatar Aug 25 '21 23:08 udinator

naw don't change on kmac side. I think it's fine for keymgr to change (easier too).

On Wed, Aug 25, 2021 at 4:27 PM udinator @.***> wrote:

Thanks for bringing this up @weicaiyang https://github.com/weicaiyang.

My understanding of the KMAC App interface protocol is that the strb is never allowed to be zero when valid is high.

If @tjaychen https://github.com/tjaychen's update to default to all 1's for the mask in this scenario somehow doesn't work out, should we update the protocol to support this? I believe it will require a few updates to the kmac_app_agent as well.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/lowRISC/opentitan/issues/7902#issuecomment-905942260, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAH2RSSQ5MNHJNYJQVKMEETT6V37VANCNFSM5CXLS5EA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email .

tjaychen avatar Aug 25 '21 23:08 tjaychen

Thanks for bringing this up @weicaiyang.

My understanding of the KMAC App interface protocol is that the strb is never allowed to be zero when valid is high.

If @tjaychen's update to default to all 1's for the mask in this scenario somehow doesn't work out, should we update the protocol to support this? I believe it will require a few updates to the kmac_app_agent as well.

using default all 1s can probably solve the problem as it will change the last strb from 0 to '1 for this corner case. To kmac, it's just same as a normal case with last strb='1. And zero strb never happens.

weicaiyang avatar Aug 26 '21 00:08 weicaiyang

hey weicai i noticed a bigger issue with this. Because i disable adv_en / gen_en etc, if we get to DISABLED state via life cycle disable, the behavior actually changes since you no longer trigger "dummy activity" with kmac. Is this what you see in sims also?

On Wed, Aug 25, 2021 at 5:07 PM weicaiyang @.***> wrote:

Thanks for bringing this up @weicaiyang https://github.com/weicaiyang.

My understanding of the KMAC App interface protocol is that the strb is never allowed to be zero when valid is high.

If @tjaychen https://github.com/tjaychen's update to default to all 1's for the mask in this scenario somehow doesn't work out, should we update the protocol to support this? I believe it will require a few updates to the kmac_app_agent as well.

using default all 1s can probably solve the problem as it will change the last strb from 0 to '1 for this corner case. To kmac, it's just same as a normal case with last strb='1. And zero strb never happens.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/lowRISC/opentitan/issues/7902#issuecomment-905956748, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAH2RSWGEA5E4HLQILWDRPTT6WATZANCNFSM5CXLS5EA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email .

tjaychen avatar Aug 26 '21 00:08 tjaychen

i noticed a bigger issue with this. Because i disable adv_en / gen_en etc, if we get to DISABLED state via life cycle disable, the behavior actually changes since you no longer trigger "dummy activity" with kmac. Is this what you see in sims also?

The behavior is indeed changed. It enters Invalid state and update status without waiting for the digest data. For interacting with KMAC side, keymgr still drives the last to indicate data are completed. I'm not quite sure what do you mean "no longer trigger "dummy activity" with kmac" Screen Shot 2021-08-25 at 5 59 33 PM

weicaiyang avatar Aug 26 '21 01:08 weicaiyang

i think what's happening now is that when life cycle disables keymgr, keymgr_ctrl won't send out "generate" operations anymore. I think there are a few issues here.

do you have a life cycle disable test case i can run?

On Wed, Aug 25, 2021 at 6:02 PM weicaiyang @.***> wrote:

i noticed a bigger issue with this. Because i disable adv_en / gen_en etc, if we get to DISABLED state via life cycle disable, the behavior actually changes since you no longer trigger "dummy activity" with kmac. Is this what you see in sims also?

The behavior is indeed changed. It enters Invalid state and update status without waiting for the digest data. For interacting with KMAC side, keymgr still drives the last to indicate data are completed. I'm not quite sure what do you mean "no longer trigger "dummy activity" with kmac" [image: Screen Shot 2021-08-25 at 5 59 33 PM] https://user-images.githubusercontent.com/49293026/130883278-6eada160-7f21-411e-ade9-63d62be70d87.png

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/lowRISC/opentitan/issues/7902#issuecomment-905978625, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAH2RSTC2LSCXOGE3A4PWE3T6WHDLANCNFSM5CXLS5EA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email .

tjaychen avatar Aug 26 '21 01:08 tjaychen

@weicaiyang can you remind me if there's anything wrong with this issue? since we closed it some time ago. was it mainly to ensure there was an assignee?

tjaychen avatar Feb 23 '22 18:02 tjaychen

@weicaiyang can you remind me if there's anything wrong with this issue? since we closed it some time ago. was it mainly to ensure there was an assignee?

yeah, nothing wrong here, just to add an assignee.

weicaiyang avatar Feb 23 '22 18:02 weicaiyang