[PATCH v7 06/52] i386/tdx: Introduce is_tdx_vm() helper and cache tdx_guest object

2025-01-24 Thread Xiaoyao Li
It will need special handling for TDX VMs all around the QEMU. Introduce is_tdx_vm() helper to query if it's a TDX VM. Cache tdx_guest object thus no need to cast from ms->cgs every time. Signed-off-by: Xiaoyao Li Acked-by: Gerd Hoffmann Reviewed-by: Isaku Yamahata --- changes in v3: - replace

[PATCH v7 19/52] i386/tdx: Track mem_ptr for each firmware entry of TDVF

2025-01-24 Thread Xiaoyao Li
For each TDVF sections, QEMU needs to copy the content to guest private memory via KVM API (KVM_TDX_INIT_MEM_REGION). Introduce a field @mem_ptr for TdxFirmwareEntry to track the memory pointer of each TDVF sections. So that QEMU can add/copy them to guest private memory later. TDVF sections can

[PATCH v7 14/52] i386/tdx: Implement user specified tsc frequency

2025-01-24 Thread Xiaoyao Li
Reuse "-cpu,tsc-frequency=" to get user wanted tsc frequency and call VM scope VM_SET_TSC_KHZ to set the tsc frequency of TD before KVM_TDX_INIT_VM. Besides, sanity check the tsc frequency to be in the legal range and legal granularity (required by TDX module). Signed-off-by: Xiaoyao Li Acked-by

[PATCH v7 24/52] i386/tdx: Call KVM_TDX_INIT_VCPU to initialize TDX vcpu

2025-01-24 Thread Xiaoyao Li
TDX vcpu needs to be initialized by SEAMCALL(TDH.VP.INIT) and KVM provides vcpu level IOCTL KVM_TDX_INIT_VCPU for it. KVM_TDX_INIT_VCPU needs the address of the HOB as input. Invoke it for each vcpu after HOB list is created. Signed-off-by: Xiaoyao Li Acked-by: Gerd Hoffmann --- target/i386/kv

[PATCH v7 36/52] i386/tdx: Don't synchronize guest tsc for TDs

2025-01-24 Thread Xiaoyao Li
From: Isaku Yamahata TSC of TDs is not accessible and KVM doesn't allow access of MSR_IA32_TSC for TDs. To avoid the assert() in kvm_get_tsc, make kvm_synchronize_all_tsc() noop for TDs, Signed-off-by: Isaku Yamahata Reviewed-by: Connor Kuehl Signed-off-by: Xiaoyao Li Acked-by: Gerd Hoffmann

[PATCH v7 31/52] i386/cpu: Introduce enable_cpuid_0x1f to force exposing CPUID 0x1f

2025-01-24 Thread Xiaoyao Li
Currently, QEMU exposes CPUID 0x1f to guest only when necessary, i.e., when topology level that cannot be enumerated by leaf 0xB, e.g., die or module level, are configured for the guest, e.g., -smp xx,dies=2. However, TDX architecture forces to require CPUID 0x1f to configure CPU topology. Introd

[PATCH v7 30/52] i386/tdx: implement tdx_cpu_instance_init()

2025-01-24 Thread Xiaoyao Li
Currently, pmu is not supported for TDX by KVM. Signed-off-by: Xiaoyao Li --- chanegs in v6: - new patch; --- target/i386/kvm/tdx.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/target/i386/kvm/tdx.c b/target/i386/kvm/tdx.c index 591de30eedf4..12c1c2503845 100644 --- a/target/i386/k

[PATCH v7 32/52] i386/tdx: Force exposing CPUID 0x1f

2025-01-24 Thread Xiaoyao Li
TDX uses CPUID 0x1f to configure TD guest's CPU topology. So set enable_cpuid_0x1f for TDs. Signed-off-by: Xiaoyao Li --- target/i386/kvm/tdx.c | 4 1 file changed, 4 insertions(+) diff --git a/target/i386/kvm/tdx.c b/target/i386/kvm/tdx.c index 12c1c2503845..982ed779df4a 100644 --- a/targ

[PATCH v7 20/52] i386/tdx: Track RAM entries for TDX VM

2025-01-24 Thread Xiaoyao Li
The RAM of TDX VM can be classified into two types: - TDX_RAM_UNACCEPTED: default type of TDX memory, which needs to be accepted by TDX guest before it can be used and will be all-zeros after being accepted. - TDX_RAM_ADDED: the RAM that is ADD'ed to TD guest before running, and can be

[PATCH v7 43/52] i386/tdx: Mask off CPUID bits by unsupported TD Attributes

2025-01-24 Thread Xiaoyao Li
For TDX, some CPUID feature bit is configured via TD attributes. Adjust the supported CPUID to mask off the bit if its matched attribute is unsupported. Signed-off-by: Xiaoyao Li --- target/i386/cpu.h | 4 target/i386/kvm/tdx.c | 54 +++ 2 files

[PATCH v7 25/52] i386/tdx: Finalize TDX VM

2025-01-24 Thread Xiaoyao Li
Invoke KVM_TDX_FINALIZE_VM to finalize the TD's measurement and make the TD vCPUs runnable once machine initialization is complete. Signed-off-by: Xiaoyao Li Acked-by: Gerd Hoffmann --- target/i386/kvm/tdx.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/target/i386/kvm/tdx.c b/target/i

[PATCH v7 51/52] i386/tdx: Validate phys_bits against host value

2025-01-24 Thread Xiaoyao Li
For TDX guest, the phys_bits is not configurable and can only be host/native value. Validate phys_bits inside tdx_check_features(). Signed-off-by: Xiaoyao Li --- target/i386/host-cpu.c | 2 +- target/i386/host-cpu.h | 1 + target/i386/kvm/tdx.c | 8 3 files changed, 10 insertions(+),

