Re: [RFC v2 00/12] Introduce Hybrid CPU Topology via Custom Topology Tree

2024-10-08 Thread Zhao Liu
Hi Jonathan, On Tue, Oct 08, 2024 at 11:30:38AM +0100, Jonathan Cameron wrote: > Date: Tue, 8 Oct 2024 11:30:38 +0100 > From: Jonathan Cameron > Subject: Re: [RFC v2 00/12] Introduce Hybrid CPU Topology via Custom > Topology Tree > X-Mailer: Claws Mail 4.1.0 (GTK 3.24.33; x86_64-w64-mingw32) >

Re: [PATCH v2] hw/nvme: i/o cmd set independent namespace data structure

2024-10-08 Thread Klaus Jensen
On Sep 25 06:14, Arun Kumar wrote: > add support for i/o command set independent namespace data > structure(cns=8h and cns=1fh) > > Signed-off-by: Klaus Jensen > Signed-off-by: Arun Kumar Looks good. Reviewed-by: Klaus Jensen > --- > hw/nvme/ctrl.c | 31 +++

Re: [PATCH v2] hw/nvme: Adding support for NPDAL and NPDGL

2024-10-08 Thread Klaus Jensen
On Oct 1 06:58, Ayush Mishra wrote: > Adding support for new 32 bit NPDGL and NPDAL fields to address the > needs of larger granularities. > > Signed-off-by: Ayush Mishra > --- > v1 -> v2: Added macros for NSFEAT in /include/block/nvme.h as suggested > by Klaus. > LGTM. I'll add a name to th

Re: [RFC v2 03/12] system/vl: Create CPU topology devices from CLI early

2024-10-08 Thread Zhao Liu
On Tue, Oct 08, 2024 at 10:50:53AM +0100, Jonathan Cameron wrote: > Date: Tue, 8 Oct 2024 10:50:53 +0100 > From: Jonathan Cameron > Subject: Re: [RFC v2 03/12] system/vl: Create CPU topology devices from CLI > early > X-Mailer: Claws Mail 4.1.0 (GTK 3.24.33; x86_64-w64-mingw32) > > On Thu, 19 Se

Re: [PATCH v2] net/tap-win32: Fix gcc 14 format truncation errors

2024-10-08 Thread Michael Tokarev
08.10.2024 23:28, Bernhard Beschow wrote: The patch fixes the following errors generated by GCC 14.2: ../src/net/tap-win32.c:343:19: error: '%s' directive output may be truncated writing up to 255 bytes into a region of size 176 [-Werror=format-truncation=] 343 | "%s\\%s\\Connec

Re: [PATCH V2] virtio/vhost-user: fix qemu abort when hotunplug vhost-user-net device

2024-10-08 Thread Zhenguo Yao
On Tue, Oct 01, 2024 at 02:21:55PM +0200, Stefano Garzarella wrote: > On Thu, Sep 19, 2024 at 03:29:44PM GMT, yaozhenguo wrote: > > During the process of hot-unplug in vhost-user-net NIC, vhost_user_cleanup > > may add same rcu node to rcu list. Function calls are as follows: > > > > vhost_user_cl

Re: [PATCH v3 0/5] Interrupt Remap support for emulated amd viommu

2024-10-08 Thread Shukla, Santosh
Ping? Gentle reminder. Thanks, Santosh On 9/27/2024 10:59 PM, Santosh Shukla wrote: > Series adds following feature support for emulated amd vIOMMU > 1) Pass Through(PT) mode > 2) Interrupt Remapping(IR) mode > > 1) PT mode > Introducing the shared 'nodma' memory region that can be aliased > b

Re: [RFC v2 03/12] system/vl: Create CPU topology devices from CLI early

2024-10-08 Thread Zhao Liu
On Tue, Oct 08, 2024 at 10:55:45AM +0100, Jonathan Cameron wrote: > Date: Tue, 8 Oct 2024 10:55:45 +0100 > From: Jonathan Cameron > Subject: Re: [RFC v2 03/12] system/vl: Create CPU topology devices from CLI > early > X-Mailer: Claws Mail 4.1.0 (GTK 3.24.33; x86_64-w64-mingw32) > > > > + > > +s

Re: [RFC v2 01/12] qdev: Allow qdev_device_add() to add specific category device

2024-10-08 Thread Zhao Liu
On Tue, Oct 08, 2024 at 10:14:25AM +0100, Jonathan Cameron wrote: > Date: Tue, 8 Oct 2024 10:14:25 +0100 > From: Jonathan Cameron > Subject: Re: [RFC v2 01/12] qdev: Allow qdev_device_add() to add specific > category device > X-Mailer: Claws Mail 4.1.0 (GTK 3.24.33; x86_64-w64-mingw32) > > On Th

Re: [RFC v2 00/12] Introduce Hybrid CPU Topology via Custom Topology Tree

