mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-08 04:42:04 -04:00
ANDROID: Setting up GS before calling __restore_processor_state.
Android Common Kernel compiled by clang with Shadow Call Stack will use GS segment. However, __restore_processor_state is called when system wakes up from S3 and at the moment GS is not restored yet. This is a hack by copying a small code snippet(setting gs base) from __restore_processor_state to restore_processor_state. It prepares GS before __restore_processor_state is called. At the same time, restore_processor_state is still small enough so that SCS is not on, as SCS seems to be on only for large functions. Bug: 166163480 Change-Id: I3bfe4ac61dee876da57de6578c9a7f01431a1743 Signed-off-by: Haitao Shan <hshan@google.com>
This commit is contained in:
parent
dea54268fb
commit
a52bcdb85f
1 changed files with 13 additions and 0 deletions
|
|
@ -268,6 +268,19 @@ static void notrace __restore_processor_state(struct saved_context *ctxt)
|
|||
/* Needed by apm.c */
|
||||
void notrace restore_processor_state(void)
|
||||
{
|
||||
#ifdef __clang__
|
||||
// The following code snippet is copied from __restore_processor_state.
|
||||
// Its purpose is to prepare GS segment before the function is called.
|
||||
// Since the function is compiled with SCS on, it will use GS at its
|
||||
// entry.
|
||||
// TODO: Hack to be removed later when compiler bug is fixed.
|
||||
#ifdef CONFIG_X86_64
|
||||
wrmsrl(MSR_GS_BASE, saved_context.kernelmode_gs_base);
|
||||
#else
|
||||
loadsegment(fs, __KERNEL_PERCPU);
|
||||
loadsegment(gs, __KERNEL_STACK_CANARY);
|
||||
#endif
|
||||
#endif
|
||||
__restore_processor_state(&saved_context);
|
||||
}
|
||||
#ifdef CONFIG_X86_32
|
||||
|
|
|
|||
Loading…
Reference in a new issue