Re: vtables and procedural macros (was Re: [PATCH] rust: pl011: convert pl011_create to safe Rust)

2025-02-11 Thread Junjie Mao
Paolo Bonzini writes: > On Tue, Feb 11, 2025 at 7:47 AM Junjie Mao wrote: >> I would suggest to keep the "sysbus" prefix in the method name, or in >> general, keep the class prefix in the method names in XXXClassMethods >> traits. Otherwise APIs from di

Re: vtables and procedural macros (was Re: [PATCH] rust: pl011: convert pl011_create to safe Rust)

2025-02-10 Thread Junjie Mao
e; but I guess now > it's > the time to evaluate this kind of thing. > > Adding Junjie since he contributed the initial proc macro infrastructure and > may > have opinions on this. I agree that uses of proc macros should be carefully evaluated to see if they really help or hurt. In this specific case, I'm not sure if using attributes solves the root cause, though. -- Best Regards Junjie Mao > > Paolo

Re: [PATCH v2 1/2] rust: add BQL-enforcing Cell variant

2024-12-02 Thread Junjie Mao
as taken from Rust's standard library, while removing unstable features > and probably-unnecessary functionality that constitute a large of the > original code. A lot of what's left is documentation, as well as unit > tests in the form of doctests. These are not yet integrated in "make > check" but can be run with "cargo test --doc". > > Signed-off-by: Paolo Bonzini Reviewed-by: Junjie Mao -- Best Regards Junjie Mao

Re: [PATCH 1/2] rust: add BQL-enforcing Cell variant

2024-11-26 Thread Junjie Mao
pi::cell::BqlCell; > +/// > +/// let cell = BqlCell::new(5); > +/// assert_eq!(cell.get(), 5); > +/// assert_eq!(cell.replace(10), 5); > +/// assert_eq!(cell.get(), 10); > + /// ``` > +#[inline] > +pub fn replace(&self, val: T) -> T { > +debug_assert!(bql_locked()); > +// SAFETY: This can cause data races if called from a separate > thread, > +// but `BqlCell` is `!Sync` so this won't happen. This comment looks out-of-date. BqlCell can be Sync but data race won't happen because of the preceding BQL check. -- Best Regards Junjie Mao

Re: [PATCH] rust/pl011: Fix range checks for device ID accesses

2024-11-18 Thread Junjie Mao
Alex Bennée writes: > Junjie Mao writes: > >> The peripheral and PrimeCell identification registers of pl011 are located at >> offset 0xFE0 - 0xFFC. To check if a read falls to such registers, the C >> implementation checks if the offset-shifted-by-2 (not the offset

Re: [RFC PATCH 08/11] rust: build: establish a baseline of lints across all crates

2024-11-13 Thread Junjie Mao
Paolo Bonzini writes: > On 11/13/24 08:14, Junjie Mao wrote: >> Paolo Bonzini writes: >> >>> Many lints that default to allow can be helpful in detecting bugs or >>> keeping the code style homogeneous. Add them liberally, though perhaps >>> not a

Re: [RFC PATCH 01/11] rust: qemu_api: do not disable lints outside bindgen-generated code

2024-11-13 Thread Junjie Mao
Paolo Bonzini writes: > On 11/12/24 11:10, Junjie Mao wrote: >> diff --git a/meson.build b/meson.build >> index 1239f5c48c..8cea09ffe1 100644 >> --- a/meson.build >> +++ b/meson.build >> @@ -4,6 +4,7 @@ project('qemu', ['c'], meson_ver

Re: [RFC PATCH 10/11] rust: fix doc test syntax

2024-11-13 Thread Junjie Mao
Paolo Bonzini writes: > Allow "cargo test --doc" to pass. > > Signed-off-by: Paolo Bonzini Reviewed-by: Junjie Mao -- Best Regards Junjie Mao

Re: [RFC PATCH 09/11] rust: build: add "make clippy", "make rustfmt"

2024-11-13 Thread Junjie Mao
> > Signed-off-by: Paolo Bonzini Reviewed-by: Junjie Mao -- Best Regards Junjie Mao

Re: [RFC PATCH 08/11] rust: build: establish a baseline of lints across all crates

2024-11-12 Thread Junjie Mao
in Rust 2024 > unsafe_op_in_unsafe_fn = "deny" > + [snip] > + > +# nice to have, but cannot be enabled yet > +#wildcard_imports = "deny" > + > +# these may have false positives > +#option_if_let_else = "deny" > +cognitive_complexity = "deny" Just to confirm, CC <= 25 is to be enforced for all methods, right? -- Best Regards Junjie Mao

Re: [RFC PATCH 01/11] rust: qemu_api: do not disable lints outside bindgen-generated code

2024-11-12 Thread Junjie Mao
Paolo Bonzini writes: > Il mar 12 nov 2024, 03:47 Junjie Mao ha scritto: > > I agree that storing generated stuff in the source directory should not > be encouraged. > > Just want to mention that such changes can lead to trouble to > rust-analyzer. Today there are tw

Re: [RFC PATCH 05/11] rust: cargo: store desired warning levels in workspace Cargo.toml

2024-11-11 Thread Junjie Mao
Paolo Bonzini writes: > Il mar 12 nov 2024, 04:17 Junjie Mao ha scritto: > > Making a universal unexpected_cfgs apply to the whole workspace may lead > to a lengthy cfg list when more devices in Rust are added. As cargo does > not allow overriding workspace-defined lints on

Re: [RFC PATCH 05/11] rust: cargo: store desired warning levels in workspace Cargo.toml

2024-11-11 Thread Junjie Mao
;] } > + Making a universal unexpected_cfgs apply to the whole workspace may lead to a lengthy cfg list when more devices in Rust are added. As cargo does not allow overriding workspace-defined lints once inherited, I think it better to keep unexpected_cfgs crate-specific. -- Best Regards Junjie Mao