2024-10-08 Thread Zhao Liu
Hi Jonathan, Thank you for looking at here! On Tue, Oct 08, 2024 at 11:30:38AM +0100, Jonathan Cameron wrote: > Date: Tue, 8 Oct 2024 11:30:38 +0100 > From: Jonathan Cameron > Subject: Re: [RFC v2 00/12] Introduce Hybrid CPU Topology via Custom > Topology Tree > X-Mailer: Claws Mail 4.1.0 (GTK

Re: [PATCH v6] i386/cpu: fixup number of addressable IDs for logical processors in the physical package

2024-10-08 Thread Zhao Liu
On Wed, Oct 09, 2024 at 11:56:38AM +0800, Chuang Xu wrote: > Date: Wed, 9 Oct 2024 11:56:38 +0800 > From: Chuang Xu > Subject: [PATCH v6] i386/cpu: fixup number of addressable IDs for logical > processors in the physical package > X-Mailer: git-send-email 2.39.3 (Apple Git-146) > > When QEMU is

[PATCH v6] i386/cpu: fixup number of addressable IDs for logical processors in the physical package

2024-10-08 Thread Chuang Xu
When QEMU is started with: -cpu host,migratable=on,host-cache-info=on,l3-cache=off -smp 180,sockets=2,dies=1,cores=45,threads=2 On Intel platform: CPUID.01H.EBX[23:16] is defined as "max number of addressable IDs for logical processors in the physical package". When executing "cpuid -1 -l 1 -r" i

Re: [PATCH] target/i386: Use probe_access_full_mmu in ptw_translate

2024-10-08 Thread Philippe Mathieu-Daudé
On 8/10/24 21:20, Richard Henderson wrote: The probe_access_full_mmu function was designed for this purpose, and does not report the memory operation event to plugins. Cc: qemu-sta...@nongnu.org Fixes: 6d03226b422 ("plugins: force slow path when plugins instrument memory ops") Signed-off-by: Ri

Re: [PATCH v2] net/tap-win32: Fix gcc 14 format truncation errors

2024-10-08 Thread Philippe Mathieu-Daudé
On 8/10/24 17:28, Bernhard Beschow wrote: The patch fixes the following errors generated by GCC 14.2: ../src/net/tap-win32.c:343:19: error: '%s' directive output may be truncated writing up to 255 bytes into a region of size 176 [-Werror=format-truncation=] 343 | "%s\\%s\\Connec

[PATCH RFC V4 33/33] hw/arm/virt: Expose cold-booted vCPUs as MADT GICC *Enabled*

2024-10-08 Thread Salil Mehta via
Hotpluggable vCPUs must be exposed as "online-capable" according to the new UEFI specification [1][2]. However, marking cold-booted vCPUs as "online-capable" during boot may cause them to go undetected by legacy operating systems, potentially leading to compatibility issues. Hence, both 'online-cap

[PATCH RFC V4 31/33] target/arm/kvm: Write vCPU's state back to KVM on cold-reset

2024-10-08 Thread Salil Mehta via
From: Jean-Philippe Brucker Previously, all `PSCI_CPU_{ON, OFF}` calls were handled directly by KVM. However, with the introduction of vCPU hotplug, these hypervisor calls are now trapped to QEMU for policy checks. This shift can lead to inconsistent vCPU states between KVM and QEMU, particularly

[PATCH RFC V4 32/33] hw/intc/arm_gicv3_kvm: Pause all vCPU to ensure locking in KVM of resetting vCPU

2024-10-08 Thread Salil Mehta via
vCPU reset can result in device access to VGIC CPU system registers using the `IOCTL KVM_DEV_ARM_VGIC_GRP_CPU_SYSREGS` interface. When accessing these registers in the KVM host, it is necessary to acquire a lock on all vCPUs during the `vgic_v3_attr_regs_access()` operation. This operation may fai

[PATCH RFC V4 30/33] target/arm/kvm, tcg: Handle SMCCC hypercall exits in VMM during PSCI_CPU_{ON, OFF}

2024-10-08 Thread Salil Mehta via
From: Author Salil Mehta To support vCPU hotplug, we must trap any `HVC`/`SMC` `PSCI_CPU_{ON,OFF}` hypercalls from the host KVM to QEMU for policy checks. This ensures the following when a vCPU is brought online: 1. The vCPU is actually plugged in (i.e., present). 2. The vCPU is not disabled. I

[PATCH RFC V4 29/33] hw/intc/arm_gicv3_common: Add GICv3CPUState 'accessible' flag migration handling

2024-10-08 Thread Salil Mehta via
The QOM `GICv3CPUState` (and consequently the corresponding KVM VGIC `ICC_*_EL1` registers) can be either 'accessible' or 'inaccessible', depending on the state of the associated QOM vCPUs. This `gicc_accessible` state should be saved during migration at the source and restored at the destination.

[PATCH RFC V4 28/33] tcg/mttcg: Introduce MTTCG thread unregistration leg

2024-10-08 Thread Salil Mehta via
From: Miguel Luis Introduce the TCG thread unregistration leg which shall be called in context to TCG/vCPU unrealize. Reported-by: Salil Mehta Signed-off-by: Miguel Luis Signed-off-by: Salil Mehta --- accel/tcg/tcg-accel-ops-mttcg.c | 1 + include/tcg/startup.h | 7 +++ tcg/t

[PATCH RFC V4 27/33] target/arm: Add support to *unrealize* ARMCPU during vCPU Hot-unplug

2024-10-08 Thread Salil Mehta via
vCPU Hot-unplug will result in QOM CPU object unrealization which will do away with all the vCPU thread creations, allocations, registrations that happened as part of the realization process. This change introduces the ARM CPU unrealize function taking care of exactly that. Note, initialized KVM v

[PATCH RFC V4 26/33] tcg: Update tcg_register_thread() leg to handle region alloc for hotplugged vCPU

2024-10-08 Thread Salil Mehta via
The TCG code cache consists of multiple regions shared among vCPUs in multi-threaded TCG mode. For cold-plugged vCPUs, these regions are sized and allocated during initialization in the `tcg_register_thread()` function when the vCPUs are realized. Later, these regions must be reallocated for hot-pl

[PATCH RFC V4 25/33] target/arm/cpu: Check if hotplugged ARM vCPU's FEAT match existing

2024-10-08 Thread Salil Mehta via
The ARM extensions configuration *must* match the existing vCPUs already initialized in KVM at VM initialization. ARM does not allow any per-vCPU features to be changed once the system has fully initialized. This is an immutable constraint of the ARM CPU architecture. Signed-off-by: Salil Mehta -

[PATCH RFC V4 24/33] arm/virt: Update the guest(via GED) about vCPU hot-(un)plug events

2024-10-08 Thread Salil Mehta via
During any vCPU hot-(un)plug operation, the running guest VM must be notified about the addition of a new vCPU or the removal of an existing vCPU. This notification is handled via an ACPI GED event, which is eventually demultiplexed into a vCPU hotplug event, and then further into a specific hot-(u

[PATCH RFC V4 23/33] hw/arm: Changes required for reset and to support next boot

2024-10-08 Thread Salil Mehta via
Updates the firmware config with the next boot cpus information and also registers the reset callback to be called when guest reboots to reset the cpu. Co-developed-by: Keqian Zhu Signed-off-by: Keqian Zhu Signed-off-by: Salil Mehta --- hw/arm/boot.c | 2 +- hw/arm/virt.c | 18

[PATCH RFC V4 22/33] hw/arm, gicv3: Changes to notify GICv3 CPU state with vCPU hot-(un)plug event

2024-10-08 Thread Salil Mehta via
Virtual CPU hot-(un)plug events must be communicated to the GIC. Introduce a notification mechanism to ensure these events are properly relayed to the GIC, allowing it to update the accessibility of the GIC CPU interface and adjust the vCPU-to-GIC CPU interface association accordingly. This approa

[PATCH RFC V4 21/33] arm/virt: Changes to (un)wire GICC<->vCPU IRQs during hot-(un)plug

2024-10-08 Thread Salil Mehta via
Refactors the existing GIC create code to extract common code to wire the vcpu<->gic interrupts. This function could be used with cold-plug case and also used when vCPU is hot-plugged. It also introduces a new function to unwire the vcpu<->gic interrupts for the vCPU hot-unplug cases. Co-developed

[PATCH RFC V4 20/33] arm/virt: Add/update basic hot-(un)plug framework

2024-10-08 Thread Salil Mehta via
Add CPU hot-unplug hooks and update hotplug hooks with additional sanity checks for use in hotplug paths. Note: The functional contents of the hooks (currently left with TODO comments) will be gradually filled in subsequent patches in an incremental approach to patch and logic building, which woul

[PATCH RFC V4 19/33] target/arm: Force ARM vCPU *present* status ACPI *persistent*

2024-10-08 Thread Salil Mehta via
The ARM CPU architecture does not permit changes to CPU presence after the kernel has booted. This is an immutable requirement from ARM and represents a strict architectural constraint [1][2]. The ACPI update [3] reinforces this by specifying that the `_STA.Present` bit in the ACPI specification c

[PATCH RFC V4 18/33] hw/acpi: Simulate *persistent* vCPU presence to Guest in ACPI _STA.{PRES, ENA} Bits

2024-10-08 Thread Salil Mehta via
Certain CPU architecture specifications [1][2][3] prohibit changes to the CPUs *presence* after the kernel has booted. This is because many system initializations depend on the exact CPU count at boot time and do not expect it to change afterward. For example, components like interrupt controllers

[PATCH RFC V4 17/33] hw/arm/acpi: MADT Tbl change to size the guest with possible vCPUs

2024-10-08 Thread Salil Mehta via
When QEMU builds the MADT table, modifications are needed to include information about possible vCPUs that are exposed as ACPI-disabled (i.e., `_STA.Enabled=0`). This new information will help the guest kernel pre-size its resources during boot time. Pre-sizing based on possible vCPUs will facilita

[PATCH RFC V4 16/33] hw/acpi: Make _MAT method optional

2024-10-08 Thread Salil Mehta via
From: Jean-Philippe Brucker The GICC interface on arm64 vCPUs is statically defined in the MADT, and doesn't require a _MAT entry. Although the GICC is indicated as present by the MADT entry, it can only be used from vCPU sysregs, which aren't accessible until hot-add. Signed-off-by: Jean-Philip

[PATCH RFC V4 15/33] arm/virt/acpi: Update ACPI DSDT Tbl to include CPUs AML with hotplug support

2024-10-08 Thread Salil Mehta via
Support for Virtual CPU Hotplug requires a sequence of ACPI handshakes between QEMU and the guest kernel when a vCPU is plugged or unplugged. Most of the AML code to support these handshakes already exists. This AML needs to be built during VM initialization for the ARM architecture as well, if GED

[PATCH RFC V4 14/33] arm/virt: Release objects for *disabled* possible vCPUs after init

2024-10-08 Thread Salil Mehta via
During `machvirt_init()`, QOM ARMCPU objects are pre-created along with the corresponding KVM vCPUs in the host for all possible vCPUs. This is necessary due to the architectural constraint that KVM restricts the deferred creation of KVM vCPUs and VGIC initialization/sizing after VM initialization.

[PATCH RFC V4 13/33] arm/virt: Init PMU at host for all possible vCPUs

2024-10-08 Thread Salil Mehta via
The PMU for all possible vCPUs must be initialized during VM initialization. Refactor the existing code to accommodate possible vCPUs. This assumes that all processors being used are identical. It is an architectural constraint of ARM CPUs that all vCPUs MUST have identical feature sets, at least u

[PATCH RFC V4 12/33] arm/virt: Create GED device before *disabled* vCPU Objects are destroyed

2024-10-08 Thread Salil Mehta via
ACPI CPU hotplug state (is_present=_STA.PRESENT, is_enabled=_STA.ENABLED) for all the possible vCPUs MUST be initialized during machine init. This is done during the creation of the GED device. VMM/Qemu MUST expose/fake the ACPI state of the disabled vCPUs to the Guest kernel as 'present' (_STA.PRE

[PATCH RFC V4 11/33] arm/virt: Enhance GED framework to handle vCPU hotplug events

2024-10-08 Thread Salil Mehta via
During GED device creation at Virt Machine initialization, add a new vCPU hotplug event to the existing set of supported GED device events. Additionally, initialize the memory map for the vCPU hotplug *control device*, which will provide an interface to exchange ACPI events between QEMU/VMM and the

[PATCH RFC V4 10/33] arm/acpi: Enable ACPI support for vCPU hotplug

2024-10-08 Thread Salil Mehta via
ACPI is required to interface QEMU with the guest. Roughly falls into below cases, 1. Convey the possible vCPUs config at the machine init time to the guest using various DSDT tables like MADT etc. 2. Convey vCPU hotplug events to guest(using GED) 3. Assist in evaluation of various ACPI methods

[PATCH RFC V4 09/33] hw/intc/arm-gicv3*: Changes required to (re)init the GICv3 vCPU Interface

2024-10-08 Thread Salil Mehta via
The GICv3 CPU interface must be (re)initialized when a vCPU is either cold- or hot-plugged. System registers need to be defined and registered with the associated vCPU. For cold-plugged vCPUs, this occurs during the GICv3 realization phase, while for hot-plugged vCPUs, it happens during the GICv3 u

[PATCH RFC V4 08/33] arm/virt, gicv3: Introduce GICv3 CPU Interface *accessibility* flag and checks

2024-10-08 Thread Salil Mehta via
Introduce a `gicc_accessible` flag to indicate whether it is safe to access the GICv3 CPU interface. This flag will determine the availability of the GICv3 CPU interface based on whether the associated QOM vCPUs are enabled or disabled. Additionally, implement checks throughout the GICv3 codebase

[PATCH RFC V4 07/33] arm/virt, gicv3: Changes to pre-size GIC with possible vCPUs @machine init

2024-10-08 Thread Salil Mehta via
The GIC must be pre-sized with the possible vCPUs during initialization. This is essential because: 1. Memory regions and resources associated with GICC/GICR cannot be modified (i.e., added, deleted, or changed) once the VM has been initialized. 2. Additionally, the `GIC_TYPER` must be initiali

[PATCH RFC V4 06/33] arm/virt, kvm: Pre-create disabled possible vCPUs @machine init

2024-10-08 Thread Salil Mehta via
In the ARMv8 architecture, the GIC must know all the CPUs it is connected to during its initialization, and this cannot change afterward. This must be ensured during the initialization of the VGIC in KVM, which requires all vCPUs to be created and present during its initialization. This is necessar

[PATCH RFC V4 05/33] arm/virt, target/arm: Machine init time change common to vCPU {cold|hot}-plug

2024-10-08 Thread Salil Mehta via
Introduce the common logic required during the initialization of both cold and hot-plugged vCPUs. Additionally, initialize the *disabled* state of the vCPUs, which will be used further during the initialization phases of various other components like GIC, PMU, ACPI, etc., as part of the virtual mac

[PATCH RFC V4 02/33] cpu-common: Add common CPU utility for possible vCPUs

2024-10-08 Thread Salil Mehta via
This patch adds various utility functions that may be required to fetch or check the state of possible vCPUs. It also introduces the concept of *disabled* vCPUs, which are part of the *possible* vCPUs but are not enabled. This state will be used during machine initialization and later during the pl

[PATCH RFC V4 04/33] hw/arm/virt: Move setting of common vCPU properties in a function

2024-10-08 Thread Salil Mehta via
Factor out vCPU properties code common for {hot,cold}-plugged vCPUs in the machvirt_init(). This allows code reuse. Signed-off-by: Salil Mehta --- hw/arm/virt.c | 219 ++ include/hw/arm/virt.h | 4 + 2 files changed, 139 insertions(+), 84 deletio

[PATCH RFC V4 03/33] hw/arm/virt: Disable vCPU hotplug for *unsupported* Accel or GIC Type

2024-10-08 Thread Salil Mehta via
For unsupported acceleration types and GIC versions, explicitly disable vCPU hotplug support and limit the number of possible vCPUs to those available at boot time (i.e., SMP CPUs). This flag will be referenced at various points in the code to verify the presence of vCPU hotplug functionality on th

[PATCH RFC V4 00/33] Support of Virtual CPU Hotplug for ARMv8 Arch

2024-10-08 Thread Salil Mehta via
PROLOGUE To assist in review and set the right expectations from this RFC, please first read the sections *APPENDED AT THE END* of this cover letter: 1. Important *DISCLAIMER* [Section (X)] 2. Work presented at KVMForum Conference (slides available) [Section (V)F] 3. Organization of patc

[PATCH RFC V4 01/33] arm/virt, target/arm: Add new ARMCPU {socket, cluster, core, thread}-id property

2024-10-08 Thread Salil Mehta via
This shall be used to store user specified topology{socket,cluster,core,thread} and shall be converted to a unique 'vcpu-id' which is used as slot-index during hot(un)plug of vCPU. Co-developed-by: Keqian Zhu Signed-off-by: Keqian Zhu Signed-off-by: Salil Mehta --- hw/arm/virt.c | 10 +

Re: [PATCH 1/1] virtio-pci: fix memory_region_find for VirtIOPCIRegion's MR

2024-10-08 Thread Gao,Shiyuan
> >> > diff --git a/hw/pci/pci_bridge.c b/hw/pci/pci_bridge.c index > >> > 6a4e38856d..74683e7445 100644 > >> > --- a/hw/pci/pci_bridge.c > >> > +++ b/hw/pci/pci_bridge.c > >> > @@ -380,6 +380,7 @@ void pci_bridge_initfn(PCIDevice *dev, const char > >> *typename) > >> > sec_bus->map_irq = br->map_i

Re: [PATCH 1/1] virtio-pci: fix memory_region_find for VirtIOPCIRegion's MR

2024-10-08 Thread Junjie Mao
"Zuo,Boqun" writes: > On Wed, Sep 25, 2024 8:58 PM Junjie Mao wrote: >> > As shown below, if a virtio PCI device is attached under a pci-bridge, >> > the MR of VirtIOPCIRegion does not belong to any address space. So >> > memory_region_find cannot be used to search for this MR. >> > >> > Introd

Re: [QEMU PATCH] cxl/cxl-mailbox-utils: Fix size check for cmd_firmware_update_get_info

2024-10-08 Thread Davidlohr Bueso
On Tue, 08 Oct 2024, nifan@gmail.com wrote:\n From: Fan Ni In the function cmd_firmware_update_get_info for handling Get FW info command (0x0200h), the vmem, pmem and DC capacity size check were incorrect. The size should be aligned to 256MiB, not smaller than 256MiB. Can get rid of a lev

Re: [PATCH v5 02/12] tcg/riscv: Add basic support for vector

2024-10-08 Thread Richard Henderson
On 10/6/24 19:56, LIU Zhiwei wrote: +} tcg_target_call_clobber_regs = -1u; tcg_regset_reset_reg(tcg_target_call_clobber_regs, TCG_REG_S0); I believe all of the vector registers are call-clobbered? This needs - tcg_target_call_clobber_regs = -1u; + tcg_target_cal

[PATCH] target/i386: Use probe_access_full_mmu in ptw_translate

2024-10-08 Thread Richard Henderson
The probe_access_full_mmu function was designed for this purpose, and does not report the memory operation event to plugins. Cc: qemu-sta...@nongnu.org Fixes: 6d03226b422 ("plugins: force slow path when plugins instrument memory ops") Signed-off-by: Richard Henderson --- target/i386/tcg/sysemu/

[PATCH v3 11/20] target/hppa: Implement TCGCPUOps.tlb_fill_align

2024-10-08 Thread Richard Henderson
Convert hppa_cpu_tlb_fill to hppa_cpu_tlb_fill_align so that we can recognize alignment exceptions in the correct priority order. Resolves: https://bugzilla.kernel.org/show_bug.cgi?id=219339 Signed-off-by: Richard Henderson --- target/hppa/cpu.h| 6 +++--- target/hppa/cpu.c| 2

[PATCH v3 00/20] accel/tcg: Introduce tlb_fill_align hook

2024-10-08 Thread Richard Henderson
This new hook will allow targets to recognize an alignment fault with the correct priority with respect to other faults that can be raised by paging. This should fix several hppa fault priority issues, most importantly that access permissions come before alignment. This should fix the documented

[PATCH v3 20/20] target/arm: Fix alignment fault priority in get_phys_addr_lpae

2024-10-08 Thread Richard Henderson
Now that we have the MemOp for the access, we can order the alignment fault caused by memory type before the permission fault for the page. For subsequent page hits, permission and stage 2 checks are known to pass, and so the TLB_CHECK_ALIGNED fault raised in generic code is not mis-ordered. Revi

[PATCH v3 19/20] target/arm: Implement TCGCPUOps.tlb_fill_align

2024-10-08 Thread Richard Henderson
Fill in the tlb_fill_align hook. Handle alignment not due to memory type, since that's no longer handled by generic code. Pass memop to get_phys_addr. Signed-off-by: Richard Henderson --- target/arm/internals.h | 6 ++--- target/arm/cpu.c| 2 +- target/arm/tcg/cpu-v7m.c|

[PATCH v3 17/20] target/arm: Pass MemOp to get_phys_addr_lpae

2024-10-08 Thread Richard Henderson
Pass the value through from get_phys_addr_nogpc. Reviewed-by: Helge Deller Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/ptw.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/target/arm/ptw.c b/target/a

[PATCH v3 09/20] target/hppa: Fix priority of T, D, and B page faults

2024-10-08 Thread Richard Henderson
Drop the 'else' so that ret is overridden with the highest priority fault. Fixes: d8bc1381250 ("target/hppa: Implement PSW_X") Reviewed-by: Helge Deller Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- target/hppa/mem_helper.c | 8 +--- 1 file changed, 5 insertions(

[PATCH v3 14/20] target/arm: Pass MemOp to get_phys_addr_gpc

2024-10-08 Thread Richard Henderson
Zero is the safe do-nothing value for callers to use. Pass the value through from get_phys_addr. Reviewed-by: Helge Deller Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/ptw.c | 11 ++- 1 file changed, 6 insertions(+), 5

[PATCH v3 15/20] target/arm: Pass MemOp to get_phys_addr_nogpc

2024-10-08 Thread Richard Henderson
Zero is the safe do-nothing value for callers to use. Pass the value through from get_phys_addr_gpc and get_phys_addr_with_space_nogpc. Reviewed-by: Helge Deller Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/ptw.c | 14 -

[PATCH v3 04/20] include/exec/memop: Introduce memop_atomicity_bits

2024-10-08 Thread Richard Henderson
Split out of mmu_lookup. Reviewed-by: Helge Deller Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- include/exec/memop.h | 24 accel/tcg/cputlb.c | 16 ++-- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/include/exec/memop

[PATCH v3 07/20] target/hppa: Add MemOp argument to hppa_get_physical_address

2024-10-08 Thread Richard Henderson
Just add the argument, unused at this point. Zero is the safe do-nothing value for all callers. Reviewed-by: Helge Deller Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- target/hppa/cpu.h| 2 +- target/hppa/int_helper.c | 2 +- target/hppa/mem_helper.c | 9

[PATCH v3 08/20] target/hppa: Perform access rights before protection id check

2024-10-08 Thread Richard Henderson
In Chapter 5, Interruptions, the group 3 exceptions lists "Data memory access rights trap" in priority order ahead of "Data memory protection ID trap". Swap these checks in hppa_get_physical_address. Reviewed-by: Helge Deller Signed-off-by: Richard Henderson --- target/hppa/mem_helper.c | 12 +

[PATCH v3 01/20] accel/tcg: Assert noreturn from write-only page for atomics

2024-10-08 Thread Richard Henderson
There should be no "just in case"; the page is already in the tlb, and known to be not readable. Reviewed-by: Helge Deller Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- accel/tcg/cputlb.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/accel/tcg/cputl

[PATCH v3 05/20] accel/tcg: Add TCGCPUOps.tlb_fill_align

2024-10-08 Thread Richard Henderson
Add a new callback to handle softmmu paging. Return the page details directly, instead of passing them indirectly to tlb_set_page. Handle alignment simultaneously with paging so that faults are handled with target-specific priority. Route all calls the two hooks through a tlb_fill_align function

[PATCH v3 13/20] target/arm: Pass MemOp to get_phys_addr_with_space_nogpc

2024-10-08 Thread Richard Henderson
Zero is the safe do-nothing value for callers to use. Reviewed-by: Helge Deller Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/internals.h | 3 ++- target/arm/helper.c| 9 + target/arm/ptw.c | 2 +- 3 files chan

[PATCH v3 03/20] include/exec/memop: Rename get_alignment_bits

2024-10-08 Thread Richard Henderson
Rename to use "memop_" prefix, like other functions that operate on MemOp. Reviewed-by: Helge Deller Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- include/exec/memop.h | 4 ++-- accel/tcg/cputlb.c | 4 ++-- accel/tcg/

[PATCH v3 10/20] target/hppa: Handle alignment faults in hppa_get_physical_address

2024-10-08 Thread Richard Henderson
In Chapter 5, Interruptions, the group 3 exceptions lists "Unaligned data reference trap" has higher priority than "Data memory break trap". Reviewed-by: Helge Deller Signed-off-by: Richard Henderson --- target/hppa/mem_helper.c | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff

[PATCH v3 02/20] include/exec/memop: Move get_alignment_bits from tcg.h

2024-10-08 Thread Richard Henderson
This function is specific to MemOp, not TCG in general. Reviewed-by: Helge Deller Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- include/exec/memop.h | 23 +++ include/tcg/tcg.h| 23 --- 2 files c

[PATCH v3 06/20] accel/tcg: Use the alignment test in tlb_fill_align

2024-10-08 Thread Richard Henderson
When we have a tlb miss, defer the alignment check to the new tlb_fill_align hook. Move the existing alignment check so that we only perform it with a tlb hit. Signed-off-by: Richard Henderson --- accel/tcg/cputlb.c | 88 -- 1 file changed, 45 inserti

[PATCH v3 12/20] target/arm: Pass MemOp to get_phys_addr

2024-10-08 Thread Richard Henderson
Zero is the safe do-nothing value for callers to use. Reviewed-by: Helge Deller Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- target/arm/internals.h | 3 ++- target/arm/ptw.c| 2 +- target/arm/tcg/m_helper.c | 8 target/arm/tcg/tlb_helper.

[PATCH v3 18/20] target/arm: Move device detection earlier in get_phys_addr_lpae

2024-10-08 Thread Richard Henderson
Determine cache attributes, and thence Device vs Normal memory, earlier in the function. We have an existing regime_is_stage2 if block into which this can be slotted. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/ptw.c | 49 -

[PATCH v3 16/20] target/arm: Pass MemOp through get_phys_addr_twostage

2024-10-08 Thread Richard Henderson
Pass memop through get_phys_addr_twostage with its recursion with get_phys_addr_nogpc. Reviewed-by: Helge Deller Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/ptw.c | 10 ++ 1 file changed, 6 insertions(+), 4 deletions(-

[PATCH v16 13/20] target/riscv: mmu changes for zicfiss shadow stack protection

2024-10-08 Thread Deepak Gupta
zicfiss protects shadow stack using new page table encodings PTE.W=1, PTE.R=0 and PTE.X=0. This encoding is reserved if zicfiss is not implemented or if shadow stack are not enabled. Loads on shadow stack memory are allowed while stores to shadow stack memory leads to access faults. Shadow stack ac

[PATCH v16 12/20] target/riscv: tb flag for shadow stack instructions

2024-10-08 Thread Deepak Gupta
Shadow stack instructions can be decoded as zimop / zcmop or shadow stack instructions depending on whether shadow stack are enabled at current privilege. This requires a TB flag so that correct TB generation and correct TB lookup happens. `DisasContext` gets a field indicating whether bcfi is enab

[PATCH v16 16/20] target/riscv: implement zicfiss instructions

2024-10-08 Thread Deepak Gupta
zicfiss has following instructions - sspopchk: pops a value from shadow stack and compares with x1/x5. If they dont match, reports a sw check exception with tval = 3. - sspush: pushes value in x1/x5 on shadow stack - ssrdp: reads current shadow stack - ssamoswap: swaps contents of shadow sta

[PATCH v16 01/20] target/riscv: expose *envcfg csr and priv to qemu-user as well

2024-10-08 Thread Deepak Gupta
Execution environment config CSR controlling user env and current privilege state shouldn't be limited to qemu-system only. *envcfg CSRs control enabling of features in next lesser mode. In some cases bits *envcfg CSR can be lit up by kernel as part of kernel policy or software (user app) can choos

[PATCH v16 02/20] target/riscv: Add zicfilp extension

2024-10-08 Thread Deepak Gupta
zicfilp [1] riscv cpu extension enables forward control flow integrity. If enabled, all indirect calls must land on a landing pad instruction. This patch sets up space for zicfilp extension in cpuconfig. zicfilp is dependend on zicsr. [1] - https://github.com/riscv/riscv-cfi Signed-off-by: Deepa

[PATCH v16 17/20] target/riscv: compressed encodings for sspush and sspopchk

2024-10-08 Thread Deepak Gupta
sspush/sspopchk have compressed encodings carved out of zcmops. compressed sspush is designated as c.mop.1 while compressed sspopchk is designated as c.mop.5. Note that c.sspush x1 exists while c.sspush x5 doesn't. Similarly c.sspopchk x5 exists while c.sspopchk x1 doesn't. Signed-off-by: Deepak

[PATCH v16 09/20] target/riscv: Expose zicfilp extension as a cpu property

2024-10-08 Thread Deepak Gupta
Signed-off-by: Deepak Gupta Reviewed-by: Alistair Francis --- target/riscv/cpu.c | 1 + 1 file changed, 1 insertion(+) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 05f727222e..135559fc95 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1469,6 +1469,7 @@ const RISCVCPUM

[PATCH v16 19/20] disas/riscv: enable disassembly for compressed sspush/sspopchk

2024-10-08 Thread Deepak Gupta
sspush and sspopchk have equivalent compressed encoding taken from zcmop. cmop.1 is sspush x1 while cmop.5 is sspopchk x5. Due to unusual encoding for both rs1 and rs2 from space bitfield, this required a new codec. Signed-off-by: Deepak Gupta Acked-by: Alistair Francis --- disas/riscv.c | 19 +

[PATCH v16 18/20] disas/riscv: enable disassembly for zicfiss instructions

2024-10-08 Thread Deepak Gupta
Enable disassembly for sspush, sspopchk, ssrdp & ssamoswap. Disasembly is only enabled if zimop and zicfiss ext is set to true. Signed-off-by: Deepak Gupta Acked-by: Alistair Francis --- disas/riscv.c | 40 +++- disas/riscv.h | 1 + 2 files changed, 40 inser

[PATCH v16 08/20] disas/riscv: enable `lpad` disassembly

2024-10-08 Thread Deepak Gupta
Signed-off-by: Deepak Gupta Co-developed-by: Jim Shu Co-developed-by: Andy Chiu Reviewed-by: Richard Henderson Reviewed-by: Alistair Francis --- disas/riscv.c | 18 +- disas/riscv.h | 2 ++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/disas/riscv.c b/disas/r

[PATCH v16 10/20] target/riscv: Add zicfiss extension

2024-10-08 Thread Deepak Gupta
zicfiss [1] riscv cpu extension enables backward control flow integrity. This patch sets up space for zicfiss extension in cpuconfig. And imple- ments dependency on A, zicsr, zimop and zcmop extensions. [1] - https://github.com/riscv/riscv-cfi Signed-off-by: Deepak Gupta Co-developed-by: Jim Sh

[PATCH v16 06/20] target/riscv: tracking indirect branches (fcfi) for zicfilp

2024-10-08 Thread Deepak Gupta
zicfilp protects forward control flow (if enabled) by enforcing all indirect call and jmp must land on a landing pad instruction `lpad`. If target of an indirect call or jmp is not `lpad` then cpu/hart must raise a sw check exception with tval = 2. This patch implements the mechanism using TCG. Ta

[PATCH v16 03/20] target/riscv: Introduce elp state and enabling controls for zicfilp

2024-10-08 Thread Deepak Gupta
zicfilp introduces a new state elp ("expected landing pad") in cpu. During normal execution, elp is idle (NO_LP_EXPECTED) i.e not expecting landing pad. On an indirect call, elp moves LP_EXPECTED. When elp is LP_EXPECTED, only a subsquent landing pad instruction can set state back to NO_LP_EXPECTED

[PATCH v16 07/20] target/riscv: zicfilp `lpad` impl and branch tracking

2024-10-08 Thread Deepak Gupta
Implements setting lp expected when `jalr` is encountered and implements `lpad` instruction of zicfilp. `lpad` instruction is taken out of auipc x0, . This is an existing HINTNOP space. If `lpad` is target of an indirect branch, cpu checks for 20 bit value in x7 upper with 20 bit value embedded in

[PATCH v16 14/20] target/riscv: AMO operations always raise store/AMO fault

2024-10-08 Thread Deepak Gupta
This patch adds one more word for tcg compile which can be obtained during unwind time to determine fault type for original operation (example AMO). Depending on that, fault can be promoted to store/AMO fault. Signed-off-by: Deepak Gupta Suggested-by: Richard Henderson Reviewed-by: Richard Hende

[PATCH v16 15/20] target/riscv: update `decode_save_opc` to store extra word2

2024-10-08 Thread Deepak Gupta
Extra word 2 is stored during tcg compile and `decode_save_opc` needs additional argument in order to pass the value. This will be used during unwind to get extra information about instruction like how to massage exceptions. Updated all callsites as well. Resolves: https://gitlab.com/qemu-project/

[PATCH v16 00/20] riscv support for control flow integrity extensions

2024-10-08 Thread Deepak Gupta
v16 for riscv zicfilp and zicfiss extensions support in qemu. Following change in this version: cache block operations of clean, flush and inval have store semantics. These operations on shadow stack must look like regular stores and must always raise store/AMO access fault. However with current l

[PATCH v16 20/20] target/riscv: Expose zicfiss extension as a cpu property

2024-10-08 Thread Deepak Gupta
Signed-off-by: Deepak Gupta Reviewed-by: Alistair Francis --- target/riscv/cpu.c | 1 + 1 file changed, 1 insertion(+) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index ac5ad6fa9d..0751d08d85 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1473,6 +1473,7 @@ const RISCVCPUM

[PATCH v16 04/20] target/riscv: save and restore elp state on priv transitions

2024-10-08 Thread Deepak Gupta
elp state is recorded in *status on trap entry (less privilege to higher privilege) and restored in elp from *status on trap exit (higher to less privilege). Additionally this patch introduces a forward cfi helper function to determine if current privilege has forward cfi is enabled or not based o

[PATCH v16 11/20] target/riscv: introduce ssp and enabling controls for zicfiss

2024-10-08 Thread Deepak Gupta
zicfiss introduces a new state ssp ("shadow stack register") in cpu. ssp is expressed as a new unprivileged csr (CSR_SSP=0x11) and holds virtual address for shadow stack as programmed by software. Shadow stack (for each mode) is enabled via bit3 in *envcfg CSRs. Shadow stack can be enabled for a m

[PATCH v16 05/20] target/riscv: additional code information for sw check

2024-10-08 Thread Deepak Gupta
sw check exception support was recently added. This patch further augments sw check exception by providing support for additional code which is provided in *tval. Adds `sw_check_code` field in cpuarchstate. Whenever sw check exception is raised *tval gets the value deposited in `sw_check_code`. Si

Re: [PATCH 2/2] migration/multifd: Fix rb->receivedmap cleanup race

2024-10-08 Thread Fabiano Rosas
Elena Ufimtseva writes: > On Fri, Sep 13, 2024 at 3:07 PM Fabiano Rosas wrote: > >> Fix a segmentation fault in multifd when rb->receivedmap is cleared >> too early. >> >> After commit 5ef7e26bdb ("migration/multifd: solve zero page causing >> multiple page faults"), multifd started using the rb

Re: [PATCH V2 05/13] physmem: preserve ram blocks for cpr

2024-10-08 Thread Peter Xu
On Tue, Oct 08, 2024 at 05:05:01PM -0400, Steven Sistare wrote: > On 10/8/2024 12:26 PM, Peter Xu wrote: > > On Tue, Oct 08, 2024 at 11:17:46AM -0400, Steven Sistare wrote: > > > On 10/7/2024 12:28 PM, Peter Xu wrote: > > > > On Mon, Oct 07, 2024 at 11:49:25AM -0400, Peter Xu wrote: > > > > > On Mo

Re: [PATCH v7 0/5] AWS Nitro Enclave emulation support

2024-10-08 Thread Dorjoy Chowdhury
Thanks for reviewing. I have now submitted a v8. https://lore.kernel.org/qemu-devel/20241008211727.49088-1-dorjoychy...@gmail.com/T/#t Regards, Dorjoy

[PATCH v8 5/6] machine/nitro-enclave: New machine type for AWS Nitro Enclaves

2024-10-08 Thread Dorjoy Chowdhury
AWS nitro enclaves[1] is an Amazon EC2[2] feature that allows creating isolated execution environments, called enclaves, from Amazon EC2 instances which are used for processing highly sensitive data. Enclaves have no persistent storage and no external networking. The enclave VMs are based on the Fi

[PATCH v8 6/6] docs/nitro-enclave: Documentation for nitro-enclave machine type

2024-10-08 Thread Dorjoy Chowdhury
Signed-off-by: Dorjoy Chowdhury --- MAINTAINERS| 1 + docs/system/i386/nitro-enclave.rst | 78 ++ 2 files changed, 79 insertions(+) create mode 100644 docs/system/i386/nitro-enclave.rst diff --git a/MAINTAINERS b/MAINTAINERS index f78a7cca06.

  1   2   3   >