···171171 int r;172172 switch (ext) {173173 case KVM_CAP_IRQCHIP:174174- case KVM_CAP_IRQFD:175174 case KVM_CAP_IOEVENTFD:176175 case KVM_CAP_DEVICE_CTRL:177176 case KVM_CAP_USER_MEMORY:···531532 kvm_vgic_flush_hwstate(vcpu);532533 kvm_timer_flush_hwstate(vcpu);533534535535+ preempt_disable();534536 local_irq_disable();535537536538 /*···544544545545 if (ret <= 0 || need_new_vmid_gen(vcpu->kvm)) {546546 local_irq_enable();547547+ preempt_enable();547548 kvm_timer_sync_hwstate(vcpu);548549 kvm_vgic_sync_hwstate(vcpu);549550 continue;···560559 ret = kvm_call_hyp(__kvm_vcpu_run, vcpu);561560562561 vcpu->mode = OUTSIDE_GUEST_MODE;563563- __kvm_guest_exit();564564- trace_kvm_exit(kvm_vcpu_trap_get_class(vcpu), *vcpu_pc(vcpu));562562+ /*563563+ * Back from guest564564+ *************************************************************/565565+565566 /*566567 * We may have taken a host interrupt in HYP mode (ie567568 * while executing the guest). This interrupt is still···577574 local_irq_enable();578575579576 /*580580- * Back from guest581581- *************************************************************/577577+ * We do local_irq_enable() before calling kvm_guest_exit() so578578+ * that if a timer interrupt hits while running the guest we579579+ * account that tick as being spent in the guest. We enable580580+ * preemption after calling kvm_guest_exit() so that if we get581581+ * preempted we make sure ticks after that is not counted as582582+ * guest time.583583+ */584584+ kvm_guest_exit();585585+ trace_kvm_exit(kvm_vcpu_trap_get_class(vcpu), *vcpu_pc(vcpu));586586+ preempt_enable();587587+582588583589 kvm_timer_sync_hwstate(vcpu);584590 kvm_vgic_sync_hwstate(vcpu);
+4-6
arch/arm/kvm/interrupts.S
···170170 @ Don't trap coprocessor accesses for host kernel171171 set_hstr vmexit172172 set_hdcr vmexit173173- set_hcptr vmexit, (HCPTR_TTA | HCPTR_TCP(10) | HCPTR_TCP(11))173173+ set_hcptr vmexit, (HCPTR_TTA | HCPTR_TCP(10) | HCPTR_TCP(11)), after_vfp_restore174174175175#ifdef CONFIG_VFPv3176176- @ Save floating point registers we if let guest use them.177177- tst r2, #(HCPTR_TCP(10) | HCPTR_TCP(11))178178- bne after_vfp_restore179179-180176 @ Switch VFP/NEON hardware state to the host's181177 add r7, vcpu, #VCPU_VFP_GUEST182178 store_vfp_state r7···184188 @ Restore FPEXC_EN which we clobbered on entry185189 pop {r2}186190 VFPFMXR FPEXC, r2191191+#else192192+after_vfp_restore:187193#endif188194189195 @ Reset Hyp-role···481483 push {r3-r7}482484483485 @ NEON/VFP used. Turn on VFP access.484484- set_hcptr vmexit, (HCPTR_TCP(10) | HCPTR_TCP(11))486486+ set_hcptr vmtrap, (HCPTR_TCP(10) | HCPTR_TCP(11))485487486488 @ Switch VFP/NEON hardware state to the guest's487489 add r7, r0, #VCPU_VFP_HOST
+18-5
arch/arm/kvm/interrupts_head.S
···412412 add r11, vcpu, #VCPU_VGIC_CPU413413414414 /* Save all interesting registers */415415- ldr r3, [r2, #GICH_HCR]416415 ldr r4, [r2, #GICH_VMCR]417416 ldr r5, [r2, #GICH_MISR]418417 ldr r6, [r2, #GICH_EISR0]···419420 ldr r8, [r2, #GICH_ELRSR0]420421 ldr r9, [r2, #GICH_ELRSR1]421422 ldr r10, [r2, #GICH_APR]422422-ARM_BE8(rev r3, r3 )423423ARM_BE8(rev r4, r4 )424424ARM_BE8(rev r5, r5 )425425ARM_BE8(rev r6, r6 )···427429ARM_BE8(rev r9, r9 )428430ARM_BE8(rev r10, r10 )429431430430- str r3, [r11, #VGIC_V2_CPU_HCR]431432 str r4, [r11, #VGIC_V2_CPU_VMCR]432433 str r5, [r11, #VGIC_V2_CPU_MISR]433434#ifdef CONFIG_CPU_ENDIAN_BE8···588591.endm589592590593/* Configures the HCPTR (Hyp Coprocessor Trap Register) on entry/return591591- * (hardware reset value is 0). Keep previous value in r2. */592592-.macro set_hcptr operation, mask594594+ * (hardware reset value is 0). Keep previous value in r2.595595+ * An ISB is emited on vmexit/vmtrap, but executed on vmexit only if596596+ * VFP wasn't already enabled (always executed on vmtrap).597597+ * If a label is specified with vmexit, it is branched to if VFP wasn't598598+ * enabled.599599+ */600600+.macro set_hcptr operation, mask, label = none593601 mrc p15, 4, r2, c1, c1, 2594602 ldr r3, =\mask595603 .if \operation == vmentry···603601 bic r3, r2, r3 @ Don't trap defined coproc-accesses604602 .endif605603 mcr p15, 4, r3, c1, c1, 2604604+ .if \operation != vmentry605605+ .if \operation == vmexit606606+ tst r2, #(HCPTR_TCP(10) | HCPTR_TCP(11))607607+ beq 1f608608+ .endif609609+ isb610610+ .if \label != none611611+ b \label612612+ .endif613613+1:614614+ .endif606615.endm607616608617/* Configures the HDCR (Hyp Debug Configuration Register) on entry/return
+2-2
arch/arm/kvm/mmu.c
···691691 * work. This is not used by the hardware and we have no692692 * alignment requirement for this allocation.693693 */694694- pgd = (pgd_t *)kmalloc(PTRS_PER_S2_PGD * sizeof(pgd_t),695695- GFP_KERNEL | __GFP_ZERO);694694+ pgd = kmalloc(PTRS_PER_S2_PGD * sizeof(pgd_t),695695+ GFP_KERNEL | __GFP_ZERO);696696697697 if (!pgd) {698698 kvm_free_hwpgd(hwpgd);
+3-13
arch/arm/kvm/psci.c
···230230 case PSCI_0_2_FN64_AFFINITY_INFO:231231 val = kvm_psci_vcpu_affinity_info(vcpu);232232 break;233233- case PSCI_0_2_FN_MIGRATE:234234- case PSCI_0_2_FN64_MIGRATE:235235- val = PSCI_RET_NOT_SUPPORTED;236236- break;237233 case PSCI_0_2_FN_MIGRATE_INFO_TYPE:238234 /*239235 * Trusted OS is MP hence does not require migration···237241 * Trusted OS is not present238242 */239243 val = PSCI_0_2_TOS_MP;240240- break;241241- case PSCI_0_2_FN_MIGRATE_INFO_UP_CPU:242242- case PSCI_0_2_FN64_MIGRATE_INFO_UP_CPU:243243- val = PSCI_RET_NOT_SUPPORTED;244244 break;245245 case PSCI_0_2_FN_SYSTEM_OFF:246246 kvm_psci_system_off(vcpu);···263271 ret = 0;264272 break;265273 default:266266- return -EINVAL;274274+ val = PSCI_RET_NOT_SUPPORTED;275275+ break;267276 }268277269278 *vcpu_reg(vcpu, 0) = val;···284291 case KVM_PSCI_FN_CPU_ON:285292 val = kvm_psci_vcpu_on(vcpu);286293 break;287287- case KVM_PSCI_FN_CPU_SUSPEND:288288- case KVM_PSCI_FN_MIGRATE:294294+ default:289295 val = PSCI_RET_NOT_SUPPORTED;290296 break;291291- default:292292- return -EINVAL;293297 }294298295299 *vcpu_reg(vcpu, 0) = val;
···897897 *898898 * KVM_IRQFD_FLAG_RESAMPLE indicates resamplefd is valid and specifies899899 * the irqfd to operate in resampling mode for level triggered interrupt900900- * emlation. See Documentation/virtual/kvm/api.txt.900900+ * emulation. See Documentation/virtual/kvm/api.txt.901901 */902902#define KVM_IRQFD_FLAG_RESAMPLE (1 << 1)903903