Re: [RFC PATCH 02/11] rust: build: move rustc_args.py invocation to individual crates

2024-11-11 Thread Junjie Mao
in this series. So I think every crate under rust/ needs a run_command(rustc_args, ...) for crate-specific arguments. -- Best Regards Junjie Mao > Remove > the temptation to use them by limiting the --cfg arguments to the > qemu-api crate. > > Signed-off-by: Paolo Bonzini &g

Re: [RFC PATCH 01/11] rust: qemu_api: do not disable lints outside bindgen-generated code

2024-11-11 Thread Junjie Mao
o ways to inform rust-analyzer of the project structure: 1. Use rust/Cargo.toml. In this case we'll hit an issue in rust-analyzer [1] that prevents it from including sources outside the crate directory. Thus, definitions in the bindgen-generated code cannot be found. 2. Use the

Re: [RFC PATCH] rust: add bindings for interrupt sources + interior mutability discussion

2024-11-08 Thread Junjie Mao
ble check on this). However, temporarily unlocking BQL is extremely rare in devices. I'm not sure if that's worthwhile at the cost of making the APIs more tedious to use. What do you think? -- Best Regards Junjie Mao > > Signed-off-by: Paolo Bonzini > --- > Do people t

Re: [PATCH] rust: qemu-api-macros: always process subprojects before dependencies

2024-11-07 Thread Junjie Mao
Paolo Bonzini writes: > Avoid looking for Rust dependencies via cmake. > > Signed-off-by: Paolo Bonzini Reviewed-by: Junjie Mao > --- > rust/qemu-api-macros/meson.build | 4 > 1 file changed, 4 insertions(+) > > diff --git a/rust/qemu-api-macros/meson.build

[PATCH] rust/pl011: Fix range checks for device ID accesses

2024-11-06 Thread Junjie Mao
Maydell Signed-off-by: Junjie Mao --- rust/hw/char/pl011/src/device.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/hw/char/pl011/src/device.rs b/rust/hw/char/pl011/src/device.rs index 2a85960b81..476cacc844 100644 --- a/rust/hw/char/pl011/src/device.rs +++ b/rust/hw/char

Re: [PATCH 15/23] rust: introduce alternative implementation of offset_of!

2024-11-04 Thread Junjie Mao
Paolo Bonzini writes: > On 11/3/24 10:54, Junjie Mao wrote: >> Paolo Bonzini writes: >> >>> diff --git a/rust/qemu-api-macros/src/lib.rs >>> b/rust/qemu-api-macros/src/lib.rs >>> index a4bc5d01ee8..c2ea22101e4 100644 >>> --- a/rust/qemu-a

Re: [PATCH 15/23] rust: introduce alternative implementation of offset_of!

2024-11-03 Thread Junjie Mao
Paolo Bonzini writes: > From: Junjie Mao > > offset_of! was stabilized in Rust 1.77.0. Use an alternative implemenation > that was found on the Rust forums, and whose author agreed to license as > MIT for use in QEMU. > > The alternative allows only one level of fi