[PATCH v7 48/52] i386/tdx: Fetch and validate CPUID of TD guest

2025-01-24 Thread Xiaoyao Li
Use KVM_TDX_GET_CPUID to get the CPUIDs that are managed and enfored by TDX module for TD guest. Check QEMU's configuration against the fetched data. Print wanring message when 1. a feature is not supported but requested by QEMU or 2. QEMU doesn't want to expose a feature while it is enforced ena

[PATCH v7 45/52] i386/tdx: Mask off CPUID bits by unsupported XFAM

2025-01-24 Thread Xiaoyao Li
Mask off the CPUID bits as unsupported if its matched XFAM bit is not supported. Otherwise, it might fail the check in setup_td_xfam() as unsupported XFAM being requested. Signed-off-by: Xiaoyao Li --- target/i386/kvm/tdx.c | 39 +++ 1 file changed, 39 inserti

[PATCH v7 26/52] i386/tdx: Enable user exit on KVM_HC_MAP_GPA_RANGE

2025-01-24 Thread Xiaoyao Li
KVM translates TDG.VP.VMCALL to KVM_HC_MAP_GPA_RANGE, and QEMU needs to enable user exit on KVM_HC_MAP_GPA_RANGE in order to handle the memory conversion requested by TD guest. Signed-off-by: Xiaoyao Li --- changes in v6: - new patch; --- target/i386/kvm/tdx.c | 7 +++ 1 file changed, 7 ins

[PATCH v7 39/52] cpu: Don't set vcpu_dirty when guest_state_protected

2025-01-24 Thread Xiaoyao Li
QEMU calls kvm_arch_put_registers() when vcpu_dirty is true in kvm_vcpu_exec(). However, for confidential guest, like TDX, putting registers is disallowed due to guest state is protected. Only set vcpu_dirty to true with guest state is not protected when creating the vcpu. Signed-off-by: Xiaoyao

[PATCH v7 33/52] i386/tdx: Set kvm_readonly_mem_enabled to false for TDX VM

2025-01-24 Thread Xiaoyao Li
TDX only supports readonly for shared memory but not for private memory. In the view of QEMU, it has no idea whether a memslot is used as shared memory of private. Thus just mark kvm_readonly_mem_enabled to false to TDX VM for simplicity. Signed-off-by: Xiaoyao Li Acked-by: Gerd Hoffmann --- t

[PATCH v7 49/52] i386/tdx: Don't treat SYSCALL as unavailable

2025-01-24 Thread Xiaoyao Li
Signed-off-by: Xiaoyao Li --- Changes in v7: - fix CPUID_EXT2_SYSCALL by adding it to actual; --- target/i386/kvm/tdx.c | 13 + 1 file changed, 13 insertions(+) diff --git a/target/i386/kvm/tdx.c b/target/i386/kvm/tdx.c index f6a4f3322e61..58ea6a4d3156 100644 --- a/target/i386/kvm/t

[PATCH v7 27/52] i386/tdx: Handle KVM_SYSTEM_EVENT_TDX_FATAL

2025-01-24 Thread Xiaoyao Li
TD guest can use TDG.VP.VMCALL to request termination. KVM translates such request into KVM_EXIT_SYSTEM_EVENT with type of KVM_SYSTEM_EVENT_TDX_FATAL. Add hanlder for such exit. Parse and print the error message, and terminate the TD guest in the handler. Signed-off-by: Xiaoyao Li --- Changes in

[PATCH v7 41/52] i386/tdx: Implement adjust_cpuid_features() for TDX

2025-01-24 Thread Xiaoyao Li
1. QEMU's support for Intel PT is borken in general, thus doesn't support for TDX. 2. Only limited KVM PV features are supported for TD guest. 3. Drop the AMD specific bits that are reserved on Intel platform. Signed-off-by: Xiaoyao Li --- target/i386/kvm/tdx.c | 44

[PATCH v7 07/52] kvm: Introduce kvm_arch_pre_create_vcpu()

2025-01-24 Thread Xiaoyao Li
Introduce kvm_arch_pre_create_vcpu(), to perform arch-dependent work prior to create any vcpu. This is for i386 TDX because it needs call TDX_INIT_VM before creating any vcpu. The specific implemnet of i386 will be added in the future patch. Signed-off-by: Xiaoyao Li Acked-by: Gerd Hoffmann ---

[PATCH v7 29/52] i386/cpu: introduce x86_confidential_guest_cpu_instance_init()

2025-01-24 Thread Xiaoyao Li
To allow execute confidential guest specific cpu init operations. Signed-off-by: Xiaoyao Li --- Changes in v6: - new patch; --- target/i386/confidential-guest.h | 11 +++ target/i386/cpu.c| 10 ++ 2 files changed, 21 insertions(+) diff --git a/target/i386/confid

Re: [PATCH v6 41/60] hw/i386: add option to forcibly report edge trigger in acpi tables

2025-01-24 Thread Xiaoyao Li
On 1/23/2025 8:53 PM, Igor Mammedov wrote: On Tue, 14 Jan 2025 21:01:27 +0800 Xiaoyao Li wrote: On 12/13/2024 6:39 AM, Ira Weiny wrote: On Tue, Nov 05, 2024 at 01:23:49AM -0500, Xiaoyao Li wrote: From: Isaku Yamahata When level trigger isn't supported on x86 platform, it used to be level

Re: [PATCH] tests/functional: Add a test for the arm microbit machine

