-
Notifications
You must be signed in to change notification settings - Fork 61
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
arm64: Avoid clobbering the stack pointer when returning to EL1 #2270
Conversation
How has this not broken before? This would seem to indicate that in hybrid kernels, every nested exception return sets the stack pointer to the per-CPU pointer? |
Indeed, I don't quite understand how this worked. Is there some other magic which restores the stack pointer? I only noticed this problem when handling breakpoints exceptions where dtrace has to manually adjust |
Oh, so in the save_registers_head, we actually save
So in actual fact, the load here is re-loading the saved |
This is also broken in upstream FWIW. If we really cared we would just do another store of x18 in the trapframe in the el ==1 case after restoring its value from |
Are you sure? In upstream kernels we don't bother restoring x18 when returning to EL1, see the comment, "We only restore called-saved registers...".
|
In fact, I'd be tempted to refine this a bit further even upstream to avoid stomping on x18 in the el == 1 case. That is, I would only load the pair of registers in the el == 0 case and just load LR:
then at the end, you have:
|
By broken I mean that the values in struct trapframe are broken, so if you are doing a stack trace in kgdb and walk up the stack of a nested exception and |
We use x18 as a temp register but in hybrid kernels this is clobbered when restoring callee-saved registers.
37f8bf1
to
1dad3bb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll work on adjusting x18 upstream, but this should be fine for now.
No description provided.