Re: [PATCH v6 30/39] accel: Propagate AccelState to AccelClass::init_machine()

2025-07-04 Thread Zhao Liu
>accelerator", so that we could get @accel by ms->accelerator. But considerring the user emulation, where the @ms is NULL, and for these cases, it needs to bring current_accel() back in patch 32. Anyway, this solution is also fine for me, so, Reviewed-by: Zhao Liu ...But there'

Re: [PATCH v6 38/39] accel: Extract AccelClass definition to 'accel/accel-ops.h'

2025-07-04 Thread Zhao Liu
gdbstub/system.c| 1 + > linux-user/main.c | 1 + > system/memory.c | 1 + > target/i386/nvmm/nvmm-all.c | 1 + > target/i386/whpx/whpx-all.c | 1 + > 19 files changed, 70 insertions(+), 40 deletions(-) > create mode 100644 include/accel/accel-ops.h Reviewed-by: Zhao Liu

Re: [PATCH v6 37/39] accel: Rename 'system/accel-ops.h' -> 'accel/accel-cpu-ops.h'

2025-07-04 Thread Zhao Liu
ACCEL_OPS_H > -#define ACCEL_OPS_H > +#ifndef ACCEL_CPU_OPS_H > +#define ACCEL_CPU_OPS_H Daniel mentioned "QEMU_" prefix is "best practice": https://lore.kernel.org/qemu-devel/aadsmexeay45n...@redhat.com/ But I also think there's no need to change anything here for now. If you agree, we can move in this direction in the future. So Reviewed-by: Zhao Liu

Re: [PATCH v4 56/65] accel: Expose and register generic_handle_interrupt()

2025-07-03 Thread Zhao Liu
| 1 + > system/cpus.c | 9 +++-- > target/i386/nvmm/nvmm-accel-ops.c | 1 + > target/i386/whpx/whpx-accel-ops.c | 1 + > 8 files changed, 12 insertions(+), 6 deletions(-) Reviewed-by: Zhao Liu

Re: [PATCH v4 59/65] accel: Always register AccelOpsClass::get_virtual_clock() handler

2025-07-03 Thread Zhao Liu
| 7 --- > target/i386/nvmm/nvmm-accel-ops.c | 1 + > target/i386/whpx/whpx-accel-ops.c | 1 + > 8 files changed, 13 insertions(+), 3 deletions(-) Reviewed-by: Zhao Liu

Re: [PATCH v4 58/65] accel: Always register AccelOpsClass::get_elapsed_ticks() handler

2025-07-03 Thread Zhao Liu
| 2 ++ > system/cpus.c | 6 ++ > target/i386/nvmm/nvmm-accel-ops.c | 3 +++ > target/i386/whpx/whpx-accel-ops.c | 3 +++ > 9 files changed, 21 insertions(+), 4 deletions(-) Reviewed-by: Zhao Liu

Re: [PATCH v4 57/65] accel: Always register AccelOpsClass::kick_vcpu_thread() handler

2025-07-03 Thread Zhao Liu
thieu-Daudé > --- > include/system/accel-ops.h | 1 + > accel/kvm/kvm-accel-ops.c | 1 + > accel/qtest/qtest.c| 1 + > accel/xen/xen-all.c| 1 + > system/cpus.c | 7 ++- > 5 files changed, 6 insertions(+), 5 deletions(-) Reviewed-by: Zhao Liu

Re: [PATCH 2/3] system/numa: Remove unnecessary 'exec/cpu-common.h' header

2024-12-17 Thread Zhao Liu
t; Nothing requires definitions from "exec/cpu-common.h", > do not include this header. > > Signed-off-by: Philippe Mathieu-Daudé > --- > include/sysemu/numa.h | 1 - > 1 file changed, 1 deletion(-) Reviewed-by: Zhao Liu

Re: [PATCH 3/3] system/accel-ops: Remove unnecessary 'exec/cpu-common.h' header

