From: Paolo Bonzini Date: Thu, 4 Aug 2016 11:59:56 +0000 (+0200) Subject: Merge tag 'kvm-arm-for-4.8-take2' of git://git.kernel.org/pub/scm/linux/kernel/git... X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=6f49b2f3414622d3e41135a65dac98968956662b;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git Merge tag 'kvm-arm-for-4.8-take2' of git://git./linux/kernel/git/kvmarm/kvmarm into HEAD KVM/ARM Changes for v4.8 - Take 2 Includes GSI routing support to go along with the new VGIC and a small fix that has been cooking in -next for a while. --- 6f49b2f3414622d3e41135a65dac98968956662b diff --cc Documentation/virtual/kvm/api.txt index 5237e1b2fd66,7a04216d7278..da3c395ed174 --- a/Documentation/virtual/kvm/api.txt +++ b/Documentation/virtual/kvm/api.txt @@@ -1468,7 -1471,11 +1471,13 @@@ struct kvm_irq_routing_entry #define KVM_IRQ_ROUTING_S390_ADAPTER 3 #define KVM_IRQ_ROUTING_HV_SINT 4 - No flags are specified so far, the corresponding field must be set to zero. + flags: -- KVM_MSI_VALID_DEVID: used along with KVM_IRQ_ROUTING_MSI - routing entry type, specifies that the devid field contains - a valid value. ++- KVM_MSI_VALID_DEVID: used along with KVM_IRQ_ROUTING_MSI routing entry ++ type, specifies that the devid field contains a valid value. The per-VM ++ KVM_CAP_MSI_DEVID capability advertises the requirement to provide ++ the device ID. If this capability is not available, userspace should ++ never set the KVM_MSI_VALID_DEVID flag as the ioctl might fail. + - zero otherwise struct kvm_irq_routing_irqchip { __u32 irqchip; @@@ -1479,13 -1486,19 +1488,20 @@@ struct kvm_irq_routing_msi __u32 address_lo; __u32 address_hi; __u32 data; - __u32 pad; + union { + __u32 pad; + __u32 devid; + }; }; -devid: If KVM_MSI_VALID_DEVID is set, contains a unique device identifier - for the device that wrote the MSI message. - For PCI, this is usually a BFD identifier in the lower 16 bits. ++If KVM_MSI_VALID_DEVID is set, devid contains a unique device identifier ++for the device that wrote the MSI message. For PCI, this is usually a ++BFD identifier in the lower 16 bits. + -The per-VM KVM_CAP_MSI_DEVID capability advertises the requirement to -provide the device ID. If this capability is not set, userland cannot -rely on the kernel to allow the KVM_MSI_VALID_DEVID flag being set. +On x86, address_hi is ignored unless the KVM_X2APIC_API_USE_32BIT_IDS +feature of KVM_CAP_X2APIC_API capability is enabled. If it is enabled, +address_hi bits 31-8 provide bits 31-8 of the destination id. Bits 7-0 of +address_hi must be zero. struct kvm_irq_routing_s390_adapter { __u64 ind_addr; @@@ -2199,18 -2197,14 +2215,18 @@@ struct kvm_msi __u8 pad[12]; }; --flags: KVM_MSI_VALID_DEVID: devid contains a valid value --devid: If KVM_MSI_VALID_DEVID is set, contains a unique device identifier -- for the device that wrote the MSI message. -- For PCI, this is usually a BFD identifier in the lower 16 bits. ++flags: KVM_MSI_VALID_DEVID: devid contains a valid value. The per-VM ++ KVM_CAP_MSI_DEVID capability advertises the requirement to provide ++ the device ID. If this capability is not available, userspace ++ should never set the KVM_MSI_VALID_DEVID flag as the ioctl might fail. --The per-VM KVM_CAP_MSI_DEVID capability advertises the need to provide --the device ID. If this capability is not set, userland cannot rely on --the kernel to allow the KVM_MSI_VALID_DEVID flag being set. ++If KVM_MSI_VALID_DEVID is set, devid contains a unique device identifier ++for the device that wrote the MSI message. For PCI, this is usually a ++BFD identifier in the lower 16 bits. + +On x86, address_hi is ignored unless the KVM_CAP_X2APIC_API capability is +enabled. If it is enabled, address_hi bits 31-8 provide bits 31-8 of the +destination id. Bits 7-0 of address_hi must be zero. 4.71 KVM_CREATE_PIT2 diff --cc virt/kvm/irqchip.c index df99e9c3b64d,c6202199e505..3bcc9990adf7 --- a/virt/kvm/irqchip.c +++ b/virt/kvm/irqchip.c @@@ -208,15 -208,19 +209,19 @@@ int kvm_set_irq_routing(struct kvm *kvm goto out; r = -EINVAL; - if (ue->flags) { - kfree(e); - goto out; + switch (ue->type) { + case KVM_IRQ_ROUTING_MSI: + if (ue->flags & ~KVM_MSI_VALID_DEVID) + goto free_entry; + break; + default: + if (ue->flags) + goto free_entry; + break; } - r = setup_routing_entry(new, e, ue); + r = setup_routing_entry(kvm, new, e, ue); - if (r) { - kfree(e); - goto out; - } + if (r) + goto free_entry; ++ue; }