GNU Linux-libre 4.9.317-gnu1
[releases.git] / arch / arm / kvm / hyp / s2-setup.c
1 /*
2  * Copyright (C) 2016 - ARM Ltd
3  * Author: Marc Zyngier <marc.zyngier@arm.com>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16  */
17
18 #include <linux/types.h>
19 #include <asm/kvm_arm.h>
20 #include <asm/kvm_asm.h>
21 #include <asm/kvm_hyp.h>
22
23 void __hyp_text __init_stage2_translation(void)
24 {
25         u64 val;
26
27         val = read_sysreg(VTCR) & ~VTCR_MASK;
28
29         val |= read_sysreg(HTCR) & VTCR_HTCR_SH;
30         val |= KVM_VTCR_SL0 | KVM_VTCR_T0SZ | KVM_VTCR_S;
31
32         write_sysreg(val, VTCR);
33 }