Re: [PATCH 13/23] rust: synchronize dependencies between subprojects and Cargo.lock

2024-11-01 Thread Junjie Mao
Paolo Bonzini writes: > Il ven 1 nov 2024, 11:21 Junjie Mao ha scritto: > > How about specifying also the exact version in Cargo.toml, e.g.: > > [dependencies] > -proc-macro2 = "1" > -quote = "1" > -syn = { version = "2", fe

Re: [PATCH 14/23] rust: create a cargo workspace

2024-11-01 Thread Junjie Mao
t be the case once more devices are added. Cargo workspace fits our use case very well! Reviewed-by: Junjie Mao

Re: [PATCH 13/23] rust: synchronize dependencies between subprojects and Cargo.lock

2024-11-01 Thread Junjie Mao
ect dependencies will be unchanged even after a cargo generate-lockfile. Unfortunately, versions of nested dependencies, such as either and unicode-ident, may still have newer patch versions after a lockfile regeneration. That can be worked around by turning nested dependencies to direct ones with fixed version constraints, but looks quite ugly. -- Best Regards Junjie Mao

Re: [PATCH v2 02/14] rust: fix cfgs of proc-macro2 for 1.63.0

2024-10-23 Thread Junjie Mao
Paolo Bonzini writes: > Replay the configuration that would be computed by build.rs when compiling > on a 1.63.0 compiler. > > Signed-off-by: Paolo Bonzini Reviewed-by: Junjie Mao One question below. > --- > subprojects/packagefiles/proc-macro2-1-rs/meson.build | 4 +++-

Re: [PATCH v2 06/14] rust: synchronize dependencies between subprojects and Cargo.lock

2024-10-23 Thread Junjie Mao
I would suggest adding those dependencies and version constraints in Cargo.toml, not Cargo.lock. Future devices in Rust will have their Cargo.lock derived from Cargo.toml of qemu-api and qemu-api-macro, so missing version info there will force device writers to manually tweak their Cargo.lock. -- Best Regards Junjie Mao

Re: [PATCH v2 01/14] rust: patch bilge-impl to allow compilation with 1.63.0

2024-10-23 Thread Junjie Mao
Paolo Bonzini writes: > Apply a patch that removes "let ... else" constructs, replacing them with > "if let ... else" or "let ... = match ...". "let ... else" was stabilized in > Rust 1.65.0. > > Reviewed-by: Zhao Liu > Signed-off-

Re: [PATCH v2 08/13] rust: cleanup module_init!, use it from #[derive(Object)]

2024-10-23 Thread Junjie Mao
Kevin Wolf writes: > Am 22.10.2024 um 08:00 hat Junjie Mao geschrieben: >> >> Paolo Bonzini writes: >> >> > On Tue, Oct 22, 2024 at 4:12 AM Junjie Mao wrote: >> >> > +($type:ident => $body:block) => { >>

Re: [PATCH v2] rust: introduce alternative implementation of offset_of!

2024-10-22 Thread Junjie Mao
Junjie Mao writes: > offset_of! was stabilized in Rust 1.77.0. Use an alternative implemenation > that was found on the Rust forums, and whose author agreed to license as > MIT for use in QEMU. > > The alternative allows only one level of field access, but apart from this > c

[PATCH v2] rust: introduce alternative implementation of offset_of!

2024-10-22 Thread Junjie Mao
Bonzini Signed-off-by: Paolo Bonzini Signed-off-by: Junjie Mao --- rust/hw/char/pl011/src/device.rs | 2 +- rust/qemu-api-macros/Cargo.toml | 6 +- rust/qemu-api-macros/src/lib.rs | 71 +- rust/qemu-api/Cargo.lock

Re: [Question] What is the definition of “private” fields in QOM?

2024-10-21 Thread Junjie Mao
s. If > we do mark all these fields not public, what would break? > The only thing that breaks today is std::mem::offset_of! which respects field visibility. Defining a Property const structure requires getting the field offset outside of the state context. To me properties are still pri

Re: [PATCH] rust: introduce alternative implementation of offset_of!

2024-10-21 Thread Junjie Mao
Paolo Bonzini writes: > Il lun 21 ott 2024, 09:24 Junjie Mao ha scritto: > > > Thanks. I still prefer to keep the procedural macro code minimal, and > have the > > code generation in a separate macro, but this is a nice start! > > > > I'm not s

Re: [PATCH v2 04/13] rust: do not use --no-size_t-is-usize

2024-10-21 Thread Junjie Mao
i Reviewed-by: Junjie Mao -- Best Regards Junjie Mao

Re: [PATCH v2 03/13] meson: pass rustc_args when building all crates

2024-10-21 Thread Junjie Mao
Paolo Bonzini writes: > rustc_args is needed to smooth the difference in warnings between the various > versions of rustc. Always include those arguments. > > Signed-off-by: Paolo Bonzini Reviewed-by: Junjie Mao -- Best Regards Junjie Mao

Re: [PATCH 03/16] rust: pass rustc_args when building all crates

2024-10-21 Thread Junjie Mao
can run clippy by: mkdir build.clippy && cd build.clippy RUSTC=clippy-driver ../configure --enable-rust ... ninja librust_x86_64_softmmu.a -- Best Regards Junjie Mao

Re: [PATCH v2 08/13] rust: cleanup module_init!, use it from #[derive(Object)]

2024-10-21 Thread Junjie Mao
Paolo Bonzini writes: > Remove the duplicate code by using the module_init! macro; at the same time, > simplify how module_init! is used, by taking inspiration from the > implementation > of #[derive(Object)]. > > Signed-off-by: Paolo Bonzini Reviewed-by: Junjie Mao

Re: [PATCH v2 07/13] rust: build integration test for the qemu_api crate

2024-10-21 Thread Junjie Mao
any other code would. > > Reviewed-by: Zhao Liu > Signed-off-by: Paolo Bonzini Reviewed-by: Junjie Mao -- Best Regards Junjie Mao

Re: [PATCH 08/13] rust: build integration test for the qemu_api crate

2024-10-21 Thread Junjie Mao
Paolo Bonzini writes: > On Mon, Oct 21, 2024 at 1:35 PM Junjie Mao wrote: >> >> >> Paolo Bonzini writes: >> >> > Adjust the integration test to compile with a subset of QEMU object >> > files, and make it actually create an object of the class it

Re: [PATCH 11/13] rust: make properties array immutable

2024-10-21 Thread Junjie Mao
; > Signed-off-by: Paolo Bonzini Reviewed-by: Junjie Mao -- Best Regards Junjie Mao

Re: [PATCH 13/13] rust: do not use TYPE_CHARDEV unnecessarily

2024-10-21 Thread Junjie Mao
t; > Signed-off-by: Paolo Bonzini Reviewed-by: Junjie Mao -- Best Regards Junjie Mao

Re: [PATCH 12/13] rust: provide safe wrapper for MaybeUninit::zeroed()

2024-10-21 Thread Junjie Mao
ble as a "const" > function until Rust 1.75.0, so this also prepares for having handwritten > implementations of the trait until we can assume that version. > > Signed-off-by: Paolo Bonzini Reviewed-by: Junjie Mao -- Best Regards Junjie Mao

Re: [PATCH 09/13] rust: clean up define_property macro

2024-10-21 Thread Junjie Mao
Paolo Bonzini writes: > Il lun 21 ott 2024, 12:39 Junjie Mao ha scritto: > > Paolo Bonzini writes: > > > Use the "struct update" syntax to initialize most of the fields to zero, > > and simplify the handmade type-checking of $name. >

Re: [PATCH 08/13] rust: build integration test for the qemu_api crate

2024-10-21 Thread Junjie Mao
cutable( 'rust_qemu_api_integration', 'tests/tests.rs', override_options: ['rust_std=2021', 'build.rust_std=2021'], rust_args: [ '--test', ], install: false, dependencies: [qemu_api, qemu_api_macros], link_whole: [rust_qemu_api_objs, libqemuutil]), args: [ '--test', '--format', 'pretty', ], protocol: 'rust', suite: ['unit', 'rust']) -- Best Regards Junjie Mao

Re: [PATCH 09/13] rust: clean up define_property macro

2024-10-21 Thread Junjie Mao
indings::Property>::zeroed().assume_init() > } zeroed() is const only since 1.75.0 [1]. Is there any alternative for older Rust versions? [1] https://doc.rust-lang.org/std/mem/union.MaybeUninit.html#method.zeroed -- Best Regards Junjie Mao

