writeback: Fix performance regression in wb_over_bg_thresh()
[deliverable/linux.git] / arch / arm64 / 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 = VTCR_EL2_FLAGS;
26 u64 tmp;
27
28 /*
29 * Read the PARange bits from ID_AA64MMFR0_EL1 and set the PS
30 * bits in VTCR_EL2. Amusingly, the PARange is 4 bits, while
31 * PS is only 3. Fortunately, bit 19 is RES0 in VTCR_EL2...
32 */
33 val |= (read_sysreg(id_aa64mmfr0_el1) & 7) << 16;
34
35 /*
36 * Read the VMIDBits bits from ID_AA64MMFR1_EL1 and set the VS
37 * bit in VTCR_EL2.
38 */
39 tmp = (read_sysreg(id_aa64mmfr1_el1) >> 4) & 0xf;
40 val |= (tmp == 2) ? VTCR_EL2_VS : 0;
41
42 write_sysreg(val, vtcr_el2);
43 }
This page took 0.029869 seconds and 5 git commands to generate.