Skip to content
Commit 823f53a3 authored by Vincent Chen's avatar Vincent Chen Committed by Anup Patel
Browse files

RISC-V: KVM: Refine __kvm_riscv_switch_to() implementation



Kernel uses __kvm_riscv_switch_to() and __kvm_switch_return() to switch
the context of host kernel and guest kernel. Several CSRs belonging to the
context will be read and written during the context switch. To ensure
atomic read-modify-write control of CSR and ordering of CSR accesses, some
hardware blocks flush the pipeline when writing a CSR. In this
circumstance, grouping CSR executions together as much as possible can
reduce the performance impact of the pipeline. Therefore, this commit
reorders the CSR instructions to enhance the context switch performance..

Signed-off-by: default avatarVincent Chen <vincent.chen@sifive.com>
Suggested-by: default avatarHsinyi Lee <hsinyi.lee@sifive.com>
Suggested-by: default avatarFu-Ching Yang <fu-ching.yang@sifive.com>
Signed-off-by: default avatarAnup Patel <anup@brainfault.org>
parent afec0c65
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment