mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-07 03:15:31 +09: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:
@@ -274,6 +274,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
|
||||
|
||||
Reference in New Issue
Block a user