Re: [PATCH 08/13] rust: build integration test for the qemu_api crate

2024-10-21 Thread Junjie Mao
any other code would. > > Signed-off-by: Paolo Bonzini Reviewed-by: Junjie Mao A few minor comments on cosmetic below. > --- > meson.build | 10 - > rust/qemu-api/meson.build| 20 +++-- > rust/qemu-api/src/tests.rs | 49 -- >

Re: [PATCH 07/13] rust: modernize #[derive(Object)] for ELF platforms

2024-10-21 Thread Junjie Mao
This is similar to how the ctor crate operates; without this change, > "#[derive(Object)]" does not work on Fedora 41. > > Signed-off-by: Paolo Bonzini Reviewed-by: Junjie Mao -- Best Regards Junjie Mao

Re: [PATCH 06/13] rust: remove unused macro module_init!

2024-10-21 Thread Junjie Mao
d I had a conversation on this. He mentioned that he had a second Rust device that needs this macro [1]. [1] https://lore.kernel.org/qemu-devel/itblf.by425lac...@linaro.org/ -- Best Regards Junjie Mao > > Signed-off-by: Paolo Bonzini > --- > rust/qemu-api/src/defi

Re: [PATCH 05/13] rust: remove uses of #[no_mangle]

2024-10-21 Thread Junjie Mao
Paolo Bonzini writes: > Mangled symbols do not cause any issue; disabling mangling is only useful if > C headers reference the Rust function, which is not the case here. > > Signed-off-by: Paolo Bonzini Reviewed-by: Junjie Mao -- Best Regards Junjie Mao

