diff mbox

[RFC,v5,4/7] target-arm/kvm: Pass requester ID to MSI routing functions

Message ID 1470161247-10251-5-git-send-email-eric.auger@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Eric Auger Aug. 2, 2016, 6:07 p.m. UTC
From: Pavel Fedin <p.fedin@samsung.com>

Introduce global kvm_arm_msi_use_devid flag and pass device IDs in
kvm_arch_fixup_msi_route(). Device IDs are required by the ITS.

Signed-off-by: Pavel Fedin <p.fedin@samsung.com>
Signed-off-by: Eric Auger <eric.auger@redhat.com>

---

v3 -> v4:
- OR route->flags with KVM_MSI_VALID_DEVID
---
 target-arm/kvm.c     | 6 ++++++
 target-arm/kvm_arm.h | 3 +++
 2 files changed, 9 insertions(+)

Comments

Peter Maydell Aug. 12, 2016, 2:19 p.m. UTC | #1
On 2 August 2016 at 19:07, Eric Auger <eric.auger@redhat.com> wrote:
> From: Pavel Fedin <p.fedin@samsung.com>
>
> Introduce global kvm_arm_msi_use_devid flag and pass device IDs in
> kvm_arch_fixup_msi_route(). Device IDs are required by the ITS.
>
> Signed-off-by: Pavel Fedin <p.fedin@samsung.com>
> Signed-off-by: Eric Auger <eric.auger@redhat.com>
>
> ---
>
> v3 -> v4:
> - OR route->flags with KVM_MSI_VALID_DEVID
> ---
>  target-arm/kvm.c     | 6 ++++++
>  target-arm/kvm_arm.h | 3 +++
>  2 files changed, 9 insertions(+)
>
> diff --git a/target-arm/kvm.c b/target-arm/kvm.c
> index dbe393c..4675aa3 100644
> --- a/target-arm/kvm.c
> +++ b/target-arm/kvm.c
> @@ -22,6 +22,7 @@
>  #include "cpu.h"
>  #include "internals.h"
>  #include "hw/arm/arm.h"
> +#include "hw/pci/pci.h"
>  #include "exec/memattrs.h"
>  #include "hw/boards.h"
>  #include "qemu/log.h"
> @@ -31,6 +32,7 @@ const KVMCapabilityInfo kvm_arch_required_capabilities[] = {
>  };
>
>  static bool cap_has_mp_state;
> +bool kvm_arm_msi_use_devid;
>
>  int kvm_arm_vcpu_init(CPUState *cs)
>  {
> @@ -619,6 +621,10 @@ int kvm_arm_vgic_probe(void)
>  int kvm_arch_fixup_msi_route(struct kvm_irq_routing_entry *route,
>                               uint64_t address, uint32_t data, PCIDevice *dev)
>  {
> +    if (kvm_arm_msi_use_devid) {
> +        route->flags |= KVM_MSI_VALID_DEVID;
> +        route->u.msi.devid = pci_requester_id(dev);
> +    }
>      return 0;
>  }
>
> diff --git a/target-arm/kvm_arm.h b/target-arm/kvm_arm.h
> index 633d088..befcfd1 100644
> --- a/target-arm/kvm_arm.h
> +++ b/target-arm/kvm_arm.h
> @@ -121,6 +121,9 @@ bool write_kvmstate_to_list(ARMCPU *cpu);
>  void kvm_arm_reset_vcpu(ARMCPU *cpu);
>
>  #ifdef CONFIG_KVM
> +
> +extern bool kvm_arm_msi_use_devid;
> +

The kernel documentation and most of the code for this flag
isn't ARM specific, which suggests to me that we should put
the QEMU support into the non-architecture-specific files too.
That is, a flag and wrapper function like all the existing
ones in include/sysemu/kvm.h, and then put the
    if (kvm_msi_use_devid()) {
        ...
    }
in the functions in kvm-all.c that need it.

thanks
-- PMM
Eric Auger Aug. 17, 2016, 4:05 p.m. UTC | #2
Hi Peter,

On 12/08/2016 16:19, Peter Maydell wrote:
> On 2 August 2016 at 19:07, Eric Auger <eric.auger@redhat.com> wrote:
>> From: Pavel Fedin <p.fedin@samsung.com>
>>
>> Introduce global kvm_arm_msi_use_devid flag and pass device IDs in
>> kvm_arch_fixup_msi_route(). Device IDs are required by the ITS.
>>
>> Signed-off-by: Pavel Fedin <p.fedin@samsung.com>
>> Signed-off-by: Eric Auger <eric.auger@redhat.com>
>>
>> ---
>>
>> v3 -> v4:
>> - OR route->flags with KVM_MSI_VALID_DEVID
>> ---
>>  target-arm/kvm.c     | 6 ++++++
>>  target-arm/kvm_arm.h | 3 +++
>>  2 files changed, 9 insertions(+)
>>
>> diff --git a/target-arm/kvm.c b/target-arm/kvm.c
>> index dbe393c..4675aa3 100644
>> --- a/target-arm/kvm.c
>> +++ b/target-arm/kvm.c
>> @@ -22,6 +22,7 @@
>>  #include "cpu.h"
>>  #include "internals.h"
>>  #include "hw/arm/arm.h"
>> +#include "hw/pci/pci.h"
>>  #include "exec/memattrs.h"
>>  #include "hw/boards.h"
>>  #include "qemu/log.h"
>> @@ -31,6 +32,7 @@ const KVMCapabilityInfo kvm_arch_required_capabilities[] = {
>>  };
>>
>>  static bool cap_has_mp_state;
>> +bool kvm_arm_msi_use_devid;
>>
>>  int kvm_arm_vcpu_init(CPUState *cs)
>>  {
>> @@ -619,6 +621,10 @@ int kvm_arm_vgic_probe(void)
>>  int kvm_arch_fixup_msi_route(struct kvm_irq_routing_entry *route,
>>                               uint64_t address, uint32_t data, PCIDevice *dev)
>>  {
>> +    if (kvm_arm_msi_use_devid) {
>> +        route->flags |= KVM_MSI_VALID_DEVID;
>> +        route->u.msi.devid = pci_requester_id(dev);
>> +    }
>>      return 0;
>>  }
>>
>> diff --git a/target-arm/kvm_arm.h b/target-arm/kvm_arm.h
>> index 633d088..befcfd1 100644
>> --- a/target-arm/kvm_arm.h
>> +++ b/target-arm/kvm_arm.h
>> @@ -121,6 +121,9 @@ bool write_kvmstate_to_list(ARMCPU *cpu);
>>  void kvm_arm_reset_vcpu(ARMCPU *cpu);
>>
>>  #ifdef CONFIG_KVM
>> +
>> +extern bool kvm_arm_msi_use_devid;
>> +
> 
> The kernel documentation and most of the code for this flag
> isn't ARM specific, which suggests to me that we should put
> the QEMU support into the non-architecture-specific files too.
> That is, a flag and wrapper function like all the existing
> ones in include/sysemu/kvm.h, and then put the
>     if (kvm_msi_use_devid()) {
>         ...
>     }
> in the functions in kvm-all.c that need it.
OK this makes sense to me too

Thank you for your time

Best Regards

Eric
> 
> thanks
> -- PMM
>
diff mbox

Patch

diff --git a/target-arm/kvm.c b/target-arm/kvm.c
index dbe393c..4675aa3 100644
--- a/target-arm/kvm.c
+++ b/target-arm/kvm.c
@@ -22,6 +22,7 @@ 
 #include "cpu.h"
 #include "internals.h"
 #include "hw/arm/arm.h"
+#include "hw/pci/pci.h"
 #include "exec/memattrs.h"
 #include "hw/boards.h"
 #include "qemu/log.h"
@@ -31,6 +32,7 @@  const KVMCapabilityInfo kvm_arch_required_capabilities[] = {
 };
 
 static bool cap_has_mp_state;
+bool kvm_arm_msi_use_devid;
 
 int kvm_arm_vcpu_init(CPUState *cs)
 {
@@ -619,6 +621,10 @@  int kvm_arm_vgic_probe(void)
 int kvm_arch_fixup_msi_route(struct kvm_irq_routing_entry *route,
                              uint64_t address, uint32_t data, PCIDevice *dev)
 {
+    if (kvm_arm_msi_use_devid) {
+        route->flags |= KVM_MSI_VALID_DEVID;
+        route->u.msi.devid = pci_requester_id(dev);
+    }
     return 0;
 }
 
diff --git a/target-arm/kvm_arm.h b/target-arm/kvm_arm.h
index 633d088..befcfd1 100644
--- a/target-arm/kvm_arm.h
+++ b/target-arm/kvm_arm.h
@@ -121,6 +121,9 @@  bool write_kvmstate_to_list(ARMCPU *cpu);
 void kvm_arm_reset_vcpu(ARMCPU *cpu);
 
 #ifdef CONFIG_KVM
+
+extern bool kvm_arm_msi_use_devid;
+
 /**
  * kvm_arm_create_scratch_host_vcpu:
  * @cpus_to_try: array of QEMU_KVM_ARM_TARGET_* values (terminated with