aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorMarc Zyngier <marc.zyngier@arm.com>2012-12-10 11:23:59 -0500
committerMarc Zyngier <marc.zyngier@arm.com>2013-06-07 09:03:37 -0400
commitf4672752c321ea36ce099cebdd7a082a8f327505 (patch)
tree459221740c16bf47bf83b55c0c1c91356aeb78a8 /arch
parentb990a9d3152bddca62cc1f8bf80518430b98737b (diff)
arm64: KVM: virtual CPU reset
Provide the reset code for a virtual CPU booted in 64bit mode. Reviewed-by: Christopher Covington <cov@codeaurora.org> Reviewed-by: Catalin Marinas <catalin.marinas@arm.com> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/arm64/kvm/reset.c76
1 files changed, 76 insertions, 0 deletions
diff --git a/arch/arm64/kvm/reset.c b/arch/arm64/kvm/reset.c
new file mode 100644
index 000000000000..f6536a06231a
--- /dev/null
+++ b/arch/arm64/kvm/reset.c
@@ -0,0 +1,76 @@
1/*
2 * Copyright (C) 2012,2013 - ARM Ltd
3 * Author: Marc Zyngier <marc.zyngier@arm.com>
4 *
5 * Derived from arch/arm/kvm/reset.c
6 * Copyright (C) 2012 - Virtual Open Systems and Columbia University
7 * Author: Christoffer Dall <c.dall@virtualopensystems.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License, version 2, as
11 * published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#include <linux/errno.h>
23#include <linux/kvm_host.h>
24#include <linux/kvm.h>
25
26#include <asm/cputype.h>
27#include <asm/ptrace.h>
28#include <asm/kvm_arm.h>
29#include <asm/kvm_coproc.h>
30
31/*
32 * ARMv8 Reset Values
33 */
34static const struct kvm_regs default_regs_reset = {
35 .regs.pstate = (PSR_MODE_EL1h | PSR_A_BIT | PSR_I_BIT |
36 PSR_F_BIT | PSR_D_BIT),
37};
38
39int kvm_arch_dev_ioctl_check_extension(long ext)
40{
41 int r;
42
43 switch (ext) {
44 default:
45 r = 0;
46 }
47
48 return r;
49}
50
51/**
52 * kvm_reset_vcpu - sets core registers and sys_regs to reset value
53 * @vcpu: The VCPU pointer
54 *
55 * This function finds the right table above and sets the registers on
56 * the virtual CPU struct to their architectually defined reset
57 * values.
58 */
59int kvm_reset_vcpu(struct kvm_vcpu *vcpu)
60{
61 const struct kvm_regs *cpu_reset;
62
63 switch (vcpu->arch.target) {
64 default:
65 cpu_reset = &default_regs_reset;
66 break;
67 }
68
69 /* Reset core registers */
70 memcpy(vcpu_gp_regs(vcpu), cpu_reset, sizeof(*cpu_reset));
71
72 /* Reset system registers */
73 kvm_reset_sys_regs(vcpu);
74
75 return 0;
76}