f7ceab1e | 21-Nov-2024 |
Junjie Mao <junjie.mao@hotmail.com> |
rust/pl011: Fix range checks for device ID accesses
The peripheral and PrimeCell identification registers of pl011 are located at offset 0xFE0 - 0xFFC. To check if a read falls to such registers, th
rust/pl011: Fix range checks for device ID accesses
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 itself) is in the range 0x3F8 - 0x3FF.
Use the same check in the Rust implementation.
This fixes the timeout of the following avocado tests:
* tests/avocado/boot_linux_console.py:BootLinuxConsole.test_arm_virt * tests/avocado/replay_kernel.py:ReplayKernelNormal.test_arm_virt * tests/avocado/replay_kernel.py:ReplayKernelNormal.test_arm_vexpressa9
Reported-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Junjie Mao <junjie.mao@hotmail.com> Tested-by: Alex Bennée <alex.bennee@linaro.org> Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Message-Id: <SY0P300MB102644C4AC34A3AAD75DC4D5955C2@SY0P300MB1026.AUSP300.PROD.OUTLOOK.COM> Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Message-Id: <20241121165806.476008-39-alex.bennee@linaro.org>
show more ...
|
88dd060d | 06-Nov-2024 |
Paolo Bonzini <pbonzini@redhat.com> |
rust: qemu-api-macros: always process subprojects before dependencies
Avoid looking for Rust dependencies via cmake.
Reviewed-by: Junjie Mao <junjie.mao@hotmail.com> Signed-off-by: Paolo Bonzini <p
rust: qemu-api-macros: always process subprojects before dependencies
Avoid looking for Rust dependencies via cmake.
Reviewed-by: Junjie Mao <junjie.mao@hotmail.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
ce4a144c | 25-Oct-2024 |
Paolo Bonzini <pbonzini@redhat.com> |
rust: do not use --generate-cstr
--generate-cstr is a good idea and generally the right thing to do, but it is not available in Debian 12 and Ubuntu 22.04. Work around the absence.
Signed-off-by:
rust: do not use --generate-cstr
--generate-cstr is a good idea and generally the right thing to do, but it is not available in Debian 12 and Ubuntu 22.04. Work around the absence.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
bb42965d | 18-Oct-2024 |
Paolo Bonzini <pbonzini@redhat.com> |
rust: do not use MaybeUninit::zeroed()
MaybeUninit::zeroed() is handy but is not available as a "const" function until Rust 1.75.0.
Remove the default implementation of Zeroable::ZERO, and write by
rust: do not use MaybeUninit::zeroed()
MaybeUninit::zeroed() is handy but is not available as a "const" function until Rust 1.75.0.
Remove the default implementation of Zeroable::ZERO, and write by hand the definitions for those types that need it. It may be possible to add automatic implementation of the trait, via a procedural macro and/or a trick similar to offset_of!, but do it the easy way for now.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
f3518400 | 24-Oct-2024 |
Junjie Mao <junjie.mao@hotmail.com> |
rust: introduce alternative implementation of offset_of!
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 lic
rust: introduce alternative implementation of offset_of!
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 can be used just by replacing core::mem::offset_of! with qemu_api::offset_of!.
The actual implementation of offset_of! is done in a declarative macro, but for simplicity and to avoid introducing an extra level of indentation, the trigger is a procedural macro #[derive(offsets)].
The procedural macro is perhaps a bit overengineered, but it helps introducing some idioms that will be useful in the future as well.
Signed-off-by: Junjie Mao <junjie.mao@hotmail.com> Co-developed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
39c8faef | 24-Oct-2024 |
Paolo Bonzini <pbonzini@redhat.com> |
rust: create a cargo workspace
Workspaces allows tracking dependencies for multiple crates at once, by having a single Cargo.lock file at the top of the rust/ tree. Because QEMU's Cargo.lock files h
rust: create a cargo workspace
Workspaces allows tracking dependencies for multiple crates at once, by having a single Cargo.lock file at the top of the rust/ tree. Because QEMU's Cargo.lock files have to be synchronized with the versions of crates in subprojects/, using a workspace avoids the need to copy over the Cargo.lock file when adding a new device (and thus a new crate) under rust/hw/.
In addition, workspaces let cargo download and build dependencies just once. While right now we have one leaf crate (hw/char/pl011), this will not be the case once more devices are added.
Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
907d2bbb | 21-Oct-2024 |
Paolo Bonzini <pbonzini@redhat.com> |
rust: synchronize dependencies between subprojects and Cargo.lock
The next commit will introduce a new build.rs dependency for rust/qemu-api, version_check. Before adding it, ensure that all depend
rust: synchronize dependencies between subprojects and Cargo.lock
The next commit will introduce a new build.rs dependency for rust/qemu-api, version_check. Before adding it, ensure that all dependencies are synchronized between the Meson- and cargo-based build systems.
Note that it's not clear whether in the long term we'll use Cargo for anything; it seems that the three main uses (clippy, rustfmt, rustdoc) can all be invoked manually---either via glue code in QEMU, or by extending Meson to gain the relevant functionality. However, for the time being we're stuck with Cargo so it should at least look at the same code as the rest of the build system.
Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
718e255f | 25-Oct-2024 |
Paolo Bonzini <pbonzini@redhat.com> |
rust: introduce a c_str macro
This allows CStr constants to be defined easily on Rust 1.63.0, while checking that there are no embedded NULs. c"" literals were only stabilized in Rust 1.77.0.
Revi
rust: introduce a c_str macro
This allows CStr constants to be defined easily on Rust 1.63.0, while checking that there are no embedded NULs. c"" literals were only stabilized in Rust 1.77.0.
Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
9f7d4520 | 24-Oct-2024 |
Paolo Bonzini <pbonzini@redhat.com> |
rust: use std::os::raw instead of core::ffi
core::ffi::c_* types were introduced in Rust 1.64.0. Use the older types in std::os::raw, which are now aliases of the types in core::ffi. There is no n
rust: use std::os::raw instead of core::ffi
core::ffi::c_* types were introduced in Rust 1.64.0. Use the older types in std::os::raw, which are now aliases of the types in core::ffi. There is no need to compile QEMU as no_std, so this is acceptable as long as we support a version of Debian with Rust 1.63.0.
Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
230b710b | 24-Oct-2024 |
Manos Pitsidianakis <manos.pitsidianakis@linaro.org> |
rust/pl011: Use correct masks for IBRD and FBRD
Port fix from commit cd247eae16ab1b9ce97fd34c000c1b883feeda45 "hw/char/pl011: Use correct masks for IBRD and FBRD"
Related issue: <https://gitlab.com
rust/pl011: Use correct masks for IBRD and FBRD
Port fix from commit cd247eae16ab1b9ce97fd34c000c1b883feeda45 "hw/char/pl011: Use correct masks for IBRD and FBRD"
Related issue: <https://gitlab.com/qemu-project/qemu/-/issues/2610>
Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Link: https://lore.kernel.org/r/20241024-rust-round-2-v1-9-051e7a25b978@linaro.org
show more ...
|
d38723f5 | 24-Oct-2024 |
Manos Pitsidianakis <manos.pitsidianakis@linaro.org> |
rust/pl011: remove commented out C code
This code juxtaposed what should be happening according to the C device model but is not needed now that this has been reviewed (I hope) and its validity chec
rust/pl011: remove commented out C code
This code juxtaposed what should be happening according to the C device model but is not needed now that this has been reviewed (I hope) and its validity checked against what the C device does (I hope, again).
No functional change.
Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Link: https://lore.kernel.org/r/20241024-rust-round-2-v1-8-051e7a25b978@linaro.org
show more ...
|
2e06e72d | 24-Oct-2024 |
Manos Pitsidianakis <manos.pitsidianakis@linaro.org> |
rust/pl011: add TYPE_PL011_LUMINARY device
Add a device specialization for the Luminary UART device.
This commit adds a DeviceId enum that utilizes the Index trait to return different bytes dependi
rust/pl011: add TYPE_PL011_LUMINARY device
Add a device specialization for the Luminary UART device.
This commit adds a DeviceId enum that utilizes the Index trait to return different bytes depending on what device id the UART has (Arm -default- or Luminary)
Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Tested-by: Zhao Liu <zhao1.liu@intel.com> Link: https://lore.kernel.org/r/20241024-rust-round-2-v1-6-051e7a25b978@linaro.org
show more ...
|
2e57bb6b | 24-Oct-2024 |
Manos Pitsidianakis <manos.pitsidianakis@linaro.org> |
rust/pl011: move CLK_NAME static to function scope
We do not need to have CLK_NAME public nor a static. No functional change.
Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org> Sig
rust/pl011: move CLK_NAME static to function scope
We do not need to have CLK_NAME public nor a static. No functional change.
Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Link: https://lore.kernel.org/r/20241024-rust-round-2-v1-5-051e7a25b978@linaro.org
show more ...
|
93243319 | 24-Oct-2024 |
Manos Pitsidianakis <manos.pitsidianakis@linaro.org> |
rust/pl011: add support for migration
Declare the vmstate description of the PL011 device.
Based on a patch by Manos Pitsidianakis (https://lore.kernel.org/qemu-devel/20241024-rust-round-2-v1-4-051
rust/pl011: add support for migration
Declare the vmstate description of the PL011 device.
Based on a patch by Manos Pitsidianakis (https://lore.kernel.org/qemu-devel/20241024-rust-round-2-v1-4-051e7a25b978@linaro.org/).
Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Link: https://lore.kernel.org/r/20241024-rust-round-2-v1-4-051e7a25b978@linaro.org
show more ...
|
113c6688 | 25-Oct-2024 |
Paolo Bonzini <pbonzini@redhat.com> |
rust/pl011: fix default value for migrate-clock
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> |
0a65e412 | 25-Oct-2024 |
Manos Pitsidianakis <manos.pitsidianakis@linaro.org> |
rust: add definitions for vmstate
Add a new qemu_api module, `vmstate`. Declare a bunch of Rust macros declared that are equivalent in spirit to the C macros in include/migration/vmstate.h.
For exa
rust: add definitions for vmstate
Add a new qemu_api module, `vmstate`. Declare a bunch of Rust macros declared that are equivalent in spirit to the C macros in include/migration/vmstate.h.
For example the Rust of equivalent of the C macro:
VMSTATE_UINT32(field_name, struct_name)
is:
vmstate_uint32!(field_name, StructName)
This breathtaking development will allow us to reach feature parity between the Rust and C pl011 implementations.
Extracted from a patch by Manos Pitsidianakis (https://lore.kernel.org/qemu-devel/20241024-rust-round-2-v1-4-051e7a25b978@linaro.org/).
Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
f60f3670 | 15-Oct-2024 |
Paolo Bonzini <pbonzini@redhat.com> |
rust: do not use TYPE_CHARDEV unnecessarily
In the invocation of qdev_prop_set_chr(), "chardev" is the name of a property rather than a type and has to match the name of the property in device_class
rust: do not use TYPE_CHARDEV unnecessarily
In the invocation of qdev_prop_set_chr(), "chardev" is the name of a property rather than a type and has to match the name of the property in device_class.rs. Do not use TYPE_CHARDEV here, just like in the C version of pl011_create.
Reviewed-by: Junjie Mao <junjie.mao@hotmail.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
6e50bde1 | 18-Oct-2024 |
Paolo Bonzini <pbonzini@redhat.com> |
rust: provide safe wrapper for MaybeUninit::zeroed()
MaybeUninit::zeroed() is handy, but it introduces unsafe (and has a pretty heavy syntax in general). Introduce a trait that provides the same fu
rust: provide safe wrapper for MaybeUninit::zeroed()
MaybeUninit::zeroed() is handy, but it introduces unsafe (and has a pretty heavy syntax in general). Introduce a trait that provides the same functionality while staying within safe Rust.
In addition, MaybeUninit::zeroed() is not available 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.
Reviewed-by: Junjie Mao <junjie.mao@hotmail.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
c92c447f | 18-Oct-2024 |
Paolo Bonzini <pbonzini@redhat.com> |
rust: make properties array immutable
Now that device_class_set_props() takes a const pointer, the only part of "define_property!" that needs to be non-const is the call to try_into(). This in turn
rust: make properties array immutable
Now that device_class_set_props() takes a const pointer, the only part of "define_property!" that needs to be non-const is the call to try_into(). This in turn will only break if offset_of returns a value with the most significant bit set (i.e. a struct size that is >=2^31 or >= 2^63, respectively on 32- and 64-bit system), which is impossible.
Just use a cast and clean everything up to remove the run-time initialization. This also removes a use of OnceLock, which was only stabilized in 1.70.0.
Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
03a573b9 | 18-Oct-2024 |
Paolo Bonzini <pbonzini@redhat.com> |
rust: clean up define_property macro
Use the "struct update" syntax to initialize most of the fields to zero, and simplify the handmade type-checking of $name.
Reviewed-by: Junjie Mao <junjie.mao@h
rust: clean up define_property macro
Use the "struct update" syntax to initialize most of the fields to zero, and simplify the handmade type-checking of $name.
Reviewed-by: Junjie Mao <junjie.mao@hotmail.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
e90d4707 | 21-Oct-2024 |
Paolo Bonzini <pbonzini@redhat.com> |
rust: cleanup module_init!, use it from #[derive(Object)]
Remove the duplicate code by using the module_init! macro; at the same time, simplify how module_init! is used, by taking inspiration from t
rust: cleanup module_init!, use it from #[derive(Object)]
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)].
Reviewed-by: Junjie Mao <junjie.mao@hotmail.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
cde3c425 | 18-Oct-2024 |
Paolo Bonzini <pbonzini@redhat.com> |
rust: build integration test for the qemu_api crate
Adjust the integration test to compile with a subset of QEMU object files, and make it actually create an object of the class it defines.
Follow
rust: build integration test for the qemu_api crate
Adjust the integration test to compile with a subset of QEMU object files, and make it actually create an object of the class it defines.
Follow the Rust filesystem conventions, where tests go in tests/ if they use the library in the same way any other code would.
Reviewed-by: Junjie Mao <junjie.mao@hotmail.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
4f752191 | 18-Oct-2024 |
Paolo Bonzini <pbonzini@redhat.com> |
rust: modernize link_section usage for ELF platforms
Some newer ABI implementations do not provide .ctors; and while some linkers rewrite .ctors into .init_array, not all of them do. Use the newer .
rust: modernize link_section usage for ELF platforms
Some newer ABI implementations do not provide .ctors; and while some linkers rewrite .ctors into .init_array, not all of them do. Use the newer .init_array ABI, which works more reliably, and apply it to all non-Apple, non-Windows platforms.
This is similar to how the ctor crate operates; without this change, "#[derive(Object)]" does not work on Fedora 41.
Reviewed-by: Junjie Mao <junjie.mao@hotmail.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
2eb6274d | 18-Oct-2024 |
Paolo Bonzini <pbonzini@redhat.com> |
rust: remove uses of #[no_mangle]
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.
Reviewed-by: Junjie
rust: remove uses of #[no_mangle]
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.
Reviewed-by: Junjie Mao <junjie.mao@hotmail.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
00ed18de | 15-Oct-2024 |
Paolo Bonzini <pbonzini@redhat.com> |
rust: do not use --no-size_t-is-usize
This is not necessary and makes it harder to write code that is portable between 32- and 64-bit systems: it adds extra casts even though size_of, align_of or of
rust: do not use --no-size_t-is-usize
This is not necessary and makes it harder to write code that is portable between 32- and 64-bit systems: it adds extra casts even though size_of, align_of or offset_of already return the right type.
Reviewed-by: Junjie Mao <junjie.mao@hotmail.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|