2024-12-17 Thread Zhao Liu
--- > include/sysemu/accel-ops.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) Reviewed-by: Zhao Liu

Re: [PATCH 1/3] hw/xen: Remove unnecessary 'exec/cpu-common.h' header

2024-12-17 Thread Zhao Liu
ng requires definitions from "exec/cpu-common.h", > do not include this header. > > Signed-off-by: Philippe Mathieu-Daudé > --- > include/hw/xen/xen.h | 2 -- > 1 file changed, 2 deletions(-) > Reviewed-by: Zhao Liu

Re: [PATCH v3 01/29] bulk: Access existing variables initialized to &S->F when available

2024-01-30 Thread Zhao Liu
ifier s, m, v; > @@ > S *s; > ... > F *v = &s->m; > <+... > -&s->m > +v > ...+> > > Inspired-by: Zhao Liu Thanks! > Signed-off-by: Philippe Mathieu-Daudé > --- > hw/display/ati.c

Re: [PATCH v3 14/29] target/i386: Prefer fast cpu_env() over slower CPU QOM cast macro

2024-01-30 Thread Zhao Liu
| 3 +- > target/i386/tcg/tcg-cpu.c| 14 +++--- > target/i386/tcg/user/excp_helper.c | 6 ++-- > target/i386/tcg/user/seg_helper.c| 3 +- > 21 files changed, 67 insertions(+), 158 deletions(-) Reviewed-by: Zhao Liu > > diff --git a/target/i386/hvf/vmx.h b/target/i

Re: [PATCH v2 10/23] target/i386: Prefer fast cpu_env() over slower CPU QOM cast macro