Re: [PATCH] rust: introduce alternative implementation of offset_of!

2024-10-21 Thread Junjie Mao
Paolo Bonzini writes: > On 10/21/24 07:40, Junjie Mao wrote: >> offset_of! was stabilized in Rust 1.77.0. Use an alternative implemenation >> that was found on the Rust forums, and whose author agreed to license as >> MIT for use in QEMU. >> The alternative all

[PATCH] rust: introduce alternative implementation of offset_of!

2024-10-20 Thread Junjie Mao
fg is added to packagefiles/syn-2-rs/meson.build, which requires meson to re-checkout the subproject. [1] https://lore.kernel.org/qemu-devel/20241015131735.518771-1-pbonz...@redhat.com Co-authored-by: Paolo Bonzini Signed-off-by: Paolo Bonzini Signed-off-by: Junjie Mao --- rust/hw/char/pl01

Re: [PATCH 10/16] rust: introduce alternative implementation of offset_of!

2024-10-17 Thread Junjie Mao
Paolo Bonzini writes: > On Thu, Oct 17, 2024 at 7:35 AM Junjie Mao wrote: >> Paolo Bonzini writes: >> > offset_of! was stabilized in Rust 1.77.0. Use an alternative implemenation >> > that was found on the Rust forums, and whose author agreed to license

Re: [PATCH 12/16] rust: allow version 1.63.0 of rustc

2024-10-17 Thread Junjie Mao
Junjie Mao writes: > Paolo Bonzini writes: > >> Il mer 16 ott 2024, 08:10 Junjie Mao ha scritto: >> >> In my Ubuntu 22.04 environment (rustc 1.76.0 and bindgen 0.59.1 from >> apt) the feature `proc_macro_byte_character` is not yet stablized but >> u

Re: [PATCH 10/16] rust: introduce alternative implementation of offset_of!

2024-10-16 Thread Junjie Mao
e and field point to the MaybeUninit<$parent> and are casted // to u8 for calculating their distance. unsafe { field.cast::().offset_from(base.cast::()) as usize } }}; } [1] https://docs.rs/memoffset/latest/memoffset/ -- Best Regards Junjie Mao

Re: [PATCH 12/16] rust: allow version 1.63.0 of rustc

2024-10-16 Thread Junjie Mao
Paolo Bonzini writes: > Il mer 16 ott 2024, 08:10 Junjie Mao ha scritto: > > In my Ubuntu 22.04 environment (rustc 1.76.0 and bindgen 0.59.1 from > apt) the feature `proc_macro_byte_character` is not yet stablized but > used in proc-macro2. Downgrading proc-macro2 to 1.0.79

Re: [PATCH 02/16] meson: remove repeated search for rust_root_crate.sh

2024-10-15 Thread Junjie Mao
Paolo Bonzini writes: > Avoid repeated lines of the form > > Program scripts/rust/rust_root_crate.sh found: YES > (/home/pbonzini/work/upstream/qemu/scripts/rust/rust_root_crate.sh) > > in the meson logs. > > Signed-off-by: Paolo Bonzini Reviewed-by: Junjie Mao Tha

Re: [PATCH 16/16] rust: allow older version of bindgen