2025-01-24 Thread Alex Bennée
Thomas Huth writes: > We don't have any functional tests for this machine yet, thus let's > add a test with a MicroPython binary that is available online We do have a basic system test: test-armv6m-undef: test-armv6m-undef.S $(CC) -mcpu=cortex-m0 -mfloat-abi=soft \

[PATCH v7 46/52] i386/tdx: Mark the configurable bit not reported by KVM as unsupported

2025-01-24 Thread Xiaoyao Li
There is no interface in KVM to report the support bits of TD guest. QEMU has to maintain the knowledge itself. E.g., fixed0 and fixed1 are already hardcoded in tdx_fixed0_bits and tdx_fixed1_bits. For configurable bits, KVM might filer some due to KVM lacks the support currently. The filtered bit

[PATCH v7 08/52] i386/tdx: Initialize TDX before creating TD vcpus

2025-01-24 Thread Xiaoyao Li
Invoke KVM_TDX_INIT in kvm_arch_pre_create_vcpu() that KVM_TDX_INIT configures global TD configurations, e.g. the canonical CPUID config, and must be executed prior to creating vCPUs. Use kvm_x86_arch_cpuid() to setup the CPUID settings for TDX VM. Note, this doesn't address the fact that QEMU ma

Re: [RFC v2 0/5] accel/kvm: Support KVM PMU filter

2025-01-24 Thread Lai, Yi
On Wed, Jan 22, 2025 at 05:05:12PM +0800, Zhao Liu wrote: > Hi folks, > > Sorry for the long wait, but RFC v2 is here at last. > > Compared with v1 [1], v2 mianly makes `action` as a global parameter, > and all events (and fixed counters) are based on a unified action. > > Learned from the discu

Basic question about QEMU emulation

2025-01-24 Thread internetarchive
Hello, I have a basic question about emulation by QEMU when there is no hardware peripheral. How does QEMU emulate wifi functionality for VMs if the underlying hardware doesn't have wifi RF module ? Basically, how does it give the user of the VM internet access through WiFi ? This question can be g

[PATCH v7 44/52] i386/cpu: Move CPUID_XSTATE_XSS_MASK to header file and introduce CPUID_XSTATE_MASK

2025-01-24 Thread Xiaoyao Li
They will be used by TDX. Signed-off-by: Xiaoyao Li --- target/i386/cpu.c | 3 --- target/i386/cpu.h | 5 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 4088bf63c48f..f1330627adbb 100644 --- a/target/i386/cpu.c +++ b/target/i386/c

Re: [PATCH 24/28] target/sh4: Move has_work() from CPUClass to SysemuCPUOps

2025-01-24 Thread Richard Henderson
On 1/21/25 06:23, Philippe Mathieu-Daudé wrote: Signed-off-by: Philippe Mathieu-Daudé --- target/sh4/cpu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) Reviewed-by: Richard Henderson r~

Re: [PATCH 27/28] target/xtensa: Move has_work() from CPUClass to SysemuCPUOps

2025-01-24 Thread Richard Henderson
On 1/21/25 06:23, Philippe Mathieu-Daudé wrote: Move has_work() from CPUClass to SysemuCPUOps, simplifying xtensa_cpu_has_work() by directly using CPU env. Signed-off-by: Philippe Mathieu-Daudé --- target/xtensa/cpu.c | 12 +--- 1 file changed, 5 insertions(+), 7 deletions(-) Review

Re: [PATCH 25/28] target/sparc: Move has_work() from CPUClass to SysemuCPUOps

2025-01-24 Thread Richard Henderson
On 1/21/25 06:23, Philippe Mathieu-Daudé wrote: Signed-off-by: Philippe Mathieu-Daudé --- target/sparc/cpu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) Reviewed-by: Richard Henderson r~

[PATCH 14/76] target/arm: Use fp_status_f16_a32 in AArch32-only helpers

2025-01-24 Thread Peter Maydell
We directly use fp_status_f16 in a handful of helpers that are AArch32-specific; switch to fp_status_f16_a32 for these. Signed-off-by: Peter Maydell --- target/arm/tcg/vec_helper.c | 4 ++-- target/arm/vfp_helper.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/target

Re: [PATCH 20/28] target/riscv: Move has_work() from CPUClass to SysemuCPUOps

2025-01-24 Thread Philippe Mathieu-Daudé
On 24/1/25 18:17, Richard Henderson wrote: On 1/21/25 06:23, Philippe Mathieu-Daudé wrote: Signed-off-by: Philippe Mathieu-Daudé ---   target/riscv/cpu.h   | 9 +   target/riscv/internals.h | 3 ---   target/riscv/cpu.c   | 8 +++-   3 files changed, 8 insertions(+), 12 deletio

[PATCH v2 5/7] memory: pass MemTxAttrs to memory_access_is_direct()

2025-01-24 Thread David Hildenbrand
We want to pass another flag that will be stored in MemTxAttrs. So pass MemTxAttrs directly. Signed-off-by: David Hildenbrand --- hw/core/loader.c | 2 +- hw/remote/vfio-user-obj.c | 2 +- include/exec/memory.h | 5 +++-- system/memory_ldst.c.inc | 18 +- system/

[RFC PATCH QEMU x3/3] contrib: Add example hotness monitoring unit server

2025-01-24 Thread Jonathan Cameron via
This is used inconjuction with the cache plugin (with port parameter supplied) and the CXL Type 3 device with a hotness monitoring unit (chmu-port parameter supplied). It implements a very basic oracle with a counter per 4KiB page and simple loop to find large counts. The hotlist length is contro

[PATCH] docs/system/arm/aspeed: Remove tacoma-bmc from the documentation

