Linux 5.6.13
[linux/fpc-iii.git] / arch / arm / kvm / hyp / cp15-sr.c
blobe6923306f69841aa88d013910c9595b6458f0600
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * Original code:
4 * Copyright (C) 2012 - Virtual Open Systems and Columbia University
5 * Author: Christoffer Dall <c.dall@virtualopensystems.com>
7 * Mostly rewritten in C by Marc Zyngier <marc.zyngier@arm.com>
8 */
10 #include <asm/kvm_hyp.h>
12 static u64 *cp15_64(struct kvm_cpu_context *ctxt, int idx)
14 return (u64 *)(ctxt->cp15 + idx);
17 void __hyp_text __sysreg_save_state(struct kvm_cpu_context *ctxt)
19 ctxt->cp15[c0_CSSELR] = read_sysreg(CSSELR);
20 ctxt->cp15[c1_SCTLR] = read_sysreg(SCTLR);
21 ctxt->cp15[c1_CPACR] = read_sysreg(CPACR);
22 *cp15_64(ctxt, c2_TTBR0) = read_sysreg(TTBR0);
23 *cp15_64(ctxt, c2_TTBR1) = read_sysreg(TTBR1);
24 ctxt->cp15[c2_TTBCR] = read_sysreg(TTBCR);
25 ctxt->cp15[c3_DACR] = read_sysreg(DACR);
26 ctxt->cp15[c5_DFSR] = read_sysreg(DFSR);
27 ctxt->cp15[c5_IFSR] = read_sysreg(IFSR);
28 ctxt->cp15[c5_ADFSR] = read_sysreg(ADFSR);
29 ctxt->cp15[c5_AIFSR] = read_sysreg(AIFSR);
30 ctxt->cp15[c6_DFAR] = read_sysreg(DFAR);
31 ctxt->cp15[c6_IFAR] = read_sysreg(IFAR);
32 *cp15_64(ctxt, c7_PAR) = read_sysreg(PAR);
33 ctxt->cp15[c10_PRRR] = read_sysreg(PRRR);
34 ctxt->cp15[c10_NMRR] = read_sysreg(NMRR);
35 ctxt->cp15[c10_AMAIR0] = read_sysreg(AMAIR0);
36 ctxt->cp15[c10_AMAIR1] = read_sysreg(AMAIR1);
37 ctxt->cp15[c12_VBAR] = read_sysreg(VBAR);
38 ctxt->cp15[c13_CID] = read_sysreg(CID);
39 ctxt->cp15[c13_TID_URW] = read_sysreg(TID_URW);
40 ctxt->cp15[c13_TID_URO] = read_sysreg(TID_URO);
41 ctxt->cp15[c13_TID_PRIV] = read_sysreg(TID_PRIV);
42 ctxt->cp15[c14_CNTKCTL] = read_sysreg(CNTKCTL);
45 void __hyp_text __sysreg_restore_state(struct kvm_cpu_context *ctxt)
47 write_sysreg(ctxt->cp15[c0_MPIDR], VMPIDR);
48 write_sysreg(ctxt->cp15[c0_CSSELR], CSSELR);
49 write_sysreg(ctxt->cp15[c1_SCTLR], SCTLR);
50 write_sysreg(ctxt->cp15[c1_CPACR], CPACR);
51 write_sysreg(*cp15_64(ctxt, c2_TTBR0), TTBR0);
52 write_sysreg(*cp15_64(ctxt, c2_TTBR1), TTBR1);
53 write_sysreg(ctxt->cp15[c2_TTBCR], TTBCR);
54 write_sysreg(ctxt->cp15[c3_DACR], DACR);
55 write_sysreg(ctxt->cp15[c5_DFSR], DFSR);
56 write_sysreg(ctxt->cp15[c5_IFSR], IFSR);
57 write_sysreg(ctxt->cp15[c5_ADFSR], ADFSR);
58 write_sysreg(ctxt->cp15[c5_AIFSR], AIFSR);
59 write_sysreg(ctxt->cp15[c6_DFAR], DFAR);
60 write_sysreg(ctxt->cp15[c6_IFAR], IFAR);
61 write_sysreg(*cp15_64(ctxt, c7_PAR), PAR);
62 write_sysreg(ctxt->cp15[c10_PRRR], PRRR);
63 write_sysreg(ctxt->cp15[c10_NMRR], NMRR);
64 write_sysreg(ctxt->cp15[c10_AMAIR0], AMAIR0);
65 write_sysreg(ctxt->cp15[c10_AMAIR1], AMAIR1);
66 write_sysreg(ctxt->cp15[c12_VBAR], VBAR);
67 write_sysreg(ctxt->cp15[c13_CID], CID);
68 write_sysreg(ctxt->cp15[c13_TID_URW], TID_URW);
69 write_sysreg(ctxt->cp15[c13_TID_URO], TID_URO);
70 write_sysreg(ctxt->cp15[c13_TID_PRIV], TID_PRIV);
71 write_sysreg(ctxt->cp15[c14_CNTKCTL], CNTKCTL);