xref: /openbmc/linux/arch/arm64/kvm/hyp/nvhe/sysreg-sr.c (revision f4fc91af)
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * Copyright (C) 2012-2015 - ARM Ltd
4  * Author: Marc Zyngier <marc.zyngier@arm.com>
5  */
6 
7 #include <hyp/sysreg-sr.h>
8 
9 #include <linux/compiler.h>
10 #include <linux/kvm_host.h>
11 
12 #include <asm/kprobes.h>
13 #include <asm/kvm_asm.h>
14 #include <asm/kvm_emulate.h>
15 #include <asm/kvm_hyp.h>
16 
17 /*
18  * Non-VHE: Both host and guest must save everything.
19  */
20 
21 void __sysreg_save_state_nvhe(struct kvm_cpu_context *ctxt)
22 {
23 	__sysreg_save_el1_state(ctxt);
24 	__sysreg_save_common_state(ctxt);
25 	__sysreg_save_user_state(ctxt);
26 	__sysreg_save_el2_return_state(ctxt);
27 }
28 
29 void __sysreg_restore_state_nvhe(struct kvm_cpu_context *ctxt)
30 {
31 	__sysreg_restore_el1_state(ctxt);
32 	__sysreg_restore_common_state(ctxt);
33 	__sysreg_restore_user_state(ctxt);
34 	__sysreg_restore_el2_return_state(ctxt);
35 }
36 
37 void __kvm_enable_ssbs(void)
38 {
39 	u64 tmp;
40 
41 	asm volatile(
42 	"mrs	%0, sctlr_el2\n"
43 	"orr	%0, %0, %1\n"
44 	"msr	sctlr_el2, %0"
45 	: "=&r" (tmp) : "L" (SCTLR_ELx_DSSBS));
46 }
47