2024-10-15 Thread Junjie Mao
pes and thus break the build. Allowlists for bindgen 0.59.1 can only be specified as regex on function, type or var. I don't find (yet) an equivalent way of --allowlist-file. A dirty trick is `--blocklist-item IPPORT_RESERVED`, which works but is so ad-hoc. -- Best Regards Junjie Mao

Re: [PATCH 12/16] rust: allow version 1.63.0 of rustc

2024-10-15 Thread Junjie Mao
tory = syn-2.0.58 +source_url = https://crates.io/api/v1/crates/syn/2.0.58/download +source_filename = syn-2.0.58.0.tar.gz +source_hash = 44cfb93f38070beee36b3fef7d4f5a16f27751d94b187b666a5cc5e9b0d30687 #method = cargo patch_directory = syn-2-rs -- Best Regards Junjie Mao > if get_option('rust').enabled() > - error('rustc

Re: [PATCH] rust/wrapper.h: define memory_order enum

2024-10-15 Thread Junjie Mao
io.h) but probably we have to leave the warning in. > > Paolo I agree with Paolo's comments. It was reported that using inconsistent versions of clang and libclang can lead to unsound bindings even they compile. I would recommend to keep that warning till a proper resolution, e.g. clang-sys provides consistent paths, is present. -- Best Regards Junjie Mao

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

2024-10-11 Thread Junjie Mao
ves: https://gitlab.com/qemu-project/qemu/-/issues/2576 > Fixes: ffa8a3e3b2e6 ("virtio-pci: Add lookup subregion of VirtIOPCIRegion MR") > > Signed-off-by: Gao Shiyuan > Signed-off-by: Zuo Boqun > Signed-off-by: Wang Liang Reviewed-by: Junjie Mao Thanks! -- Best Regards Junjie Mao

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_f

Re: Rust BoF and maintainer minutes and planning the roadmap to Rust

2024-09-26 Thread Junjie Mao
ate and a test driver. In that sense, I don't think mixed C/Rust code can be unit-tested in the current draft of Rust enabling where the C and Rust code are separately built into libraries and finally linked together. -- Best Regards Junjie Mao

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

2024-09-25 Thread Junjie Mao
a38c7..fddceaaa47 100644 > --- a/include/hw/virtio/virtio-pci.h > +++ b/include/hw/virtio/virtio-pci.h > @@ -147,6 +147,7 @@ struct VirtIOPCIProxy { > }; > MemoryRegion modern_bar; > MemoryRegion io_bar; > +AddressSpace modern_as; How about naming it "config_as" or "config_mem_as"? While the PCI configuration access capability is specific to modern devices, what it maps (and only maps) are the virtio config regions. Also, we may need another "config_io_as" for the port I/O mapped notification config region. > uint32_t legacy_io_bar_idx; > uint32_t msix_bar_idx; > uint32_t modern_io_bar_idx; -- Best Regards Junjie Mao

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

2024-09-25 Thread Junjie Mao
fig regions. The PCI capability can be regarded as a window to a register space that is inaccessible otherwise under certain conditions. Also, device-specific address spaces are not rare today. Directly travering the subregions does not look like a good approach as it breaks abstraction. Accesses to memory regions require extra care about RCU and refcount. Scatter such operations in multiple files will make the abstraction harder to maintain. Adding another API for finding a subregion within a region not in any address space is an alternative, but I'm not sure if that looks like an overkill. -- Best Regards Junjie Mao

Re: [PATCH v10 9/9] rust: add PL011 device model

2024-09-14 Thread Junjie Mao
Junjie Mao writes: > Manos Pitsidianakis writes: > >> This commit adds a re-implementation of hw/char/pl011.c in Rust. >> >> How to build: >> >> 1. Configure a QEMU build with: >>--enable-system --target-list=aarch64-softmmu --enable-rust >> 2

Re: [PATCH v10 8/9] rust: add utility procedural macro crate

2024-09-14 Thread Junjie Mao
y: Manos Pitsidianakis Reviewed-by: Junjie Mao > --- > MAINTAINERS| 1 + > rust/meson.build | 1 + > rust/qemu-api-macros/Cargo.lock| 47 > ++ > r

Re: [PATCH v10 9/9] rust: add PL011 device model

