diff options
author | Catalin Marinas <catalin.marinas@arm.com> | 2013-06-12 11:48:38 -0400 |
---|---|---|
committer | Catalin Marinas <catalin.marinas@arm.com> | 2013-06-12 11:48:38 -0400 |
commit | 63917f0b5ba2a932d4fca7f67d1a1eae9034269e (patch) | |
tree | 2e5b219ca98b56868136e227601a91143d289daf /arch/arm64/kvm/sys_regs_generic_v8.c | |
parent | d822d2a1e33144967b01f9535ce217639aa75279 (diff) | |
parent | aa4a73a0a23a65a2f531d01f1865d1e61c6acb55 (diff) |
Merge branch 'kvm-arm64/kvm-for-3.11' of git://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms into upstream
* 'kvm-arm64/kvm-for-3.11' of git://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms: (33 commits)
arm64: KVM: document kernel object mappings in HYP
arm64: KVM: MAINTAINERS update
arm64: KVM: userspace API documentation
arm64: KVM: enable initialization of a 32bit vcpu
arm64: KVM: 32bit guest fault injection
arm64: KVM: 32bit specific register world switch
arm64: KVM: CPU specific 32bit coprocessor access
arm64: KVM: 32bit handling of coprocessor traps
arm64: KVM: 32bit conditional execution emulation
arm64: KVM: 32bit GP register access
arm64: KVM: define 32bit specific registers
arm64: KVM: Build system integration
arm64: KVM: PSCI implementation
arm64: KVM: Plug the arch timer
ARM: KVM: timer: allow DT matching for ARMv8 cores
arm64: KVM: Plug the VGIC
arm64: KVM: Exit handling
arm64: KVM: HYP mode world switch implementation
arm64: KVM: hypervisor initialization code
arm64: KVM: guest one-reg interface
...
Conflicts:
arch/arm64/Makefile
Diffstat (limited to 'arch/arm64/kvm/sys_regs_generic_v8.c')
-rw-r--r-- | arch/arm64/kvm/sys_regs_generic_v8.c | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/arch/arm64/kvm/sys_regs_generic_v8.c b/arch/arm64/kvm/sys_regs_generic_v8.c new file mode 100644 index 000000000000..4268ab9356b1 --- /dev/null +++ b/arch/arm64/kvm/sys_regs_generic_v8.c | |||
@@ -0,0 +1,95 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2012,2013 - ARM Ltd | ||
3 | * Author: Marc Zyngier <marc.zyngier@arm.com> | ||
4 | * | ||
5 | * Based on arch/arm/kvm/coproc_a15.c: | ||
6 | * Copyright (C) 2012 - Virtual Open Systems and Columbia University | ||
7 | * Authors: Rusty Russell <rusty@rustcorp.au> | ||
8 | * Christoffer Dall <c.dall@virtualopensystems.com> | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU General Public License, version 2, as | ||
12 | * published by the Free Software Foundation. | ||
13 | * | ||
14 | * This program is distributed in the hope that it will be useful, | ||
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | * GNU General Public License for more details. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License | ||
20 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
21 | */ | ||
22 | #include <linux/kvm_host.h> | ||
23 | #include <asm/cputype.h> | ||
24 | #include <asm/kvm_arm.h> | ||
25 | #include <asm/kvm_asm.h> | ||
26 | #include <asm/kvm_host.h> | ||
27 | #include <asm/kvm_emulate.h> | ||
28 | #include <asm/kvm_coproc.h> | ||
29 | #include <linux/init.h> | ||
30 | |||
31 | #include "sys_regs.h" | ||
32 | |||
33 | static bool access_actlr(struct kvm_vcpu *vcpu, | ||
34 | const struct sys_reg_params *p, | ||
35 | const struct sys_reg_desc *r) | ||
36 | { | ||
37 | if (p->is_write) | ||
38 | return ignore_write(vcpu, p); | ||
39 | |||
40 | *vcpu_reg(vcpu, p->Rt) = vcpu_sys_reg(vcpu, ACTLR_EL1); | ||
41 | return true; | ||
42 | } | ||
43 | |||
44 | static void reset_actlr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *r) | ||
45 | { | ||
46 | u64 actlr; | ||
47 | |||
48 | asm volatile("mrs %0, actlr_el1\n" : "=r" (actlr)); | ||
49 | vcpu_sys_reg(vcpu, ACTLR_EL1) = actlr; | ||
50 | } | ||
51 | |||
52 | /* | ||
53 | * Implementation specific sys-reg registers. | ||
54 | * Important: Must be sorted ascending by Op0, Op1, CRn, CRm, Op2 | ||
55 | */ | ||
56 | static const struct sys_reg_desc genericv8_sys_regs[] = { | ||
57 | /* ACTLR_EL1 */ | ||
58 | { Op0(0b11), Op1(0b000), CRn(0b0001), CRm(0b0000), Op2(0b001), | ||
59 | access_actlr, reset_actlr, ACTLR_EL1 }, | ||
60 | }; | ||
61 | |||
62 | static const struct sys_reg_desc genericv8_cp15_regs[] = { | ||
63 | /* ACTLR */ | ||
64 | { Op1(0b000), CRn(0b0001), CRm(0b0000), Op2(0b001), | ||
65 | access_actlr }, | ||
66 | }; | ||
67 | |||
68 | static struct kvm_sys_reg_target_table genericv8_target_table = { | ||
69 | .table64 = { | ||
70 | .table = genericv8_sys_regs, | ||
71 | .num = ARRAY_SIZE(genericv8_sys_regs), | ||
72 | }, | ||
73 | .table32 = { | ||
74 | .table = genericv8_cp15_regs, | ||
75 | .num = ARRAY_SIZE(genericv8_cp15_regs), | ||
76 | }, | ||
77 | }; | ||
78 | |||
79 | static int __init sys_reg_genericv8_init(void) | ||
80 | { | ||
81 | unsigned int i; | ||
82 | |||
83 | for (i = 1; i < ARRAY_SIZE(genericv8_sys_regs); i++) | ||
84 | BUG_ON(cmp_sys_reg(&genericv8_sys_regs[i-1], | ||
85 | &genericv8_sys_regs[i]) >= 0); | ||
86 | |||
87 | kvm_register_target_sys_reg_table(KVM_ARM_TARGET_AEM_V8, | ||
88 | &genericv8_target_table); | ||
89 | kvm_register_target_sys_reg_table(KVM_ARM_TARGET_FOUNDATION_V8, | ||
90 | &genericv8_target_table); | ||
91 | kvm_register_target_sys_reg_table(KVM_ARM_TARGET_CORTEX_A57, | ||
92 | &genericv8_target_table); | ||
93 | return 0; | ||
94 | } | ||
95 | late_initcall(sys_reg_genericv8_init); | ||