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

[proposal] reduce stacking by storing PC to link register, instead of HANDLER_RETURN pattern #3

Open
jnk0le opened this issue Nov 11, 2018 · 3 comments

Comments

@jnk0le
Copy link

jnk0le commented Nov 11, 2018

This proposal aims to reduce number of stacked registers or have another caller saved register defined in EABI.

Instead of stacking PC and generating HANDLER_RETURN pattern which is inserted into the link register, we can just store PC into the link register with the lowest bit set to indicate an unstacking operation when returning from handler function.

The control bits defined in HANDLER_RETURN pattern will have to be moved into status csr.

The JALR to address with lsb set, will now cause:

  • handler return procedure if hart is currently running in handler mode.
  • Instruction address misaligned exception otherwise. Or at least forbid any use of function pointers with "auxiliary information" bit set in EABI compliant software, except the handler return case.
    (lsb in immediate field can be ignored since we care only about pointers).

Of course this proposal requires a slight redefinition of JALR instruction which is currently defined to ignore the lowest bit of calculated address. I'm not certainly sure if such kind of ISA changes in embedded profile are even possible, but jumps to unaligned addresses are sign that something went wrong with pointer arithmetic, it is rather instruction side-effect change and prior software anyway will not be compatible with EABI calling conventions, so I thought that it might be worth for further discussion.

@ilg-ul
Copy link
Contributor

ilg-ul commented Nov 11, 2018

Thank you, I added a note in the Exceptions and Interrupts page.

@ilg-ul ilg-ul closed this as completed Nov 11, 2018
@jnk0le
Copy link
Author

jnk0le commented Nov 14, 2018

As to reduce profanation of the base ISA, we can make JALR modifications exclusive to link register only. So the EABI will mandate that all function returns must be handled through link register.

And I would recommend to reserve 'closed' state of public issues to those that were accepter/rejected/fixed etc. So it is easier to find pending proposals and leave feedback on them.

@ilg-ul ilg-ul reopened this Nov 14, 2018
@ilg-ul
Copy link
Contributor

ilg-ul commented Nov 14, 2018

I reopened this issue if you think it is useful.

As for using the alignment reserved bits vs a separate HANDLER_RETURN pattern, I think that the latter is more versatile, since it allows more bits to be used for multiple modes (as in Cortex-M case).

Also I think that making modifications to the base ISA might be problematic with regards to passing compliance tests.

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

No branches or pull requests

2 participants