2024-09-14 Thread Junjie Mao
Rust version >of the pl011 device > > Co-authored-by: Junjie Mao > Co-authored-by: Paolo Bonzini > Signed-off-by: Junjie Mao > Signed-off-by: Paolo Bonzini > Signed-off-by: Manos Pitsidianakis > --- [snip] > diff --git a/rust/hw/char/pl011/src/device.rs >

Re: [PATCH v10 7/9] rust: add crate to expose bindings and interfaces

2024-09-13 Thread Junjie Mao
Manos Pitsidianakis writes: > Add rust/qemu-api, which exposes rust-bindgen generated FFI bindings and > provides some declaration macros for symbols visible to the rest of > QEMU. > > Co-authored-by: Junjie Mao > Co-authored-by: Paolo Bonzini > Signed-off-by: Junjie

Re: [PATCH RESEND v9 7/9] rust: add crate to expose bindings and interfaces

2024-09-04 Thread Junjie Mao
On 9/4/2024 7:01 PM, Paolo Bonzini wrote: On Wed, Aug 28, 2024 at 6:12 AM Manos Pitsidianakis wrote: Add rust/qemu-api, which exposes rust-bindgen generated FFI bindings and provides some declaration macros for symbols visible to the rest of QEMU. The only comment I have is that I would drop

Re: [PATCH RESEND v9 7/9] rust: add crate to expose bindings and interfaces

2024-09-01 Thread Junjie Mao
On 8/31/2024 4:25 PM, Manos Pitsidianakis wrote: On Fri, 30 Aug 2024 14:03, Alex Bennée wrote: [.snip.] It is there:  /usr/lib/llvm-14/lib/clang/14.0.6/include/stdatomic.h in the search path:  clang -E -Wp,-v -  clang -cc1 version 14.0.6 based upon LLVM 14.0.6 default target x86_64-pc-linu

Re: [PATCH RESEND v9 7/9] rust: add crate to expose bindings and interfaces

2024-08-30 Thread Junjie Mao
On 8/30/2024 2:43 PM, Manos Pitsidianakis wrote: 🎱 On Fri, 30 Aug 2024, 04:19 Junjie Mao, <mailto:junjie@intel.com>> wrote: On 8/28/2024 9:08 PM, Alex Bennée wrote: > Manos Pitsidianakis mailto:manos.pitsidiana...@linaro.org>> writes: > >&g

Re: [PATCH RESEND v9 7/9] rust: add crate to expose bindings and interfaces

2024-08-29 Thread Junjie Mao
RGS"); println!( "cargo:rerun-if-env-changed=BINDGEN_EXTRA_CLANG_ARGS_{}", std::env::var("TARGET").unwrap() ); println!( "cargo:rerun-if-env-changed=BINDGEN_EXTRA_CLANG_ARGS_{}", std::env::var("TARGET&q

Re: [PATCH v8 6/8] rust: add crate to expose bindings and interfaces

2024-08-26 Thread Junjie Mao
On 8/26/2024 2:12 PM, Manos Pitsidianakis wrote: On Mon, 26 Aug 2024 08:03, Junjie Mao wrote: Hi Manos, On 8/23/2024 4:11 PM, Manos Pitsidianakis wrote: Add rust/qemu-api, which exposes rust-bindgen generated FFI bindings and provides some declaration macros for symbols visible to the rest

Re: [PATCH v8 6/8] rust: add crate to expose bindings and interfaces

