Pull arm64 fixes from Will Deacon: "Two KVM/arm fixes for MMIO emulation and UBSAN. Unusually, we're routing them via the arm64 tree as per Paolo's request on the list: https://lore.kernel.org/kvm/21ae69a2-2546-29d0-bff6-2ea825e3d968@redhat.com/ We don't actually have any other arm64 fixes pending at the moment (touch wood), so I've pulled from Marc, written a merge commit, tagged the result and run it through my build/boot/bisect scripts" * tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux: 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 | 86 | unsigned int len; |
| 87 | 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 | 95 | if (!run->mmio.is_write) { |
| 90 | 96 | len = run->mmio.len; |
| 91 | 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 | 194 | run->mmio.is_write = is_write; |
| 189 | 195 | run->mmio.phys_addr = fault_ipa; |
| 190 | 196 | run->mmio.len = len; |
| 197 | + vcpu->mmio_needed = 1; | |
| 191 | 198 | |
| 192 | 199 | if (!ret) { |
| 193 | 200 | /* We handled the access successfully in the kernel. */ |
| @@ -8,6 +8,7 @@ · 7 unmodified lines | ||
| 8 | 8 | #include <linux/cpu.h> |
| 9 | 9 | #include <linux/kvm_host.h> |
| 10 | 10 | #include <kvm/arm_vgic.h> |
| 11 | +#include <asm/kvm_emulate.h> | |
| 11 | 12 | #include <asm/kvm_mmu.h> |
| 12 | 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 | 165 | irq->vcpu = NULL; |
| 165 | 166 | irq->target_vcpu = vcpu0; |
| 166 | 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 | 170 | irq->targets = 0; |
| 169 | 171 | irq->group = 0; |
| 170 | − } else { | |
| 172 | + break; | |
| 173 | + case KVM_DEV_TYPE_ARM_VGIC_V3: | |
| 171 | 174 | irq->mpidr = 0; |
| 172 | 175 | irq->group = 1; |
| 176 | + break; | |
| 177 | + default: | |
| 178 | + kfree(dist->spis); | |
| 179 | + return -EINVAL; | |
| 173 | 180 | } |
| 174 | 181 | } |
| 175 | 182 | return 0; |
| @@ -209,7 +216,6 @@ int kvm_vgic_vcpu_init(struct kvm_vcpu *vcpu) · 33 unmodified lines | ||
| 209 | 216 | irq->intid = i; |
| 210 | 217 | irq->vcpu = NULL; |
| 211 | 218 | irq->target_vcpu = vcpu; |
| 212 | − irq->targets = 1U << vcpu->vcpu_id; | |
| 213 | 219 | kref_init(&irq->refcount); |
| 214 | 220 | if (vgic_irq_is_sgi(i)) { |
| 215 | 221 | /* SGIs */ |
| @@ -219,11 +225,6 @@ int kvm_vgic_vcpu_init(struct kvm_vcpu *vcpu) · 3 unmodified lines | ||
| 219 | 225 | /* PPIs */ |
| 220 | 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 | 230 | if (!irqchip_in_kernel(vcpu->kvm)) |
| @@ -286,10 +287,19 @@ int vgic_init(struct kvm *kvm) · 56 unmodified lines | ||
| 286 | 287 | |
| 287 | 288 | for (i = 0; i < VGIC_NR_PRIVATE_IRQS; i++) { |
| 288 | 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 | 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 | 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 | |