acrn-hypervisor/hypervisor/arch/x86/sched.S
Jason Chen CJ 285b64faec replace arch_switch_to with pure asm code instead of inline asm
after compile, the compiled code could change rsp, so use pure asm code
to avoid such problem which will cause schedule switch failure.

Tracked-On: #2410
Signed-off-by: Jason Chen CJ <jason.cj.chen@intel.com>
2019-01-25 11:39:47 +08:00

42 lines
988 B
ArmAsm

/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
/*
* Function schedule() will finally call arch_switch_to here for x86 platform, which use
* the pointer of previous & next sched_obj->host_sp as the input parameters (rdi & rsi).
*
* Function arch_switch_to will save rflags, rbx, rbp, r12~r15, and rdi in the previous
* sched_obj's stack, then switch stack pointer(rsp) from previous to next sched_obj (saved
* in sched_obj->host_sp) and restore above registers from next sched_obj's stack.
* It make sure the execution context return to the same point of next sched_obj when it got
* scheduled last time.
*/
.text
.code64
.align 8
.global arch_switch_to
arch_switch_to:
pushf
pushq %rbx
pushq %rbp
pushq %r12
pushq %r13
pushq %r14
pushq %r15
pushq %rdi
movq %rsp, (%rdi)
movq (%rsi), %rsp
popq %rdi
popq %r15
popq %r14
popq %r13
popq %r12
popq %rbp
popq %rbx
popf
retq