2024-08-26 Thread Junjie Mao
On 8/26/2024 2:41 PM, Manos Pitsidianakis wrote: On Mon, 26 Aug 2024 08:31, Junjie Mao wrote: +unsafe impl GlobalAlloc for QemuAllocator { +    unsafe fn alloc(&self, layout: Layout) -> *mut u8 { +    if layout.align() == 0 { +    g_malloc0(layout.size().try_into().unwrap(

Re: [PATCH v8 6/8] rust: add crate to expose bindings and interfaces

2024-08-25 Thread Junjie Mao
On 8/23/2024 4:11 PM, Manos Pitsidianakis wrote: Add rust/qemu-api, which exposes rust-bindgen generated FFI bindings and provides some declaration macros for symbols visible to the rest of QEMU. Co-authored-by: Junjie Mao Co-authored-by: Paolo Bonzini Signed-off-by: Junjie Mao Signed-off-by

Re: [PATCH v8 7/8] rust: add utility procedural macro crate

2024-08-25 Thread Junjie Mao
os, but the later generates code that uses types defined by the former. So to me qemu-api-macros should depend on qemu-api, not vice versa. --- Best Regards Junjie Mao

Re: [PATCH v8 6/8] rust: add crate to expose bindings and interfaces

2024-08-25 Thread Junjie Mao
Hi Manos, On 8/23/2024 4:11 PM, Manos Pitsidianakis wrote: Add rust/qemu-api, which exposes rust-bindgen generated FFI bindings and provides some declaration macros for symbols visible to the rest of QEMU. Co-authored-by: Junjie Mao Co-authored-by: Paolo Bonzini Signed-off-by: Junjie Mao

Re: [PATCH v7 0/7] Add Rust build support, ARM PL011 device impl

2024-08-18 Thread Junjie Mao
On 8/16/2024 4:17 PM, Manos Pitsidianakis wrote: On Fri, 16 Aug 2024, 11:06 Junjie Mao, <mailto:junjie@intel.com>> wrote: On 8/15/2024 7:42 PM, Manos Pitsidianakis wrote: > Outstanding issues > == > > Outstanding issues that

Re: [PATCH v7 6/7] rust: add crate to expose bindings and interfaces

2024-08-16 Thread Junjie Mao
On 8/15/2024 7:42 PM, Manos Pitsidianakis wrote: Add rust/qemu-api, which exposes rust-bindgen generated FFI bindings and provides some declaration macros for symbols visible to the rest of QEMU. Co-authored-by: Junjie Mao Co-authored-by: Paolo Bonzini Signed-off-by: Junjie Mao Signed-off-by

Re: [PATCH v7 0/7] Add Rust build support, ARM PL011 device impl

2024-08-16 Thread Junjie Mao
jects using the C linker. That somehow works (with some tricks) but is not officially supported and may break in the future. I'm working on (1), but would like to have your thoughts and preference on those options. [1] https://github.com/rust-lang/rust/issues/73632 --- Best Regards Junjie Mao

[RFC PATCH 2/2] rust: Specify Rust edition by rust_std=20XX

2024-08-13 Thread Junjie Mao
Signed-off-by: Junjie Mao --- rust/hw/char/pl011/meson.build | 4 +--- rust/meson.build | 4 +--- rust/qemu-api/meson.build | 2 +- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/rust/hw/char/pl011/meson.build b/rust/hw/char/pl011/meson.build index 1c139d3af9

[RFC PATCH 1/2] meson: subprojects: Specify Rust edition by rust_std=20XX

2024-08-13 Thread Junjie Mao
Signed-off-by: Junjie Mao --- subprojects/packagefiles/arbitrary-int-1-rs/meson.build | 4 +--- subprojects/packagefiles/bilge-impl-0.2-rs/meson.build| 2 +- subprojects/packagefiles/either-1-rs/meson.build | 2 +- subprojects/packagefiles/itertools-0.11-rs/meson.build

[RFC PATCH 0/2] meson: Specify Rust edition by rust_std=20XX

2024-08-13 Thread Junjie Mao
11-rfc-v6 [3]. Feel free to squash these changes into that series. [1] https://github.com/mesonbuild/meson/pull/7934 [2] https://gitlab.com/bonzini/qemu/-/tree/rust-for-manos [3] https://lore.kernel.org/qemu-devel/rust-pl011-rfc-v6.git.manos.pitsidiana...@linaro.org Junjie Mao (2): meson: subpr

Re: [RFC PATCH v6 5/5] rust: add PL011 device model

2024-08-12 Thread Junjie Mao
f --git a/subprojects/packagefiles/unicode-ident-1-rs/meson.build b/subprojects/packagefiles/unicode-ident-1-rs/meson.build index 80d088282c..c398f59211 100644 --- a/subprojects/packagefiles/unicode-ident-1-rs/meson.build +++ b/subprojects/packagefiles/unicode-ident-1-rs/meson.build @@ -19,4 +19,4 @@ unicode_ident_dep = declare_dependency( link_with: _unicode_ident_rs, ) -meson.override_dependency('unicode-ident-1-rs-native', unicode_ident_dep) +meson.override_dependency('unicode-ident-1-rs-native', unicode_ident_dep, native: true) Besides, I think we don't need the "-native" suffix in the dependency names since we already have that "native: true" argument. I also tested configuration and build after execute "find . -name 'meson.build' | xargs -n 1 sed -i 's/-native//g'" under subprojects/packagefiles, and it worked as well. With the changes above, I'm able to cross-build except for one known linking issue [1]. [1] https://github.com/llvm/llvm-project/pull/93890 Thanks Junjie Mao Paolo