2025-01-24 Thread Thomas Huth
The tacoma-bmc machine has recently been removed, so let's remove it from the documentation now, too. Fixes: 2b1b66e01f ("arm: Remove tacoma-bmc machine") Signed-off-by: Thomas Huth --- docs/system/arm/aspeed.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/system

Re: [PATCH 2/2] hw/char/sh_serial: Convert to TypeInfo

2025-01-24 Thread Philippe Mathieu-Daudé
On 24/1/25 18:50, Philippe Mathieu-Daudé wrote: QOM types are now registered using as TypeInfo via DEFINE_TYPES() or type_init(). Update TYPE_SH_SERIAL, removing the empty QOM instance_init/finalize handlers. Signed-off-by: Philippe Mathieu-Daudé --- hw/char/sh_serial.c | 23 +++--

Re: [PATCH v1 3/3] hw/s390x: support migration of CPI values

2025-01-24 Thread Nina Schoetterl-Glausch
On Wed, 2025-01-15 at 14:31 +0100, Shalini Chellathurai Saroja wrote: > This commit saves the state of CPI values in the guest and > transfers this state during live migration of the guest. IMO, using active voice and directly stating what is done is preferable. Something like: Register Control-P

Re: [PATCH v1 2/3] hw/s390x: add CPI values to QOM

2025-01-24 Thread Nina Schoetterl-Glausch
On Wed, 2025-01-15 at 14:31 +0100, Shalini Chellathurai Saroja wrote: > This commit adds the firmware control-program > identifiers received from a KVM guest via the > SCLP event type Control-Program Identification to QOM. > A timestamp in which the data is received is also > added to QOM. > > Exa

Re: [PATCH 2/7] guest_memfd: Introduce an object to manage the guest-memfd with RamDiscardManager

2025-01-24 Thread David Hildenbrand
Definitely not suggesting to install an invalid pointer anywhere. The mapped pointer will still be valid for gmem for example, but the fault isn't. We need to differenciate two things (1) virtual address mapping, then (2) permission and accesses on the folios / pages of the mapping. Here I think

Re: [PATCH 07/28] cpus: Introduce SysemuCPUOps::has_work() handler

2025-01-24 Thread Richard Henderson
On 1/21/25 06:23, Philippe Mathieu-Daudé wrote: SysemuCPUOps::has_work() is similar to CPUClass::has_work(), but only exposed on system emulation. Signed-off-by: Philippe Mathieu-Daudé --- include/hw/core/sysemu-cpu-ops.h | 4 hw/core/cpu-system.c | 4 2 files changed,

Re: [PATCH 09/28] target/arm: Move has_work() from CPUClass to SysemuCPUOps

2025-01-24 Thread Richard Henderson
On 1/21/25 06:23, Philippe Mathieu-Daudé wrote: Signed-off-by: Philippe Mathieu-Daudé --- target/arm/cpu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) Reviewed-by: Richard Henderson r~

Re: [PATCH 1/2] hw/hppa: Support up to 256 GiB RAM on 64-bit machines

2025-01-24 Thread Helge Deller
On 1/24/25 18:52, Philippe Mathieu-Daudé wrote: On 22/1/25 19:09, del...@kernel.org wrote: From: Helge Deller Allow up to 256 GB RAM, which is the maximum a rp8440 machine (the very last 64-bit PA-RISC machine) physically supports. Signed-off-by: Helge Deller ---   hw/hppa/hppa_hardware.h | 

[PATCH v3 0/2] s390x/pci: relax I/O address translation requirement

2025-01-24 Thread Matthew Rosato
This series introduces the concept of the relaxed translation requirement for s390x guests in order to allow bypass of the guest IOMMU for more efficient PCI passthrough. With this series, QEMU can indicate to the guest that an IOMMU is not strictly required for a zPCI device. This would subseque

[PATCH v3 2/2] s390x/pci: indicate QEMU supports relaxed translation for passthrough

2025-01-24 Thread Matthew Rosato
Specifying this bit in the guest CLP response indicates that the guest can optionally choose to skip translation and instead use identity-mapped operations. Signed-off-by: Matthew Rosato --- hw/s390x/s390-pci-vfio.c| 5 - include/hw/s390x/s390-pci-clp.h | 1 + 2 files changed, 5 inse

Re: [PATCH 22/28] target/s390x: Restrict I/O handler installers to system emulation

2025-01-24 Thread Richard Henderson
On 1/21/25 06:23, Philippe Mathieu-Daudé wrote: Signed-off-by: Philippe Mathieu-Daudé --- target/s390x/s390x-internal.h | 2 ++ 1 file changed, 2 insertions(+) Reviewed-by: Richard Henderson r~

Re: [PULL 00/48] i386, rust changes for 2024-01-24

2025-01-24 Thread Paolo Bonzini
Il ven 24 gen 2025, 20:05 Stefan Hajnoczi ha scritto: > Hi Paolo, > Please take a look at this failure and send a v2 pull request, if > necessary: > > thread '' panicked at 'already borrowed', > rust/qemu-api/libqemu_api.rlib.p/structured/cell.rs:450:5 > note: run with `RUST_BACKTRACE=1` environm

Re: [RFC PATCH QEMU 0/3] cxl/plugins: Hotness Monitoring Unit with 'real' data.

