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

arch: _callee_saved_tstruct arch_csf & pass csf to fatal handling APIs #78029

Closed
wants to merge 5 commits into from

Conversation

ycsin
Copy link
Member

@ycsin ycsin commented Sep 5, 2024

  • Deprecate _callee_saved_t
  • Rename struct _callee_saved to struct arch_csf, and add it to the arch_interface.h

The goal is to pass arch-agnostic callee-saved-registers to k_sys_fatal_error_handler & z_fatal_error, so that the error handlers can do more.

This is somewhat similar to #73593

Rename every architecture's `struct _callee_saved` to
`struct arch_csf`.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
@ycsin ycsin changed the title arch: _callee_savedt -> struct arch_csf & pass csf to fatal handling APIs arch: _callee_savedtstruct arch_csf & pass csf to fatal handling APIs Sep 5, 2024
@ycsin ycsin changed the title arch: _callee_savedtstruct arch_csf & pass csf to fatal handling APIs arch: _callee_saved_tstruct arch_csf & pass csf to fatal handling APIs Sep 5, 2024
@ycsin ycsin requested a review from npitre September 5, 2024 04:38
Make `struct arch_csf` compulsory for all architectures by
declaring it in the `arch_interface.h` header.

Update all references of `_callee_saved_t` internally to
`struct arch_csf`.

Update offsets generation with `struct arch_csf`.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
Add a note about the introduction of `struct arch_csf` and the
deprecation of `_callee_saved_t`.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
Copy link
Contributor

@andyross andyross left a comment

Choose a reason for hiding this comment

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

Would maybe a cleaner way to do this be to move all the register block info out of the core kernel interface entirely? Then each arch can define its own arch-specific region of the stack frame struct (potentially even as a pointer to the context save data in the thread struct, avoiding some copies we currently have to do), and get the core kernel out of the business of trying to define what lives there?

Basically not loving the extra argument to z_fatal_error() -- that API should be getting less complicated, not more, IMHO.

@npitre
Copy link
Collaborator

npitre commented Sep 5, 2024

I have a nagging impression that this is just too much churn.

Why not simply adding a field in the esf structure for a csf pointer instead?

Those architectures who care can do it, those who don't may ignore it, and
the core code remains oblivious to such particularities. Otherwise, an extra
argument does add some small overhead to everyone even when unused.

Change `k_sys_fatal_error_handler()` & `z_fatal_error()` API to
accept an additional `struct arch_csf` argument, which can be helpful
to debug an error.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
`ztest_post_fatal_error_hook()` now accepts an additional
`struct arch_csf *pCsf` argument.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
@zephyrbot
Copy link
Collaborator

The following west manifest projects have been modified in this Pull Request:

Name Old Revision New Revision Diff
sof zephyrproject-rtos/sof@0e4c4ef (zephyr) zephyrproject-rtos/sof#49 zephyrproject-rtos/sof#49/files

Note: This message is automatically posted and updated by the Manifest GitHub Action.

@zephyrbot zephyrbot added manifest manifest-sof DNM This PR should not be merged (Do Not Merge) labels Sep 5, 2024
@ycsin
Copy link
Member Author

ycsin commented Sep 5, 2024

Why not simply adding a field in the esf structure for a csf pointer instead?

I did something similar internally by (ab)using the CONFIG_RISCV_SOC_CONTEXT_SAVE, could you take a look at #78065?

@ycsin
Copy link
Member Author

ycsin commented Sep 5, 2024

Then each arch can define its own arch-specific region of the stack frame struct (potentially even as a pointer to the context save data in the thread struct, avoiding some copies we currently have to do), and get the core kernel out of the business of trying to define what lives there?

Sorry, I don't quite get this, could you elaborate this a little more, maybe with an arch as an example?

@andyross
Copy link
Contributor

andyross commented Sep 5, 2024

I have a nagging impression that this is just too much churn.

True enough, though to be honest some churn here wouldn't be a bad thing. The "callee_saved" region is a weird mess, and very old. A clean abstraction for "how to pass arch-dependent exception data to the app fatal error handler" would definitely be a good thing.

@ycsin
Copy link
Member Author

ycsin commented Sep 6, 2024

Is the rename of _callee_saved_tstruct arch_csf in this PR something that we would want?

@ycsin ycsin closed this Sep 12, 2024
@ycsin ycsin deleted the pr/fatal-csf branch September 12, 2024 07:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DNM This PR should not be merged (Do Not Merge) manifest manifest-sof
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants