Skip to content

Conversation

@AlexJones0
Copy link
Contributor

@AlexJones0 AlexJones0 commented May 22, 2025

Note: Ideally merge after #74 to pull in the fixes necessary to get the Heartbleed demo to compile first.

The legacy demo unintentionally aliased a 32-bit rdcycle function to rdcycle64, and used its 32-bit output as a 64-bit value. This caused an overflow in the value of mcycle that was read after a short while of running, which left the demo stuck and unable to progress in its legacy component. Specifically,
$$\frac{2^{32} - 1}{40 * 1000 * 1000} \approx 1$$ min 47 s.
So after around 2 minutes the legacy component of the demo will stop working.

This PR replaces this function with an actual 64-bit mcycle read using the low/high registers appropriately. It will now take >10000 years to overflow, so I've opted not to add additional logic to catch overflows here.

The legacy demo unintentionally aliased a 32-bit `rdcycle` function to
`rdcycle64`, and used its 32-bit output as a 64-bit value. This caused
an overflow in `mcycle` after a few minutes of running, which sometimes
left the demo stuck and unable to progress in its legacy component.

Replace this function with an actual 64-bit mcycle read using the
low/high registers appropriately.

Signed-off-by: Alex Jones <alex.jones@lowrisc.org>
@AlexJones0 AlexJones0 merged commit 1a2b6f2 into lowRISC:main May 22, 2025
1 check passed
Copy link
Contributor

@marnovandermaas marnovandermaas left a comment

Choose a reason for hiding this comment

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

Nice fix Alex!

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.

3 participants