2025-01-24 Thread Pierrick Bouvier
Hi Jonathan, thanks for posting this. It's a creative usage of plugins. I think that your current approach, decoupling plugins, CHMU and device model is a good thing. I'm not familiar with CXL, but one question that comes to my mind is: Is that mandatory to do this analysis during execution (

Re: [PATCH v1 1/5] linux-headers: NOTFORMERGE - placeholder uapi updates for AP config change

2025-01-24 Thread Cédric Le Goater
On 1/14/25 20:55, Eric Farman wrote: On Tue, 2025-01-14 at 13:51 -0500, Rorie Reyes wrote: On 1/8/25 2:29 AM, Cédric Le Goater wrote: Hello Rorie, On 1/7/25 19:43, Rorie Reyes wrote: This patch adds enumeration constant VFIO_AP_CFG_CHG_IRQ_INDEX to specify an IRQ index for signaling that a ch

[PATCH] target/riscv: rvv: Fix incorrect vlen comparison in prop_vlen_set

2025-01-24 Thread Max Chou
In prop_vlen_set function, there is an incorrect comparison between vlen(bit) and vlenb(byte). This will cause unexpected error when user applies the `vlen=1024` cpu option with a vendor predefined cpu type that the default vlen is 1024(vlenb=128). Signed-off-by: Max Chou --- target/riscv/cpu.c

Re: [PATCH v1 2/5] hw/vfio/ap: notification handler for AP config changed event

2025-01-24 Thread Cédric Le Goater
On 1/7/25 19:43, Rorie Reyes wrote: Register an event notifier handler to process AP configuration change events by queuing the event and generating a CRW to let the guest know its AP configuration has changed Signed-off-by: Rorie Reyes Reviewed-by: Anthony Krowiak Tested-by: Anthony Krowiak

Re: [PATCH v1 3/5] hw/vfio/ap: store object indicating AP config changed in a queue

2025-01-24 Thread Cédric Le Goater
On 1/7/25 19:43, Rorie Reyes wrote: Creates an object indicating that an AP configuration change event has been received and stores it in a queue. These objects will later be used to store event information for an AP configuration change when the CHSC instruction is intercepted. Signed-off-by: R

Re: [PATCH v1 4/5] hw/vfio/ap: Storing event information for an AP configuration change event

2025-01-24 Thread Cédric Le Goater
On 1/7/25 19:43, Rorie Reyes wrote: These functions can be invoked by the function that handles interception of the CHSC SEI instruction for requests indicating the accessibility of one or more adjunct processors has changed. Signed-off-by: Rorie Reyes --- hw/vfio/ap.c | 37 ++

Re: [PATCH] hw/virtio/vhost: Disable IOTLB callbacks when IOMMU gets disabled

2025-01-24 Thread Jason Wang
On Fri, Jan 24, 2025 at 12:01 PM Duan, Zhenzhong wrote: > > > > >-Original Message- > >From: Jason Wang > >Subject: Re: [PATCH] hw/virtio/vhost: Disable IOTLB callbacks when IOMMU gets > >disabled > > > >On Fri, Jan 24, 2025 at 11:30 AM Jason Wang wrote: > >> > >> On Fri, Jan 24, 2025 at

Re: [PATCH 2/2] hw/cxl/cxl-mailbox-utils: Add support for Media operations Sanitize and Write Zeros commands (8.2.9.9.5.3)

2025-01-24 Thread Jonathan Cameron via
On Thu, 23 Jan 2025 10:39:03 +0530 Vinayak Holikatti wrote: > CXL spec 3.1 section 8.2.9.9.5.3 describes media operations commands. > CXL devices supports media operations Sanitize and Write zero command. As before, don't indent this. > > Signed-off-by: Vinayak Holikatti > --- > hw/c

[PATCH v2 0/7] physmem: teach cpu_memory_rw_debug() to write to more memory regions

2025-01-24 Thread David Hildenbrand
This is a follow-up to [1], implementing it by avoiding the use of address_space_write_rom() in cpu_memory_rw_debug() completely, and teaching address_space_write() about debug access instead, the can also write to ROM. The goal is to let GDB via cpu_memory_rw_debug() to also properly write to MMI

Re: [PATCH v3 4/4] tests/qtest/migration: add postcopy test with multifd

2025-01-24 Thread Peter Xu
On Fri, Jan 24, 2025 at 06:15:20PM +0530, Prasad Pandit wrote: > Hello Peter, > > On Thu, 23 Jan 2025 at 16:39, Prasad Pandit wrote: > > On Wed, 22 Jan 2025 at 21:40, Peter Xu wrote: > > > I believe many of the tests can be avoided, but still below is a list of > > > minimum tests that I think m

[PATCH v2 6/7] hmp: use cpu_get_phys_page_debug() in hmp_gva2gpa()

2025-01-24 Thread David Hildenbrand
We don't need the MemTxAttrs, so let's simply use the simpler function variant. Signed-off-by: David Hildenbrand --- monitor/hmp-cmds-target.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/monitor/hmp-cmds-target.c b/monitor/hmp-cmds-target.c index 0300faa8a2..0d2e9dce69

Re: [PATCH v2 5/7] memory: pass MemTxAttrs to memory_access_is_direct()

2025-01-24 Thread Philippe Mathieu-Daudé
On 24/1/25 16:45, David Hildenbrand wrote: We want to pass another flag that will be stored in MemTxAttrs. So pass MemTxAttrs directly. Signed-off-by: David Hildenbrand --- hw/core/loader.c | 2 +- hw/remote/vfio-user-obj.c | 2 +- include/exec/memory.h | 5 +++-- system/me

Re: [PATCH v2 6/7] hmp: use cpu_get_phys_page_debug() in hmp_gva2gpa()

2025-01-24 Thread Philippe Mathieu-Daudé
On 24/1/25 16:45, David Hildenbrand wrote: We don't need the MemTxAttrs, so let's simply use the simpler function variant. Signed-off-by: David Hildenbrand --- monitor/hmp-cmds-target.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) Reviewed-by: Philippe Mathieu-Daudé

Re: [PATCH 3/4] vfio/igd: refactor vfio_probe_igd_bar4_quirk() into pci config quirk

2025-01-24 Thread Alex Williamson
On Thu, 23 Jan 2025 01:17:30 +0800 Tomita Moeko wrote: > The actual IO BAR4 write quirk in vfio_probe_igd_bar4_quirk() was > removed in previous change, leaving the function not matching its name, > so move it into the newly introduced vfio_config_quirk_setup(). There > is no functional change in

Re: [PATCH 1/5] tests/functional: Add a decorator for skipping long running tests

2025-01-24 Thread Philippe Mathieu-Daudé
On 24/1/25 15:15, Thomas Huth wrote: Some tests have a very long runtime and might run into timeout issues e.g. when QEMU has been compiled with --enable-debug. Add a decorator for marking them more easily and document the corresponding environment variable that is used to enable the tests. Sign

[PATCH v2 4/7] physmem: disallow direct access to RAM DEVICE in address_space_write_rom()

2025-01-24 Thread David Hildenbrand
As documented in commit 4a2e242bbb306 ("memory: Don't use memcpy for ram_device regions"), we disallow direct access to RAM DEVICE regions. This change implies that address_space_write_rom() and cpu_memory_rw_debug() won't be able to write to RAM DEVICE regions. It will also affect cpu_flush_icach

Re: [PATCH] hw/virtio/vhost: Disable IOTLB callbacks when IOMMU gets disabled

2025-01-24 Thread Peter Xu
Hello, Jason, Eric, On Fri, Jan 24, 2025 at 11:30:56AM +0800, Jason Wang wrote: > It might be because neither virtio bus nor virtio-net provides a > shutdown method. > > There used to be requests to provide those to unbreak the kexec. > > A quick try might be to provide a .driver.shutdown to > v

Re: [PATCH] tcg: drop qemu_cpu_is_self() in tlb_flush_by_mmuidx[_async_work]

2025-01-24 Thread Alex Bennée
Igor Mammedov writes: > On Thu, 23 Jan 2025 12:23:43 +0100 > Igor Mammedov wrote: > >> On Thu, 23 Jan 2025 10:52:15 + >> Alex Bennée wrote: >> >> > Igor Mammedov writes: >> > >> > > QEMU will crash with following debug enabled >> > > # define DEBUG_TLB_GATE 1 >> > > # define DEBUG_

Re: [PATCH RFC v3 3/3] mhsld: implement MHSLD device

2025-01-24 Thread Gregory Price
On Fri, Jan 24, 2025 at 02:12:46PM +, Jonathan Cameron wrote: > On Fri, 18 Oct 2024 12:12:52 -0400 > Gregory Price wrote: > > > From: Svetly Todorov > > > > Using a shared-memory bytemap, validates that DC adds, releases, > > and reclamations happen on extents belonging to the appropriate >

[PATCH v2 1/7] physmem: factor out memory_region_is_ram_device() check in memory_access_is_direct()

2025-01-24 Thread David Hildenbrand
As documented in commit 4a2e242bbb306 ("memory: Don't use memcpy for ram_device regions"), we disallow direct access to RAM DEVICE regions. Let's make this clearer to prepare for further changes. Note that romd regions will never be RAM DEVICE at the same time. Signed-off-by: David Hildenbrand -

Re: [PATCH 2/5] tests/functional: Add the ReplayKernelBase class

2025-01-24 Thread Daniel P . Berrangé
On Fri, Jan 24, 2025 at 03:15:26PM +0100, Thomas Huth wrote: > Copy the ReplayKernelBase class from the avocado tests. We are going > to need it to convert the related replay tests in the following patches. > > Signed-off-by: Thomas Huth > --- > tests/functional/replay_kernel.py | 84 +++

[PATCH v2 3/7] physmem: factor out direct access check into memory_region_supports_direct_access()

2025-01-24 Thread David Hildenbrand
Let's factor the complete "directly accessible" check independent of the "write" condition out so we can reuse it next. We can now split up the checks RAM and ROMD check, so we really only check for RAM DEVICE in case of RAM -- ROM DEVICE is neither RAM not RAM DEVICE. Signed-off-by: David Hilden

[PATCH 00/76] target/arm: Implement FEAT_AFP and FEAT_RPRES

2025-01-24 Thread Peter Maydell
This patchset implements emulation of the Arm FEAT_AFP and FEAT_RPRES extensions, which are floating-point related. It's based on the small i386 bugfix series I sent out a while back: Based-on: 20250116112536.4117889-1-peter.mayd...@linaro.org ("target/i386: Fix 0 * Inf + QNaN regression") (It wo

Re: [PATCH 2/2] hw/cxl: Allow tracing component I/O accesses

2025-01-24 Thread Philippe Mathieu-Daudé
On 24/1/25 17:20, Jonathan Cameron wrote: On Thu, 23 Jan 2025 09:51:51 + Jonathan Cameron via wrote: On Wed, 22 Jan 2025 07:56:24 +0100 Philippe Mathieu-Daudé wrote: Map the component I/O region as UnimplementedDevice to be able to trace guest I/O accesses with '-d unimp'. Signed-off-b

[PATCH 08/76] target/arm: Use fp_status_a32 in vjvct helper

2025-01-24 Thread Peter Maydell
Use fp_status_a32 in the vjcvt helper function; this is called only from the A32/T32 decoder and is not used inside a set_rmode/restore_rmode sequence. Signed-off-by: Peter Maydell --- target/arm/vfp_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/arm/vfp_help

[PATCH 12/76] target/arm: Remove now-unused vfp.fp_status and FPST_FPCR

2025-01-24 Thread Peter Maydell
Now we have moved all the uses of vfp.fp_status and FPST_FPCR to either the A32 or A64 fields, we can remove these. Signed-off-by: Peter Maydell --- target/arm/cpu.h | 2 -- target/arm/tcg/translate.h | 6 -- target/arm/cpu.c | 1 - target/arm/vfp_helper.c| 8 +---

[PATCH 04/76] target/arm: Use FPSR_ constants in vfp_exceptbits_from_host()

2025-01-24 Thread Peter Maydell
Use the FPSR_ named constants in vfp_exceptbits_from_host(), rather than hardcoded magic numbers. Signed-off-by: Peter Maydell --- target/arm/vfp_helper.c | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c index fc20

[PATCH 03/76] target/arm: arm_reset_sve_state() should set FPSR, not FPCR

2025-01-24 Thread Peter Maydell
The pseudocode ResetSVEState() does: FPSR = ZeroExtend(0x089f<31:0>, 64); but QEMU's arm_reset_sve_state() called vfp_set_fpcr() by accident. Before the advent of FEAT_AFP, this was only setting a collection of RES0 bits, which vfp_set_fpsr() would then ignore, so the only effect was that

[PATCH 27/76] target/arm: Define FPCR AH, FIZ, NEP bits

2025-01-24 Thread Peter Maydell
The Armv8.7 FEAT_AFP feature defines three new control bits in the FPCR: * FPCR.AH: "alternate floating point mode"; this changes floating point behaviour in a variety of ways, including: - the sign of a default NaN is 1, not 0 - if FPCR.FZ is also 1, denormals detected after rounding

[PATCH 20/76] fpu: Rename float_flag_output_denormal to float_flag_output_denormal_flushed

2025-01-24 Thread Peter Maydell
Our float_flag_output_denormal exception flag is set when the fpu code flushes an output denormal to zero. Rename it to float_flag_output_denormal_flushed: * this keeps it parallel with the flag for flushing input denormals, which we just renamed * it makes it clearer that it doesn't mean "set

[PATCH 02/76] tests/tcg/x86_64/fma: Test some x86 fused-multiply-add cases

2025-01-24 Thread Peter Maydell
Add a test case which tests some corner case behaviour of fused-multiply-add on x86: * 0 * Inf + SNaN should raise Invalid * 0 * Inf + QNaN shouldh not raise Invalid * tininess should be detected after rounding There is also one currently-disabled test case: * flush-to-zero should be done afte

[PATCH 06/76] target/arm: Define new fp_status_a32 and fp_status_a64

2025-01-24 Thread Peter Maydell
We want to split the existing fp_status in the Arm CPUState into separate float_status fields for AArch32 and AArch64. (This is because new control bits defined by FEAT_AFP only have an effect for AArch64, not AArch32.) To make this split we will: * define new fp_status_a32 and fp_status_a64 whic

[PATCH 34/76] target/arm: Use FPST_FPCR_AH for BFCVT* insns

2025-01-24 Thread Peter Maydell
When FPCR.AH is 1, use FPST_FPCR_AH for: * AdvSIMD BFCVT, BFCVTN, BFCVTN2 * SVE BFCVT, BFCVTNT so that they get the required behaviour changes. Signed-off-by: Peter Maydell --- target/arm/tcg/translate-a64.c | 27 +-- target/arm/tcg/translate-sve.c | 6 -- 2 files

[PATCH 32/76] target/arm: Set up float_status to use for FPCR.AH=1 behaviour

2025-01-24 Thread Peter Maydell
When FPCR.AH is 1, the behaviour of some instructions changes: * AdvSIMD BFCVT, BFCVTN, BFCVTN2, BFMLALB, BFMLALT * SVE BFCVT, BFCVTNT, BFMLALB, BFMLALT, BFMLSLB, BFMLSLT * SME BFCVT, BFCVTN, BFMLAL, BFMLSL (these are all in SME2 which QEMU does not yet implement) * FRECPE, FRECPS, FRECPX, F

[PATCH 18/76] target/arm: Remove now-unused vfp.fp_status_f16 and FPST_FPCR_F16

2025-01-24 Thread Peter Maydell
Now we have moved all the uses of vfp.fp_status_f16 and FPST_FPCR_F16 to the new A32 or A64 fields, we can remove these. Signed-off-by: Peter Maydell --- target/arm/cpu.h | 2 -- target/arm/tcg/translate.h | 6 -- target/arm/cpu.c | 1 - target/arm/vfp_helper.c| 7 ---

[PATCH 25/76] target/arm: Remove redundant advsimd float16 helpers

2025-01-24 Thread Peter Maydell
The advsimd_addh etc helpers defined in helper-a64.c are identical to the vfp_addh etc helpers defined in helper-vfp.c: both take two float16 inputs (in a uint32_t type) plus a float_status* and are simple wrappers around the softfloat float16_* functions. (The duplication seems to be a historical

[PATCH 22/76] fpu: Add float_class_denormal

2025-01-24 Thread Peter Maydell
Currently in softfloat we canonicalize input denormals and so the code that implements floating point operations does not need to care whether the input value was originally normal or denormal. However, both x86 and Arm FEAT_AFP require that an exception flag is set if: * an input is denormal *

[PATCH 07/76] target/arm: Use vfp.fp_status_a64 in A64-only helper functions

2025-01-24 Thread Peter Maydell
Switch from vfp.fp_status to vfp.fp_status_a64 for helpers which: * directly reference an fp_status field * are called only from the A64 decoder * are not called inside a set_rmode/restore_rmode sequence Signed-off-by: Peter Maydell --- target/arm/tcg/sme_helper.c | 2 +- target/arm/tcg/vec_

[PATCH 13/76] target/arm: Define new fp_status_f16_a32 and fp_status_f16_a64

2025-01-24 Thread Peter Maydell
As the first part of splitting the existing fp_status_f16 into separate float_status fields for AArch32 and AArch64 (so that we can make FEAT_AFP control bits apply only for AArch64), define the two new fp_status_f16_a32 and fp_status_f16_a64 fields, but don't use them yet. Signed-off-by: Peter Ma

[PATCH 19/76] fpu: Rename float_flag_input_denormal to float_flag_input_denormal_flushed

2025-01-24 Thread Peter Maydell
Our float_flag_input_denormal exception flag is set when the fpu code flushes an input denormal to zero. This is what many guest architectures (eg classic Arm behaviour) require, but it is not the only donarmal-related reason we might want to set an exception flag. The x86 behaviour (which we do n

[PATCH 40/76] target/arm: Handle FPCR.NEP for 1-input scalar operations

2025-01-24 Thread Peter Maydell
Handle FPCR.NEP for the 1-input scalar operations. Signed-off-by: Peter Maydell --- target/arm/tcg/translate-a64.c | 26 ++ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index 944bdf8cafe..6

[PATCH 39/76] target/arm: Handle FPCR.NEP for BFCVT scalar

2025-01-24 Thread Peter Maydell
Currently we implement BFCVT scalar via do_fp1_scalar(). This works even though BFCVT is a narrowing operation from 32 to 16 bits, because we can use write_fp_sreg() for float16. However, FPCR.NEP support requires that we use write_fp_hreg_merging() for float16 outputs, so we can't continue to bor

[PATCH 36/76] target/arm: Add FPCR.NEP to TBFLAGS

2025-01-24 Thread Peter Maydell
For FEAT_AFP, we want to emit different code when FPCR.NEP is set, so that instead of zeroing the high elements of a vector register when we write the output of a scalar operation to it, we instead merge in those elements from one of the source registers. Since this affects the generated code, we

[PATCH 54/76] target/arm: Handle FPCR.AH in vector FABD

2025-01-24 Thread Peter Maydell
Split the handling of vector FABD so that it calls a different set of helpers when FPCR.AH is 1, which implement the "no negation of the sign of a NaN" semantics. Signed-off-by: Peter Maydell --- target/arm/helper.h| 4 target/arm/tcg/translate-a64.c | 7 ++- target/arm/tc

[PATCH 21/76] fpu: Fix a comment in softfloat-types.h

2025-01-24 Thread Peter Maydell
In softfloat-types.h a comment documents that if the float_status field flush_to_zero is set then we flush denormalised results to 0 and set the inexact flag. This isn't correct: the status flag that we set when flush_to_zero causes us to flush an output to zero is float_flag_output_denormal_flush

[PATCH 38/76] target/arm: Handle FPCR.NEP for 3-input scalar operations

2025-01-24 Thread Peter Maydell
Handle FPCR.NEP for the 3-input scalar operations which use do_fmla_scalar_idx() and do_fmadd(), by making them call the appropriate write_fp_*reg_merging() functions. Signed-off-by: Peter Maydell --- target/arm/tcg/translate-a64.c | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(

[PATCH 17/76] target/arm: Use FPST_FPCR_F16_A64 in A64 decoder

2025-01-24 Thread Peter Maydell
In the A32 decoder, use FPST_FPCR_F16_A32 rather than FPST_FPCR_F16. By doing an automated conversion of the whole file we avoid possibly using more than one fpst value in a set_rmode/op/restore_rmode sequence. Patch created with perl -p -i -e 's/FPST_FPCR_F16(?!_)/FPST_FPCR_F16_A64/g' target/a

[PATCH 05/76] target/arm: Use uint32_t in vfp_exceptbits_from_host()

2025-01-24 Thread Peter Maydell
In vfp_exceptbits_from_host(), we accumulate the FPSR flags in an "int", and our return type is also "int". However, the only callsite returns the same information as a uint32_t, and more generally we handle FPSR values in the code as uint32_t, not int. Bring this function in to line with that conv

[PATCH 15/76] target/arm: Use fp_status_f16_a64 in AArch64-only helpers

2025-01-24 Thread Peter Maydell
We directly use fp_status_f16 in a handful of helpers that are AArch64-specific; switch to fp_status_f16_a64 for these. Signed-off-by: Peter Maydell --- target/arm/tcg/sme_helper.c | 4 ++-- target/arm/tcg/vec_helper.c | 8 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/

[PATCH 53/76] target/arm: Implement FPCR.AH handling for scalar FABS and FABD

2025-01-24 Thread Peter Maydell
FPCR.AH == 1 mandates that taking the absolute value of a NaN should not change its sign bit. This means we can no longer use gen_vfp_abs*() everywhere but must instead generate slightly more complex code when FPCR.AH is set. Implement these semantics for scalar FABS and FABD. This change also a

[PATCH 76/76] tests/tcg/x86_64/fma: add test for exact-denormal output

2025-01-24 Thread Peter Maydell
Add some fma test cases that check for correct handling of FTZ and for the flag that indicates that the input denormal was consumed. Signed-off-by: Peter Maydell --- tests/tcg/x86_64/fma.c | 12 1 file changed, 12 insertions(+) diff --git a/tests/tcg/x86_64/fma.c b/tests/tcg/x86_64

[PATCH 45/76] target/arm: Implement FPCR.AH semantics for scalar FMIN/FMAX

2025-01-24 Thread Peter Maydell
When FPCR.AH == 1, floating point FMIN and FMAX have some odd special cases: * comparing two zeroes (even of different sign) or comparing a NaN with anything always returns the second argument (possibly squashed to zero) * denormal outputs are not squashed to zero regardless of FZ or FZ16

<    1   2   3   4   >