diff options
Diffstat (limited to 'arch/arm/kvm/arm.c')
-rw-r--r-- | arch/arm/kvm/arm.c | 49 |
1 files changed, 34 insertions, 15 deletions
diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c index b18165ca1d38..1d8248ea5669 100644 --- a/arch/arm/kvm/arm.c +++ b/arch/arm/kvm/arm.c | |||
@@ -138,6 +138,8 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type) | |||
138 | if (ret) | 138 | if (ret) |
139 | goto out_free_stage2_pgd; | 139 | goto out_free_stage2_pgd; |
140 | 140 | ||
141 | kvm_timer_init(kvm); | ||
142 | |||
141 | /* Mark the initial VMID generation invalid */ | 143 | /* Mark the initial VMID generation invalid */ |
142 | kvm->arch.vmid_gen = 0; | 144 | kvm->arch.vmid_gen = 0; |
143 | 145 | ||
@@ -189,6 +191,7 @@ int kvm_dev_ioctl_check_extension(long ext) | |||
189 | case KVM_CAP_IRQCHIP: | 191 | case KVM_CAP_IRQCHIP: |
190 | r = vgic_present; | 192 | r = vgic_present; |
191 | break; | 193 | break; |
194 | case KVM_CAP_DEVICE_CTRL: | ||
192 | case KVM_CAP_USER_MEMORY: | 195 | case KVM_CAP_USER_MEMORY: |
193 | case KVM_CAP_SYNC_MMU: | 196 | case KVM_CAP_SYNC_MMU: |
194 | case KVM_CAP_DESTROY_MEMORY_REGION_WORKS: | 197 | case KVM_CAP_DESTROY_MEMORY_REGION_WORKS: |
@@ -340,6 +343,13 @@ void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu) | |||
340 | 343 | ||
341 | void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu) | 344 | void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu) |
342 | { | 345 | { |
346 | /* | ||
347 | * The arch-generic KVM code expects the cpu field of a vcpu to be -1 | ||
348 | * if the vcpu is no longer assigned to a cpu. This is used for the | ||
349 | * optimized make_all_cpus_request path. | ||
350 | */ | ||
351 | vcpu->cpu = -1; | ||
352 | |||
343 | kvm_arm_set_running_vcpu(NULL); | 353 | kvm_arm_set_running_vcpu(NULL); |
344 | } | 354 | } |
345 | 355 | ||
@@ -463,6 +473,8 @@ static void update_vttbr(struct kvm *kvm) | |||
463 | 473 | ||
464 | static int kvm_vcpu_first_run_init(struct kvm_vcpu *vcpu) | 474 | static int kvm_vcpu_first_run_init(struct kvm_vcpu *vcpu) |
465 | { | 475 | { |
476 | int ret; | ||
477 | |||
466 | if (likely(vcpu->arch.has_run_once)) | 478 | if (likely(vcpu->arch.has_run_once)) |
467 | return 0; | 479 | return 0; |
468 | 480 | ||
@@ -472,22 +484,12 @@ static int kvm_vcpu_first_run_init(struct kvm_vcpu *vcpu) | |||
472 | * Initialize the VGIC before running a vcpu the first time on | 484 | * Initialize the VGIC before running a vcpu the first time on |
473 | * this VM. | 485 | * this VM. |
474 | */ | 486 | */ |
475 | if (irqchip_in_kernel(vcpu->kvm) && | 487 | if (unlikely(!vgic_initialized(vcpu->kvm))) { |
476 | unlikely(!vgic_initialized(vcpu->kvm))) { | 488 | ret = kvm_vgic_init(vcpu->kvm); |
477 | int ret = kvm_vgic_init(vcpu->kvm); | ||
478 | if (ret) | 489 | if (ret) |
479 | return ret; | 490 | return ret; |
480 | } | 491 | } |
481 | 492 | ||
482 | /* | ||
483 | * Handle the "start in power-off" case by calling into the | ||
484 | * PSCI code. | ||
485 | */ | ||
486 | if (test_and_clear_bit(KVM_ARM_VCPU_POWER_OFF, vcpu->arch.features)) { | ||
487 | *vcpu_reg(vcpu, 0) = KVM_PSCI_FN_CPU_OFF; | ||
488 | kvm_psci_call(vcpu); | ||
489 | } | ||
490 | |||
491 | return 0; | 493 | return 0; |
492 | } | 494 | } |
493 | 495 | ||
@@ -701,6 +703,24 @@ int kvm_vm_ioctl_irq_line(struct kvm *kvm, struct kvm_irq_level *irq_level, | |||
701 | return -EINVAL; | 703 | return -EINVAL; |
702 | } | 704 | } |
703 | 705 | ||
706 | static int kvm_arch_vcpu_ioctl_vcpu_init(struct kvm_vcpu *vcpu, | ||
707 | struct kvm_vcpu_init *init) | ||
708 | { | ||
709 | int ret; | ||
710 | |||
711 | ret = kvm_vcpu_set_target(vcpu, init); | ||
712 | if (ret) | ||
713 | return ret; | ||
714 | |||
715 | /* | ||
716 | * Handle the "start in power-off" case by marking the VCPU as paused. | ||
717 | */ | ||
718 | if (__test_and_clear_bit(KVM_ARM_VCPU_POWER_OFF, vcpu->arch.features)) | ||
719 | vcpu->arch.pause = true; | ||
720 | |||
721 | return 0; | ||
722 | } | ||
723 | |||
704 | long kvm_arch_vcpu_ioctl(struct file *filp, | 724 | long kvm_arch_vcpu_ioctl(struct file *filp, |
705 | unsigned int ioctl, unsigned long arg) | 725 | unsigned int ioctl, unsigned long arg) |
706 | { | 726 | { |
@@ -714,8 +734,7 @@ long kvm_arch_vcpu_ioctl(struct file *filp, | |||
714 | if (copy_from_user(&init, argp, sizeof(init))) | 734 | if (copy_from_user(&init, argp, sizeof(init))) |
715 | return -EFAULT; | 735 | return -EFAULT; |
716 | 736 | ||
717 | return kvm_vcpu_set_target(vcpu, &init); | 737 | return kvm_arch_vcpu_ioctl_vcpu_init(vcpu, &init); |
718 | |||
719 | } | 738 | } |
720 | case KVM_SET_ONE_REG: | 739 | case KVM_SET_ONE_REG: |
721 | case KVM_GET_ONE_REG: { | 740 | case KVM_GET_ONE_REG: { |
@@ -773,7 +792,7 @@ static int kvm_vm_ioctl_set_device_addr(struct kvm *kvm, | |||
773 | case KVM_ARM_DEVICE_VGIC_V2: | 792 | case KVM_ARM_DEVICE_VGIC_V2: |
774 | if (!vgic_present) | 793 | if (!vgic_present) |
775 | return -ENXIO; | 794 | return -ENXIO; |
776 | return kvm_vgic_set_addr(kvm, type, dev_addr->addr); | 795 | return kvm_vgic_addr(kvm, type, &dev_addr->addr, true); |
777 | default: | 796 | default: |
778 | return -ENODEV; | 797 | return -ENODEV; |
779 | } | 798 | } |