]>
Commit | Line | Data |
---|---|---|
a2f0542b SL |
1 | From 358c9d5eac5ca38ff4f1ca49fd102f629d2c660b Mon Sep 17 00:00:00 2001 |
2 | From: Mark Rutland <mark.rutland@arm.com> | |
3 | Date: Fri, 18 Jan 2019 17:55:53 +0000 | |
4 | Subject: arm64/kvm: consistently handle host HCR_EL2 flags | |
5 | ||
6 | [ Backport of upstream commit 4eaed6aa2c628101246bcabc91b203bfac1193f8 ] | |
7 | ||
8 | In KVM we define the configuration of HCR_EL2 for a VHE HOST in | |
9 | HCR_HOST_VHE_FLAGS, but we don't have a similar definition for the | |
10 | non-VHE host flags, and open-code HCR_RW. Further, in head.S we | |
11 | open-code the flags for VHE and non-VHE configurations. | |
12 | ||
13 | In future, we're going to want to configure more flags for the host, so | |
14 | lets add a HCR_HOST_NVHE_FLAGS defintion, and consistently use both | |
15 | HCR_HOST_VHE_FLAGS and HCR_HOST_NVHE_FLAGS in the kvm code and head.S. | |
16 | ||
17 | We now use mov_q to generate the HCR_EL2 value, as we use when | |
18 | configuring other registers in head.S. | |
19 | ||
20 | Reviewed-by: Marc Zyngier <marc.zyngier@arm.com> | |
21 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | |
22 | Signed-off-by: Mark Rutland <mark.rutland@arm.com> | |
23 | Reviewed-by: Christoffer Dall <christoffer.dall@arm.com> | |
24 | Cc: Catalin Marinas <catalin.marinas@arm.com> | |
25 | Cc: Marc Zyngier <marc.zyngier@arm.com> | |
26 | Cc: Will Deacon <will.deacon@arm.com> | |
27 | Cc: kvmarm@lists.cs.columbia.edu | |
28 | Signed-off-by: Will Deacon <will.deacon@arm.com> | |
29 | [kristina: backport to 4.4.y: non-VHE only; __deactivate_traps_nvhe in | |
30 | assembly; add #include] | |
31 | Signed-off-by: Kristina Martsenko <kristina.martsenko@arm.com> | |
32 | Signed-off-by: Sasha Levin <sashal@kernel.org> | |
33 | --- | |
34 | arch/arm64/include/asm/kvm_arm.h | 1 + | |
35 | arch/arm64/kernel/head.S | 3 ++- | |
36 | arch/arm64/kvm/hyp.S | 2 +- | |
37 | 3 files changed, 4 insertions(+), 2 deletions(-) | |
38 | ||
39 | diff --git a/arch/arm64/include/asm/kvm_arm.h b/arch/arm64/include/asm/kvm_arm.h | |
40 | index ef8e13d379cb..013b7de45ee7 100644 | |
41 | --- a/arch/arm64/include/asm/kvm_arm.h | |
42 | +++ b/arch/arm64/include/asm/kvm_arm.h | |
43 | @@ -81,6 +81,7 @@ | |
44 | HCR_AMO | HCR_SWIO | HCR_TIDCP | HCR_RW) | |
45 | #define HCR_VIRT_EXCP_MASK (HCR_VA | HCR_VI | HCR_VF) | |
46 | #define HCR_INT_OVERRIDE (HCR_FMO | HCR_IMO) | |
47 | +#define HCR_HOST_NVHE_FLAGS (HCR_RW) | |
48 | ||
49 | ||
50 | /* Hyp System Control Register (SCTLR_EL2) bits */ | |
51 | diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S | |
52 | index d019c3a58cc2..0382eba4bf7b 100644 | |
53 | --- a/arch/arm64/kernel/head.S | |
54 | +++ b/arch/arm64/kernel/head.S | |
55 | @@ -30,6 +30,7 @@ | |
56 | #include <asm/cache.h> | |
57 | #include <asm/cputype.h> | |
58 | #include <asm/kernel-pgtable.h> | |
59 | +#include <asm/kvm_arm.h> | |
60 | #include <asm/memory.h> | |
61 | #include <asm/pgtable-hwdef.h> | |
62 | #include <asm/pgtable.h> | |
63 | @@ -464,7 +465,7 @@ CPU_LE( bic x0, x0, #(3 << 24) ) // Clear the EE and E0E bits for EL1 | |
64 | ret | |
65 | ||
66 | /* Hyp configuration. */ | |
67 | -2: mov x0, #(1 << 31) // 64-bit EL1 | |
68 | +2: mov_q x0, HCR_HOST_NVHE_FLAGS | |
69 | msr hcr_el2, x0 | |
70 | ||
71 | /* Generic timers. */ | |
72 | diff --git a/arch/arm64/kvm/hyp.S b/arch/arm64/kvm/hyp.S | |
73 | index 86c289832272..8d3da858c257 100644 | |
74 | --- a/arch/arm64/kvm/hyp.S | |
75 | +++ b/arch/arm64/kvm/hyp.S | |
76 | @@ -494,7 +494,7 @@ | |
77 | .endm | |
78 | ||
79 | .macro deactivate_traps | |
80 | - mov x2, #HCR_RW | |
81 | + mov_q x2, HCR_HOST_NVHE_FLAGS | |
82 | msr hcr_el2, x2 | |
83 | msr hstr_el2, xzr | |
84 | ||
85 | -- | |
86 | 2.19.1 | |
87 |