qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

hw/cpu: introduce CPU clusters

This commit adds the cpu-cluster type. It aims at gathering CPUs from
the same cluster in a machine.

For now it only has a `cluster-id` property.

Documentation in cluster.h written with the help of Peter Maydell.

Signed-off-by: Luc Michel <luc.michel@greensocs.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
Message-id: 20181207090135.7651-2-luc.michel@greensocs.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

authored by

Luc Michel and committed by
Peter Maydell
335d52f4 407e6ce7

+111 -1
+2
MAINTAINERS
··· 1195 1195 S: Supported 1196 1196 F: hw/core/machine.c 1197 1197 F: hw/core/null-machine.c 1198 + F: hw/cpu/cluster.c 1198 1199 F: include/hw/boards.h 1200 + F: include/hw/cpu/cluster.h 1199 1201 T: git https://github.com/ehabkost/qemu.git machine-next 1200 1202 1201 1203 Xtensa Machines
+1 -1
hw/cpu/Makefile.objs
··· 2 2 obj-$(CONFIG_REALVIEW) += realview_mpcore.o 3 3 obj-$(CONFIG_A9MPCORE) += a9mpcore.o 4 4 obj-$(CONFIG_A15MPCORE) += a15mpcore.o 5 - common-obj-y += core.o 5 + common-obj-y += core.o cluster.o
+50
hw/cpu/cluster.c
··· 1 + /* 2 + * QEMU CPU cluster 3 + * 4 + * Copyright (c) 2018 GreenSocs SAS 5 + * 6 + * This program is free software; you can redistribute it and/or 7 + * modify it under the terms of the GNU General Public License 8 + * as published by the Free Software Foundation; either version 2 9 + * of the License, or (at your option) any later version. 10 + * 11 + * This program is distributed in the hope that it will be useful, 12 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 + * GNU General Public License for more details. 15 + * 16 + * You should have received a copy of the GNU General Public License 17 + * along with this program; if not, see 18 + * <http://www.gnu.org/licenses/gpl-2.0.html> 19 + */ 20 + 21 + #include "qemu/osdep.h" 22 + #include "hw/cpu/cluster.h" 23 + #include "qapi/error.h" 24 + #include "qemu/module.h" 25 + 26 + static Property cpu_cluster_properties[] = { 27 + DEFINE_PROP_UINT32("cluster-id", CPUClusterState, cluster_id, 0), 28 + DEFINE_PROP_END_OF_LIST() 29 + }; 30 + 31 + static void cpu_cluster_class_init(ObjectClass *klass, void *data) 32 + { 33 + DeviceClass *dc = DEVICE_CLASS(klass); 34 + 35 + dc->props = cpu_cluster_properties; 36 + } 37 + 38 + static const TypeInfo cpu_cluster_type_info = { 39 + .name = TYPE_CPU_CLUSTER, 40 + .parent = TYPE_DEVICE, 41 + .instance_size = sizeof(CPUClusterState), 42 + .class_init = cpu_cluster_class_init, 43 + }; 44 + 45 + static void cpu_cluster_register_types(void) 46 + { 47 + type_register_static(&cpu_cluster_type_info); 48 + } 49 + 50 + type_init(cpu_cluster_register_types)
+58
include/hw/cpu/cluster.h
··· 1 + /* 2 + * QEMU CPU cluster 3 + * 4 + * Copyright (c) 2018 GreenSocs SAS 5 + * 6 + * This program is free software; you can redistribute it and/or 7 + * modify it under the terms of the GNU General Public License 8 + * as published by the Free Software Foundation; either version 2 9 + * of the License, or (at your option) any later version. 10 + * 11 + * This program is distributed in the hope that it will be useful, 12 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 + * GNU General Public License for more details. 15 + * 16 + * You should have received a copy of the GNU General Public License 17 + * along with this program; if not, see 18 + * <http://www.gnu.org/licenses/gpl-2.0.html> 19 + */ 20 + #ifndef HW_CPU_CLUSTER_H 21 + #define HW_CPU_CLUSTER_H 22 + 23 + #include "qemu/osdep.h" 24 + #include "hw/qdev.h" 25 + 26 + /* 27 + * CPU Cluster type 28 + * 29 + * A cluster is a group of CPUs which are all identical and have the same view 30 + * of the rest of the system. It is mainly an internal QEMU representation and 31 + * does not necessarily match with the notion of clusters on the real hardware. 32 + * 33 + * If CPUs are not identical (for example, Cortex-A53 and Cortex-A57 CPUs in an 34 + * Arm big.LITTLE system) they should be in different clusters. If the CPUs do 35 + * not have the same view of memory (for example the main CPU and a management 36 + * controller processor) they should be in different clusters. 37 + */ 38 + 39 + #define TYPE_CPU_CLUSTER "cpu-cluster" 40 + #define CPU_CLUSTER(obj) \ 41 + OBJECT_CHECK(CPUClusterState, (obj), TYPE_CPU_CLUSTER) 42 + 43 + /** 44 + * CPUClusterState: 45 + * @cluster_id: The cluster ID. This value is for internal use only and should 46 + * not be exposed directly to the user or to the guest. 47 + * 48 + * State of a CPU cluster. 49 + */ 50 + typedef struct CPUClusterState { 51 + /*< private >*/ 52 + DeviceState parent_obj; 53 + 54 + /*< public >*/ 55 + uint32_t cluster_id; 56 + } CPUClusterState; 57 + 58 + #endif