vITS support
v5 cover vITS support
This series introduces support for in-kernel GICv3 ITS emulation. It is based on a kernel API which is not yet released.
Tested on Cavium ThunderX with virtio-net-pci and vhost-net with both dt and ACPI guests
Host Kernel dependencies:
- [PATCH v10 00/17] KVM: arm64: GICv3 ITS emulation
http://www.spinics.net/lists/kvm/msg135687.html
- [RFC v9 0/6] KVM: arm/arm64: gsi routing support
http://www.spinics.net/lists/kvm/msg136083.html
Guest Kernel dependencies for resp. ACPI ITS and PCIe support:
- [PATCH V7 0/8] Introduce ACPI world to ITS,
https://lkml.org/lkml/2016/6/20/321
- Support for ARM64 ACPI based PCI host controller,
https://lwn.net/Articles/690995/
Host kernel series can be found at:
https://github.com/eauger/linux/tree/v4.7-its-emul-v10-gsi-routing-v9
This QEMU series can be found at:
v5: https://github.com/eauger/qemu/tree/v2.6.0-vITS-v5
Previous versions are available at:
v4: https://github.com/eauger/qemu/tree/v2.6.0-vITS-v4
v3: https://lists.gnu.org/archive/html/qemu-devel/2015-11/msg05197.html
History:
v4 => v5:
- fix compilation issue with arm-softmmu target
- rebase on target-arm: Fix unreachable code in gicv3_class_name()
- add ACPI support
- kernel ITS init sequence is not yet similar to GICv2/V3 ones. This will be addressed in a subsequent respin.
v3 => v4:
- Took into account Peter's comments (at the exception of sub-class operation changes)
- rebase on Andre's kernel ITS emulation series v8
- rework KVM init sequence and KVM device creation/settings overall. I do not use kvm_arm_register_device due to the way the kernel API is devises (see discussion on the kernel ML)
- change the computation of the GITS_TRANSLATER base address
- fix compilation issues
- new "arget-arm: move gicv3_class_name from machine to kvm_arm.h"
v2 => v3:
- Really added unmigratable flag, was overlooked in v2
- Fixed checkpatch issue with initializing static variable to zero
/bin/bash: indent : commande introuvabledded registers and reset method
- Added unmigratable flag
- Rebased on top of current master, use kvm_arch_fixup_msi_route() now
Pavel Fedin (5):
hw/intc: Implement ITS base class
kernel: Add vGICv3 ITS definitions
kvm_arm: Pass requester ID to MSI routing functions
kvm_arm: Implement support for ITS emulation by KVM arm/virt: Add ITS to the virt board
Eric Auger (2):
target-arm: move gicv3_class_name from machine to kvm_arm.h hw/arm/virt-acpi-build: Add ITS description in ACPI MADT table
Pavel Fedin (5):
hw/intc/arm_gicv3_its: Implement ITS base class
linux-headers: update to 4.7-rc6 + ITS emulation and GSI routing target-arm/kvm: Pass requester ID to MSI routing functions hw/intc/arm_gicv3_its: Implement support for in-kernel ITS emulation arm/virt: Add ITS to the virt board
hw/arm/virt-acpi-build.c | 7 + hw/arm/virt.c | 47 ++++++- hw/intc/Makefile.objs | 2 + hw/intc/arm_gicv3_its_common.c | 155 +++++++++++++++++++++ hw/intc/arm_gicv3_its_kvm.c | 145 +++++++++++++++++++ include/hw/acpi/acpi-defs.h | 13 +- include/hw/intc/arm_gicv3_its_common.h | 75 ++++++++++ include/standard-headers/linux/input-event-codes.h | 31 +++++ include/standard-headers/linux/input.h | 1 + linux-headers/asm-arm64/kvm.h | 2 + linux-headers/linux/kvm.h | 12 +- target-arm/kvm.c | 6 + target-arm/kvm_arm.h | 38 ++++- target-arm/machine.c | 15 -- 14 files changed, 524 insertions(+), 25 deletions(-) create mode 100644 hw/intc/arm_gicv3_its_common.c create mode 100644 hw/intc/arm_gicv3_its_kvm.c create mode 100644 include/hw/intc/arm_gicv3_its_common.h
Signature · 1 line
2.5.5
RFC v5 1/7 hw/intc/arm_gicv3_its: Implement ITS base class
From: Pavel Fedin <[email protected]>
This is the basic skeleton for both KVM and software-emulated ITS. Since we already prepare status structure, we also introduce complete VMState description. But, because we currently have no migratable implementations, we also set unmigratable flag.
---
v4 -> v5:
- send_msi can return 0 meaning the MSI was rejected by guest. Handle this value as an error
v3 -> v4:
- fix compilation error
- msi_supported -> msi_nonbroken
- streamid -> requester_id
- use PRIx64
- read ops uses _with_attrs form
- 16/32b write access allowed to GITS_TRANSLATER
- move its_class_name in kvm_arm.h and remove #ifdef TARGET_AARCH64
- add new kvm device dev_fd field
- add new gits_translater_gpa field in GICv3ITSState
--- hw/intc/Makefile.objs | 1 + hw/intc/arm_gicv3_its_common.c | 155 +++++++++++++++++++++++++++++++++ include/hw/intc/arm_gicv3_its_common.h | 75 ++++++++++++++++ target-arm/kvm_arm.h | 19 ++++ 4 files changed, 250 insertions(+) create mode 100644 hw/intc/arm_gicv3_its_common.c create mode 100644 include/hw/intc/arm_gicv3_its_common.h
hw/intc/Makefile.objs +1 -0
@@ -16,6 +16,7 @@ common-obj-$(CONFIG_ARM_GIC) += arm_gicv3_common.o common-obj-$(CONFIG_ARM_GIC) += arm_gicv3.o common-obj-$(CONFIG_ARM_GIC) += arm_gicv3_dist.o common-obj-$(CONFIG_ARM_GIC) += arm_gicv3_redist.o +common-obj-$(CONFIG_ARM_GIC) += arm_gicv3_its_common.o common-obj-$(CONFIG_OPENPIC) += openpic.o obj-$(CONFIG_APIC) += apic.o apic_common.o
hw/intc/arm_gicv3_its_common.c new file +155 -0
155 lines not on this page · raw message
include/hw/intc/arm_gicv3_its_common.h new file +75 -0
75 lines not on this page · raw message
target-arm/kvm_arm.h +19 -0
@@ -255,4 +255,23 @@ struct kvm_guest_debug_arch;void kvm_arm_copy_hw_debug_data (struct kvm_guest_debug_arch *ptr); +/** +* its_class_name +* +* Return the ITS class name to use depending on whether KVM acceleration +* and KVM CAP_SIGNAL_MSI are supported +* +* Returns: class name to use or NULL +*/ +static inline const char *its_class_name (void ) +{ +if (kvm_irqchip_in_kernel ()) { +/* KVM implementation requires this capability */ +return kvm_direct_msi_enabled () ?"arm-its-kvm" :NULL ; + }else { +/* Software emulation is not implemented yet */ +return NULL ; + } +} +#endif
Signature · 1 line
2.5.5
Re: [Qemu-arm] [RFC v5 1/7] hw/intc/arm_gicv3_its: Implement ITS base class
Quoted 101 lines · Eric Auger
From: Pavel Fedin <[email protected]>
This is the basic skeleton for both KVM and software-emulated ITS. Since we already prepare status structure, we also introduce complete VMState description. But, because we currently have no migratable implementations, we also set unmigratable flag.
Signed-off-by Pavel Fedin <[email protected]>Signed-off-by Eric Auger <[email protected]>---
v4 -> v5:
-send_msican return 0 meaning the MSI was rejected by guest. Handle this value as an errorv3 -> v4:
- fix compilation error
-msi_supported->msi_nonbroken
- streamid ->requester_id
- use PRIx64
- read ops uses_with_attrsform
- 16/32b write access allowed toGITS_TRANSLATER
- moveits_class_nameinkvm_arm.hand remove #ifdefTARGET_AARCH64
- add new kvm devicedev_fdfield
- add newgits_translater_gpafield in GICv3ITSState--- hw/intc/Makefile.objs | 1 + hw/intc/arm_gicv3_its_common.c | 155 +++++++++++++++++++++++++++++++++ include/hw/intc/arm_gicv3_its_common.h | 75 ++++++++++++++++ target-arm/kvm_arm.h | 19 ++++ 4 files changed, 250 insertions(+) create mode 100644 hw/intc/arm_gicv3_its_common.c create mode 100644 include/hw/intc/arm_gicv3_its_common.hhw/intc/Makefile.objs +1
-0@@ -16,6 +16,7 @@ common-obj-$(CONFIG_ARM_GIC) += arm_gicv3_common.o common-obj-$(CONFIG_ARM_GIC) += arm_gicv3.o common-obj-$(CONFIG_ARM_GIC) += arm_gicv3_dist.o common-obj-$(CONFIG_ARM_GIC) += arm_gicv3_redist.o +common-obj-$(CONFIG_ARM_GIC) += arm_gicv3_its_common.o common-obj-$(CONFIG_OPENPIC) += openpic.o obj-$(CONFIG_APIC) += apic.o apic_common.ohw/intc/arm_gicv3_its_common.c new file +49
-0@@ -0,0 +1,155 @@ +/* +* ITS base class for a GICv3-based system +* +* Copyright (c) 2015 Samsung Electronics Co., Ltd. +* Written by Pavel Fedin +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License along +* with this program; if not, see <http://www.gnu.org/licenses/>. +*/ + +#include "qemu/osdep.h" +#include "hw/pci/msi.h" +#include "hw/intc/arm_gicv3_its_common.h" +#include "qemu/log.h" + +static void gicv3_its_pre_save (void *opaque) +{ +GICv3ITSState *s = (GICv3ITSState *)opaque; +GICv3ITSCommonClass *c =ARM_GICV3_ITS_COMMON_GET_CLASS (s); + +if (c->pre_save) { + c->pre_save (s); + } +} + +static int gicv3_its_post_load (void *opaque,int version_id) +{ +GICv3ITSState *s = (GICv3ITSState *)opaque; +GICv3ITSCommonClass *c =ARM_GICV3_ITS_COMMON_GET_CLASS (s); + +if (c->post_load) { + c->post_load (s); + } +return 0 ; +} + +static const VMStateDescription vmstate_its = { + .name ="arm_gicv3_its" , + .pre_save = gicv3_its_pre_save,
hw/intc/arm_gicv3_its_common.c line 59
Quoted 10 lines
hw/intc/arm_gicv3_its_common.c new file +10
-0+ .post_load = gicv3_its_post_load, + .fields = (VMStateField []) { +VMSTATE_UINT32 (ctlr, GICv3ITSState), +VMSTATE_UINT64 (cbaser, GICv3ITSState), +VMSTATE_UINT64 (cwriter, GICv3ITSState), +VMSTATE_UINT64 (creadr, GICv3ITSState), +VMSTATE_UINT64_ARRAY (baser, GICv3ITSState,8 ), +VMSTATE_END_OF_LIST () + }, + .unmigratable = true,
Why define the fields and also mark it unmigratable? A comment saying why the device is unmigratable would be good.
Quoted 19 lines
hw/intc/arm_gicv3_its_common.c new file +19
-0+}; + +static MemTxResult gicv3_its_trans_read (void *opaque,hwaddr offset, +uint64_t *data,unsigned size, +MemTxAttrs attrs) +{ +qemu_log_mask (LOG_GUEST_ERROR ,"ITS read at offset 0x%" PRIx64"\n" , offset); +return MEMTX_ERROR ; +} + +static MemTxResult gicv3_its_trans_write (void *opaque,hwaddr offset, +uint64_t value,unsigned size, +MemTxAttrs attrs) +{ +if (offset ==0x0040 && ((size ==2 ) || (size ==4 ))) { +GICv3ITSState *s =ARM_GICV3_ITS_COMMON (opaque); +GICv3ITSCommonClass *c =ARM_GICV3_ITS_COMMON_GET_CLASS (s); +int ret = c->send_msi (s,le64_to_cpu (value), attrs.requester_id); +
hw/intc/arm_gicv3_its_common.c line 88
Quoted 10 lines
hw/intc/arm_gicv3_its_common.c new file +10
-0+if (ret <=0 ) { +qemu_log_mask (LOG_GUEST_ERROR , +"ITS: Error sending MSI: %s\n" ,strerror (-ret)); +return MEMTX_DECODE_ERROR ; + } + +return MEMTX_OK ; + }else { +qemu_log_mask (LOG_GUEST_ERROR , +"ITS write at bad offset 0x%jX\n" , offset);
Can we be consistent about the format string used for printing hwaddrs? I suspect this one won't build on 32-bit.
Quoted 33 lines
hw/intc/arm_gicv3_its_common.c new file +33
-0+return MEMTX_DECODE_ERROR ; + } +} + +static const MemoryRegionOps gicv3_its_trans_ops = { + .read_with_attrs = gicv3_its_trans_read, + .write_with_attrs = gicv3_its_trans_write, + .endianness =DEVICE_NATIVE_ENDIAN , +}; + +void gicv3_its_init_mmio (GICv3ITSState *s,const MemoryRegionOps *ops) +{ +SysBusDevice *sbd =SYS_BUS_DEVICE (s); + +memory_region_init_io (&s->iomem_its_cntrl,OBJECT (s), ops, s, +"control" ,ITS_CONTROL_SIZE ); +memory_region_init_io (&s->iomem_its,OBJECT (s), &gicv3_its_trans_ops, s, +"translation" ,ITS_TRANS_SIZE ); + +/* Our two regions are always adjacent, therefore we now combine them +* into a single one in order to make our users' life easier. +*/ +memory_region_init (&s->iomem_main,OBJECT (s),"gicv3_its" ,ITS_SIZE ); +memory_region_add_subregion (&s->iomem_main,0 , &s->iomem_its_cntrl); +memory_region_add_subregion (&s->iomem_main,ITS_CONTROL_SIZE , + &s->iomem_its); +sysbus_init_mmio (sbd, &s->iomem_main); + + msi_nonbroken = true; +} + +static void gicv3_its_common_reset (DeviceState *dev) +{
hw/intc/arm_gicv3_its_common.c line 131
Quoted 10 lines
hw/intc/arm_gicv3_its_common.c new file +10
-0+GICv3ITSState *s =ARM_GICV3_ITS_COMMON (dev); + + s->ctlr =0 ; + s->cbaser =0 ; + s->cwriter =0 ; + s->creadr =0 ; +memset (&s->baser,0 ,sizeof (s->baser)); + +gicv3_its_post_load (s,0 ); +}
thanks
-- PMM
Re: [Qemu-arm] [RFC v5 1/7] hw/intc/arm_gicv3_its: Implement ITS base class
Hi Peter,
Quoted 107 lines · Peter Maydell
Quoted 106 lines · Eric Auger
From: Pavel Fedin <[email protected]>
This is the basic skeleton for both KVM and software-emulated ITS. Since we already prepare status structure, we also introduce complete VMState description. But, because we currently have no migratable implementations, we also set unmigratable flag.
Signed-off-by Pavel Fedin <[email protected]>Signed-off-by Eric Auger <[email protected]>---
v4 -> v5:
-send_msican return 0 meaning the MSI was rejected by guest. Handle this value as an errorv3 -> v4:
- fix compilation error
-msi_supported->msi_nonbroken
- streamid ->requester_id
- use PRIx64
- read ops uses_with_attrsform
- 16/32b write access allowed toGITS_TRANSLATER
- moveits_class_nameinkvm_arm.hand remove #ifdefTARGET_AARCH64
- add new kvm devicedev_fdfield
- add newgits_translater_gpafield in GICv3ITSState--- hw/intc/Makefile.objs | 1 + hw/intc/arm_gicv3_its_common.c | 155 +++++++++++++++++++++++++++++++++ include/hw/intc/arm_gicv3_its_common.h | 75 ++++++++++++++++ target-arm/kvm_arm.h | 19 ++++ 4 files changed, 250 insertions(+) create mode 100644 hw/intc/arm_gicv3_its_common.c create mode 100644 include/hw/intc/arm_gicv3_its_common.hhw/intc/Makefile.objs +1
-0@@ -16,6 +16,7 @@ common-obj-$(CONFIG_ARM_GIC) += arm_gicv3_common.o common-obj-$(CONFIG_ARM_GIC) += arm_gicv3.o common-obj-$(CONFIG_ARM_GIC) += arm_gicv3_dist.o common-obj-$(CONFIG_ARM_GIC) += arm_gicv3_redist.o +common-obj-$(CONFIG_ARM_GIC) += arm_gicv3_its_common.o common-obj-$(CONFIG_OPENPIC) += openpic.o obj-$(CONFIG_APIC) += apic.o apic_common.ohw/intc/arm_gicv3_its_common.c new file +54
-0@@ -0,0 +1,155 @@ +/* +* ITS base class for a GICv3-based system +* +* Copyright (c) 2015 Samsung Electronics Co., Ltd. +* Written by Pavel Fedin +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License along +* with this program; if not, see <http://www.gnu.org/licenses/>. +*/ + +#include "qemu/osdep.h" +#include "hw/pci/msi.h" +#include "hw/intc/arm_gicv3_its_common.h" +#include "qemu/log.h" + +static void gicv3_its_pre_save (void *opaque) +{ +GICv3ITSState *s = (GICv3ITSState *)opaque; +GICv3ITSCommonClass *c =ARM_GICV3_ITS_COMMON_GET_CLASS (s); + +if (c->pre_save) { + c->pre_save (s); + } +} + +static int gicv3_its_post_load (void *opaque,int version_id) +{ +GICv3ITSState *s = (GICv3ITSState *)opaque; +GICv3ITSCommonClass *c =ARM_GICV3_ITS_COMMON_GET_CLASS (s); + +if (c->post_load) { + c->post_load (s); + } +return 0 ; +} + +static const VMStateDescription vmstate_its = { + .name ="arm_gicv3_its" , + .pre_save = gicv3_its_pre_save, + .post_load = gicv3_its_post_load, + .fields = (VMStateField []) { +VMSTATE_UINT32 (ctlr, GICv3ITSState), +VMSTATE_UINT64 (cbaser, GICv3ITSState), +VMSTATE_UINT64 (cwriter, GICv3ITSState),
Quoted 8 lines
hw/intc/arm_gicv3_its_common.c line 59
Quoted 5 lines
hw/intc/arm_gicv3_its_common.c new file +5
-0+VMSTATE_UINT64 (creadr, GICv3ITSState), +VMSTATE_UINT64_ARRAY (baser, GICv3ITSState,8 ), +VMSTATE_END_OF_LIST () + }, + .unmigratable = true,Why define the fields and also mark it unmigratable? A comment saying why the device is unmigratable would be good.
Yes sure I will remove the fields and add a comment on the migration status.
Quoted 25 lines
Quoted 25 lines
hw/intc/arm_gicv3_its_common.c new file +24
-0+}; + +static MemTxResult gicv3_its_trans_read (void *opaque,hwaddr offset, +uint64_t *data,unsigned size, +MemTxAttrs attrs) +{ +qemu_log_mask (LOG_GUEST_ERROR ,"ITS read at offset 0x%" PRIx64"\n" , offset); +return MEMTX_ERROR ; +} + +static MemTxResult gicv3_its_trans_write (void *opaque,hwaddr offset, +uint64_t value,unsigned size, +MemTxAttrs attrs) +{ +if (offset ==0x0040 && ((size ==2 ) || (size ==4 ))) { +GICv3ITSState *s =ARM_GICV3_ITS_COMMON (opaque); +GICv3ITSCommonClass *c =ARM_GICV3_ITS_COMMON_GET_CLASS (s); +int ret = c->send_msi (s,le64_to_cpu (value), attrs.requester_id); + +if (ret <=0 ) { +qemu_log_mask (LOG_GUEST_ERROR , +"ITS: Error sending MSI: %s\n" ,strerror (-ret)); +return MEMTX_DECODE_ERROR ; + }
Quoted 8 lines
hw/intc/arm_gicv3_its_common.c line 88
Quoted 5 lines
hw/intc/arm_gicv3_its_common.c new file +5
-0+ +return MEMTX_OK ; + }else { +qemu_log_mask (LOG_GUEST_ERROR , +"ITS write at bad offset 0x%jX\n" , offset);Can we be consistent about the format string used for printing hwaddrs? I suspect this one won't build on 32-bit.
I will use PRIx64 instead.
Thanks
Eric
Quoted 49 lines
Quoted 34 lines
hw/intc/arm_gicv3_its_common.c new file +33
-0+return MEMTX_DECODE_ERROR ; + } +} + +static const MemoryRegionOps gicv3_its_trans_ops = { + .read_with_attrs = gicv3_its_trans_read, + .write_with_attrs = gicv3_its_trans_write, + .endianness =DEVICE_NATIVE_ENDIAN , +}; + +void gicv3_its_init_mmio (GICv3ITSState *s,const MemoryRegionOps *ops) +{ +SysBusDevice *sbd =SYS_BUS_DEVICE (s); + +memory_region_init_io (&s->iomem_its_cntrl,OBJECT (s), ops, s, +"control" ,ITS_CONTROL_SIZE ); +memory_region_init_io (&s->iomem_its,OBJECT (s), &gicv3_its_trans_ops, s, +"translation" ,ITS_TRANS_SIZE ); + +/* Our two regions are always adjacent, therefore we now combine them +* into a single one in order to make our users' life easier. +*/ +memory_region_init (&s->iomem_main,OBJECT (s),"gicv3_its" ,ITS_SIZE ); +memory_region_add_subregion (&s->iomem_main,0 , &s->iomem_its_cntrl); +memory_region_add_subregion (&s->iomem_main,ITS_CONTROL_SIZE , + &s->iomem_its); +sysbus_init_mmio (sbd, &s->iomem_main); + + msi_nonbroken = true; +} + +static void gicv3_its_common_reset (DeviceState *dev) +{hw/intc/arm_gicv3_its_common.c line 131
Quoted 10 lines
hw/intc/arm_gicv3_its_common.c new file +10
-0+GICv3ITSState *s =ARM_GICV3_ITS_COMMON (dev); + + s->ctlr =0 ; + s->cbaser =0 ; + s->cwriter =0 ; + s->creadr =0 ; +memset (&s->baser,0 ,sizeof (s->baser)); + +gicv3_its_post_load (s,0 ); +}thanks
-- PMM
RFC v5 2/7 target-arm: move gicv3_class_name from machine to kvm_arm.h
In reply to Eric AugerMachine.c contains code related to migration. Let's move gicv3_class_name to kvm_arm.h instead.
---
v4 -> v5:
- add #include "qemu/error-report.h"
- rebased on target-arm: Fix unreachable code in gicv3_class_name()
v4: creation
Conflicts:
target-arm/machine.c
--- target-arm/kvm_arm.h | 16 +++++++++++++++- target-arm/machine.c | 15 --------------- 2 files changed, 15 insertions(+), 16 deletions(-)
target-arm/kvm_arm.h +15 -1
@@ -13,6 +13,7 @@#include "sysemu/kvm.h" #include "exec/memory.h" +#include "qemu/error-report.h" /** * kvm_arm_vcpu_init:
@@ -223,7 +224,20 @@ static inline const char *gic_class_name(void)* * Returns: class name to use */ -const char *gicv3_class_name (void ); +static inline const char *gicv3_class_name (void ) +{ +if (kvm_irqchip_in_kernel ()) { +#ifdef TARGET_AARCH64 +return "kvm-arm-gicv3" ; +#else +error_report ("KVM GICv3 acceleration is not supported on this " +"platform" ); +exit (1 ); +#endif + }else { +return "arm-gicv3" ; + } +}/** * kvm_arm_handle_debug:
target-arm/machine.c +0 -15
@@ -331,18 +331,3 @@ const VMStateDescription vmstate_arm_cpu = { NULL } }; - -const char *gicv3_class_name (void ) -{ -if (kvm_irqchip_in_kernel ()) { -#ifdef TARGET_AARCH64 -return "kvm-arm-gicv3" ; -#else -error_report ("KVM GICv3 acceleration is not supported on this " -"platform" ); -exit (1 ); -#endif - }else { -return "arm-gicv3" ; - } -}
Signature · 1 line
2.5.5
Re: [Qemu-arm] [RFC v5 2/7] target-arm: move gicv3_class_name from machine to kvm_arm.h
Quoted 7 lines · Eric Auger
Machine.ccontains code related to migration. Let's movegicv3_class_nametokvm_arm.hinstead.Signed-off-by Eric Auger <[email protected]>Suggested-by Peter Maydell <[email protected]>---
thanks
-- PMM
RFC v5 3/7 linux-headers: update to 4.7-rc6 + ITS emulation and GSI routing
In reply to Eric AugerFrom: Pavel Fedin <[email protected]>
Linux header update for in-kernel ITS emulation and KVM MSI routing.
The kernel can be found at
https://github.com/eauger/linux/tree/v4.7-rc6-its-emul-v7-gsi-routing-v5
---
v4 -> v5:
- upgrade
--- include/standard-headers/linux/input-event-codes.h | 31 ++++++++++++++++++++++ include/standard-headers/linux/input.h | 1 + linux-headers/asm-arm64/kvm.h | 2 ++ linux-headers/linux/kvm.h | 12 +++++++-- 4 files changed, 44 insertions(+), 2 deletions(-)
include/standard-headers/linux/input-event-codes.h +31 -0
@@ -611,6 +611,37 @@#define KEY_KBDINPUTASSIST_ACCEPT 0x264#define KEY_KBDINPUTASSIST_CANCEL 0x265 +/* Diagonal movement keys */ +#define KEY_RIGHT_UP 0x266 +#define KEY_RIGHT_DOWN 0x267 +#define KEY_LEFT_UP 0x268 +#define KEY_LEFT_DOWN 0x269 + +#define KEY_ROOT_MENU 0x26a/* Show Device's Root Menu */ +/* Show Top Menu of the Media (e.g. DVD) */ +#define KEY_MEDIA_TOP_MENU 0x26b +#define KEY_NUMERIC_11 0x26c +#define KEY_NUMERIC_12 0x26d +/* +* Toggle Audio Description: refers to an audio service that helps blind and +* visually impaired consumers understand the action in a program. Note: in +* some countries this is referred to as "Video Description". +*/ +#define KEY_AUDIO_DESC 0x26e +#define KEY_3D_MODE 0x26f +#define KEY_NEXT_FAVORITE 0x270 +#define KEY_STOP_RECORD 0x271 +#define KEY_PAUSE_RECORD 0x272 +#define KEY_VOD 0x273/* Video on Demand */ +#define KEY_UNMUTE 0x274 +#define KEY_FASTREVERSE 0x275 +#define KEY_SLOWREVERSE 0x276 +/* +* Control a data application associated with the currently viewed channel, +* e.g. teletext or data broadcast application (MHEG, MHP, HbbTV, etc.) +*/ +#define KEY_DATA 0x275 +#define BTN_TRIGGER_HAPPY 0x2c0#define BTN_TRIGGER_HAPPY1 0x2c0#define BTN_TRIGGER_HAPPY2 0x2c1
include/standard-headers/linux/input.h +1 -0
@@ -244,6 +244,7 @@ struct input_mask {#define BUS_ATARI 0x1B#define BUS_SPI 0x1C#define BUS_RMI 0x1D +#define BUS_CEC 0x1E/* * MT_TOOL types
linux-headers/asm-arm64/kvm.h +2 -0
@@ -87,9 +87,11 @@ struct kvm_regs {/* Supported VGICv3 address types */ #define KVM_VGIC_V3_ADDR_TYPE_DIST 2#define KVM_VGIC_V3_ADDR_TYPE_REDIST 3 +#define KVM_VGIC_ITS_ADDR_TYPE 4#define KVM_VGIC_V3_DIST_SIZE SZ_64K#define KVM_VGIC_V3_REDIST_SIZE (2 * SZ_64K) +#define KVM_VGIC_V3_ITS_SIZE SZ_64K#define KVM_ARM_VCPU_POWER_OFF 0/* CPU is started in OFF state */ #define KVM_ARM_VCPU_EL1_32BIT 1/* CPU running a 32bit VM */
linux-headers/linux/kvm.h +10 -2
@@ -866,6 +866,7 @@ struct kvm_ppc_smmu_info {#define KVM_CAP_ARM_PMU_V3 126#define KVM_CAP_VCPU_ATTRIBUTES 127#define KVM_CAP_MAX_VCPU_ID 128 +#define KVM_CAP_MSI_DEVID 129#ifdef KVM_CAP_IRQ_ROUTING
@@ -878,7 +879,10 @@ struct kvm_irq_routing_msi {__u32 address_lo;__u32 address_hi;__u32 data; -__u32 pad; +union { +__u32 pad; +__u32 devid; + }; };struct kvm_irq_routing_s390_adapter {
@@ -1024,12 +1028,14 @@ struct kvm_one_reg {__u64 addr; }; +#define KVM_MSI_VALID_DEVID (1U << 0)struct kvm_msi {__u32 address_lo;__u32 address_hi;__u32 data;__u32 flags; -__u8 pad[16 ]; +__u32 devid; +__u8 pad[12 ]; };struct kvm_arm_device_addr {
@@ -1074,6 +1080,8 @@ enum kvm_device_type {#define KVM_DEV_TYPE_FLIC KVM_DEV_TYPE_FLIC KVM_DEV_TYPE_ARM_VGIC_V3,#define KVM_DEV_TYPE_ARM_VGIC_V3 KVM_DEV_TYPE_ARM_VGIC_V3 + KVM_DEV_TYPE_ARM_VGIC_ITS, +#define KVM_DEV_TYPE_ARM_VGIC_ITS KVM_DEV_TYPE_ARM_VGIC_ITS KVM_DEV_TYPE_MAX, };
Signature · 1 line
2.5.5
RFC v5 4/7 target-arm/kvm: Pass requester ID to MSI routing functions
In reply to Eric AugerFrom: Pavel Fedin <[email protected]>
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.
---
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(+)
target-arm/kvm.c +6 -0
@@ -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 ; }
target-arm/kvm_arm.h +3 -0
@@ -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
Signature · 1 line
2.5.5
Re: [Qemu-arm] [RFC v5 4/7] target-arm/kvm: Pass requester ID to MSI routing functions
Quoted 53 lines · Eric Auger
From: Pavel Fedin <[email protected]>
Introduce global
kvm_arm_msi_use_devidflag and pass device IDs inkvm_arch_fixup_msi_route(). Device IDs are required by the ITS.Signed-off-by Pavel Fedin <[email protected]>Signed-off-by Eric Auger <[email protected]>---
v3 -> v4:
- ORroute->flagswithKVM_MSI_VALID_DEVID--- target-arm/kvm.c | 6 ++++++ target-arm/kvm_arm.h | 3 +++ 2 files changed, 9 insertions(+)target-arm/kvm.c +6
-0@@ -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 ; }target-arm/kvm_arm.h +0
-0
target-arm/kvm_arm.h bool write_kvmstate_to_list(ARMCPU *cpu); · line 126
Quoted 6 lines
target-arm/kvm_arm.h +3
-0@@ -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
Re: [Qemu-devel] [RFC v5 4/7] target-arm/kvm: Pass requester ID to MSI routing functions
Hi Peter,
Quoted 66 lines · Peter Maydell
Quoted 53 lines · Eric Auger
From: Pavel Fedin <[email protected]>
Introduce global
kvm_arm_msi_use_devidflag and pass device IDs inkvm_arch_fixup_msi_route(). Device IDs are required by the ITS.Signed-off-by Pavel Fedin <[email protected]>Signed-off-by Eric Auger <[email protected]>---
v3 -> v4:
- ORroute->flagswithKVM_MSI_VALID_DEVID--- target-arm/kvm.c | 6 ++++++ target-arm/kvm_arm.h | 3 +++ 2 files changed, 9 insertions(+)target-arm/kvm.c +6
-0@@ -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 ; }target-arm/kvm_arm.h +0
-0target-arm/kvm_arm.h bool write_kvmstate_to_list(ARMCPU *cpu); · line 126
Quoted 6 lines
target-arm/kvm_arm.h +3
-0@@ -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
Quoted 4 lines
if (kvm_msi_use_devid()) { ... }in the functions in
kvm-all.cthat need it.
OK this makes sense to me too
Thank you for your time
Best Regards
Eric
Quoted 4 lines
thanks
-- PMM
RFC v5 5/7 hw/intc/arm_gicv3_its: Implement support for in-kernel ITS emulation
In reply to Eric AugerFrom: Pavel Fedin <[email protected]>
The ITS control frame is in-kernel emulated while accesses to the GITS_TRANSLATER are mediated through the KVM_SIGNAL_MSI ioctl (MSI direct MSI injection advertised by the CAP_SIGNAL_MSI capability)
the kvm_gsi_direct_mapping is explicitly set to false to emphasize the difference with GICv2M. Direct mapping cannot work with ITS since the content of the MSI data is not the target interrupt ID but an eventd id.
GSI routing is advertised (kvm_gsi_routing_allowed) as well as msi/irqfd signaling (kvm_msi_via_irqfd_allowed).
---
v3 -> v4:
- include "qemu/osdep.h" and "qapi/error.h"
- rename KVM_VGIC_V3_ADDR_TYPE_ITS into KVM_VGIC_ITS_ADDR_TYPE
- reword commit message
- change kvm_msi_via_irqfd_allowed definition (attached to irqfd dynamic availability + MSI controller availability)
- create the ITS KVM device (previously abstracted by the GICv3 KVM device)
- init sequence changed
- absolute GITS_TRANSLATER GPA stored
--- hw/intc/Makefile.objs | 1 + hw/intc/arm_gicv3_its_kvm.c | 145 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 146 insertions(+) create mode 100644 hw/intc/arm_gicv3_its_kvm.c
hw/intc/Makefile.objs +1 -0
@@ -22,6 +22,7 @@ common-obj-$(CONFIG_OPENPIC) += openpic.o obj-$(CONFIG_APIC) += apic.o apic_common.o obj-$(CONFIG_ARM_GIC_KVM) += arm_gic_kvm.o obj-$(call land,$(CONFIG_ARM_GIC_KVM),$(TARGET_AARCH64)) += arm_gicv3_kvm.o +obj-$(call land,$(CONFIG_ARM_GIC_KVM),$(TARGET_AARCH64)) += arm_gicv3_its_kvm.o obj-$(CONFIG_STELLARIS) += armv7m_nvic.o obj-$(CONFIG_EXYNOS4) += exynos4210_gic.o exynos4210_combiner.o obj-$(CONFIG_GRLIB) += grlib_irqmp.o
hw/intc/arm_gicv3_its_kvm.c new file +145 -0
145 lines not on this page · raw message
Signature · 1 line
2.5.5
Re: [Qemu-arm] [RFC v5 5/7] hw/intc/arm_gicv3_its: Implement support for in-kernel ITS emulation
Quoted 78 lines · Eric Auger
From: Pavel Fedin <[email protected]>
The ITS control frame is in-kernel emulated while accesses to the
GITS_TRANSLATERare mediated through theKVM_SIGNAL_MSIioctl (MSI direct MSI injection advertised by theCAP_SIGNAL_MSIcapability)the
kvm_gsi_direct_mappingis explicitly set to false to emphasize the difference with GICv2M. Direct mapping cannot work with ITS since the content of the MSI data is not the target interrupt ID but an eventd id.GSI routing is advertised (
kvm_gsi_routing_allowed) as well as msi/irqfd signaling (kvm_msi_via_irqfd_allowed).Signed-off-by Pavel Fedin <[email protected]>Signed-off-by Eric Auger <[email protected]>---
v3 -> v4:
- include "qemu/osdep.h" and "qapi/error.h"
- renameKVM_VGIC_V3_ADDR_TYPE_ITSintoKVM_VGIC_ITS_ADDR_TYPE
- reword commit message
- changekvm_msi_via_irqfd_alloweddefinition (attached to irqfd dynamic availability + MSI controller availability)
- create the ITS KVM device (previously abstracted by the GICv3 KVM device)
- init sequence changed
- absoluteGITS_TRANSLATERGPA stored--- hw/intc/Makefile.objs | 1 + hw/intc/arm_gicv3_its_kvm.c | 145 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 146 insertions(+) create mode 100644 hw/intc/arm_gicv3_its_kvm.chw/intc/Makefile.objs +1
-0@@ -22,6 +22,7 @@ common-obj-$(CONFIG_OPENPIC) += openpic.o obj-$(CONFIG_APIC) += apic.o apic_common.o obj-$(CONFIG_ARM_GIC_KVM) += arm_gic_kvm.o obj-$(call land,$(CONFIG_ARM_GIC_KVM),$(TARGET_AARCH64)) += arm_gicv3_kvm.o +obj-$(call land,$(CONFIG_ARM_GIC_KVM),$(TARGET_AARCH64)) += arm_gicv3_its_kvm.o obj-$(CONFIG_STELLARIS) += armv7m_nvic.o obj-$(CONFIG_EXYNOS4) += exynos4210_gic.o exynos4210_combiner.o obj-$(CONFIG_GRLIB) += grlib_irqmp.ohw/intc/arm_gicv3_its_kvm.c new file +26
-0@@ -0,0 +1,145 @@ +/* +* KVM-based ITS implementation for a GICv3-based system +* +* Copyright (c) 2015 Samsung Electronics Co., Ltd. +* Written by Pavel Fedin <[email protected]> +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, see <http://www.gnu.org/licenses/>. +*/ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "hw/intc/arm_gicv3_its_common.h" +#include "sysemu/sysemu.h" +#include "sysemu/kvm.h" +#include "kvm_arm.h"
hw/intc/arm_gicv3_its_kvm.c line 36
Quoted 10 lines
hw/intc/arm_gicv3_its_kvm.c new file +10
-0+ +#define TYPE_KVM_ARM_ITS "arm-its-kvm" +#define KVM_ARM_ITS (obj) OBJECT_CHECK(GICv3ITSState, (obj), TYPE_KVM_ARM_ITS) + +static int kvm_its_send_msi (GICv3ITSState *s,uint32_t value,uint16_t devid) +{ +struct kvm_msi msi; + + msi.address_lo = s->gits_translater_gpa &0xFFFFFFFFULL ; + msi.address_hi = s->gits_translater_gpa >>32 ;
extract64() might be preferable?
Quoted 11 lines
hw/intc/arm_gicv3_its_kvm.c new file +11
-0+ msi.data = value; + msi.flags =KVM_MSI_VALID_DEVID ; + msi.devid = devid; +memset (msi.pad,0 ,sizeof (msi.pad)); + +return kvm_vm_ioctl (kvm_state,KVM_SIGNAL_MSI , &msi); +} + +typedef struct ItsInitNotifierParams { + Notifier notifier; + GICv3ITSState *s;
hw/intc/arm_gicv3_its_kvm.c line 57
Quoted 10 lines
hw/intc/arm_gicv3_its_kvm.c new file +10
-0+} ItsInitNotifierParams; + +/** +* +* We currently do not use kvm_arm_register_device to provide +* the kernel with the vITS control frame base address since the +* KVM_DEV_ARM_VGIC_CTRL_INIT init MUST be called after the +* KVM_ARM_SET_DEVICE_ADDR and the kvm_arm_register_device +* infra does not allow this. +*/
I thought we'd fixed the kernel API so we didn't need to have this workaround?
Quoted 20 lines
hw/intc/arm_gicv3_its_kvm.c new file +20
-0+static void its_notify (Notifier *notifier,void *data) +{ +ItsInitNotifierParams *p =DO_UPCAST (ItsInitNotifierParams, + notifier, notifier); +GICv3ITSState *s = p->s; +MemoryRegion *mr = &s->iomem_its_cntrl; +MemoryRegionSection mrs; +struct kvm_device_attr attr; +uint64_t addr; +int ret; + + mrs =memory_region_find (mr,0 ,1 ); + addr = mrs.offset_within_address_space; + + attr.flags =0 ; + attr.group =KVM_DEV_ARM_VGIC_GRP_ADDR ; + attr.attr =KVM_VGIC_ITS_ADDR_TYPE ; + attr.addr = (uintptr_t )&addr; + + s->gits_translater_gpa = addr +ITS_CONTROL_SIZE +0x40 ;
hw/intc/arm_gicv3_its_kvm.c line 87
Quoted 10 lines
hw/intc/arm_gicv3_its_kvm.c new file +10
-0+ + ret =kvm_device_ioctl (s->dev_fd,KVM_SET_DEVICE_ATTR , attr); +if (ret) { +error_setg_errno (&error_fatal, -ret, +"not able to set base address for vITS ctrl frame" ); + } + +kvm_device_access (s->dev_fd,KVM_DEV_ARM_VGIC_GRP_CTRL , +KVM_DEV_ARM_VGIC_CTRL_INIT ,NULL , true); +}
thanks
-- PMM
Re: [Qemu-arm] [RFC v5 5/7] hw/intc/arm_gicv3_its: Implement support for in-kernel ITS emulation
Hi Peter,
Quoted 108 lines · Peter Maydell
Quoted 78 lines · Eric Auger
From: Pavel Fedin <[email protected]>
The ITS control frame is in-kernel emulated while accesses to the
GITS_TRANSLATERare mediated through theKVM_SIGNAL_MSIioctl (MSI direct MSI injection advertised by theCAP_SIGNAL_MSIcapability)the
kvm_gsi_direct_mappingis explicitly set to false to emphasize the difference with GICv2M. Direct mapping cannot work with ITS since the content of the MSI data is not the target interrupt ID but an eventd id.GSI routing is advertised (
kvm_gsi_routing_allowed) as well as msi/irqfd signaling (kvm_msi_via_irqfd_allowed).Signed-off-by Pavel Fedin <[email protected]>Signed-off-by Eric Auger <[email protected]>---
v3 -> v4:
- include "qemu/osdep.h" and "qapi/error.h"
- renameKVM_VGIC_V3_ADDR_TYPE_ITSintoKVM_VGIC_ITS_ADDR_TYPE
- reword commit message
- changekvm_msi_via_irqfd_alloweddefinition (attached to irqfd dynamic availability + MSI controller availability)
- create the ITS KVM device (previously abstracted by the GICv3 KVM device)
- init sequence changed
- absoluteGITS_TRANSLATERGPA stored--- hw/intc/Makefile.objs | 1 + hw/intc/arm_gicv3_its_kvm.c | 145 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 146 insertions(+) create mode 100644 hw/intc/arm_gicv3_its_kvm.chw/intc/Makefile.objs +1
-0@@ -22,6 +22,7 @@ common-obj-$(CONFIG_OPENPIC) += openpic.o obj-$(CONFIG_APIC) += apic.o apic_common.o obj-$(CONFIG_ARM_GIC_KVM) += arm_gic_kvm.o obj-$(call land,$(CONFIG_ARM_GIC_KVM),$(TARGET_AARCH64)) += arm_gicv3_kvm.o +obj-$(call land,$(CONFIG_ARM_GIC_KVM),$(TARGET_AARCH64)) += arm_gicv3_its_kvm.o obj-$(CONFIG_STELLARIS) += armv7m_nvic.o obj-$(CONFIG_EXYNOS4) += exynos4210_gic.o exynos4210_combiner.o obj-$(CONFIG_GRLIB) += grlib_irqmp.ohw/intc/arm_gicv3_its_kvm.c new file +26
-0@@ -0,0 +1,145 @@ +/* +* KVM-based ITS implementation for a GICv3-based system +* +* Copyright (c) 2015 Samsung Electronics Co., Ltd. +* Written by Pavel Fedin <[email protected]> +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, see <http://www.gnu.org/licenses/>. +*/ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "hw/intc/arm_gicv3_its_common.h" +#include "sysemu/sysemu.h" +#include "sysemu/kvm.h" +#include "kvm_arm.h" hw/intc/arm_gicv3_its_kvm.c line 36
Quoted 10 lines
hw/intc/arm_gicv3_its_kvm.c new file +10
-0+ +#define TYPE_KVM_ARM_ITS "arm-its-kvm" +#define KVM_ARM_ITS (obj) OBJECT_CHECK(GICv3ITSState, (obj), TYPE_KVM_ARM_ITS) + +static int kvm_its_send_msi (GICv3ITSState *s,uint32_t value,uint16_t devid) +{ +struct kvm_msi msi; + + msi.address_lo = s->gits_translater_gpa &0xFFFFFFFFULL ; + msi.address_hi = s->gits_translater_gpa >>32 ;
extract64()might be preferable?Quoted 16 lines
hw/intc/arm_gicv3_its_kvm.c new file +16
-0+ msi.data = value; + msi.flags =KVM_MSI_VALID_DEVID ; + msi.devid = devid; +memset (msi.pad,0 ,sizeof (msi.pad)); + +return kvm_vm_ioctl (kvm_state,KVM_SIGNAL_MSI , &msi); +} + +typedef struct ItsInitNotifierParams { +Notifier notifier; +GICv3ITSState *s; +}ItsInitNotifierParams ; + +/** +* +* We currently do not use kvm_arm_register_device to provide
Quoted 8 lines
hw/intc/arm_gicv3_its_kvm.c line 57
Quoted 5 lines
hw/intc/arm_gicv3_its_kvm.c new file +5
-0+* the kernel with the vITS control frame base address since the +* KVM_DEV_ARM_VGIC_CTRL_INIT init MUST be called after the +* KVM_ARM_SET_DEVICE_ADDR and the kvm_arm_register_device +* infra does not allow this. +*/ I thought we'd fixed the kernel API so we didn't need to have this workaround?
The kernel fixes landed in kvmarm/master so I will respin the series accordingly.
Thanks
Eric
Quoted 35 lines
Quoted 21 lines
hw/intc/arm_gicv3_its_kvm.c new file +20
-0+static void its_notify (Notifier *notifier,void *data) +{ +ItsInitNotifierParams *p =DO_UPCAST (ItsInitNotifierParams, + notifier, notifier); +GICv3ITSState *s = p->s; +MemoryRegion *mr = &s->iomem_its_cntrl; +MemoryRegionSection mrs; +struct kvm_device_attr attr; +uint64_t addr; +int ret; + + mrs =memory_region_find (mr,0 ,1 ); + addr = mrs.offset_within_address_space; + + attr.flags =0 ; + attr.group =KVM_DEV_ARM_VGIC_GRP_ADDR ; + attr.attr =KVM_VGIC_ITS_ADDR_TYPE ; + attr.addr = (uintptr_t )&addr; + + s->gits_translater_gpa = addr +ITS_CONTROL_SIZE +0x40 ;hw/intc/arm_gicv3_its_kvm.c line 87
Quoted 10 lines
hw/intc/arm_gicv3_its_kvm.c new file +10
-0+ + ret =kvm_device_ioctl (s->dev_fd,KVM_SET_DEVICE_ATTR , attr); +if (ret) { +error_setg_errno (&error_fatal, -ret, +"not able to set base address for vITS ctrl frame" ); + } + +kvm_device_access (s->dev_fd,KVM_DEV_ARM_VGIC_GRP_CTRL , +KVM_DEV_ARM_VGIC_CTRL_INIT ,NULL , true); +}thanks
-- PMM
RFC v5 6/7 arm/virt: Add ITS to the virt board
In reply to Eric AugerFrom: Pavel Fedin <[email protected]>
If supported by the configuration, ITS will be added automatically.
This patch also renames v2m_phandle to msi_phandle because it's now used by both MSI implementations.
--
v3 -> v4:
- added Peter's R-b
--- hw/arm/virt.c | 47 +++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 6 deletions(-)
hw/arm/virt.c +41 -6
@@ -76,7 +76,7 @@ typedef struct VirtBoardInfo {int fdt_size;uint32_t clock_phandle;uint32_t gic_phandle; -uint32_t v2m_phandle; +uint32_t msi_phandle;bool using_psci; } VirtBoardInfo;
@@ -423,9 +423,22 @@ static void fdt_add_cpu_nodes(const VirtBoardInfo *vbi) } } +static void fdt_add_its_gic_node (VirtBoardInfo *vbi) +{ + vbi->msi_phandle =qemu_fdt_alloc_phandle (vbi->fdt); +qemu_fdt_add_subnode (vbi->fdt,"/intc/its" ); +qemu_fdt_setprop_string (vbi->fdt,"/intc/its" ,"compatible" , +"arm,gic-v3-its" ); +qemu_fdt_setprop (vbi->fdt,"/intc/its" ,"msi-controller" ,NULL ,0 ); +qemu_fdt_setprop_sized_cells (vbi->fdt,"/intc/its" ,"reg" , +2 , vbi->memmap[VIRT_GIC_ITS ].base, +2 , vbi->memmap[VIRT_GIC_ITS ].size); +qemu_fdt_setprop_cell (vbi->fdt,"/intc/its" ,"phandle" , vbi->msi_phandle); +} +static void fdt_add_v2m_gic_node (VirtBoardInfo *vbi) { - vbi->v2m_phandle =qemu_fdt_alloc_phandle (vbi->fdt); + vbi->msi_phandle =qemu_fdt_alloc_phandle (vbi->fdt);qemu_fdt_add_subnode (vbi->fdt,"/intc/v2m" );qemu_fdt_setprop_string (vbi->fdt,"/intc/v2m" ,"compatible" ,"arm,gic-v2m-frame" );
@@ -433,7 +446,7 @@ static void fdt_add_v2m_gic_node(VirtBoardInfo *vbi)qemu_fdt_setprop_sized_cells (vbi->fdt,"/intc/v2m" ,"reg" ,2 , vbi->memmap[VIRT_GIC_V2M ].base,2 , vbi->memmap[VIRT_GIC_V2M ].size); -qemu_fdt_setprop_cell (vbi->fdt,"/intc/v2m" ,"phandle" , vbi->v2m_phandle); +qemu_fdt_setprop_cell (vbi->fdt,"/intc/v2m" ,"phandle" , vbi->msi_phandle); }static void fdt_add_gic_node (VirtBoardInfo *vbi,int type)
@@ -500,6 +513,26 @@ static void fdt_add_pmu_nodes(const VirtBoardInfo *vbi, int gictype) } } +static void create_its (VirtBoardInfo *vbi,DeviceState *gicdev) +{ +const char *itsclass =its_class_name (); +DeviceState *dev; + +if (!itsclass) { +/* Do nothing if not supported */ +return ; + } + + dev =qdev_create (NULL , itsclass); + +object_property_set_link (OBJECT (dev),OBJECT (gicdev),"parent-gicv3" , + &error_abort); +qdev_init_nofail (dev); +sysbus_mmio_map (SYS_BUS_DEVICE (dev),0 , vbi->memmap[VIRT_GIC_ITS ].base); + +fdt_add_its_gic_node (vbi); +} +static void create_v2m (VirtBoardInfo *vbi,qemu_irq *pic) {int i;
@@ -583,7 +616,9 @@ static void create_gic(VirtBoardInfo *vbi, qemu_irq *pic, int type, bool secure)fdt_add_gic_node (vbi, type); -if (type ==2 ) { +if (type ==3 ) { +create_its (vbi, gicdev); + }else {create_v2m (vbi, pic); } }
@@ -1025,9 +1060,9 @@ static void create_pcie(const VirtBoardInfo *vbi, qemu_irq *pic, nr_pcie_buses - 1);qemu_fdt_setprop (vbi->fdt, nodename,"dma-coherent" ,NULL ,0 ); -if (vbi->v2m_phandle) { +if (vbi->msi_phandle) {qemu_fdt_setprop_cells (vbi->fdt, nodename,"msi-parent" , - vbi->v2m_phandle); + vbi->msi_phandle); } qemu_fdt_setprop_sized_cells(vbi->fdt, nodename, "reg",
Signature · 1 line
2.5.5
RFC v5 7/7 hw/arm/virt-acpi-build: Add ITS description in ACPI MADT table
In reply to Eric AugerThis patch exposes the GICv3 ITS to the ACPI guest. The ITS structure is added to the MADT table.
---
v5: new
Tested with Tomasz' kernel series on guest side:
- [PATCH V7 0/8] Introduce ACPI world to ITS,
https://lkml.org/lkml/2016/6/20/321
- for running PCIe on the guest (virtio-pci-net or vhost-net) the following series is also needed, although not directly ITS:
Support for ARM64 ACPI based PCI host controller,
https://lwn.net/Articles/690995/
--- hw/arm/virt-acpi-build.c | 7 +++++++ include/hw/acpi/acpi-defs.h | 13 ++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-)
hw/arm/virt-acpi-build.c +7 -0
@@ -546,6 +546,7 @@ build_madt(GArray *table_data, BIOSLinker *linker, VirtGuestInfo *guest_info) }if (guest_info->gic_version ==3 ) { +AcpiMadtGicIts *gic_its;AcpiMadtGenericRedistributor *gicr =acpi_data_push (table_data,sizeof *gicr);
@@ -553,6 +554,12 @@ build_madt(GArray *table_data, BIOSLinker *linker, VirtGuestInfo *guest_info) gicr->length =sizeof (*gicr); gicr->base_address =cpu_to_le64 (memmap[VIRT_GIC_REDIST ].base); gicr->range_length =cpu_to_le32 (memmap[VIRT_GIC_REDIST ].size); + + gic_its =acpi_data_push (table_data,sizeof *gic_its); + gic_its->type =ACPI_APIC_ITS_STRUCTURE ; + gic_its->length =sizeof (*gic_its); + gic_its->gic_its_id =0 ; + gic_its->base_address =cpu_to_le64 (memmap[VIRT_GIC_ITS ].base); }else { gic_msi =acpi_data_push (table_data,sizeof *gic_msi); gic_msi->type =ACPI_APIC_GENERIC_MSI_FRAME ;
include/hw/acpi/acpi-defs.h +12 -1
@@ -294,7 +294,8 @@ typedef struct AcpiMultipleApicTable AcpiMultipleApicTable;#define ACPI_APIC_GENERIC_DISTRIBUTOR 12#define ACPI_APIC_GENERIC_MSI_FRAME 13#define ACPI_APIC_GENERIC_REDISTRIBUTOR 14 -#define ACPI_APIC_RESERVED 15/* 15 and greater are reserved */ +#define ACPI_APIC_ITS_STRUCTURE 15 +#define ACPI_APIC_RESERVED 16/* 16 and greater are reserved */ /* * MADT sub-structures (Follow MULTIPLE_APIC_DESCRIPTION_TABLE)
@@ -386,6 +387,16 @@ struct AcpiMadtGenericMsiFrame {typedef struct AcpiMadtGenericMsiFrame AcpiMadtGenericMsiFrame ; +struct AcpiMadtGicIts { +ACPI_SUB_HEADER_DEF + uint16_t reserved; +uint32_t gic_its_id; +uint64_t base_address; +uint32_t reserved2; +}QEMU_PACKED ; + +typedef struct AcpiMadtGicIts AcpiMadtGicIts ; +struct AcpiMadtGenericRedistributor {ACPI_SUB_HEADER_DEF uint16_t reserved;
Signature · 1 line
2.5.5
Re: [Qemu-arm] [Qemu-devel] [RFC v5 7/7] hw/arm/virt-acpi-build: Add ITS description in ACPI MADT table
Hi Eric,
Quoted 34 lines · Eric Auger
This patch exposes the GICv3 ITS to the ACPI guest. The ITS structure is added to the MADT table.
Signed-off-by Eric Auger <[email protected]>---
v5: new
Tested with Tomasz' kernel series on guest side:
- [PATCH V7 0/8] Introduce ACPI world to ITS,
https://lkml.org/lkml/2016/6/20/321
- for running PCIe on the guest (virtio-pci-net or vhost-net) the following series is also needed, although not directly ITS:
Support for ARM64 ACPI based PCI host controller,
https://lwn.net/Articles/690995/--- hw/arm/virt-acpi-build.c | 7 +++++++ include/hw/acpi/acpi-defs.h | 13 ++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-)hw/arm/virt-acpi-build.c +1
-0@@ -546,6 +546,7 @@ build_madt(GArray *table_data, BIOSLinker *linker, VirtGuestInfo *guest_info) }if (guest_info->gic_version ==3 ) { +AcpiMadtGicIts *gic_its;AcpiMadtGenericRedistributor *gicr =acpi_data_push (table_data,sizeof *gicr);
hw/arm/virt-acpi-build.c build_madt(GArray *table_data, BIOSLinker *linker, VirtGuestInfo *guest_info) · line 562
Quoted 9 lines
hw/arm/virt-acpi-build.c +6
-0@@ -553,6 +554,12 @@ build_madt(GArray *table_data, BIOSLinker *linker, VirtGuestInfo *guest_info) gicr->length =sizeof (*gicr); gicr->base_address =cpu_to_le64 (memmap[VIRT_GIC_REDIST ].base); gicr->range_length =cpu_to_le32 (memmap[VIRT_GIC_REDIST ].size); + + gic_its =acpi_data_push (table_data,sizeof *gic_its); + gic_its->type =ACPI_APIC_ITS_STRUCTURE ; + gic_its->length =sizeof (*gic_its); + gic_its->gic_its_id =0 ; + gic_its->base_address =cpu_to_le64 (memmap[VIRT_GIC_ITS ].base);
Since for TCG it doesn't support ITS yet, it should check here using its_class_name().
include/hw/acpi/acpi-defs.h typedef struct AcpiMultipleApicTable AcpiMultipleApicTable; · line 297
Quoted 13 lines
hw/arm/virt-acpi-build.c +0
-0}else { gic_msi =acpi_data_push (table_data,sizeof *gic_msi); gic_msi->type =ACPI_APIC_GENERIC_MSI_FRAME ;include/hw/acpi/acpi-defs.h +1
-1@@ -294,7 +294,8 @@ typedef struct AcpiMultipleApicTable AcpiMultipleApicTable;#define ACPI_APIC_GENERIC_DISTRIBUTOR 12#define ACPI_APIC_GENERIC_MSI_FRAME 13#define ACPI_APIC_GENERIC_REDISTRIBUTOR 14 -#define ACPI_APIC_RESERVED 15/* 15 and greater are reserved */ +#define ACPI_APIC_ITS_STRUCTURE 15
use ACPI_APIC_GENERIC_TRANSLATOR instead.
Quoted 8 lines
include/hw/acpi/acpi-defs.h +1
-0+#define ACPI_APIC_RESERVED 16/* 16 and greater are reserved */ /* * MADT sub-structures (Follow MULTIPLE_APIC_DESCRIPTION_TABLE) @@ -386,6 +387,16 @@ struct AcpiMadtGenericMsiFrame {typedef struct AcpiMadtGenericMsiFrame AcpiMadtGenericMsiFrame ;
include/hw/acpi/acpi-defs.h struct AcpiMadtGenericMsiFrame { · line 399
Quoted 10 lines
include/hw/acpi/acpi-defs.h +10
-0+struct AcpiMadtGicIts { +ACPI_SUB_HEADER_DEF + uint16_t reserved; +uint32_t gic_its_id; +uint64_t base_address; +uint32_t reserved2; +}QEMU_PACKED ; + +typedef struct AcpiMadtGicIts AcpiMadtGicIts ; +
Define it like below to respect the name in linux kernel and also keep consistent with other structures.
+struct AcpiMadtGenericTranslator {
+ ACPI_SUB_HEADER_DEF + uint16_t reserved; + uint32_t translation_id; + uint64_t base_address; + uint32_t reserved2;
+} QEMU_PACKED;
+
+typedef struct AcpiMadtGenericTranslator AcpiMadtGenericTranslator;
BTW, you could have a look at [1] which I sent before.
[1] https://lists.gnu.org/archive/html/qemu-devel/2015-11/msg06282.html
Thanks,
Signature · 1 line
Shannon
Re: [Qemu-arm] [Qemu-devel] [RFC v5 7/7] hw/arm/virt-acpi-build: Add ITS description in ACPI MADT table
Hi Shannon,
Quoted 95 lines · Shannon Zhao
Hi Eric,
Quoted 34 lines · Eric Auger
This patch exposes the GICv3 ITS to the ACPI guest. The ITS structure is added to the MADT table.
Signed-off-by Eric Auger <[email protected]>---
v5: new
Tested with Tomasz' kernel series on guest side:
- [PATCH V7 0/8] Introduce ACPI world to ITS,
https://lkml.org/lkml/2016/6/20/321
- for running PCIe on the guest (virtio-pci-net or vhost-net) the following series is also needed, although not directly ITS:
Support for ARM64 ACPI based PCI host controller,
https://lwn.net/Articles/690995/--- hw/arm/virt-acpi-build.c | 7 +++++++ include/hw/acpi/acpi-defs.h | 13 ++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-)hw/arm/virt-acpi-build.c +1
-0@@ -546,6 +546,7 @@ build_madt(GArray *table_data, BIOSLinker *linker, VirtGuestInfo *guest_info) }if (guest_info->gic_version ==3 ) { +AcpiMadtGicIts *gic_its;AcpiMadtGenericRedistributor *gicr =acpi_data_push (table_data,sizeof *gicr);hw/arm/virt-acpi-build.c build_madt(GArray *table_data, BIOSLinker *linker, VirtGuestInfo *guest_info) · line 562
Quoted 9 lines
hw/arm/virt-acpi-build.c +6
-0@@ -553,6 +554,12 @@ build_madt(GArray *table_data, BIOSLinker *linker, VirtGuestInfo *guest_info) gicr->length =sizeof (*gicr); gicr->base_address =cpu_to_le64 (memmap[VIRT_GIC_REDIST ].base); gicr->range_length =cpu_to_le32 (memmap[VIRT_GIC_REDIST ].size); + + gic_its =acpi_data_push (table_data,sizeof *gic_its); + gic_its->type =ACPI_APIC_ITS_STRUCTURE ; + gic_its->length =sizeof (*gic_its); + gic_its->gic_its_id =0 ; + gic_its->base_address =cpu_to_le64 (memmap[VIRT_GIC_ITS ].base);Since for TCG it doesn't support ITS yet, it should check here using
its_class_name().include/hw/acpi/acpi-defs.h typedef struct AcpiMultipleApicTable AcpiMultipleApicTable; · line 297
Quoted 13 lines
hw/arm/virt-acpi-build.c +0
-0}else { gic_msi =acpi_data_push (table_data,sizeof *gic_msi); gic_msi->type =ACPI_APIC_GENERIC_MSI_FRAME ;include/hw/acpi/acpi-defs.h +1
-1@@ -294,7 +294,8 @@ typedef struct AcpiMultipleApicTable AcpiMultipleApicTable;#define ACPI_APIC_GENERIC_DISTRIBUTOR 12#define ACPI_APIC_GENERIC_MSI_FRAME 13#define ACPI_APIC_GENERIC_REDISTRIBUTOR 14 -#define ACPI_APIC_RESERVED 15/* 15 and greater are reserved */ +#define ACPI_APIC_ITS_STRUCTURE 15use
ACPI_APIC_GENERIC_TRANSLATORinstead.Quoted 8 lines
include/hw/acpi/acpi-defs.h +1
-0+#define ACPI_APIC_RESERVED 16/* 16 and greater are reserved */ /* * MADT sub-structures (Follow MULTIPLE_APIC_DESCRIPTION_TABLE) @@ -386,6 +387,16 @@ struct AcpiMadtGenericMsiFrame {typedef struct AcpiMadtGenericMsiFrame AcpiMadtGenericMsiFrame ;include/hw/acpi/acpi-defs.h struct AcpiMadtGenericMsiFrame { · line 399
Quoted 10 lines
include/hw/acpi/acpi-defs.h +10
-0+struct AcpiMadtGicIts { +ACPI_SUB_HEADER_DEF + uint16_t reserved; +uint32_t gic_its_id; +uint64_t base_address; +uint32_t reserved2; +}QEMU_PACKED ; + +typedef struct AcpiMadtGicIts AcpiMadtGicIts ; +Define it like below to respect the name in linux kernel and also keep consistent with other structures.
include/hw/acpi/acpi-defs.h +9
-0+struct AcpiMadtGenericTranslator { +ACPI_SUB_HEADER_DEF + uint16_t reserved; +uint32_t translation_id; +uint64_t base_address; +uint32_t reserved2; +}QEMU_PACKED ; + +typedef struct AcpiMadtGenericTranslator AcpiMadtGenericTranslator ;
Quoted 3 lines
BTW, you could have a look at [1] which I sent before.
[1] https://lists.gnu.org/archive/html/qemu-devel/2015-11/msg06282.html
Hum sorry, please apologize. I was not aware of those. Do you want to respin or shall I respin mine taking into account your comments and changing the author. Besides, thanks for the review.
Thanks
Eric
Quoted 3 lines
Thanks,
Re: [Qemu-arm] [Qemu-devel] [RFC v5 7/7] hw/arm/virt-acpi-build: Add ITS description in ACPI MADT table
Quoted 98 lines · Auger Eric
Hi Shannon,
Quoted 95 lines · Shannon Zhao
Quoted 95 lines
Hi Eric,
Quoted 33 lines · Eric Auger
Quoted 33 lines
This patch exposes the GICv3 ITS to the ACPI guest. The ITS structure is added to the MADT table.
Signed-off-by Eric Auger <[email protected]>---
v5: new
Tested with Tomasz' kernel series on guest side:
- [PATCH V7 0/8] Introduce ACPI world to ITS,
https://lkml.org/lkml/2016/6/20/321
- for running PCIe on the guest (virtio-pci-net or vhost-net) the following series is also needed, although not directly ITS:
Support for ARM64 ACPI based PCI host controller,
https://lwn.net/Articles/690995/--- hw/arm/virt-acpi-build.c | 7 +++++++ include/hw/acpi/acpi-defs.h | 13 ++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-)hw/arm/virt-acpi-build.c +1
-0@@ -546,6 +546,7 @@ build_madt(GArray *table_data, BIOSLinker *linker, VirtGuestInfo *guest_info) }if (guest_info->gic_version ==3 ) { +AcpiMadtGicIts *gic_its;AcpiMadtGenericRedistributor *gicr =acpi_data_push (table_data,sizeof *gicr);Quoted 10 lines
hw/arm/virt-acpi-build.c build_madt(GArray *table_data, BIOSLinker *linker, VirtGuestInfo *guest_info) · line 562
Quoted 10 lines
hw/arm/virt-acpi-build.c +6
-0@@ -553,6 +554,12 @@ build_madt(GArray *table_data, BIOSLinker *linker, VirtGuestInfo *guest_info) gicr->length =sizeof (*gicr); gicr->base_address =cpu_to_le64 (memmap[VIRT_GIC_REDIST ].base); gicr->range_length =cpu_to_le32 (memmap[VIRT_GIC_REDIST ].size); + + gic_its =acpi_data_push (table_data,sizeof *gic_its); + gic_its->type =ACPI_APIC_ITS_STRUCTURE ; + gic_its->length =sizeof (*gic_its); + gic_its->gic_its_id =0 ; + gic_its->base_address =cpu_to_le64 (memmap[VIRT_GIC_ITS ].base);Since for TCG it doesn't support ITS yet, it should check here using
its_class_name().Quoted 5 lines
Quoted 5 lines
hw/arm/virt-acpi-build.c +0
-0}else { gic_msi =acpi_data_push (table_data,sizeof *gic_msi); gic_msi->type =ACPI_APIC_GENERIC_MSI_FRAME ;include/hw/acpi/acpi-defs.h +0
-0Quoted 8 lines
include/hw/acpi/acpi-defs.h typedef struct AcpiMultipleApicTable AcpiMultipleApicTable; · line 297
Quoted 8 lines
include/hw/acpi/acpi-defs.h +1
-1@@ -294,7 +294,8 @@ typedef struct AcpiMultipleApicTable AcpiMultipleApicTable;#define ACPI_APIC_GENERIC_DISTRIBUTOR 12#define ACPI_APIC_GENERIC_MSI_FRAME 13#define ACPI_APIC_GENERIC_REDISTRIBUTOR 14 -#define ACPI_APIC_RESERVED 15/* 15 and greater are reserved */ +#define ACPI_APIC_ITS_STRUCTURE 15use
ACPI_APIC_GENERIC_TRANSLATORinstead.Quoted 8 lines
Quoted 8 lines
include/hw/acpi/acpi-defs.h +1
-0+#define ACPI_APIC_RESERVED 16/* 16 and greater are reserved */ /* * MADT sub-structures (Follow MULTIPLE_APIC_DESCRIPTION_TABLE) @@ -386,6 +387,16 @@ struct AcpiMadtGenericMsiFrame {typedef struct AcpiMadtGenericMsiFrame AcpiMadtGenericMsiFrame ;Quoted 10 lines
include/hw/acpi/acpi-defs.h struct AcpiMadtGenericMsiFrame { · line 399
Quoted 10 lines
include/hw/acpi/acpi-defs.h +10
-0+struct AcpiMadtGicIts { +ACPI_SUB_HEADER_DEF + uint16_t reserved; +uint32_t gic_its_id; +uint64_t base_address; +uint32_t reserved2; +}QEMU_PACKED ; + +typedef struct AcpiMadtGicIts AcpiMadtGicIts ; +Define it like below to respect the name in linux kernel and also keep consistent with other structures.
include/hw/acpi/acpi-defs.h +9
-0+struct AcpiMadtGenericTranslator { +ACPI_SUB_HEADER_DEF + uint16_t reserved; +uint32_t translation_id; +uint64_t base_address; +uint32_t reserved2; +}QEMU_PACKED ; + +typedef struct AcpiMadtGenericTranslator AcpiMadtGenericTranslator ;
Quoted 6 lines
Quoted 3 lines
Quoted 3 lines
BTW, you could have a look at [1] which I sent before.
[1] https://lists.gnu.org/archive/html/qemu-devel/2015-11/msg06282.html
Hum sorry, please apologize. I was not aware of those. Do you want to respin or shall I respin mine taking into account your comments and changing the author. Besides, thanks for the review.
Never mind. I think you can respin yours.
Thanks,
Signature · 1 line
Shannon
Re: [Qemu-arm] [Qemu-devel] [RFC v5 7/7] hw/arm/virt-acpi-build: Add ITS description in ACPI MADT table
Hi Shannon,
Quoted 101 lines · Shannon Zhao
Quoted 98 lines · Auger Eric
Hi Shannon,
Quoted 95 lines · Shannon Zhao
Quoted 95 lines
Hi Eric,
Quoted 33 lines · Eric Auger
Quoted 33 lines
This patch exposes the GICv3 ITS to the ACPI guest. The ITS structure is added to the MADT table.
Signed-off-by Eric Auger <[email protected]>---
v5: new
Tested with Tomasz' kernel series on guest side:
- [PATCH V7 0/8] Introduce ACPI world to ITS,
https://lkml.org/lkml/2016/6/20/321
- for running PCIe on the guest (virtio-pci-net or vhost-net) the following series is also needed, although not directly ITS:
Support for ARM64 ACPI based PCI host controller,
https://lwn.net/Articles/690995/--- hw/arm/virt-acpi-build.c | 7 +++++++ include/hw/acpi/acpi-defs.h | 13 ++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-)hw/arm/virt-acpi-build.c +1
-0@@ -546,6 +546,7 @@ build_madt(GArray *table_data, BIOSLinker *linker, VirtGuestInfo *guest_info) }if (guest_info->gic_version ==3 ) { +AcpiMadtGicIts *gic_its;AcpiMadtGenericRedistributor *gicr =acpi_data_push (table_data,sizeof *gicr);Quoted 10 lines
hw/arm/virt-acpi-build.c build_madt(GArray *table_data, BIOSLinker *linker, VirtGuestInfo *guest_info) · line 562
Quoted 10 lines
hw/arm/virt-acpi-build.c +6
-0@@ -553,6 +554,12 @@ build_madt(GArray *table_data, BIOSLinker *linker, VirtGuestInfo *guest_info) gicr->length =sizeof (*gicr); gicr->base_address =cpu_to_le64 (memmap[VIRT_GIC_REDIST ].base); gicr->range_length =cpu_to_le32 (memmap[VIRT_GIC_REDIST ].size); + + gic_its =acpi_data_push (table_data,sizeof *gic_its); + gic_its->type =ACPI_APIC_ITS_STRUCTURE ; + gic_its->length =sizeof (*gic_its); + gic_its->gic_its_id =0 ; + gic_its->base_address =cpu_to_le64 (memmap[VIRT_GIC_ITS ].base);Since for TCG it doesn't support ITS yet, it should check here using
its_class_name().Quoted 5 lines
Quoted 5 lines
hw/arm/virt-acpi-build.c +0
-0}else { gic_msi =acpi_data_push (table_data,sizeof *gic_msi); gic_msi->type =ACPI_APIC_GENERIC_MSI_FRAME ;include/hw/acpi/acpi-defs.h +0
-0Quoted 8 lines
include/hw/acpi/acpi-defs.h typedef struct AcpiMultipleApicTable AcpiMultipleApicTable; · line 297
Quoted 8 lines
include/hw/acpi/acpi-defs.h +1
-1@@ -294,7 +294,8 @@ typedef struct AcpiMultipleApicTable AcpiMultipleApicTable;#define ACPI_APIC_GENERIC_DISTRIBUTOR 12#define ACPI_APIC_GENERIC_MSI_FRAME 13#define ACPI_APIC_GENERIC_REDISTRIBUTOR 14 -#define ACPI_APIC_RESERVED 15/* 15 and greater are reserved */ +#define ACPI_APIC_ITS_STRUCTURE 15use
ACPI_APIC_GENERIC_TRANSLATORinstead.Quoted 8 lines
Quoted 8 lines
include/hw/acpi/acpi-defs.h +1
-0+#define ACPI_APIC_RESERVED 16/* 16 and greater are reserved */ /* * MADT sub-structures (Follow MULTIPLE_APIC_DESCRIPTION_TABLE) @@ -386,6 +387,16 @@ struct AcpiMadtGenericMsiFrame {typedef struct AcpiMadtGenericMsiFrame AcpiMadtGenericMsiFrame ;Quoted 10 lines
include/hw/acpi/acpi-defs.h struct AcpiMadtGenericMsiFrame { · line 399
Quoted 10 lines
include/hw/acpi/acpi-defs.h +10
-0+struct AcpiMadtGicIts { +ACPI_SUB_HEADER_DEF + uint16_t reserved; +uint32_t gic_its_id; +uint64_t base_address; +uint32_t reserved2; +}QEMU_PACKED ; + +typedef struct AcpiMadtGicIts AcpiMadtGicIts ; +Define it like below to respect the name in linux kernel and also keep consistent with other structures.
include/hw/acpi/acpi-defs.h +9
-0+struct AcpiMadtGenericTranslator { +ACPI_SUB_HEADER_DEF + uint16_t reserved; +uint32_t translation_id; +uint64_t base_address; +uint32_t reserved2; +}QEMU_PACKED ; + +typedef struct AcpiMadtGenericTranslator AcpiMadtGenericTranslator ;
Quoted 7 lines
Quoted 6 lines
Quoted 3 lines
Quoted 3 lines
BTW, you could have a look at [1] which I sent before.
[1] https://lists.gnu.org/archive/html/qemu-devel/2015-11/msg06282.html
Hum sorry, please apologize. I was not aware of those. Do you want to respin or shall I respin mine taking into account your comments and changing the author. Besides, thanks for the review.
Never mind. I think you can respin yours.
OK thanks.
Eric
Quoted 3 lines
Thanks,