Merge tag 'kvmarm-fixes-for-5.3-2' of git://git.kernel.org/pub/scm/linux/kernel/git...
authorPaolo Bonzini <pbonzini@redhat.com>
Fri, 9 Aug 2019 14:53:50 +0000 (16:53 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 9 Aug 2019 14:53:50 +0000 (16:53 +0200)
KVM/arm fixes for 5.3, take #2

- Fix our system register reset so that we stop writing
  non-sensical values to them, and track which registers
  get reset instead.
- Sync VMCR back from the GIC on WFI so that KVM has an
  exact vue of PMR.
- Reevaluate state of HW-mapped, level triggered interrupts
  on enable.

1  2 
virt/kvm/arm/arm.c
virt/kvm/arm/vgic/vgic.h

diff --combined virt/kvm/arm/arm.c
index 3f7bea930acff3f6cb5e3d5273385eca31645e44,482b20256fa831faa1d9b5402dd533e473b4b627..35a069815baf1a4f970e9707460d677cc0e11907
@@@ -144,6 -144,11 +144,6 @@@ out_fail_alloc
        return ret;
  }
  
 -bool kvm_arch_has_vcpu_debugfs(void)
 -{
 -      return false;
 -}
 -
  int kvm_arch_create_vcpu_debugfs(struct kvm_vcpu *vcpu)
  {
        return 0;
@@@ -318,6 -323,17 +318,17 @@@ int kvm_cpu_has_pending_timer(struct kv
  
  void kvm_arch_vcpu_blocking(struct kvm_vcpu *vcpu)
  {
+       /*
+        * If we're about to block (most likely because we've just hit a
+        * WFI), we need to sync back the state of the GIC CPU interface
+        * so that we have the lastest PMR and group enables. This ensures
+        * that kvm_arch_vcpu_runnable has up-to-date data to decide
+        * whether we have pending interrupts.
+        */
+       preempt_disable();
+       kvm_vgic_vmcr_sync(vcpu);
+       preempt_enable();
        kvm_vgic_v4_enable_doorbell(vcpu);
  }
  
@@@ -724,7 -740,7 +735,7 @@@ int kvm_arch_vcpu_ioctl_run(struct kvm_
                 * Ensure we set mode to IN_GUEST_MODE after we disable
                 * interrupts and before the final VCPU requests check.
                 * See the comment in kvm_vcpu_exiting_guest_mode() and
 -               * Documentation/virtual/kvm/vcpu-requests.rst
 +               * Documentation/virt/kvm/vcpu-requests.rst
                 */
                smp_store_mb(vcpu->mode, IN_GUEST_MODE);
  
diff --combined virt/kvm/arm/vgic/vgic.h
index 3b7525deec80e7b1e23eff1c60d971428f1d73ab,11adbdac1d56177bcab9aa471e1f5bb7307906d7..797e05004d807a1041b4711488913f78f98636bb
@@@ -42,7 -42,7 +42,7 @@@
                            VGIC_AFFINITY_LEVEL(val, 3))
  
  /*
 - * As per Documentation/virtual/kvm/devices/arm-vgic-v3.txt,
 + * As per Documentation/virt/kvm/devices/arm-vgic-v3.txt,
   * below macros are defined for CPUREG encoding.
   */
  #define KVM_REG_ARM_VGIC_SYSREG_OP0_MASK   0x000000000000c000
@@@ -63,7 -63,7 +63,7 @@@
                                      KVM_REG_ARM_VGIC_SYSREG_OP2_MASK)
  
  /*
 - * As per Documentation/virtual/kvm/devices/arm-vgic-its.txt,
 + * As per Documentation/virt/kvm/devices/arm-vgic-its.txt,
   * below macros are defined for ITS table entry encoding.
   */
  #define KVM_ITS_CTE_VALID_SHIFT               63
@@@ -193,6 -193,7 +193,7 @@@ int vgic_register_dist_iodev(struct kv
  void vgic_v2_init_lrs(void);
  void vgic_v2_load(struct kvm_vcpu *vcpu);
  void vgic_v2_put(struct kvm_vcpu *vcpu);
+ void vgic_v2_vmcr_sync(struct kvm_vcpu *vcpu);
  
  void vgic_v2_save_state(struct kvm_vcpu *vcpu);
  void vgic_v2_restore_state(struct kvm_vcpu *vcpu);
@@@ -223,6 -224,7 +224,7 @@@ bool vgic_v3_check_base(struct kvm *kvm
  
  void vgic_v3_load(struct kvm_vcpu *vcpu);
  void vgic_v3_put(struct kvm_vcpu *vcpu);
+ void vgic_v3_vmcr_sync(struct kvm_vcpu *vcpu);
  
  bool vgic_has_its(struct kvm *kvm);
  int kvm_vgic_register_its_device(void);