Skip to content

AR: Clarify itrigger and trigger number translation#903

Merged
timsifive merged 1 commit into
masterfrom
itrigger_fire
Oct 12, 2023
Merged

AR: Clarify itrigger and trigger number translation#903
timsifive merged 1 commit into
masterfrom
itrigger_fire

Conversation

@timsifive
Copy link
Copy Markdown
Contributor

itrigger numbers relate to the value written to *cause when the trap is taken.

Addresses #889.

Comment thread xml/hwbp_registers.xml Outdated
Comment on lines +1139 to +1141
trap is taken. For interrupts whose numbers are translated, that means
the number checked is the one in the mode that the trap handler executes
in.
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 don't think that this sentence will make sense to people who aren't familiar with AIA. I would say something like:

Suggested change
trap is taken. For interrupts whose numbers are translated, that means
the number checked is the one in the mode that the trap handler executes
in.
trap is taken. For virtualized interrupts that have different interrupt numbers
when viewed from different modes, that means
the number checked is the one in the mode that the trap handler executes
in.

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.

Do we also need to say something about how we don't care why the interrupt is taken? It could be that the input wire asserted, it could be that M mode wrote mie.STIE=1 in the original priv arch, it could be that the hypervisor is playing with hvip, etc. This was one of John's concerns. We don't have to spell out the cases but we should say something about how the trigger is based on the interrupt trap regardless of the original cause of the interrupt.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I kind of agree with you, but I'm not sure how to say that. Aren't interrupt traps by definition taken in response to interrupts?

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 think that John's question was whether one category of reasons for taking an interrupt would be treated differently than another category of reasons for taking an interrupt.

Rereading what's currently there, it basically says that the trigger matches/fires only if we trap but it doesn't say that it fires every time that we trap. Maybe it's as simple as saying "The trigger fires if and only if the hart takes a trap because of the interrupt." That would presumably clarify that the reason for the trap doesn't matter.

Comment thread xml/hwbp_registers.xml Outdated
The trigger only fires if the hart takes a trap because of the
interrupt. (E.g.\ it does not fire when a timer interrupt occurs but that
interrupt is not enabled in \Rmie.)
interrupt. (E.g.\ it does not fire for an interrupt that is masked.)
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.

If possible, I like to avoid "masked" because sometimes you have positive masks (A & mask) and sometimes you have negative masks (A & ~mask) so it can be ambiguous. What you have is probably not that ambiguous but how about using something closer to the original language? That also applies to global enable (mstatus.MIE) rather than just local enables (mie).

Suggested change
interrupt. (E.g.\ it does not fire for an interrupt that is masked.)
interrupt. (E.g.\ it does not fire for an interrupt that is not enabled.)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

disabled? Done.

@timsifive
Copy link
Copy Markdown
Contributor Author

I've rewritten this, hopefully to be more clear.

Comment thread xml/hwbp_registers.xml Outdated
Comment on lines +1135 to +1136
For interrupts where it is enabled, this trigger fires when an interrupt
trap is taken from a privilege mode where the trigger is enabled.
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 wasn't sure what the first "it" is. It seems like it refers to an interrupt but singular "it" doesn't match "interrupts" plural. Then I wondered if it would be clearer to just remove everything before the comma.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

How about:
This trigger fires when an interrupt trap is taken from a privilege mode
where the trigger is enabled and that interrupt is also enabled in the
trigger.

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.

Now I understand. There are a lot of enables here: the mode bits in tdata1, the interrupt number in tdata2, and the interrupt enables (both mie and mstatus.MIE). I like something more like this tweak to the earlier language:

    For an interrupt where that interrupt number is enabled in tdata2, this trigger fires when an interrupt
    trap is taken from a privilege mode where the trigger is enabled.

That doesn't actually talk about the interrupt enables but that's implicit when you talk about taking a trap.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don't want to explicitly call out tdata2 here, because nmi is also an option. I agree there are a lot of enables. Maybe I just need to capitulate and make a numbered list.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I made it even simpler. We don't need to talk about the mode at all in this sentence. It's already in the bits. The only real need is to indicate what the trigger is useful for. 2 paragraphs down (When the trigger matches...) already makes it clear that it only happens when a trap is actually taken. We don't need the parenthetical about interrupts being masked or whatever. The trigger fires when the trap is taken. Done.

itrigger numbers relate to the value written to *cause when the trap is
taken.

Addresses #889.
Copy link
Copy Markdown
Collaborator

@pdonahue-ventana pdonahue-ventana left a comment

Choose a reason for hiding this comment

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

That's simpler but still conveys all the necessary information. Looks good.

@timsifive timsifive merged commit f5b2ed3 into master Oct 12, 2023
@timsifive timsifive deleted the itrigger_fire branch October 12, 2023 19:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants