summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorHyungwoo Yang <hyungwoo.yang@intel.com>2019-01-29 18:17:01 -0800
committerchrome-bot <chrome-bot@chromium.org>2019-02-04 12:42:08 -0800
commit193a3c47ad8af6528ff1605a4595fc7367a09834 (patch)
tree02a590392ac069431d023cd0119c4ba2fa55591c /core
parent099edd8bd7710db630fe5333f8e5b50c7b8d0e84 (diff)
downloadchrome-ec-193a3c47ad8af6528ff1605a4595fc7367a09834.tar.gz
ish: use system stack for exceptions and irqs
currently exceptions are using current preempted task stack. It means the size of each task stack should be more than it needs while considering maximum stack usage of exceptions. It waste memory and engineering efforts. this patch uses system stack for handling exceptions. BRANCH=none BUG=none TEST=verified in Atlas platform Change-Id: I1c8fdc16e9f7a3834638b5ce0916f00b3d440798 Reviewed-on: https://chromium-review.googlesource.com/1440022 Commit-Ready: Hyungwoo Yang <hyungwoo.yang@intel.com> Tested-by: Hyungwoo Yang <hyungwoo.yang@intel.com> Reviewed-by: Jett Rink <jettrink@chromium.org>
Diffstat (limited to 'core')
-rw-r--r--core/minute-ia/irq_handler.h5
-rw-r--r--core/minute-ia/switch.S10
2 files changed, 15 insertions, 0 deletions
diff --git a/core/minute-ia/irq_handler.h b/core/minute-ia/irq_handler.h
index b121413d8d..c561ee472b 100644
--- a/core/minute-ia/irq_handler.h
+++ b/core/minute-ia/irq_handler.h
@@ -39,6 +39,7 @@ struct irq_data {
*
* Note: No 'naked' function support for x86, so function is implemented within
* __asm__
+ * Note: currently we don't allow nested irq handling
*/
#define DECLARE_IRQ(irq, routine) DECLARE_IRQ_(irq, routine, irq + 32 + 10)
/* Each irq has a irq_data structure placed in .rodata.irqs section,
@@ -54,12 +55,16 @@ struct irq_data {
"_irq_"#irq"_handler:\n" \
"pusha\n" \
ASM_LOCK_PREFIX "addl $1, __in_isr\n" \
+ "movl %esp, %eax\n" \
+ "movl $stack_end, %esp\n" \
+ "push %eax\n" \
task_start_irq_handler_call \
"call "#routine"\n" \
"push $0\n" \
"push $0\n" \
"call switch_handler\n" \
"addl $0x08, %esp\n" \
+ "pop %esp\n" \
"test %eax, %eax\n" \
"je 1f\n" \
"movl current_task, %eax\n" \
diff --git a/core/minute-ia/switch.S b/core/minute-ia/switch.S
index 52883671eb..eed2f7929f 100644
--- a/core/minute-ia/switch.S
+++ b/core/minute-ia/switch.S
@@ -49,8 +49,13 @@ default_int_handler:
pusha
ASM_LOCK_PREFIX addl $1, __in_isr
+ movl %esp, %eax
+ movl $stack_end, %esp # use system stack
+ push %eax # push sp of preempted context
+
call unhandled_vector # Handle system interrupts and
# unregistered user interrupts
+ pop %esp # restore sp of preempted context
# unhandled_vector call loads eax with vector for comparison
cmpl $LAPIC_SPURIOUS_INT_VECTOR, %eax
je 1f # No EOI for LAPIC_SPURIOUS_INT_VECTOR
@@ -78,6 +83,10 @@ __switchto:
pusha
ASM_LOCK_PREFIX addl $1, __in_isr
+ movl %esp, %eax
+ movl $stack_end, %esp # use system stack
+ push %eax # push sp of preempted context
+
# __schedule() copies 'resched' to %ecx and 'desched' to %edx before
# triggering ISH_TS_VECTOR
#
@@ -95,6 +104,7 @@ __switchto:
# Stack is already set up from previous pushes
call switch_handler
addl $0x8, %esp # Clean up stack
+ pop %esp # restore sp of preempted context
test %eax, %eax # Check if task switch required
jz 1f