2024-01-27 Thread Zhao Liu
target/i386/tcg/user/excp_helper.c index b3bdb7831a7a..02fcd64fc080 100644 --- a/target/i386/tcg/user/excp_helper.c +++ b/target/i386/tcg/user/excp_helper.c @@ -52,6 +52,5 @@ void x86_cpu_record_sigsegv(CPUState *cs, vaddr addr, void x86_cpu_record_sigbus(CPUState *cs, vaddr addr, MMUAccessType access_type, uintptr_t ra) { -X86CPU *cpu = X86_CPU(cs); -handle_unaligned_access(&cpu->env, addr, access_type, ra); +handle_unaligned_access(cpu_env(cs), addr, access_type, ra); } [snip] LGTM. Reviewed-by: Zhao Liu

Re: [RFC 00/41] qom-topo: Abstract Everything about CPU Topology

2023-12-11 Thread Zhao Liu
Hi maintainers, Just a ping. Welcome your feedbacks! We wonder if the current RFC is an appropriate attempt towards the final hybrid topology. Thanks, Zhao On Thu, Nov 30, 2023 at 10:41:22PM +0800, Zhao Liu wrote: > Date: Thu, 30 Nov 2023 22:41:22 +0800 > From: Zhao Liu > Subject: [

[RFC 34/41] hw/core/topo: Implement user-child to collect topology device from cli

2023-11-30 Thread Zhao Liu
From: Zhao Liu Support user-child for topology devices. This will affect these 2 aspects: 1. For the basic topology device (with DEVICE_CATEGORY_CPU_DEF category), user could specify "parent" to build the topology relationship from cli. And cpu-slot will collect all topology

[RFC 33/41] hw/machine: Validate smp topology tree without -smp

2023-11-30 Thread Zhao Liu
From: Zhao Liu QOM topology allows user to create topology tree from cli without -smp, in this case, validate the topology tree to meet the smp requirement. Currently, for compatibility with MachineState.smp, initialize MachineState.smp from topology tree in this case. Signed-off-by: Zhao Liu

[RFC 06/41] qdev: Introduce user-child interface to collect devices from -device

2023-11-30 Thread Zhao Liu
From: Zhao Liu Topology relationship is based on child<> property, therefore introduce a new user-child interface to help bus-less devices create child<> property from cli. User-child interface works in qdev_set_id(), where the child<> property is created for cli devices. Wi

[RFC 05/41] qdev: Set device parent and id after setting properties

2023-11-30 Thread Zhao Liu
From: Zhao Liu The properties setting does not conflict with the creation of child<> property. Pre-setting the device's properties can help the device's parent selection. Some topology devices (e.g., CPUs that support hotplug) usually define topology sub indexes as properties, a

[RFC 39/41] hw/i386: Add the interface to search parent for QOM topology

2023-11-30 Thread Zhao Liu
From: Zhao Liu QOM topology needs to search parent cpu-core for hotplugged CPU to create topology child<> property in qdev_set_id(). This process is before x86_cpu_pre_plug(), thus place 2 helpers x86_cpu_assign_apic_id() and x86_cpu_assign_topo_id() in x86_cpu_search_parent_pre_plug() t

[RFC 04/41] qom/object: Introduce helper to resolve path from non-direct parent

2023-11-30 Thread Zhao Liu
From: Zhao Liu When we support child<> property creation from cli, the peripheral container (/machine/peripheral) may not be the direct parent of the devices created from cli. For this case, add a helper to resolve path from non-direct parent. Signed-off-by: Zhao Liu --- include/qom/ob

[RFC 41/41] hw/i386: Cleanup non-QOM topology support

2023-11-30 Thread Zhao Liu
From: Zhao Liu After i386 supports QOM topology, drop original topology logic. Signed-off-by: Zhao Liu --- hw/i386/x86.c | 52 +++ 1 file changed, 11 insertions(+), 41 deletions(-) diff --git a/hw/i386/x86.c b/hw/i386/x86.c index 99f6c502de43

[RFC 37/41] hw/i386: Allow i386 to create new CPUs from QOM topology

2023-11-30 Thread Zhao Liu
From: Zhao Liu For QOM topology, maximum number of CPUs and the number of plugged CPUs are configured in core level. Iterate through all the cpu-cores to determine how many CPUs should be created in each cpu-core. Signed-off-by: Zhao Liu --- hw/i386/x86.c | 32

[RFC 07/41] qdev: Introduce parent option in -device

2023-11-30 Thread Zhao Liu
From: Zhao Liu Currently, the devices added by "-device" are linked via bus, and are set the parent as peripheral-anon or peripheral containers of the machine. But this is not enough for building CPU topology hierarchies as: 1. The relationship between different CPU hierarchie

[RFC 03/41] system: Create base category devices from cli before board initialization

2023-11-30 Thread Zhao Liu
From: Zhao Liu Topology devices are required to complete CPU topology building before *_init_cpus() in MachineClass.init(). Add a qemu_create_cli_base_devices() before board initialization to help create and realize topology devices from cli early. Signed-off-by: Zhao Liu --- system/vl.c

[RFC 40/41] hw/i386: Support QOM topology

2023-11-30 Thread Zhao Liu
From: Zhao Liu Set MachineClass.smp_props.possible_cpus_qom_granu and TopoClass.search_parent_pre_plug for i386. So far, the i386 topology is based on the QOM topology. Signed-off-by: Zhao Liu --- hw/i386/x86.c | 1 + target/i386/cpu.c | 4 2 files changed, 5 insertions(+) diff

[RFC 35/41] hw/i386: Make x86_cpu_new() private in x86.c

2023-11-30 Thread Zhao Liu
From: Zhao Liu x86_cpu_new() is only invoked in x86.c. Declear it as static in x86.c. Signed-off-by: Zhao Liu --- hw/i386/x86.c | 3 ++- include/hw/i386/x86.h | 2 -- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/hw/i386/x86.c b/hw/i386/x86.c index b3d054889bba

[RFC 29/41] hw/core/slot: Statistics topology information in CPU slot

2023-11-30 Thread Zhao Liu
From: Zhao Liu The CPU slot, as the root of the topology tree, is responsible for global topology information collection and updates. When a new topology device is added to/deleted from the topology tree, update the corresponding information in the slot. Signed-off-by: Zhao Liu --- hw/core

[RFC 38/41] hw/i386: Wrap apic id and topology sub ids assigning as helpers

2023-11-30 Thread Zhao Liu
From: Zhao Liu For QOM topology, these 2 helpers are needed for hotplugged CPU to verify its topology sub indexes and then search its parent core. Signed-off-by: Zhao Liu --- hw/i386/x86.c | 173 -- 1 file changed, 96 insertions(+), 77 deletions

[RFC 27/41] hw/core/slot: Introduce CPU slot as the root of CPU topology

2023-11-30 Thread Zhao Liu
From: Zhao Liu Abstract the root of topology tree as a special topology device "cpu-slot". Signed-off-by: Zhao Liu --- MAINTAINERS| 2 ++ hw/core/cpu-slot.c | 48 ++ hw/core/meson.build| 1 + include/hw/core/cpu-s

[RFC 25/41] hw/cpu/book: Abstract cpu-book level as topology device

2023-11-30 Thread Zhao Liu
From: Zhao Liu Abstract book level as a topology device "cpu-book" to allow user to create book level topology from cli and later the cpu-books could be added into topology tree. In addition, mark the cpu-book as DEVICE_CATEGORY_CPU_DEF category to indicate it belongs to the

[RFC 32/41] hw/machine: Build smp topology tree from -smp

2023-11-30 Thread Zhao Liu
From: Zhao Liu For the architecture supports QOM topology (the field MachineClass.possible_cpus_qom_granu is set), implement smp QOM topology tree from MachineState.smp. Signed-off-by: Zhao Liu --- hw/core/cpu-slot.c | 217 + hw/core/machine-smp.c

[RFC 36/41] hw/i386: Allow x86_cpu_new() to specify parent for new CPU

2023-11-30 Thread Zhao Liu
From: Zhao Liu For QOM topology, CPU should be inserted under its parent core. Extend x86_cpu_new() to allow caller to specify topology parent. Signed-off-by: Zhao Liu --- hw/i386/x86.c | 16 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/hw/i386/x86.c b/hw

[RFC 23/41] hw/cpu/die: Abstract cpu-die level as topology device

2023-11-30 Thread Zhao Liu
From: Zhao Liu Abstract die level as a topology device "cpu-die" to allow user to create die level topology from cli and later the cpu-dies could be added into topology tree. In addition, mark the cpu-die as DEVICE_CATEGORY_CPU_DEF category to indicate it belongs to the basic CPU defi

[RFC 30/41] hw/core/slot: Check topology child to be added under CPU slot

2023-11-30 Thread Zhao Liu
From: Zhao Liu Implement CPUTopoClass.check_topo_child() in cpu-slot to be compatible with the limitations of the current smp topology. Signed-off-by: Zhao Liu --- hw/core/cpu-slot.c | 37 + hw/core/cpu-topo.c | 2 +- include/hw/core/cpu

[RFC 26/41] hw/cpu/drawer: Abstract cpu-drawer level as topology device

2023-11-30 Thread Zhao Liu
From: Zhao Liu Abstract drawer level as a topology device "cpu-drawer" to allow user to create drawer level topology from cli and later the cpu-drawers could be added into topology tree. In addition, mark the cpu-drawer as DEVICE_CATEGORY_CPU_DEF category to indicate it belongs to the

[RFC 31/41] hw/machine: Plug cpu-slot into machine to maintain topology tree

2023-11-30 Thread Zhao Liu
From: Zhao Liu Add a cpu-slot in machine as the root of topology tree to maintain the QOM topology. Signed-off-by: Zhao Liu --- hw/core/cpu-slot.c | 31 +++ include/hw/boards.h| 2 ++ include/hw/core/cpu-slot.h | 7 +++ system/vl.c

[RFC 21/41] hw/cpu/cluster: Allow cpu-cluster to be created by -device

2023-11-30 Thread Zhao Liu
From: Zhao Liu Since we will extend cpu-cluster to build CPU topology in virtualization case via -device, remove the original limitition. Signed-off-by: Zhao Liu --- hw/cpu/cluster.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/hw/cpu/cluster.c b/hw/cpu/cluster.c index 27ab9e25a265

[RFC 19/41] hw/cpu/cluster: Wrap TCG related ops and props into CONFIG_TCG

2023-11-30 Thread Zhao Liu
From: Zhao Liu Currenltly cpu-cluster is used in TCG case to organize CPUs with the same type. Wrap 2 things into TCG specific areas: 1. cluster-id: The cluster-id in TCG case is global, since no higher topology container above cluster. To simplify the logic of cluster topology in

[RFC 28/41] hw/core/slot: Maintain the core queue in CPU slot

2023-11-30 Thread Zhao Liu
From: Zhao Liu Maintain the cores queue at cpu-slot to facilitate direct traversal of all cores. Signed-off-by: Zhao Liu --- hw/core/cpu-slot.c | 43 ++ include/hw/core/cpu-slot.h | 9 include/hw/cpu/core.h | 2 ++ 3 files changed

[RFC 13/41] hw/core/cpu: Convert CPU from general device to topology device

2023-11-30 Thread Zhao Liu
From: Zhao Liu Convert CPU to topology device then its parent topology devices could count the number of CPUs when new CPUs are added into topology tree. Note since CPUs are created from *_init_cpus() in MachineClass.init() or added from hotplug way, it depends on board initialization. Thus CPU

[RFC 00/41] qom-topo: Abstract Everything about CPU Topology

2023-11-30 Thread Zhao Liu
From: Zhao Liu Hi list, This series is our latest attempt after the previous RFC [1] about hybrid topology support, which is based on the commit 4705fc0c8511 ("Merge tag 'pull-for-8.2-fixes-231123-1' of https://gitlab.com/ stsquad/qemu into staging") with our previous c

[RFC 17/41] hw/cpu/core: Convert cpu-core from general device to topology device

2023-11-30 Thread Zhao Liu
From: Zhao Liu Convert cpu-core to topology device then user could create core level topology from cli and later the cpu-cores could be added into topology tree. In addition, mark the common cpu-core as DEVICE_CATEGORY_CPU_DEF category to indicate it belongs to the basic CPU definition and

[RFC 15/41] hw/cpu/core: Allow to configure plugged threads for cpu-core

2023-11-30 Thread Zhao Liu
From: Zhao Liu When the core abstraction is applied for the architecture support CPU hotplug, the plugged CPUs and unplugged CPUs are distributed among the cores created in the topology tree. Add plugged_threads field to help cpu-core decide to how many CPUs to create. Signed-off-by: Zhao Liu

[RFC 24/41] hw/cpu/socket: Abstract cpu-socket level as topology device

2023-11-30 Thread Zhao Liu
From: Zhao Liu Abstract socket level as a topology device "cpu-socket" to allow user to create socket level topology from cli and later the cpu-sockets could be added into topology tree. In addition, mark the cpu-socket as DEVICE_CATEGORY_CPU_DEF category to indicate it belongs to the

[RFC 09/41] hw/core/topo: Support topology index for topology device

2023-11-30 Thread Zhao Liu
From: Zhao Liu Topology index is used to identify the topology child under the same parent topology device. This field corresponds to the topology sub index (e.g., socket-id/ core-id/thread-id) used for addressing. Signed-off-by: Zhao Liu --- hw/core/cpu-topo.c | 77

[RFC 22/41] hw/cpu/cluster: Convert cpu-cluster from general device to topology device

2023-11-30 Thread Zhao Liu
From: Zhao Liu Convert cpu-cluster to topology device then user could create cluster level topology from cli and later the cpu-clusters could be added into topology tree. In addition, mark the cpu-cluster as DEVICE_CATEGORY_CPU_DEF category to indicate it belongs to the basic CPU definition and

[RFC 11/41] hw/core/topo: Add virtual method to check topology child

2023-11-30 Thread Zhao Liu
From: Zhao Liu When a new topology child is to be inserted into the topology tree, its parents (including non-direct parents) need to check if this child is supported. Add the virtual method to allow topology device to check the support for their topology children. Signed-off-by: Zhao Liu

[RFC 20/41] hw/cpu/cluster: Descript cluster is not only used for TCG in comment

2023-11-30 Thread Zhao Liu
From: Zhao Liu Update the comment to make the cpu-cluster description more general for both TCG and accel cases. Signed-off-by: Zhao Liu --- hw/cpu/cluster.c | 2 +- include/hw/cpu/cluster.h | 20 +++- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/hw

[RFC 18/41] hw/cpu/cluster: Rename CPUClusterState to CPUCluster

2023-11-30 Thread Zhao Liu
From: Zhao Liu To keep the same naming style as cpu-core, rename CPUClusterState to CPUCluster. Signed-off-by: Zhao Liu --- gdbstub/system.c | 2 +- hw/cpu/cluster.c | 8 include/hw/arm/armsse.h| 2 +- include/hw/arm/xlnx-versal.h

[RFC 16/41] PPC/ppc-core: Limit plugged-threads and nr-threads to be equal

2023-11-30 Thread Zhao Liu
From: Zhao Liu PPC supports CPU hotplug at core granularity, thus ppc-core only accepts all CPUs in a core are plugged. Check if plugged_threads and nr_threads are equal when ppc-core realizes. Signed-off-by: Zhao Liu --- hw/ppc/ppc_core.c | 18 ++ include/hw/ppc

[RFC 14/41] PPC/ppc-core: Offload core-id to PPC specific core abstarction

2023-11-30 Thread Zhao Liu
From: Zhao Liu PPC (spapr) supports hotplugs at the core granularity (spapr core) and treats core-id as the global id for all cores. But other architectures that support hotplugging at CPU granularity, use core-id as the local id to indicate the core within the parent topology container instand

[RFC 12/41] hw/core/topo: Add helpers to traverse the CPU topology tree

2023-11-30 Thread Zhao Liu
From: Zhao Liu The topology devices will be organized as a topology tree. Each topology device may have many topology children with lower topology level. Add the helpers to traverse the CPU topology tree. Signed-off-by: Zhao Liu --- hw/core/cpu-topo.c | 41

[RFC 10/41] hw/core/topo: Add virtual method to update topology info for parent

2023-11-30 Thread Zhao Liu
From: Zhao Liu When a new topology device is inserted into the topology tree, its'parents (including non-direct parent) need to update topology information. Add the virtual method to help parents on topology tree update topology information statistics. Signed-off-by: Zhao Liu --- hw/cor

[RFC 01/41] qdev: Introduce new device category to cover basic topology device

2023-11-30 Thread Zhao Liu
From: Zhao Liu Topology devices are used to define CPUs and need to be created and realized before the board initialization. Use this new catogory to identify such special devices. Signed-off-by: Zhao Liu --- include/hw/qdev-core.h | 1 + system/qdev-monitor.c | 1 + 2 files changed, 2

[RFC 08/41] hw/core/topo: Introduce CPU topology device abstraction

2023-11-30 Thread Zhao Liu
From: Zhao Liu To create more flexible CPU topologies (both symmetric and heterogeneous) via the "-device" interface, it is necessary to convert the current CPU topology hierarchies into the special CPU topology devices. The CPU topology will be built as a tree, and the devic

[RFC 02/41] qdev: Allow qdev_device_add() to add specific category device

2023-11-30 Thread Zhao Liu
From: Zhao Liu Topology devices need to be created and realized before board initialization. Allow qdev_device_add() to specify category to help create topology devices early. Signed-off-by: Zhao Liu --- hw/net/virtio-net.c| 2 +- hw/usb/xen-usb.c | 3 ++- include/monitor/qdev.h