aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/kvm/arm.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/kvm/arm.c')
-rw-r--r--arch/arm/kvm/arm.c39
1 files changed, 11 insertions, 28 deletions
diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c
index a99e0cdf8ba2..9e193c8a959e 100644
--- a/arch/arm/kvm/arm.c
+++ b/arch/arm/kvm/arm.c
@@ -82,12 +82,12 @@ struct kvm_vcpu *kvm_arm_get_running_vcpu(void)
82/** 82/**
83 * kvm_arm_get_running_vcpus - get the per-CPU array of currently running vcpus. 83 * kvm_arm_get_running_vcpus - get the per-CPU array of currently running vcpus.
84 */ 84 */
85struct kvm_vcpu __percpu **kvm_get_running_vcpus(void) 85struct kvm_vcpu * __percpu *kvm_get_running_vcpus(void)
86{ 86{
87 return &kvm_arm_running_vcpu; 87 return &kvm_arm_running_vcpu;
88} 88}
89 89
90int kvm_arch_hardware_enable(void *garbage) 90int kvm_arch_hardware_enable(void)
91{ 91{
92 return 0; 92 return 0;
93} 93}
@@ -97,27 +97,16 @@ int kvm_arch_vcpu_should_kick(struct kvm_vcpu *vcpu)
97 return kvm_vcpu_exiting_guest_mode(vcpu) == IN_GUEST_MODE; 97 return kvm_vcpu_exiting_guest_mode(vcpu) == IN_GUEST_MODE;
98} 98}
99 99
100void kvm_arch_hardware_disable(void *garbage)
101{
102}
103
104int kvm_arch_hardware_setup(void) 100int kvm_arch_hardware_setup(void)
105{ 101{
106 return 0; 102 return 0;
107} 103}
108 104
109void kvm_arch_hardware_unsetup(void)
110{
111}
112
113void kvm_arch_check_processor_compat(void *rtn) 105void kvm_arch_check_processor_compat(void *rtn)
114{ 106{
115 *(int *)rtn = 0; 107 *(int *)rtn = 0;
116} 108}
117 109
118void kvm_arch_sync_events(struct kvm *kvm)
119{
120}
121 110
122/** 111/**
123 * kvm_arch_init_vm - initializes a VM data structure 112 * kvm_arch_init_vm - initializes a VM data structure
@@ -172,6 +161,8 @@ void kvm_arch_destroy_vm(struct kvm *kvm)
172 kvm->vcpus[i] = NULL; 161 kvm->vcpus[i] = NULL;
173 } 162 }
174 } 163 }
164
165 kvm_vgic_destroy(kvm);
175} 166}
176 167
177int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext) 168int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
@@ -188,6 +179,7 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
188 case KVM_CAP_ONE_REG: 179 case KVM_CAP_ONE_REG:
189 case KVM_CAP_ARM_PSCI: 180 case KVM_CAP_ARM_PSCI:
190 case KVM_CAP_ARM_PSCI_0_2: 181 case KVM_CAP_ARM_PSCI_0_2:
182 case KVM_CAP_READONLY_MEM:
191 r = 1; 183 r = 1;
192 break; 184 break;
193 case KVM_CAP_COALESCED_MMIO: 185 case KVM_CAP_COALESCED_MMIO:
@@ -253,6 +245,7 @@ void kvm_arch_vcpu_free(struct kvm_vcpu *vcpu)
253{ 245{
254 kvm_mmu_free_memory_caches(vcpu); 246 kvm_mmu_free_memory_caches(vcpu);
255 kvm_timer_vcpu_terminate(vcpu); 247 kvm_timer_vcpu_terminate(vcpu);
248 kvm_vgic_vcpu_destroy(vcpu);
256 kmem_cache_free(kvm_vcpu_cache, vcpu); 249 kmem_cache_free(kvm_vcpu_cache, vcpu);
257} 250}
258 251
@@ -268,26 +261,15 @@ int kvm_cpu_has_pending_timer(struct kvm_vcpu *vcpu)
268 261
269int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu) 262int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu)
270{ 263{
271 int ret;
272
273 /* Force users to call KVM_ARM_VCPU_INIT */ 264 /* Force users to call KVM_ARM_VCPU_INIT */
274 vcpu->arch.target = -1; 265 vcpu->arch.target = -1;
275 266
276 /* Set up VGIC */
277 ret = kvm_vgic_vcpu_init(vcpu);
278 if (ret)
279 return ret;
280
281 /* Set up the timer */ 267 /* Set up the timer */
282 kvm_timer_vcpu_init(vcpu); 268 kvm_timer_vcpu_init(vcpu);
283 269
284 return 0; 270 return 0;
285} 271}
286 272
287void kvm_arch_vcpu_uninit(struct kvm_vcpu *vcpu)
288{
289}
290
291void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu) 273void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
292{ 274{
293 vcpu->cpu = cpu; 275 vcpu->cpu = cpu;
@@ -427,10 +409,10 @@ static void update_vttbr(struct kvm *kvm)
427 kvm_next_vmid++; 409 kvm_next_vmid++;
428 410
429 /* update vttbr to be used with the new vmid */ 411 /* update vttbr to be used with the new vmid */
430 pgd_phys = virt_to_phys(kvm->arch.pgd); 412 pgd_phys = virt_to_phys(kvm_get_hwpgd(kvm));
413 BUG_ON(pgd_phys & ~VTTBR_BADDR_MASK);
431 vmid = ((u64)(kvm->arch.vmid) << VTTBR_VMID_SHIFT) & VTTBR_VMID_MASK; 414 vmid = ((u64)(kvm->arch.vmid) << VTTBR_VMID_SHIFT) & VTTBR_VMID_MASK;
432 kvm->arch.vttbr = pgd_phys & VTTBR_BADDR_MASK; 415 kvm->arch.vttbr = pgd_phys | vmid;
433 kvm->arch.vttbr |= vmid;
434 416
435 spin_unlock(&kvm_vmid_lock); 417 spin_unlock(&kvm_vmid_lock);
436} 418}
@@ -826,7 +808,8 @@ static int hyp_init_cpu_notify(struct notifier_block *self,
826 switch (action) { 808 switch (action) {
827 case CPU_STARTING: 809 case CPU_STARTING:
828 case CPU_STARTING_FROZEN: 810 case CPU_STARTING_FROZEN:
829 cpu_init_hyp_mode(NULL); 811 if (__hyp_get_vectors() == hyp_default_vectors)
812 cpu_init_hyp_mode(NULL);
830 break; 813 break;
831 } 814 }
832 815