forked from agners/linux-fslc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ARM: KVM: Add banked registers save/restore
Banked registers are one of the many perks of the 32bit architecture, and the world switch needs to cope with it. This requires some "special" accessors, as these are not accessed using a standard coprocessor instruction. Reviewed-by: Christoffer Dall <[email protected]> Signed-off-by: Marc Zyngier <[email protected]>
- Loading branch information
Marc Zyngier
committed
Feb 29, 2016
1 parent
59cbcdb
commit 33280b4
Showing
3 changed files
with
89 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* Original code: | ||
* Copyright (C) 2012 - Virtual Open Systems and Columbia University | ||
* Author: Christoffer Dall <[email protected]> | ||
* | ||
* Mostly rewritten in C by Marc Zyngier <[email protected]> | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 2 as | ||
* published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include "hyp.h" | ||
|
||
__asm__(".arch_extension virt"); | ||
|
||
void __hyp_text __banked_save_state(struct kvm_cpu_context *ctxt) | ||
{ | ||
ctxt->gp_regs.usr_regs.ARM_sp = read_special(SP_usr); | ||
ctxt->gp_regs.usr_regs.ARM_pc = read_special(ELR_hyp); | ||
ctxt->gp_regs.usr_regs.ARM_cpsr = read_special(SPSR); | ||
ctxt->gp_regs.KVM_ARM_SVC_sp = read_special(SP_svc); | ||
ctxt->gp_regs.KVM_ARM_SVC_lr = read_special(LR_svc); | ||
ctxt->gp_regs.KVM_ARM_SVC_spsr = read_special(SPSR_svc); | ||
ctxt->gp_regs.KVM_ARM_ABT_sp = read_special(SP_abt); | ||
ctxt->gp_regs.KVM_ARM_ABT_lr = read_special(LR_abt); | ||
ctxt->gp_regs.KVM_ARM_ABT_spsr = read_special(SPSR_abt); | ||
ctxt->gp_regs.KVM_ARM_UND_sp = read_special(SP_und); | ||
ctxt->gp_regs.KVM_ARM_UND_lr = read_special(LR_und); | ||
ctxt->gp_regs.KVM_ARM_UND_spsr = read_special(SPSR_und); | ||
ctxt->gp_regs.KVM_ARM_IRQ_sp = read_special(SP_irq); | ||
ctxt->gp_regs.KVM_ARM_IRQ_lr = read_special(LR_irq); | ||
ctxt->gp_regs.KVM_ARM_IRQ_spsr = read_special(SPSR_irq); | ||
ctxt->gp_regs.KVM_ARM_FIQ_r8 = read_special(R8_fiq); | ||
ctxt->gp_regs.KVM_ARM_FIQ_r9 = read_special(R9_fiq); | ||
ctxt->gp_regs.KVM_ARM_FIQ_r10 = read_special(R10_fiq); | ||
ctxt->gp_regs.KVM_ARM_FIQ_fp = read_special(R11_fiq); | ||
ctxt->gp_regs.KVM_ARM_FIQ_ip = read_special(R12_fiq); | ||
ctxt->gp_regs.KVM_ARM_FIQ_sp = read_special(SP_fiq); | ||
ctxt->gp_regs.KVM_ARM_FIQ_lr = read_special(LR_fiq); | ||
ctxt->gp_regs.KVM_ARM_FIQ_spsr = read_special(SPSR_fiq); | ||
} | ||
|
||
void __hyp_text __banked_restore_state(struct kvm_cpu_context *ctxt) | ||
{ | ||
write_special(ctxt->gp_regs.usr_regs.ARM_sp, SP_usr); | ||
write_special(ctxt->gp_regs.usr_regs.ARM_pc, ELR_hyp); | ||
write_special(ctxt->gp_regs.usr_regs.ARM_cpsr, SPSR_cxsf); | ||
write_special(ctxt->gp_regs.KVM_ARM_SVC_sp, SP_svc); | ||
write_special(ctxt->gp_regs.KVM_ARM_SVC_lr, LR_svc); | ||
write_special(ctxt->gp_regs.KVM_ARM_SVC_spsr, SPSR_svc); | ||
write_special(ctxt->gp_regs.KVM_ARM_ABT_sp, SP_abt); | ||
write_special(ctxt->gp_regs.KVM_ARM_ABT_lr, LR_abt); | ||
write_special(ctxt->gp_regs.KVM_ARM_ABT_spsr, SPSR_abt); | ||
write_special(ctxt->gp_regs.KVM_ARM_UND_sp, SP_und); | ||
write_special(ctxt->gp_regs.KVM_ARM_UND_lr, LR_und); | ||
write_special(ctxt->gp_regs.KVM_ARM_UND_spsr, SPSR_und); | ||
write_special(ctxt->gp_regs.KVM_ARM_IRQ_sp, SP_irq); | ||
write_special(ctxt->gp_regs.KVM_ARM_IRQ_lr, LR_irq); | ||
write_special(ctxt->gp_regs.KVM_ARM_IRQ_spsr, SPSR_irq); | ||
write_special(ctxt->gp_regs.KVM_ARM_FIQ_r8, R8_fiq); | ||
write_special(ctxt->gp_regs.KVM_ARM_FIQ_r9, R9_fiq); | ||
write_special(ctxt->gp_regs.KVM_ARM_FIQ_r10, R10_fiq); | ||
write_special(ctxt->gp_regs.KVM_ARM_FIQ_fp, R11_fiq); | ||
write_special(ctxt->gp_regs.KVM_ARM_FIQ_ip, R12_fiq); | ||
write_special(ctxt->gp_regs.KVM_ARM_FIQ_sp, SP_fiq); | ||
write_special(ctxt->gp_regs.KVM_ARM_FIQ_lr, LR_fiq); | ||
write_special(ctxt->gp_regs.KVM_ARM_FIQ_spsr, SPSR_fiq); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters