[PATCH v3] tcg/optimize: optimize TSTNE using smask and zmask

2025-01-29 Thread Paolo Bonzini
y case it's meant to optimize because brcond_i64 cc_dst,$0x,tsteq,$L1 (test %ebx, %ebx) is 1 byte smaller than brcond_i64 cc_dst,$0x0,eq,$L1 (test %rbx, %rbx). However, in general it is an improvement, especially if it avoids placing a large immediate in the constant pool. Sig

Re: [PATCH 0/1] meson: Deprecate 32-bit host systems

2025-01-29 Thread Paolo Bonzini
On 1/29/25 13:23, Peter Maydell wrote: I'm not really strongly opposed to dropping 32-bit host support, but I don't think a thread on qemu-devel is exactly likely to get the attention of the people who might be using this functionality. (You could argue that functionality without representation a

[PULL v3 00/49] i386, Rust changes for 2025-01-24

2025-01-29 Thread Paolo Bonzini
backtraces v2->v3: drop PL011Registers borrow before calling PL011State::update() include full Rust backtraces in test runs Paolo Bonzini (38): rust: pl011: fix repr(C) for PL011Class target/i386: inline gen_jcc into sole caller target/i386: remove trailing 1 from

[PULL 42/49] rust: pl011: wrap registers with BqlRefCell

2025-01-29 Thread Paolo Bonzini
This is a step towards making memory ops use a shared reference to the device type; it's not yet possible due to the calls to character device functions. Reviewed-by: Zhao Liu Signed-off-by: Paolo Bonzini --- rust/hw/char/pl011/src/device.rs | 46 -- rust/hw

[PULL 49/49] gitlab-ci: include full Rust backtraces in test runs

2025-01-29 Thread Paolo Bonzini
Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Thomas Huth Signed-off-by: Paolo Bonzini --- .gitlab-ci.d/buildtest-template.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.d/buildtest-template.yml b/.gitlab-ci.d/buildtest-template.yml index 39da7698b09..4cc19239319 100644

Re: [PATCH 04/10] rust: add bindings for gpio_{in|out} initialization

2025-01-29 Thread Paolo Bonzini
On Sat, Jan 25, 2025 at 1:32 PM Zhao Liu wrote: +fn init_gpio_in FnCall<(&'a Self::Target, u32, u32)>>(&self, num_lines: u32, _f: F) { +unsafe extern "C" fn rust_irq_handler FnCall<(&'a T, u32, u32)>>( +opaque: *mut c_void, +line: c_int, +leve

Re: [PATCH 09/10] rust/timer/hpet: add qom and qdev APIs support

2025-01-29 Thread Paolo Bonzini
On Sat, Jan 25, 2025 at 1:32 PM Zhao Liu wrote: fn read(&mut self, addr: hwaddr, _size: u32) -> u64 { This can be &self. let shift: u64 = (addr & 4) * 8; +match addr { +HPET_TN_CFG_REG => self.config >> shift, // including interrupt capabilities This

Re: [PATCH 06/10] rust: add bindings for timer

2025-01-29 Thread Paolo Bonzini
On Sat, Jan 25, 2025 at 1:32 PM Zhao Liu wrote: + c_nocopy = [ +'QEMUTimer', + ] + # Used to customize Drop trait + foreach struct : c_nocopy +bindgen_args += ['--no-copy', struct] + endforeach Nice. +pub use bindings::QEMUTimer; + +use crate::{ +bindings::{ +self

Re: [PATCH 07/10] rust/timer/hpet: define hpet_cfg

2025-01-29 Thread Paolo Bonzini
On Sat, Jan 25, 2025 at 1:32 PM Zhao Liu wrote: @@ -5,6 +5,7 @@ edition = "2021" authors = ["Zhao Liu "] license = "GPL-2.0-or-later" description = "IA-PC High Precision Event Timer emulation in Rust" Please add rust-version = "1.63.0" here. +// SAFETY: all accesses go throug

Re: [PATCH 08/10] rust/timer/hpet: add basic HPET timer and HPETState

2025-01-29 Thread Paolo Bonzini
On Sat, Jan 25, 2025 at 1:32 PM Zhao Liu wrote: +// Register space for each timer block. (HPET_BASE isn't defined here.) +const HPET_REG_SPACE_LEN: u64 = 0x400; // 1024 bytes Use doc comments "///"... +// Timer N FSB Interrupt Route Register (masked by 0x18) +const HPET_TN_FSB_ROUTE_REG:

Re: [PATCH 02/10] rust: qom: add reference counting functionality

2025-01-29 Thread Paolo Bonzini
On Mon, Jan 27, 2025 at 8:38 AM Zhao Liu wrote: > > > +impl Owned { > > +/// Convert a raw C pointer into an owned reference to the QOM > > +/// object it points to. The object's reference count will be > > +/// decreased when the `Owned` is dropped. > > +/// > > +/// # Panics

Re: [PATCH 02/10] rust: qom: add reference counting functionality

2025-01-29 Thread Paolo Bonzini
On Sun, Jan 26, 2025 at 3:56 PM Zhao Liu wrote: > > Hi Paolo, > > On Fri, Jan 17, 2025 at 08:39:55PM +0100, Paolo Bonzini wrote: > > Date: Fri, 17 Jan 2025 20:39:55 +0100 > > From: Paolo Bonzini > > Subject: [PATCH 02/10] rust: qom: add reference counting functi

[PATCH 1/2] rust: remove unnecessary Cargo.toml metadata

2025-01-29 Thread Paolo Bonzini
-off-by: Paolo Bonzini --- rust/hw/char/pl011/Cargo.toml | 3 --- rust/hw/char/pl011/README.md| 31 --- rust/hw/char/pl011/src/lib.rs | 14 ++ rust/qemu-api-macros/Cargo.toml | 3 --- rust/qemu-api-macros/README.md | 1 - 5 files changed, 6

[PATCH 0/2] rust: small cleanups to Cargo.toml files

2025-01-29 Thread Paolo Bonzini
Remove duplicate or stale information, and add the rustc version to help clippy produce good warnings. Paolo Paolo Bonzini (2): rust: remove unnecessary Cargo.toml metadata rust: include rust_version in Cargo.toml rust/hw/char/pl011/Cargo.toml | 4 +--- rust/hw/char/pl011

[PATCH] rust: add docs

2025-01-29 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini --- docs/devel/index-process.rst | 1 + docs/devel/rust.rst | 423 +++ 2 files changed, 424 insertions(+) create mode 100644 docs/devel/rust.rst diff --git a/docs/devel/index-process.rst b/docs/devel/index-process.rst

[PATCH 2/2] rust: include rust_version in Cargo.toml

2025-01-29 Thread Paolo Bonzini
Tell clippy the minimum supported Rust version for QEMU. Signed-off-by: Paolo Bonzini --- rust/hw/char/pl011/Cargo.toml | 1 + rust/hw/char/pl011/src/device_class.rs | 1 - rust/qemu-api-macros/Cargo.toml| 1 + rust/qemu-api/Cargo.toml | 1 + 4 files changed, 3

[PATCH] gitlab-ci: include full Rust backtraces in test runs

2025-01-29 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini --- .gitlab-ci.d/buildtest-template.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.d/buildtest-template.yml b/.gitlab-ci.d/buildtest-template.yml index 39da7698b09..4cc19239319 100644 --- a/.gitlab-ci.d/buildtest-template.yml +++ b/.gitlab-ci.d

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

2025-01-28 Thread Paolo Bonzini
On 1/28/25 15:19, Stefan Hajnoczi wrote: thread '' panicked at 'already borrowed', rust/qemu-api/libqemu_api.rlib.p/structured/cell.rs:450:5 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace fatal runtime error: failed to initiate panic, error 5 https://gitlab.com/qem

[PULL 38/48] rust: pl011: extract conversion to RegisterOffset

2025-01-28 Thread Paolo Bonzini
As an added bonus, this also makes the new function return u32 instead of u64, thus factoring some casts into a single place. Reviewed-by: Zhao Liu Signed-off-by: Paolo Bonzini --- rust/hw/char/pl011/src/device.rs | 137 ++- rust/hw/char/pl011/src/lib.rs| 2

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

2025-01-28 Thread Paolo Bonzini
/i386: new Sierra Forest and Clearwater Forest models * rust: type-safe vmstate implementation * rust: use interior mutability for PL011 * rust: clean ups * memtxattrs: remove usage of bitfields from MEMTXATTRS_UNSPECIFIED -------- Paolo B

Rust in QEMU update, January 2025

2025-01-28 Thread Paolo Bonzini
It's been roughly two months since my previous posting of a roadmap for Rust in QEMU, so it's time for an update. While the project is still at an experimental phase, the amount of functionality available from safe Rust is enough that it could be considered for new devices. As before, this mostl

Re: [PATCH 10/10] rust: bindings for MemoryRegionOps

2025-01-27 Thread Paolo Bonzini
On Mon, Jan 27, 2025 at 12:53 PM Zhao Liu wrote: > > @@ -490,20 +490,24 @@ impl PL011State { > > /// location/instance. All its fields are expected to hold unitialized > > /// values with the sole exception of `parent_obj`. > > unsafe fn init(&mut self) { > > +static PL011_O

Re: [PATCH 08/10] rust: qdev: switch from legacy reset to Resettable

2025-01-27 Thread Paolo Bonzini
On Mon, Jan 27, 2025 at 11:12 AM Zhao Liu wrote: > > +/// If not None, this is called when the object for entry into reset, > > once > > +/// every object in the system which is being reset has had its > > +/// @phases.enter method called. At this point devices can do actions > > Mayb

Re: [PATCH 0/2] qom: Introduce class_post_init() handler

2025-01-27 Thread Paolo Bonzini
class_base_init() before class_init() qom: Introduce class_post_init() handler include/qom/object.h | 17 ++--- qom/object.c | 14 -- rust/qemu-api/src/qom.rs | 8 +++- 3 files changed, 29 insertions(+), 10 deletions(-) Acked-by: Paolo Bonzini

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

2025-01-24 Thread Paolo Bonzini
0:5 > note: run with `RUST_BACKTRACE=1` environment variable to display a > backtrace > fatal runtime error: failed to initiate panic, error 5 > > https://gitlab.com/qemu-project/qemu/-/jobs/8946857796 Yes, it's a real bug. Paolo > > Thanks, > Stefan > > > &g

Re: [PATCH 0/2] target/i386: Fix 0 * Inf + QNaN regression

2025-01-24 Thread Paolo Bonzini
Queued, thanks. Paolo

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

2025-01-24 Thread Paolo Bonzini
/i386: new Sierra Forest and Clearwater Forest models * rust: type-safe vmstate implementation * rust: use interior mutability for PL011 * rust: clean ups * memtxattrs: remove usage of bitfields from MEMTXATTRS_UNSPECIFIED -------- Paolo B

[PULL 41/48] rust: pl011: extract PL011Registers

2025-01-24 Thread Paolo Bonzini
Pull all the mutable fields of PL011State into a separate struct. Reviewed-by: Zhao Liu Signed-off-by: Paolo Bonzini --- rust/hw/char/pl011/src/device.rs | 251 ++--- rust/hw/char/pl011/src/device_class.rs | 46 +++-- 2 files changed, 168 insertions(+), 129 deletions

[PATCH v2] tcg/optimize: optimize TSTNE using smask and zmask

2025-01-24 Thread Paolo Bonzini
y case it's meant to optimize because brcond_i64 cc_dst,$0x,tsteq,$L1 (test %ebx, %ebx) is 1 byte smaller than brcond_i64 cc_dst,$0x0,eq,$L1 (test %rbx, %rbx). However, in general it is an improvement, especially if it avoids placing a large immediate in the constant pool. Sig

[PULL 24/48] memattrs: Check the size of MemTxAttrs

2025-01-24 Thread Paolo Bonzini
From: Zhao Liu Make sure MemTxAttrs is packed into 8 bytes and does not exceed 8 bytes. Suggested-by: Philippe Mathieu-Daudà Signed-off-by: Zhao Liu Link: https://lore.kernel.org/r/20250121151322.171832-3-zhao1@intel.com Signed-off-by: Paolo Bonzini --- include/exec/memattrs.h | 2 ++ 1

[PULL 43/48] rust: pl011: remove duplicate definitions

2025-01-24 Thread Paolo Bonzini
Unify the "Interrupt" enum and the "INT_*" constants with a struct that contains the bits. The "int_level" and "int_enabled" fields could use a crate such as "bitflags". Reviewed-by: Zhao Liu Signed-off-by: Paolo Bonzini --- rust/hw/char/pl0

[PULL 39/48] rust: pl011: extract CharBackend receive logic into a separate function

2025-01-24 Thread Paolo Bonzini
Prepare for moving all references to the registers and the FIFO into a separate struct. Reviewed-by: Zhao Liu Signed-off-by: Paolo Bonzini --- rust/hw/char/pl011/src/device.rs | 15 +-- 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/rust/hw/char/pl011/src/device.rs b

[PULL 45/48] rust: pl011: drop use of ControlFlow

2025-01-24 Thread Paolo Bonzini
It is a poor match for what the code is doing, anyway. Reviewed-by: Zhao Liu Signed-off-by: Paolo Bonzini --- rust/hw/char/pl011/src/device.rs | 39 +++- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/rust/hw/char/pl011/src/device.rs b/rust/hw/char

[PULL 30/48] rust: vmstate: add public utility macros to implement VMState

2025-01-24 Thread Paolo Bonzini
Reviewed-by: Zhao Liu Signed-off-by: Paolo Bonzini --- rust/qemu-api/src/vmstate.rs | 61 ++-- 1 file changed, 58 insertions(+), 3 deletions(-) diff --git a/rust/qemu-api/src/vmstate.rs b/rust/qemu-api/src/vmstate.rs index a262c315da1..9ac699b73b7 100644 --- a

[PULL 44/48] rust: pl011: pull device-specific code out of MemoryRegionOps callbacks

2025-01-24 Thread Paolo Bonzini
read() can now return a simple u64. Reviewed-by: Zhao Liu Signed-off-by: Paolo Bonzini --- rust/hw/char/pl011/src/device.rs | 23 +-- rust/hw/char/pl011/src/memory_ops.rs | 18 ++ 2 files changed, 15 insertions(+), 26 deletions(-) diff --git a/rust/hw

[PULL 01/48] rust: pl011: fix repr(C) for PL011Class

2025-01-24 Thread Paolo Bonzini
Reviewed-by: Zhao Liu Signed-off-by: Paolo Bonzini --- rust/hw/char/pl011/src/device.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/rust/hw/char/pl011/src/device.rs b/rust/hw/char/pl011/src/device.rs index 994c2fc0593..65a1234b9ff 100644 --- a/rust/hw/char/pl011/src/device.rs +++ b/rust

[PULL 23/48] memattrs: Convert unspecified member to bool

2025-01-24 Thread Paolo Bonzini
reserved members to ensure that the whole structure is packed into 8 bytes. Suggested-by: Richard Henderson Suggested-by: Paolo Bonzini Signed-off-by: Zhao Liu Link: https://lore.kernel.org/r/20250121151322.171832-2-zhao1@intel.com Signed-off-by: Paolo Bonzini --- include/exec/memattrs.h | 19

[PULL 18/48] target/i386: Add new CPU model ClearwaterForest

2025-01-24 Thread Paolo Bonzini
Reviewed-by: Zhao Liu Link: https://lore.kernel.org/r/20250121020650.1899618-4-tao1...@linux.intel.com Signed-off-by: Paolo Bonzini --- target/i386/cpu.h | 33 +--- target/i386/cpu.c | 135 ++ 2 files changed, 162 insertions(+), 6 deletions(-) diff

[PULL 15/48] target/i386: avoid using s->tmp0 for add to implicit registers

2025-01-24 Thread Paolo Bonzini
instructions for the MO_TL case. Signed-off-by: Paolo Bonzini Reviewed-by: Richard Henderson Link: https://lore.kernel.org/r/20241215090613.89588-14-pbonz...@redhat.com Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 23 +++ 1 file changed, 15 insertions(+), 8

[PULL 19/48] docs: Add GNR, SRF and CWF CPU models

2025-01-24 Thread Paolo Bonzini
rnel.org/r/20250121020650.1899618-5-tao1...@linux.intel.com Signed-off-by: Paolo Bonzini --- docs/system/cpu-models-x86.rst.inc | 50 +++--- 1 file changed, 46 insertions(+), 4 deletions(-) diff --git a/docs/system/cpu-models-x86.rst.inc b/docs/system/cpu-models-x86.rst

[PULL 22/48] rust/pl011: Avoid bindings::*

2025-01-24 Thread Paolo Bonzini
From: Zhao Liu List all the necessary bindings to better identify gaps in rust/qapi. And include the bindings wrapped by rust/qapi instead mapping the raw bindings directly. Inspired-by: Paolo Bonzini Signed-off-by: Zhao Liu Link: https://lore.kernel.org/r/20250121140457.84631-3-zhao1

[PULL 48/48] rust: qemu-api: add sub-subclass to the integration tests

2025-01-24 Thread Paolo Bonzini
Signed-off-by: Zhao Liu Signed-off-by: Paolo Bonzini --- rust/qemu-api/tests/tests.rs | 56 ++-- 1 file changed, 53 insertions(+), 3 deletions(-) diff --git a/rust/qemu-api/tests/tests.rs b/rust/qemu-api/tests/tests.rs index 526c3f4f8ea..5c3e75ed3d5 100644 --- a

[PULL 46/48] rust: qdev: make reset take a shared reference

2025-01-24 Thread Paolo Bonzini
Because register reset is within a borrow_mut() call, reset does not need anymore a mut reference to the PL011State. Reviewed-by: Zhao Liu Signed-off-by: Paolo Bonzini --- rust/hw/char/pl011/src/device.rs | 4 ++-- rust/qemu-api/src/qdev.rs| 2 +- 2 files changed, 3 insertions(+), 3

[PULL 34/48] rust: vmstate: make order of parameters consistent in vmstate_clock

2025-01-24 Thread Paolo Bonzini
Place struct_name before field_name, similar to offset_of. Signed-off-by: Paolo Bonzini --- rust/hw/char/pl011/src/device_class.rs | 2 +- rust/qemu-api/src/vmstate.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rust/hw/char/pl011/src/device_class.rs b/rust

[PULL 21/48] rust/qdev: Make REALIZE safe

2025-01-24 Thread Paolo Bonzini
s passed to C to mutable pointers. Thus, make REALIZE accept immutable reference. Signed-off-by: Zhao Liu Link: https://lore.kernel.org/r/20250121140457.84631-2-zhao1@intel.com Signed-off-by: Paolo Bonzini --- rust/hw/char/pl011/src/device.rs | 10 +- rust/qemu-api/src/qdev.rs

[PULL 36/48] rust: pl011: remove unnecessary "extern crate"

2025-01-24 Thread Paolo Bonzini
Reviewed-by: Zhao Liu Signed-off-by: Paolo Bonzini --- rust/hw/char/pl011/src/lib.rs | 4 1 file changed, 4 deletions(-) diff --git a/rust/hw/char/pl011/src/lib.rs b/rust/hw/char/pl011/src/lib.rs index f30f9850ad4..d10f0805aac 100644 --- a/rust/hw/char/pl011/src/lib.rs +++ b/rust/hw/char

[PULL 33/48] rust: vmstate: remove translation of C vmstate macros

2025-01-24 Thread Paolo Bonzini
Keep vmstate_clock!; because it uses a field of type VMStateDescription, it cannot be converted to the VMState trait without access to the const_refs_static feature. Reviewed-by: Zhao Liu Signed-off-by: Paolo Bonzini --- rust/qemu-api/src/vmstate.rs | 274 +++ 1

[PULL 47/48] rust/zeroable: Implement Zeroable with const_zero macro

2025-01-24 Thread Paolo Bonzini
Paolo Bonzini Signed-off-by: Zhao Liu Link: https://lore.kernel.org/r/20250123163143.679841-1-zhao1@intel.com Signed-off-by: Paolo Bonzini --- rust/qemu-api/src/zeroable.rs | 137 +++--- 1 file changed, 61 insertions(+), 76 deletions(-) diff --git a/rust/qemu-ap

[PULL 38/48] rust: pl011: extract conversion to RegisterOffset

2025-01-24 Thread Paolo Bonzini
As an added bonus, this also makes the new function return u32 instead of u64, thus factoring some casts into a single place. Reviewed-by: Zhao Liu Signed-off-by: Paolo Bonzini --- rust/hw/char/pl011/src/device.rs | 113 +-- 1 file changed, 64 insertions(+), 49

[PULL 16/48] target/i386: Introduce SierraForest-v2 model

2025-01-24 Thread Paolo Bonzini
vulnerabilities are mitigated in stepping 3. Tested-by: Xuelian Guo Signed-off-by: Tao Su Reviewed-by: Zhao Liu Link: https://lore.kernel.org/r/20250121020650.1899618-2-tao1...@linux.intel.com Signed-off-by: Paolo Bonzini --- target/i386/cpu.c | 19 +++ 1 file changed, 19 insertions

[PULL 25/48] rust: vmstate: add new type safe implementation

2025-01-24 Thread Paolo Bonzini
by: Zhao Liu Signed-off-by: Paolo Bonzini --- rust/qemu-api/src/prelude.rs | 2 + rust/qemu-api/src/vmstate.rs | 113 +-- 2 files changed, 109 insertions(+), 6 deletions(-) diff --git a/rust/qemu-api/src/prelude.rs b/rust/qemu-api/src/prelude.rs index 4ea70b9c823

[PULL 32/48] rust: pl011: switch vmstate to new-style macros

2025-01-24 Thread Paolo Bonzini
Reviewed-by: Zhao Liu Signed-off-by: Paolo Bonzini --- rust/hw/char/pl011/src/device.rs | 3 ++- rust/hw/char/pl011/src/device_class.rs | 36 +- rust/hw/char/pl011/src/lib.rs | 6 + 3 files changed, 26 insertions(+), 19 deletions(-) diff --git a

[PULL 12/48] target/i386: execute multiple REP/REPZ iterations without leaving TB

2025-01-24 Thread Paolo Bonzini
interrupts. Signed-off-by: Paolo Bonzini Reviewed-by: Richard Henderson Link: https://lore.kernel.org/r/20241215090613.89588-12-pbonz...@redhat.com Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 55 + 1 file changed, 49 insertions(+), 6 deletions

[PULL 26/48] rust: vmstate: implement VMState for non-leaf types

2025-01-24 Thread Paolo Bonzini
Arrays, pointers and cells use a VMStateField that is based on that for the inner type. The implementation therefore delegates to the VMState implementation of the inner type. Signed-off-by: Paolo Bonzini --- rust/qemu-api/src/vmstate.rs | 79 +++- 1 file

[PULL 37/48] rust: pl011: hide unnecessarily "pub" items from outside pl011::device

2025-01-24 Thread Paolo Bonzini
The only public interfaces for pl011 are TYPE_PL011 and pl011_create. Remove pub from everything else. Note: the "allow(dead_code)" is removed later. Reviewed-by: Zhao Liu Signed-off-by: Paolo Bonzini --- rust/hw/char/pl011/src/device.rs | 2 +- rust/hw/char/pl011/src/devic

[PULL 40/48] rust: pl011: pull interrupt updates out of read/write ops

2025-01-24 Thread Paolo Bonzini
Zhao Liu Signed-off-by: Paolo Bonzini --- rust/hw/char/pl011/src/device.rs | 84 ++-- 1 file changed, 48 insertions(+), 36 deletions(-) diff --git a/rust/hw/char/pl011/src/device.rs b/rust/hw/char/pl011/src/device.rs index de5110038a5..9cac9d352a2 100644 --- a/ru

[PULL 29/48] rust: vmstate: implement VMState for scalar types

2025-01-24 Thread Paolo Bonzini
VMStateInfos in an enum, and going from enum to &VMStateInfo only when building the VMStateField. The same thing cannot be done with VMS_STRUCT because the set of VMStateDescriptions extends to structs defined by the devices. Therefore, structs and cells cannot yet use vmstate_of!. Signed-off-by: P

[PULL 27/48] rust: vmstate: add varray support to vmstate_of!

2025-01-24 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini --- rust/qemu-api/src/vmstate.rs | 42 ++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/rust/qemu-api/src/vmstate.rs b/rust/qemu-api/src/vmstate.rs index 211c3d096b7..2b14d4839df 100644 --- a/rust/qemu-api/src

[PULL 28/48] rust: vmstate: implement Zeroable for VMStateField

2025-01-24 Thread Paolo Bonzini
This shortens a bit the constants. Do not bother using it in the vmstate macros since most of them will go away soon. Reviewed-by: Zhao Liu Signed-off-by: Paolo Bonzini --- rust/qemu-api/src/vmstate.rs | 18 +++--- rust/qemu-api/src/zeroable.rs | 31

[PULL 31/48] rust: qemu_api: add vmstate_struct

2025-01-24 Thread Paolo Bonzini
It is not type safe, but it's the best that can be done without const_refs_static. It can also be used with BqlCell and BqlRefCell. Signed-off-by: Paolo Bonzini --- rust/qemu-api/src/vmstate.rs | 33 + 1 file changed, 33 insertions(+) diff --git a/rust/qem

[PULL 35/48] rust: prefer NonNull::new to assertions

2025-01-24 Thread Paolo Bonzini
Do not use new_unchecked; the effect is the same, but the code is easier to read and unsafe regions become smaller. Likewise, NonNull::new can be used instead of assertion and followed by as_ref() or as_mut() instead of dereferencing the pointer. Suggested-by: Zhao Liu Signed-off-by: Paolo

[PULL 04/48] target/i386: unify REP and REPZ/REPNZ generation

2025-01-24 Thread Paolo Bonzini
It only differs in a single call to gen_jcc, so use a "bool" argument to distinguish the two cases; do not duplicate code. Signed-off-by: Paolo Bonzini Reviewed-by: Richard Henderson Link: https://lore.kernel.org/r/20241215090613.89588-4-pbonz...@redhat.com Signed-off-by: Pao

[PULL 42/48] rust: pl011: wrap registers with BqlRefCell

2025-01-24 Thread Paolo Bonzini
This is a step towards making memory ops use a shared reference to the device type; it's not yet possible due to the calls to character device functions. Reviewed-by: Zhao Liu Signed-off-by: Paolo Bonzini --- rust/hw/char/pl011/src/device.rs | 40 ++ rust/hw

[PULL 03/48] target/i386: remove trailing 1 from gen_{j, cmov, set}cc1

2025-01-24 Thread Paolo Bonzini
This is not needed anymore now that gen_jcc has been eliminated (merged into the similarly-named gen_Jcc, where the uppercase letter gives away that it is an emission function). Signed-off-by: Paolo Bonzini Reviewed-by: Richard Henderson Link: https://lore.kernel.org/r/20241215090613.89588-3

[PULL 20/48] stub: Fix build failure with --enable-user --disable-system --enable-tools

2025-01-24 Thread Paolo Bonzini
o1@intel.com Signed-off-by: Paolo Bonzini --- stubs/meson.build | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stubs/meson.build b/stubs/meson.build index e91614a874d..a8b3aeb5645 100644 --- a/stubs/meson.build +++ b/stubs/meson.build @@ -57,8 +57,8 @@ if have_user stub

[PULL 08/48] target/i386: fix RF handling for string instructions

2025-01-24 Thread Paolo Bonzini
RF must be set on traps and interrupts from a string instruction, except if they occur after the last iteration. Ensure it is set before giving the main loop a chance to execute. Signed-off-by: Paolo Bonzini Reviewed-by: Richard Henderson Link: https://lore.kernel.org/r/20241215090613.89588-8

[PULL 17/48] target/i386: Export BHI_NO bit to guests

2025-01-24 Thread Paolo Bonzini
additional mitigation is required to prevent BHI. Make BHI_NO bit available to guests. Tested-by: Xuelian Guo Signed-off-by: Tao Su Reviewed-by: Zhao Liu Link: https://lore.kernel.org/r/20250121020650.1899618-3-tao1...@linux.intel.com Signed-off-by: Paolo Bonzini --- target/i386/cpu.c | 2 +- 1

[PULL 10/48] target/i386: do not use gen_op_jz_ecx for repeated string operations

2025-01-24 Thread Paolo Bonzini
(reg, cx_mask). Signed-off-by: Paolo Bonzini Reviewed-by: Richard Henderson Link: https://lore.kernel.org/r/20241215090613.89588-10-pbonz...@redhat.com Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/target/i386

[PULL 09/48] target/i386: make cc_op handling more explicit for repeated string instructions.

2025-01-24 Thread Paolo Bonzini
what x86_restore_state_to_opc would do. Signed-off-by: Paolo Bonzini Link: https://lore.kernel.org/r/20241215090613.89588-9-pbonz...@redhat.com Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 24 +--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/target/i38

[PULL 06/48] target/i386: reorganize ops emitted by do_gen_rep, drop repz_opt

2025-01-24 Thread Paolo Bonzini
. For clarity, mark the cc_op explicitly as DYNAMIC even if at the end of the translation block; the cc_op can come from either the previous instruction or the string instruction, and currently we rely on a gen_update_cc_op() that is hidden in the bowels of gen_jcc() to spill cc_op and mark it cle

[PULL 13/48] target/i386: pull computation of string update value out of loop

2025-01-24 Thread Paolo Bonzini
This is a common operation that is executed many times in rep movs or rep stos loops. It can improve performance by several percentage points. Signed-off-by: Paolo Bonzini Link: https://lore.kernel.org/r/20241215090613.89588-13-pbonz...@redhat.com Signed-off-by: Paolo Bonzini --- target/i386

[PULL 07/48] target/i386: tcg: move gen_set/reset_* earlier in the file

2025-01-24 Thread Paolo Bonzini
Allow using them in the code that translates REP/REPZ, without forward declarations. Signed-off-by: Paolo Bonzini Reviewed-by: Richard Henderson Link: https://lore.kernel.org/r/20241215090613.89588-7-pbonz...@redhat.com Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 80

[PULL 05/48] target/i386: unify choice between single and repeated string instructions

2025-01-24 Thread Paolo Bonzini
The same "if" is present in all generator functions for string instructions. Push it inside gen_repz() and gen_repz_nz() instead. Signed-off-by: Paolo Bonzini Link: https://lore.kernel.org/r/20241215090613.89588-5-pbonz...@redhat.com Signed-off-by: Paolo Bonzini --- target/i386/tcg/t

[PULL 14/48] target/i386: extract common bits of gen_repz/gen_repz_nz

2025-01-24 Thread Paolo Bonzini
Now that everything has been cleaned up, look at DF and prefixes in a single function, and call that one from gen_repz and gen_repz_nz. Suggested-by: Richard Henderson Reviewed-by: Richard Henderson Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 34

[PULL 02/48] target/i386: inline gen_jcc into sole caller

2025-01-24 Thread Paolo Bonzini
The code of gen_Jcc is very similar to gen_LOOP* and gen_JCXZ, but this is hidden by gen_jcc. Signed-off-by: Paolo Bonzini Reviewed-by: Richard Henderson Link: https://lore.kernel.org/r/20241215090613.89588-2-pbonz...@redhat.com Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 8

[PULL 11/48] target/i386: optimize CX handling in repeated string operations

2025-01-24 Thread Paolo Bonzini
work for subsequent changes. In particular, introducing cx_next prepares for when ECX will be decremented *before* calling fn(s, ot), and therefore cannot yet be written back to cpu_regs. Signed-off-by: Paolo Bonzini Reviewed-by: Richard Henderson Link: https://lore.kernel.org/r

Re: [RFC 06/13] rust: add bindings for memattrs

2025-01-23 Thread Paolo Bonzini
On 1/23/25 16:10, Zhao Liu wrote: Another solution would be to implement Zeroable for __BindgenBitfieldUnit in bindings.rs, but this is much nicer! It works even with old Rust versions and, even though it needs manual implementation of the trait each type, it doesn't require enumerating the fiel

Re: [PATCH 07/10] rust: pl011: wrap registers with BqlRefCell

2025-01-23 Thread Paolo Bonzini
Il gio 23 gen 2025, 10:05 Zhao Liu ha scritto: > > I will double check. But I do see that there is no mut access inside, at > > least not until the qemu_chr_fe_accept_input() is moved here. > Unfortunately > > until all MemoryRegion and CharBackend bindings are available the uses of > > &mut and

Re: [PATCH] Fix a data race with goflag in rcutorture test

2025-01-23 Thread Paolo Bonzini
On Wed, Jan 22, 2025 at 2:59 PM Vitalii Mordan wrote: > > This patch addresses a potential data race involving the global variable > goflag in the rcutorture test. The issue is resolved by adding the atomic > qualifier to ensure proper synchronization. Hello! QEMU does not use _Atomic; in genera

Re: [PATCH 06/10] rust: pl011: extract PL011Registers

2025-01-23 Thread Paolo Bonzini
Il gio 23 gen 2025, 04:25 Zhao Liu ha scritto: > > --- a/rust/hw/char/pl011/src/device_class.rs > > +++ b/rust/hw/char/pl011/src/device_class.rs > > @@ -6,11 +6,11 @@ > > use std::os::raw::{c_int, c_void}; > > > > use qemu_api::{ > > -bindings::*, c_str, vmstate_clock, vmstate_fields, vmsta

Re: [PATCH 07/10] rust: pl011: wrap registers with BqlRefCell

2025-01-23 Thread Paolo Bonzini
Il gio 23 gen 2025, 06:27 Zhao Liu ha scritto: > On Fri, Jan 17, 2025 at 10:26:54AM +0100, Paolo Bonzini wrote: > > Date: Fri, 17 Jan 2025 10:26:54 +0100 > > From: Paolo Bonzini > > Subject: [PATCH 07/10] rust: pl011: wrap registers with BqlRefCell > > X-Ma

Re: [PATCH 05/10] rust: vmstate: implement VMState for scalar types

2025-01-22 Thread Paolo Bonzini
On 1/22/25 13:33, Zhao Liu wrote: On Fri, Jan 17, 2025 at 10:00:41AM +0100, Paolo Bonzini wrote: Date: Fri, 17 Jan 2025 10:00:41 +0100 From: Paolo Bonzini Subject: [PATCH 05/10] rust: vmstate: implement VMState for scalar types X-Mailer: git-send-email 2.47.1 Scalar types are those that have

Re: [PATCH 05/10] rust: pl011: pull interrupt updates out of read/write ops

2025-01-22 Thread Paolo Bonzini
Il mer 22 gen 2025, 17:31 Zhao Liu ha scritto: > > if event == bindings::QEMUChrEvent::CHR_EVENT_BREAK && > !self.loopback_enabled() { > > -self.put_fifo(registers::Data::BREAK.into()); > > +let update = self.put_fifo(registers::Data::BREAK.into()); > > We can omi

Re: [PATCH 04/10] rust: pl011: extract CharBackend receive logic into a separate function

2025-01-22 Thread Paolo Bonzini
On 1/22/25 15:59, Zhao Liu wrote: if size > 0 { debug_assert!(!buf.is_null()); -state.as_mut().put_fifo(c_uint::from(buf.read_volatile())) An extra question...here I'm not sure, do we really need read_volatile? No, the buffer is not guest visible. It will

Re: [PATCH 03/10] rust: pl011: extract conversion to RegisterOffset

2025-01-22 Thread Paolo Bonzini
On 1/22/25 15:34, Zhao Liu wrote: On Fri, Jan 17, 2025 at 10:26:50AM +0100, Paolo Bonzini wrote: Date: Fri, 17 Jan 2025 10:26:50 +0100 From: Paolo Bonzini Subject: [PATCH 03/10] rust: pl011: extract conversion to RegisterOffset X-Mailer: git-send-email 2.47.1 As an added bonus, this also

[PATCH] target/i386: extract common bits of gen_repz/gen_repz_nz

2025-01-22 Thread Paolo Bonzini
Now that everything has been cleaned up, look at DF and prefixes in a single function, and call that one from gen_repz and gen_repz_nz. Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 34 ++ 1 file changed, 14 insertions(+), 20 deletions(-) diff

[PATCH] target/i386: extract common bits of gen_repz/gen_repz_nz

2025-01-22 Thread Paolo Bonzini
Now that everything has been cleaned up, look at DF and prefixes in a single function, and call that one from gen_repz and gen_repz_nz. Based-on: <20241215090613.89588-1-pbonz...@redhat.com> Suggested-by: Richard Henderson Signed-off-by: Paolo Bonzini --- This was requested

[PATCH] rust: pl011: fix repr(C) for PL011Class

2025-01-21 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini --- rust/hw/char/pl011/src/device.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/rust/hw/char/pl011/src/device.rs b/rust/hw/char/pl011/src/device.rs index c95ab49fd62..4f1080ff19f 100644 --- a/rust/hw/char/pl011/src/device.rs +++ b/rust/hw/char/pl011/src

Re: [PATCH RESEND 0/2] rust/pl011: miscellaneous cleanups

2025-01-21 Thread Paolo Bonzini
On 1/21/25 15:04, Zhao Liu wrote: (Resend the series since it was missed on https://lore.kernel.org/qemu-devel/.) Hi, This series includes the following cleanups: * Patch 1: Make realize() safe to only accept immutable self reference, which is in prepare to introduce gpio bindin

Re: [PATCH] stub: Fix build failure with --enable-user --disable-system --enable-tools

2025-01-21 Thread Paolo Bonzini
On 1/21/25 16:43, Zhao Liu wrote: Configuring "--enable-user --disable-system --enable-tools" causes the build failure with the following information: /usr/bin/ld: libhwcore.a.p/hw_core_qdev.c.o: in function `device_finalize': /qemu/build/../hw/core/qdev.c:688: undefined reference to `qapi_even

Re: [PATCH 0/4] Introduce SierraForest-v2 and ClearwaterForest CPU model

2025-01-21 Thread Paolo Bonzini
Queued with the tweaks suggested by Zoltan and Zhao; thanks! Paolo

Re: [PATCH 1/2] memattrs: Get rid of bit fields

2025-01-20 Thread Paolo Bonzini
On 1/20/25 17:38, Zhao Liu wrote: Thanks for the reminder, yes it is currently full. I found I missed a commnet from Paolo [*], that he suggested only convert `unspecified` to a bool. My bad :-( It still raises the size to 8 bytes but saves spare space, like: typedef struct MemTxAttrs { un

Re: [RFC 06/13] rust: add bindings for memattrs

2025-01-20 Thread Paolo Bonzini
On 1/20/25 17:52, Zhao Liu wrote: Sorry I missed this comment before... Now I have a MemTxAttrs like, typedef struct MemTxAttrs { unsigned int secure:1; unsigned int space:2; unsigned int user:1; unsigned int memory:1; unsigned int requester_id:16; unsigned int pid

[PATCH 05/10] rust: qdev: add clock creation

2025-01-17 Thread Paolo Bonzini
stricter than C. Signed-off-by: Paolo Bonzini --- rust/hw/char/pl011/src/device.rs | 28 +--- rust/qemu-api/src/prelude.rs | 2 + rust/qemu-api/src/qdev.rs| 76 ++-- rust/qemu-api/src/vmstate.rs | 4 +- 4 files changed, 87 insertions(+), 23

[PATCH 08/10] rust: qdev: switch from legacy reset to Resettable

2025-01-17 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini --- meson.build | 1 + rust/hw/char/pl011/src/device.rs | 10 ++- rust/qemu-api/src/qdev.rs| 116 --- rust/qemu-api/tests/tests.rs | 5 +- 4 files changed, 102 insertions(+), 30 deletions(-) diff

[PATCH 09/10] rust: bindings: add Sync markers to types referred to by MemoryRegionOps

2025-01-17 Thread Paolo Bonzini
This is needed for the MemoryRegionOps to be declared as static; Rust requires static elements to be Sync. Signed-off-by: Paolo Bonzini --- rust/qemu-api/src/bindings.rs | 19 ++- rust/qemu-api/src/irq.rs | 3 +++ 2 files changed, 21 insertions(+), 1 deletion(-) diff

[PATCH 07/10] rust: qdev: make ObjectImpl a supertrait of DeviceImpl

2025-01-17 Thread Paolo Bonzini
In practice it has to be implemented always in order to access an implementation of ClassInitImpl. Make the relationship explicit in the code. Signed-off-by: Paolo Bonzini --- rust/qemu-api/src/qdev.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/qemu-api/src

[PATCH 04/10] rust: callbacks: allow passing optional callbacks as ()

2025-01-17 Thread Paolo Bonzini
It is possible to enforce that a callback is valid by adding a "let _: () = F::ASSERT_IS_SOME" before the invocation of F::call. Signed-off-by: Paolo Bonzini --- rust/qemu-api/src/callbacks.rs | 97 ++ 1 file changed, 97 insertions(+) diff --git a

[PATCH 01/10] rust: qemu-api: add sub-subclass to the integration tests

2025-01-17 Thread Paolo Bonzini
From: Zhao Liu missing signed-off-by from zhao --- rust/qemu-api/tests/tests.rs | 56 ++-- 1 file changed, 53 insertions(+), 3 deletions(-) diff --git a/rust/qemu-api/tests/tests.rs b/rust/qemu-api/tests/tests.rs index 526c3f4f8ea..5c3e75ed3d5 100644 --- a/rust/q

[PATCH 03/10] rust: qom: add object creation functionality

2025-01-17 Thread Paolo Bonzini
The basic object lifecycle test can now be implemented using safe code! Signed-off-by: Paolo Bonzini --- rust/hw/char/pl011/src/device.rs | 13 - rust/qemu-api/src/prelude.rs | 1 + rust/qemu-api/src/qom.rs | 23 +-- rust/qemu-api/tests/tests.rs

  1   2   3   4   5   6   7   8   9   10   >