Pull KVM/arm fixes from Marc Zyngier as per Paulo's request at: https://lkml.kernel.org/r/21ae69a2-2546-29d0-bff6-2ea825e3d968@redhat.com "One (hopefully last) set of fixes for KVM/arm for 5.3: an embarassing MMIO emulation regression, and a UBSAN splat. Oh well... - Don't overskip instructions on MMIO emulation - Fix UBSAN splat when initializing PPI priorities" * tag 'kvmarm-fixes-for-5.3-3' of git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm: KVM: arm/arm64: VGIC: Properly initialise private IRQ affinity KVM: arm/arm64: Only skip MMIO insn once
Unified · Split
| @@ -86,6 +86,12 @@ int kvm_handle_mmio_return(struct kvm_vcpu *vcpu, struct kvm_run *run) · 85 unmodified lines | |||
| 86 | unsigned int len; | 86 | unsigned int len; |
| 87 | int mask; | 87 | int mask; |
| 88 | 88 | ||
| 89 | /* Detect an already handled MMIO return */ | ||
| 90 | if (unlikely(!vcpu->mmio_needed)) | ||
| 91 | return 0; | ||
| 92 | |||
| 93 | vcpu->mmio_needed = 0; | ||
| 94 | |||
| 89 | if (!run->mmio.is_write) { | 95 | if (!run->mmio.is_write) { |
| 90 | len = run->mmio.len; | 96 | len = run->mmio.len; |
| 91 | if (len > sizeof(unsigned long)) | 97 | if (len > sizeof(unsigned long)) |
| @@ -188,6 +194,7 @@ int io_mem_abort(struct kvm_vcpu *vcpu, struct kvm_run *run, · 96 unmodified lines | |||
| 188 | run->mmio.is_write = is_write; | 194 | run->mmio.is_write = is_write; |
| 189 | run->mmio.phys_addr = fault_ipa; | 195 | run->mmio.phys_addr = fault_ipa; |
| 190 | run->mmio.len = len; | 196 | run->mmio.len = len; |
| 197 | vcpu->mmio_needed = 1; | ||
| 191 | 198 | ||
| 192 | if (!ret) { | 199 | if (!ret) { |
| 193 | /* We handled the access successfully in the kernel. */ | 200 | /* We handled the access successfully in the kernel. */ |
| @@ -8,6 +8,7 @@ · 7 unmodified lines | |||
| 8 | #include <linux/cpu.h> | 8 | #include <linux/cpu.h> |
| 9 | #include <linux/kvm_host.h> | 9 | #include <linux/kvm_host.h> |
| 10 | #include <kvm/arm_vgic.h> | 10 | #include <kvm/arm_vgic.h> |
| 11 | #include <asm/kvm_emulate.h> | ||
| 11 | #include <asm/kvm_mmu.h> | 12 | #include <asm/kvm_mmu.h> |
| 12 | #include "vgic.h" | 13 | #include "vgic.h" |
| 13 | 14 | ||
| @@ -164,12 +165,18 @@ static int kvm_vgic_dist_init(struct kvm *kvm, unsigned int nr_spis) · 150 unmodified lines | |||
| 164 | irq->vcpu = NULL; | 165 | irq->vcpu = NULL; |
| 165 | irq->target_vcpu = vcpu0; | 166 | irq->target_vcpu = vcpu0; |
| 166 | kref_init(&irq->refcount); | 167 | kref_init(&irq->refcount); |
| 167 | if (dist->vgic_model == KVM_DEV_TYPE_ARM_VGIC_V2) { | 168 | switch (dist->vgic_model) { |
| 169 | case KVM_DEV_TYPE_ARM_VGIC_V2: | ||
| 168 | irq->targets = 0; | 170 | irq->targets = 0; |
| 169 | irq->group = 0; | 171 | irq->group = 0; |
| 170 | } else { | 172 | break; |
| 173 | case KVM_DEV_TYPE_ARM_VGIC_V3: | ||
| 171 | irq->mpidr = 0; | 174 | irq->mpidr = 0; |
| 172 | irq->group = 1; | 175 | irq->group = 1; |
| 176 | break; | ||
| 177 | default: | ||
| 178 | kfree(dist->spis); | ||
| 179 | return -EINVAL; | ||
| 173 | } | 180 | } |
| 174 | } | 181 | } |
| 175 | return 0; | 182 | return 0; |
| @@ -209,7 +216,6 @@ int kvm_vgic_vcpu_init(struct kvm_vcpu *vcpu) · 33 unmodified lines | |||
| 209 | irq->intid = i; | 216 | irq->intid = i; |
| 210 | irq->vcpu = NULL; | 217 | irq->vcpu = NULL; |
| 211 | irq->target_vcpu = vcpu; | 218 | irq->target_vcpu = vcpu; |
| 212 | irq->targets = 1U << vcpu->vcpu_id; | ||
| 213 | kref_init(&irq->refcount); | 219 | kref_init(&irq->refcount); |
| 214 | if (vgic_irq_is_sgi(i)) { | 220 | if (vgic_irq_is_sgi(i)) { |
| 215 | /* SGIs */ | 221 | /* SGIs */ |
| @@ -219,11 +225,6 @@ int kvm_vgic_vcpu_init(struct kvm_vcpu *vcpu) · 3 unmodified lines | |||
| 219 | /* PPIs */ | 225 | /* PPIs */ |
| 220 | irq->config = VGIC_CONFIG_LEVEL; | 226 | irq->config = VGIC_CONFIG_LEVEL; |
| 221 | } | 227 | } |
| 222 | |||
| 223 | if (dist->vgic_model == KVM_DEV_TYPE_ARM_VGIC_V3) | ||
| 224 | irq->group = 1; | ||
| 225 | else | ||
| 226 | irq->group = 0; | ||
| 227 | } | 228 | } |
| 228 | 229 | ||
| 229 | if (!irqchip_in_kernel(vcpu->kvm)) | 230 | if (!irqchip_in_kernel(vcpu->kvm)) |
| @@ -286,10 +287,19 @@ int vgic_init(struct kvm *kvm) · 56 unmodified lines | |||
| 286 | 287 | ||
| 287 | for (i = 0; i < VGIC_NR_PRIVATE_IRQS; i++) { | 288 | for (i = 0; i < VGIC_NR_PRIVATE_IRQS; i++) { |
| 288 | struct vgic_irq *irq = &vgic_cpu->private_irqs[i]; | 289 | struct vgic_irq *irq = &vgic_cpu->private_irqs[i]; |
| 289 | if (dist->vgic_model == KVM_DEV_TYPE_ARM_VGIC_V3) | 290 | switch (dist->vgic_model) { |
| 291 | case KVM_DEV_TYPE_ARM_VGIC_V3: | ||
| 290 | irq->group = 1; | 292 | irq->group = 1; |
| 291 | else | 293 | irq->mpidr = kvm_vcpu_get_mpidr_aff(vcpu); |
| 294 | break; | ||
| 295 | case KVM_DEV_TYPE_ARM_VGIC_V2: | ||
| 292 | irq->group = 0; | 296 | irq->group = 0; |
| 297 | irq->targets = 1U << idx; | ||
| 298 | break; | ||
| 299 | default: | ||
| 300 | ret = -EINVAL; | ||
| 301 | goto out; | ||
| 302 | } | ||
| 293 | } | 303 | } |
| 294 | } | 304 | } |
| 295 | 305 | ||