11e0c135aSWill Deacon #include "kvm/kvm-cpu.h"
21e0c135aSWill Deacon #include "kvm/kvm.h"
3fc9d8ec3SMarc Zyngier #include "kvm/virtio.h"
41e0c135aSWill Deacon
51e0c135aSWill Deacon #include <asm/ptrace.h>
6*ca31abf5SOliver Upton #include <linux/bitops.h>
71e0c135aSWill Deacon
81e0c135aSWill Deacon #define COMPAT_PSR_F_BIT 0x00000040
91e0c135aSWill Deacon #define COMPAT_PSR_I_BIT 0x00000080
10fc9d8ec3SMarc Zyngier #define COMPAT_PSR_E_BIT 0x00000200
111e0c135aSWill Deacon #define COMPAT_PSR_MODE_SVC 0x00000013
121e0c135aSWill Deacon
13fc9d8ec3SMarc Zyngier #define SCTLR_EL1_E0E_MASK (1 << 24)
14fc9d8ec3SMarc Zyngier #define SCTLR_EL1_EE_MASK (1 << 25)
15fc9d8ec3SMarc Zyngier
__core_reg_id(__u64 offset)165ae841d1SDave Martin static __u64 __core_reg_id(__u64 offset)
175ae841d1SDave Martin {
185ae841d1SDave Martin __u64 id = KVM_REG_ARM64 | KVM_REG_ARM_CORE | offset;
195ae841d1SDave Martin
205ae841d1SDave Martin if (offset < KVM_REG_ARM_CORE_REG(fp_regs))
215ae841d1SDave Martin id |= KVM_REG_SIZE_U64;
225ae841d1SDave Martin else if (offset < KVM_REG_ARM_CORE_REG(fp_regs.fpsr))
235ae841d1SDave Martin id |= KVM_REG_SIZE_U128;
245ae841d1SDave Martin else
255ae841d1SDave Martin id |= KVM_REG_SIZE_U32;
265ae841d1SDave Martin
275ae841d1SDave Martin return id;
285ae841d1SDave Martin }
295ae841d1SDave Martin
305ae841d1SDave Martin #define ARM64_CORE_REG(x) __core_reg_id(KVM_REG_ARM_CORE_REG(x))
311e0c135aSWill Deacon
kvm_cpu__get_vcpu_mpidr(struct kvm_cpu * vcpu)32d06bc640SMarc Zyngier unsigned long kvm_cpu__get_vcpu_mpidr(struct kvm_cpu *vcpu)
33d06bc640SMarc Zyngier {
34d06bc640SMarc Zyngier struct kvm_one_reg reg;
35d06bc640SMarc Zyngier u64 mpidr;
36d06bc640SMarc Zyngier
37d06bc640SMarc Zyngier reg.id = ARM64_SYS_REG(ARM_CPU_ID, ARM_CPU_ID_MPIDR);
38d06bc640SMarc Zyngier reg.addr = (u64)&mpidr;
39d06bc640SMarc Zyngier if (ioctl(vcpu->vcpu_fd, KVM_GET_ONE_REG, ®) < 0)
40d06bc640SMarc Zyngier die("KVM_GET_ONE_REG failed (get_mpidr vcpu%ld", vcpu->cpu_id);
41d06bc640SMarc Zyngier
42d06bc640SMarc Zyngier return mpidr;
43d06bc640SMarc Zyngier }
44d06bc640SMarc Zyngier
reset_vcpu_aarch32(struct kvm_cpu * vcpu)451e0c135aSWill Deacon static void reset_vcpu_aarch32(struct kvm_cpu *vcpu)
461e0c135aSWill Deacon {
471e0c135aSWill Deacon struct kvm *kvm = vcpu->kvm;
481e0c135aSWill Deacon struct kvm_one_reg reg;
491e0c135aSWill Deacon u64 data;
501e0c135aSWill Deacon
511e0c135aSWill Deacon reg.addr = (u64)&data;
521e0c135aSWill Deacon
531e0c135aSWill Deacon /* pstate = all interrupts masked */
541e0c135aSWill Deacon data = COMPAT_PSR_I_BIT | COMPAT_PSR_F_BIT | COMPAT_PSR_MODE_SVC;
551e0c135aSWill Deacon reg.id = ARM64_CORE_REG(regs.pstate);
561e0c135aSWill Deacon if (ioctl(vcpu->vcpu_fd, KVM_SET_ONE_REG, ®) < 0)
571e0c135aSWill Deacon die_perror("KVM_SET_ONE_REG failed (spsr[EL1])");
581e0c135aSWill Deacon
591e0c135aSWill Deacon /* Secondary cores are stopped awaiting PSCI wakeup */
601e0c135aSWill Deacon if (vcpu->cpu_id != 0)
611e0c135aSWill Deacon return;
621e0c135aSWill Deacon
631e0c135aSWill Deacon /* r0 = 0 */
641e0c135aSWill Deacon data = 0;
651e0c135aSWill Deacon reg.id = ARM64_CORE_REG(regs.regs[0]);
661e0c135aSWill Deacon if (ioctl(vcpu->vcpu_fd, KVM_SET_ONE_REG, ®) < 0)
671e0c135aSWill Deacon die_perror("KVM_SET_ONE_REG failed (r0)");
681e0c135aSWill Deacon
691e0c135aSWill Deacon /* r1 = machine type (-1) */
701e0c135aSWill Deacon data = -1;
711e0c135aSWill Deacon reg.id = ARM64_CORE_REG(regs.regs[1]);
721e0c135aSWill Deacon if (ioctl(vcpu->vcpu_fd, KVM_SET_ONE_REG, ®) < 0)
731e0c135aSWill Deacon die_perror("KVM_SET_ONE_REG failed (r1)");
741e0c135aSWill Deacon
751e0c135aSWill Deacon /* r2 = physical address of the device tree blob */
761e0c135aSWill Deacon data = kvm->arch.dtb_guest_start;
771e0c135aSWill Deacon reg.id = ARM64_CORE_REG(regs.regs[2]);
781e0c135aSWill Deacon if (ioctl(vcpu->vcpu_fd, KVM_SET_ONE_REG, ®) < 0)
791e0c135aSWill Deacon die_perror("KVM_SET_ONE_REG failed (r2)");
801e0c135aSWill Deacon
811e0c135aSWill Deacon /* pc = start of kernel image */
821e0c135aSWill Deacon data = kvm->arch.kern_guest_start;
831e0c135aSWill Deacon reg.id = ARM64_CORE_REG(regs.pc);
841e0c135aSWill Deacon if (ioctl(vcpu->vcpu_fd, KVM_SET_ONE_REG, ®) < 0)
851e0c135aSWill Deacon die_perror("KVM_SET_ONE_REG failed (pc)");
861e0c135aSWill Deacon }
871e0c135aSWill Deacon
reset_vcpu_aarch64(struct kvm_cpu * vcpu)881e0c135aSWill Deacon static void reset_vcpu_aarch64(struct kvm_cpu *vcpu)
891e0c135aSWill Deacon {
901e0c135aSWill Deacon struct kvm *kvm = vcpu->kvm;
911e0c135aSWill Deacon struct kvm_one_reg reg;
921e0c135aSWill Deacon u64 data;
931e0c135aSWill Deacon
941e0c135aSWill Deacon reg.addr = (u64)&data;
951e0c135aSWill Deacon
961e0c135aSWill Deacon /* pstate = all interrupts masked */
971e0c135aSWill Deacon data = PSR_D_BIT | PSR_A_BIT | PSR_I_BIT | PSR_F_BIT | PSR_MODE_EL1h;
981e0c135aSWill Deacon reg.id = ARM64_CORE_REG(regs.pstate);
991e0c135aSWill Deacon if (ioctl(vcpu->vcpu_fd, KVM_SET_ONE_REG, ®) < 0)
1001e0c135aSWill Deacon die_perror("KVM_SET_ONE_REG failed (spsr[EL1])");
1011e0c135aSWill Deacon
1021e0c135aSWill Deacon /* x1...x3 = 0 */
1031e0c135aSWill Deacon data = 0;
1041e0c135aSWill Deacon reg.id = ARM64_CORE_REG(regs.regs[1]);
1051e0c135aSWill Deacon if (ioctl(vcpu->vcpu_fd, KVM_SET_ONE_REG, ®) < 0)
1061e0c135aSWill Deacon die_perror("KVM_SET_ONE_REG failed (x1)");
1071e0c135aSWill Deacon
1081e0c135aSWill Deacon reg.id = ARM64_CORE_REG(regs.regs[2]);
1091e0c135aSWill Deacon if (ioctl(vcpu->vcpu_fd, KVM_SET_ONE_REG, ®) < 0)
1101e0c135aSWill Deacon die_perror("KVM_SET_ONE_REG failed (x2)");
1111e0c135aSWill Deacon
1121e0c135aSWill Deacon reg.id = ARM64_CORE_REG(regs.regs[3]);
1131e0c135aSWill Deacon if (ioctl(vcpu->vcpu_fd, KVM_SET_ONE_REG, ®) < 0)
1141e0c135aSWill Deacon die_perror("KVM_SET_ONE_REG failed (x3)");
1151e0c135aSWill Deacon
1161e0c135aSWill Deacon /* Secondary cores are stopped awaiting PSCI wakeup */
1171e0c135aSWill Deacon if (vcpu->cpu_id == 0) {
1181e0c135aSWill Deacon /* x0 = physical address of the device tree blob */
1191e0c135aSWill Deacon data = kvm->arch.dtb_guest_start;
1201e0c135aSWill Deacon reg.id = ARM64_CORE_REG(regs.regs[0]);
1211e0c135aSWill Deacon if (ioctl(vcpu->vcpu_fd, KVM_SET_ONE_REG, ®) < 0)
1221e0c135aSWill Deacon die_perror("KVM_SET_ONE_REG failed (x0)");
1231e0c135aSWill Deacon
1241e0c135aSWill Deacon /* pc = start of kernel image */
1251e0c135aSWill Deacon data = kvm->arch.kern_guest_start;
1261e0c135aSWill Deacon reg.id = ARM64_CORE_REG(regs.pc);
1271e0c135aSWill Deacon if (ioctl(vcpu->vcpu_fd, KVM_SET_ONE_REG, ®) < 0)
1281e0c135aSWill Deacon die_perror("KVM_SET_ONE_REG failed (pc)");
1291e0c135aSWill Deacon }
1301e0c135aSWill Deacon }
1311e0c135aSWill Deacon
kvm_cpu__select_features(struct kvm * kvm,struct kvm_vcpu_init * init)13274c5e7b2SDave Martin void kvm_cpu__select_features(struct kvm *kvm, struct kvm_vcpu_init *init)
13374c5e7b2SDave Martin {
134412ee137SAlexandru Elisei if (kvm->cfg.arch.aarch32_guest) {
135412ee137SAlexandru Elisei if (!kvm__supports_extension(kvm, KVM_CAP_ARM_EL1_32BIT))
136412ee137SAlexandru Elisei die("32bit guests are not supported\n");
137412ee137SAlexandru Elisei init->features[0] |= 1UL << KVM_ARM_VCPU_EL1_32BIT;
138412ee137SAlexandru Elisei }
139412ee137SAlexandru Elisei
140412ee137SAlexandru Elisei if (kvm->cfg.arch.has_pmuv3) {
141412ee137SAlexandru Elisei if (!kvm__supports_extension(kvm, KVM_CAP_ARM_PMU_V3))
142412ee137SAlexandru Elisei die("PMUv3 is not supported");
143412ee137SAlexandru Elisei init->features[0] |= 1UL << KVM_ARM_VCPU_PMU_V3;
144412ee137SAlexandru Elisei }
145412ee137SAlexandru Elisei
14674c5e7b2SDave Martin /* Enable pointer authentication if available */
14774c5e7b2SDave Martin if (kvm__supports_extension(kvm, KVM_CAP_ARM_PTRAUTH_ADDRESS) &&
14874c5e7b2SDave Martin kvm__supports_extension(kvm, KVM_CAP_ARM_PTRAUTH_GENERIC)) {
14974c5e7b2SDave Martin init->features[0] |= 1UL << KVM_ARM_VCPU_PTRAUTH_ADDRESS;
15074c5e7b2SDave Martin init->features[0] |= 1UL << KVM_ARM_VCPU_PTRAUTH_GENERIC;
15174c5e7b2SDave Martin }
152a0eab49aSDave Martin
153a0eab49aSDave Martin /* Enable SVE if available */
154a0eab49aSDave Martin if (kvm__supports_extension(kvm, KVM_CAP_ARM_SVE))
155a0eab49aSDave Martin init->features[0] |= 1UL << KVM_ARM_VCPU_SVE;
156a0eab49aSDave Martin }
157a0eab49aSDave Martin
sve_vl_parser(const struct option * opt,const char * arg,int unset)158*ca31abf5SOliver Upton int sve_vl_parser(const struct option *opt, const char *arg, int unset)
159a0eab49aSDave Martin {
160*ca31abf5SOliver Upton struct kvm *kvm = opt->ptr;
161*ca31abf5SOliver Upton unsigned long val;
162*ca31abf5SOliver Upton unsigned int vq;
163*ca31abf5SOliver Upton
164*ca31abf5SOliver Upton errno = 0;
165*ca31abf5SOliver Upton val = strtoull(arg, NULL, 10);
166*ca31abf5SOliver Upton if (errno == ERANGE)
167*ca31abf5SOliver Upton die("SVE vector length too large: %s", arg);
168*ca31abf5SOliver Upton
169*ca31abf5SOliver Upton if (!val || (val & (val - 1)))
170*ca31abf5SOliver Upton die("SVE vector length isn't power of 2: %s", arg);
171*ca31abf5SOliver Upton
172*ca31abf5SOliver Upton vq = val / 128;
173*ca31abf5SOliver Upton if (vq > KVM_ARM64_SVE_VQ_MAX || vq < KVM_ARM64_SVE_VQ_MIN)
174*ca31abf5SOliver Upton die("SVE vector length out of range: %s", arg);
175*ca31abf5SOliver Upton
176*ca31abf5SOliver Upton kvm->cfg.arch.sve_max_vq = vq;
177*ca31abf5SOliver Upton return 0;
178*ca31abf5SOliver Upton }
179*ca31abf5SOliver Upton
vcpu_configure_sve(struct kvm_cpu * vcpu)180*ca31abf5SOliver Upton static int vcpu_configure_sve(struct kvm_cpu *vcpu)
181*ca31abf5SOliver Upton {
182*ca31abf5SOliver Upton unsigned int max_vq = vcpu->kvm->cfg.arch.sve_max_vq;
183a0eab49aSDave Martin int feature = KVM_ARM_VCPU_SVE;
184a0eab49aSDave Martin
185*ca31abf5SOliver Upton if (max_vq) {
186*ca31abf5SOliver Upton unsigned long vls[KVM_ARM64_SVE_VLS_WORDS];
187*ca31abf5SOliver Upton struct kvm_one_reg reg = {
188*ca31abf5SOliver Upton .id = KVM_REG_ARM64_SVE_VLS,
189*ca31abf5SOliver Upton .addr = (u64)&vls,
190*ca31abf5SOliver Upton };
191*ca31abf5SOliver Upton unsigned int vq;
192*ca31abf5SOliver Upton
193*ca31abf5SOliver Upton if (ioctl(vcpu->vcpu_fd, KVM_GET_ONE_REG, ®))
194*ca31abf5SOliver Upton die_perror("KVM_GET_ONE_REG failed (KVM_ARM64_SVE_VLS)");
195*ca31abf5SOliver Upton
196*ca31abf5SOliver Upton if (!test_bit(max_vq - KVM_ARM64_SVE_VQ_MIN, vls))
197*ca31abf5SOliver Upton die("SVE vector length (%u) not supported", max_vq * 128);
198*ca31abf5SOliver Upton
199*ca31abf5SOliver Upton for (vq = KVM_ARM64_SVE_VQ_MAX; vq > max_vq; vq--)
200*ca31abf5SOliver Upton clear_bit(vq - KVM_ARM64_SVE_VQ_MIN, vls);
201*ca31abf5SOliver Upton
202*ca31abf5SOliver Upton if (ioctl(vcpu->vcpu_fd, KVM_SET_ONE_REG, ®))
203*ca31abf5SOliver Upton die_perror("KVM_SET_ONE_REG failed (KVM_ARM64_SVE_VLS)");
204*ca31abf5SOliver Upton }
205*ca31abf5SOliver Upton
206a0eab49aSDave Martin if (ioctl(vcpu->vcpu_fd, KVM_ARM_VCPU_FINALIZE, &feature)) {
207a0eab49aSDave Martin pr_err("KVM_ARM_VCPU_FINALIZE: %s", strerror(errno));
208a0eab49aSDave Martin return -1;
209a0eab49aSDave Martin }
210*ca31abf5SOliver Upton
211*ca31abf5SOliver Upton return 0;
212a0eab49aSDave Martin }
213a0eab49aSDave Martin
kvm_cpu__configure_features(struct kvm_cpu * vcpu)214*ca31abf5SOliver Upton int kvm_cpu__configure_features(struct kvm_cpu *vcpu)
215*ca31abf5SOliver Upton {
216*ca31abf5SOliver Upton if (kvm__supports_extension(vcpu->kvm, KVM_CAP_ARM_SVE))
217*ca31abf5SOliver Upton return vcpu_configure_sve(vcpu);
218*ca31abf5SOliver Upton
219a0eab49aSDave Martin return 0;
22074c5e7b2SDave Martin }
22174c5e7b2SDave Martin
kvm_cpu__reset_vcpu(struct kvm_cpu * vcpu)2221e0c135aSWill Deacon void kvm_cpu__reset_vcpu(struct kvm_cpu *vcpu)
2231e0c135aSWill Deacon {
2248ec1e8bfSAlexandru Elisei struct kvm *kvm = vcpu->kvm;
2258ec1e8bfSAlexandru Elisei cpu_set_t *affinity;
2268ec1e8bfSAlexandru Elisei int ret;
2278ec1e8bfSAlexandru Elisei
2288ec1e8bfSAlexandru Elisei affinity = kvm->arch.vcpu_affinity_cpuset;
2298ec1e8bfSAlexandru Elisei if (affinity) {
2308ec1e8bfSAlexandru Elisei ret = sched_setaffinity(0, sizeof(cpu_set_t), affinity);
2318ec1e8bfSAlexandru Elisei if (ret == -1)
2328ec1e8bfSAlexandru Elisei die_perror("sched_setaffinity");
2338ec1e8bfSAlexandru Elisei }
2348ec1e8bfSAlexandru Elisei
2358ec1e8bfSAlexandru Elisei if (kvm->cfg.arch.aarch32_guest)
2361e0c135aSWill Deacon return reset_vcpu_aarch32(vcpu);
2371e0c135aSWill Deacon else
2381e0c135aSWill Deacon return reset_vcpu_aarch64(vcpu);
2391e0c135aSWill Deacon }
2401e0c135aSWill Deacon
kvm_cpu__get_endianness(struct kvm_cpu * vcpu)241fc9d8ec3SMarc Zyngier int kvm_cpu__get_endianness(struct kvm_cpu *vcpu)
242fc9d8ec3SMarc Zyngier {
243fc9d8ec3SMarc Zyngier struct kvm_one_reg reg;
244fc9d8ec3SMarc Zyngier u64 psr;
245fc9d8ec3SMarc Zyngier u64 sctlr;
246fc9d8ec3SMarc Zyngier
247fc9d8ec3SMarc Zyngier /*
248fc9d8ec3SMarc Zyngier * Quoting the definition given by Peter Maydell:
249fc9d8ec3SMarc Zyngier *
250fc9d8ec3SMarc Zyngier * "Endianness of the CPU which does the virtio reset at the
251fc9d8ec3SMarc Zyngier * point when it does that reset"
252fc9d8ec3SMarc Zyngier *
253fc9d8ec3SMarc Zyngier * We first check for an AArch32 guest: its endianness can
254fc9d8ec3SMarc Zyngier * change when using SETEND, which affects the CPSR.E bit.
255fc9d8ec3SMarc Zyngier *
256fc9d8ec3SMarc Zyngier * If we're AArch64, use SCTLR_EL1.E0E if access comes from
257fc9d8ec3SMarc Zyngier * EL0, and SCTLR_EL1.EE if access comes from EL1.
258fc9d8ec3SMarc Zyngier */
259fc9d8ec3SMarc Zyngier reg.id = ARM64_CORE_REG(regs.pstate);
260fc9d8ec3SMarc Zyngier reg.addr = (u64)&psr;
261fc9d8ec3SMarc Zyngier if (ioctl(vcpu->vcpu_fd, KVM_GET_ONE_REG, ®) < 0)
262fc9d8ec3SMarc Zyngier die("KVM_GET_ONE_REG failed (spsr[EL1])");
263fc9d8ec3SMarc Zyngier
264fc9d8ec3SMarc Zyngier if (psr & PSR_MODE32_BIT)
265fc9d8ec3SMarc Zyngier return (psr & COMPAT_PSR_E_BIT) ? VIRTIO_ENDIAN_BE : VIRTIO_ENDIAN_LE;
266fc9d8ec3SMarc Zyngier
267fc9d8ec3SMarc Zyngier reg.id = ARM64_SYS_REG(ARM_CPU_CTRL, ARM_CPU_CTRL_SCTLR_EL1);
268fc9d8ec3SMarc Zyngier reg.addr = (u64)&sctlr;
269fc9d8ec3SMarc Zyngier if (ioctl(vcpu->vcpu_fd, KVM_GET_ONE_REG, ®) < 0)
270fc9d8ec3SMarc Zyngier die("KVM_GET_ONE_REG failed (SCTLR_EL1)");
271fc9d8ec3SMarc Zyngier
272fc9d8ec3SMarc Zyngier if ((psr & PSR_MODE_MASK) == PSR_MODE_EL0t)
273fc9d8ec3SMarc Zyngier sctlr &= SCTLR_EL1_E0E_MASK;
274fc9d8ec3SMarc Zyngier else
275fc9d8ec3SMarc Zyngier sctlr &= SCTLR_EL1_EE_MASK;
276fc9d8ec3SMarc Zyngier return sctlr ? VIRTIO_ENDIAN_BE : VIRTIO_ENDIAN_LE;
277fc9d8ec3SMarc Zyngier }
278fc9d8ec3SMarc Zyngier
kvm_cpu__show_code(struct kvm_cpu * vcpu)2791e0c135aSWill Deacon void kvm_cpu__show_code(struct kvm_cpu *vcpu)
2801e0c135aSWill Deacon {
2811e0c135aSWill Deacon struct kvm_one_reg reg;
2821e0c135aSWill Deacon unsigned long data;
28330c31b66SWill Deacon int debug_fd = kvm_cpu__get_debug_fd();
2841e0c135aSWill Deacon
2851e0c135aSWill Deacon reg.addr = (u64)&data;
2861e0c135aSWill Deacon
28730c31b66SWill Deacon dprintf(debug_fd, "\n*pc:\n");
2881e0c135aSWill Deacon reg.id = ARM64_CORE_REG(regs.pc);
2891e0c135aSWill Deacon if (ioctl(vcpu->vcpu_fd, KVM_GET_ONE_REG, ®) < 0)
2901e0c135aSWill Deacon die("KVM_GET_ONE_REG failed (show_code @ PC)");
2911e0c135aSWill Deacon
29230c31b66SWill Deacon kvm__dump_mem(vcpu->kvm, data, 32, debug_fd);
2931e0c135aSWill Deacon
29430c31b66SWill Deacon dprintf(debug_fd, "\n*lr:\n");
2951e0c135aSWill Deacon reg.id = ARM64_CORE_REG(regs.regs[30]);
2961e0c135aSWill Deacon if (ioctl(vcpu->vcpu_fd, KVM_GET_ONE_REG, ®) < 0)
2971e0c135aSWill Deacon die("KVM_GET_ONE_REG failed (show_code @ LR)");
2981e0c135aSWill Deacon
29930c31b66SWill Deacon kvm__dump_mem(vcpu->kvm, data, 32, debug_fd);
3001e0c135aSWill Deacon }
3011e0c135aSWill Deacon
kvm_cpu__show_registers(struct kvm_cpu * vcpu)3021e0c135aSWill Deacon void kvm_cpu__show_registers(struct kvm_cpu *vcpu)
3031e0c135aSWill Deacon {
3041e0c135aSWill Deacon struct kvm_one_reg reg;
3051e0c135aSWill Deacon unsigned long data;
3061e0c135aSWill Deacon int debug_fd = kvm_cpu__get_debug_fd();
3071e0c135aSWill Deacon
3081e0c135aSWill Deacon reg.addr = (u64)&data;
3091e0c135aSWill Deacon dprintf(debug_fd, "\n Registers:\n");
3101e0c135aSWill Deacon
3111e0c135aSWill Deacon reg.id = ARM64_CORE_REG(regs.pc);
3121e0c135aSWill Deacon if (ioctl(vcpu->vcpu_fd, KVM_GET_ONE_REG, ®) < 0)
3131e0c135aSWill Deacon die("KVM_GET_ONE_REG failed (pc)");
3141e0c135aSWill Deacon dprintf(debug_fd, " PC: 0x%lx\n", data);
3151e0c135aSWill Deacon
3161e0c135aSWill Deacon reg.id = ARM64_CORE_REG(regs.pstate);
3171e0c135aSWill Deacon if (ioctl(vcpu->vcpu_fd, KVM_GET_ONE_REG, ®) < 0)
3181e0c135aSWill Deacon die("KVM_GET_ONE_REG failed (pstate)");
3191e0c135aSWill Deacon dprintf(debug_fd, " PSTATE: 0x%lx\n", data);
3201e0c135aSWill Deacon
3211e0c135aSWill Deacon reg.id = ARM64_CORE_REG(sp_el1);
3221e0c135aSWill Deacon if (ioctl(vcpu->vcpu_fd, KVM_GET_ONE_REG, ®) < 0)
3231e0c135aSWill Deacon die("KVM_GET_ONE_REG failed (sp_el1)");
3241e0c135aSWill Deacon dprintf(debug_fd, " SP_EL1: 0x%lx\n", data);
3251e0c135aSWill Deacon
3261e0c135aSWill Deacon reg.id = ARM64_CORE_REG(regs.regs[30]);
3271e0c135aSWill Deacon if (ioctl(vcpu->vcpu_fd, KVM_GET_ONE_REG, ®) < 0)
3281e0c135aSWill Deacon die("KVM_GET_ONE_REG failed (lr)");
3291e0c135aSWill Deacon dprintf(debug_fd, " LR: 0x%lx\n", data);
3301e0c135aSWill Deacon }
331