aboutsummaryrefslogtreecommitdiffstats
path: root/virt
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2019-05-15 17:41:43 -0400
committerPaolo Bonzini <pbonzini@redhat.com>2019-05-15 17:41:43 -0400
commitdd53f6102c30a774e0db8e55d49017a38060f6f6 (patch)
tree82ac5f5dcd56225c70516d82a1612439e8d73669 /virt
parent59c5c58c5b93285753d5c1de34d2e00039c27bc0 (diff)
parent9eecfc22e0bfc7a4c8ca007f083f0ae492d6e891 (diff)
Merge tag 'kvmarm-for-v5.2' of git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm into HEAD
KVM/arm updates for 5.2 - guest SVE support - guest Pointer Authentication support - Better discrimination of perf counters between host and guests Conflicts: include/uapi/linux/kvm.h
Diffstat (limited to 'virt')
-rw-r--r--virt/kvm/arm/arm.c40
1 files changed, 34 insertions, 6 deletions
diff --git a/virt/kvm/arm/arm.c b/virt/kvm/arm/arm.c
index be4ec5f3ba5f..e5312f47d8e1 100644
--- a/virt/kvm/arm/arm.c
+++ b/virt/kvm/arm/arm.c
@@ -56,7 +56,7 @@
56__asm__(".arch_extension virt"); 56__asm__(".arch_extension virt");
57#endif 57#endif
58 58
59DEFINE_PER_CPU(kvm_cpu_context_t, kvm_host_cpu_state); 59DEFINE_PER_CPU(kvm_host_data_t, kvm_host_data);
60static DEFINE_PER_CPU(unsigned long, kvm_arm_hyp_stack_page); 60static DEFINE_PER_CPU(unsigned long, kvm_arm_hyp_stack_page);
61 61
62/* Per-CPU variable containing the currently running vcpu. */ 62/* Per-CPU variable containing the currently running vcpu. */
@@ -357,8 +357,10 @@ int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu)
357void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu) 357void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
358{ 358{
359 int *last_ran; 359 int *last_ran;
360 kvm_host_data_t *cpu_data;
360 361
361 last_ran = this_cpu_ptr(vcpu->kvm->arch.last_vcpu_ran); 362 last_ran = this_cpu_ptr(vcpu->kvm->arch.last_vcpu_ran);
363 cpu_data = this_cpu_ptr(&kvm_host_data);
362 364
363 /* 365 /*
364 * We might get preempted before the vCPU actually runs, but 366 * We might get preempted before the vCPU actually runs, but
@@ -370,18 +372,21 @@ void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
370 } 372 }
371 373
372 vcpu->cpu = cpu; 374 vcpu->cpu = cpu;
373 vcpu->arch.host_cpu_context = this_cpu_ptr(&kvm_host_cpu_state); 375 vcpu->arch.host_cpu_context = &cpu_data->host_ctxt;
374 376
375 kvm_arm_set_running_vcpu(vcpu); 377 kvm_arm_set_running_vcpu(vcpu);
376 kvm_vgic_load(vcpu); 378 kvm_vgic_load(vcpu);
377 kvm_timer_vcpu_load(vcpu); 379 kvm_timer_vcpu_load(vcpu);
378 kvm_vcpu_load_sysregs(vcpu); 380 kvm_vcpu_load_sysregs(vcpu);
379 kvm_arch_vcpu_load_fp(vcpu); 381 kvm_arch_vcpu_load_fp(vcpu);
382 kvm_vcpu_pmu_restore_guest(vcpu);
380 383
381 if (single_task_running()) 384 if (single_task_running())
382 vcpu_clear_wfe_traps(vcpu); 385 vcpu_clear_wfe_traps(vcpu);
383 else 386 else
384 vcpu_set_wfe_traps(vcpu); 387 vcpu_set_wfe_traps(vcpu);
388
389 vcpu_ptrauth_setup_lazy(vcpu);
385} 390}
386 391
387void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu) 392void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu)
@@ -390,6 +395,7 @@ void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu)
390 kvm_vcpu_put_sysregs(vcpu); 395 kvm_vcpu_put_sysregs(vcpu);
391 kvm_timer_vcpu_put(vcpu); 396 kvm_timer_vcpu_put(vcpu);
392 kvm_vgic_put(vcpu); 397 kvm_vgic_put(vcpu);
398 kvm_vcpu_pmu_restore_host(vcpu);
393 399
394 vcpu->cpu = -1; 400 vcpu->cpu = -1;
395 401
@@ -542,6 +548,9 @@ static int kvm_vcpu_first_run_init(struct kvm_vcpu *vcpu)
542 if (likely(vcpu->arch.has_run_once)) 548 if (likely(vcpu->arch.has_run_once))
543 return 0; 549 return 0;
544 550
551 if (!kvm_arm_vcpu_is_finalized(vcpu))
552 return -EPERM;
553
545 vcpu->arch.has_run_once = true; 554 vcpu->arch.has_run_once = true;
546 555
547 if (likely(irqchip_in_kernel(kvm))) { 556 if (likely(irqchip_in_kernel(kvm))) {
@@ -1113,6 +1122,10 @@ long kvm_arch_vcpu_ioctl(struct file *filp,
1113 if (unlikely(!kvm_vcpu_initialized(vcpu))) 1122 if (unlikely(!kvm_vcpu_initialized(vcpu)))
1114 break; 1123 break;
1115 1124
1125 r = -EPERM;
1126 if (!kvm_arm_vcpu_is_finalized(vcpu))
1127 break;
1128
1116 r = -EFAULT; 1129 r = -EFAULT;
1117 if (copy_from_user(&reg_list, user_list, sizeof(reg_list))) 1130 if (copy_from_user(&reg_list, user_list, sizeof(reg_list)))
1118 break; 1131 break;
@@ -1166,6 +1179,17 @@ long kvm_arch_vcpu_ioctl(struct file *filp,
1166 1179
1167 return kvm_arm_vcpu_set_events(vcpu, &events); 1180 return kvm_arm_vcpu_set_events(vcpu, &events);
1168 } 1181 }
1182 case KVM_ARM_VCPU_FINALIZE: {
1183 int what;
1184
1185 if (!kvm_vcpu_initialized(vcpu))
1186 return -ENOEXEC;
1187
1188 if (get_user(what, (const int __user *)argp))
1189 return -EFAULT;
1190
1191 return kvm_arm_vcpu_finalize(vcpu, what);
1192 }
1169 default: 1193 default:
1170 r = -EINVAL; 1194 r = -EINVAL;
1171 } 1195 }
@@ -1546,11 +1570,11 @@ static int init_hyp_mode(void)
1546 } 1570 }
1547 1571
1548 for_each_possible_cpu(cpu) { 1572 for_each_possible_cpu(cpu) {
1549 kvm_cpu_context_t *cpu_ctxt; 1573 kvm_host_data_t *cpu_data;
1550 1574
1551 cpu_ctxt = per_cpu_ptr(&kvm_host_cpu_state, cpu); 1575 cpu_data = per_cpu_ptr(&kvm_host_data, cpu);
1552 kvm_init_host_cpu_context(cpu_ctxt, cpu); 1576 kvm_init_host_cpu_context(&cpu_data->host_ctxt, cpu);
1553 err = create_hyp_mappings(cpu_ctxt, cpu_ctxt + 1, PAGE_HYP); 1577 err = create_hyp_mappings(cpu_data, cpu_data + 1, PAGE_HYP);
1554 1578
1555 if (err) { 1579 if (err) {
1556 kvm_err("Cannot map host CPU state: %d\n", err); 1580 kvm_err("Cannot map host CPU state: %d\n", err);
@@ -1661,6 +1685,10 @@ int kvm_arch_init(void *opaque)
1661 if (err) 1685 if (err)
1662 return err; 1686 return err;
1663 1687
1688 err = kvm_arm_init_sve();
1689 if (err)
1690 return err;
1691
1664 if (!in_hyp_mode) { 1692 if (!in_hyp_mode) {
1665 err = init_hyp_mode(); 1693 err = init_hyp_mode();
1666 if (err) 1694 if (err)