rust, i386 changes for 2025-06-03
The following changes since commit 6322b753f798337835e205b6d805356bea582c86:
Merge tag 'for_upstream' of https://git.kernel.org/pub/scm/virt/kvm/mst/qemu into staging (2025-06-02 14:52:45 -0400)
are available in the Git repository at:
https://gitlab.com/bonzini/qemu.git tags/for-upstream
for you to fetch changes up to 214518614c1ce7eb7a002452cd43a7597f90d543:
rust: qemu-api-macros: add from_bits and into_bits to #[derive(TryInto)] (2025-06-03 22:44:40 +0200)
----------------------------------------------------------------
* rust: use native Meson support for clippy and rustdoc
* rust: add "bits", a custom bitflags implementation
* target/i386: Remove FRED dependency on WRMSRNS
* target/i386: Add the immediate form MSR access instruction support
* TDX fixes
----------------------------------------------------------------
Cédric Le Goater (2):
i386/tdx: Fix build on 32-bit host
i386/tdvf: Fix build on 32-bit host
Paolo Bonzini (10):
rust: bindings: allow ptr_offset_with_cast
meson: update to version 1.8.1
rust: use "objects" for Rust executables as well
build, dockerfiles: add support for detecting rustdoc
rust: add qemu-api doctests to "meson test"
rust: cell: remove support for running doctests with "cargo test --doc"
rust: use native Meson support for clippy and rustdoc
rust: add "bits", a custom bitflags implementation
rust: pl011: use the bits macro
rust: qemu-api-macros: add from_bits and into_bits to #[derive(TryInto)]
Pierrick Bouvier (1):
meson: use config_base_arch for target libraries
Xin Li (Intel) (3):
target/i386: Remove FRED dependency on WRMSRNS target/i386: Add a new CPU feature word for CPUID.7.1.ECX target/i386: Add the immediate form MSR access instruction support
docs/devel/rust.rst | 12 +- configure | 16 + meson.build | 11 +- target/i386/cpu.h | 5 + hw/i386/tdvf.c | 6 +- target/i386/cpu.c | 27 +- target/i386/kvm/tdx.c | 26 +- .gitlab-ci.d/buildtest-template.yml | 3 +- .gitlab-ci.d/buildtest.yml | 11 +- rust/clippy.toml => clippy.toml | 2 +- python/scripts/vendor.py | 4 +- python/wheels/meson-1.5.0-py3-none-any.whl | Bin 959846 -> 0 bytes python/wheels/meson-1.8.1-py3-none-any.whl | Bin 0 -> 1013001 bytes pythondeps.toml | 2 +- rust/Cargo.lock | 8 + rust/Cargo.toml | 2 +- rust/bits/Cargo.toml | 19 + rust/bits/meson.build | 16 + rust/bits/src/lib.rs | 443 +++++++++++++++++++++ rust/hw/char/pl011/Cargo.toml | 1 + rust/hw/char/pl011/meson.build | 1 + rust/hw/char/pl011/src/device.rs | 51 ++- rust/hw/char/pl011/src/registers.rs | 39 +- rust/meson.build | 15 +- rust/qemu-api-macros/src/bits.rs | 229 +++++++++++ rust/qemu-api-macros/src/lib.rs | 60 ++- rust/qemu-api/meson.build | 34 +- rust/qemu-api/src/bindings.rs | 1 + rust/qemu-api/src/cell.rs | 22 +- scripts/rust/rustc_args.py | 5 +- .../docker/dockerfiles/fedora-rust-nightly.docker | 2 + tests/docker/dockerfiles/ubuntu2204.docker | 1 + tests/lcitool/mappings.yml | 6 +- tests/lcitool/refresh | 3 + 34 files changed, 934 insertions(+), 149 deletions(-) rename rust/clippy.toml => clippy.toml (55%) delete mode 100644 python/wheels/meson-1.5.0-py3-none-any.whl create mode 100644 python/wheels/meson-1.8.1-py3-none-any.whl create mode 100644 rust/bits/Cargo.toml create mode 100644 rust/bits/meson.build create mode 100644 rust/bits/src/lib.rs create mode 100644 rust/qemu-api-macros/src/bits.rs
Signature · 1 line
2.49.0
[PULL 07/16] rust: use native Meson support for clippy and rustdoc
Meson has support for invoking clippy and rustdoc on all crates (1.7.0 for clippy, 1.8.0 for rustdoc). Use it instead of the homegrown version; this requires disabling the multiple_crate_versions lint (the only one that was enabled from the "cargo" group)---which was not particularly useful anyway because all dependencies are converted by hand into Meson subprojects.
rustfmt is still not supported.
--- docs/devel/rust.rst | 10 +++++++--- meson.build | 2 +- rust/clippy.toml => clippy.toml | 2 +- rust/Cargo.toml | 1 - rust/meson.build | 12 ------------ scripts/rust/rustc_args.py | 5 +---- 6 files changed, 10 insertions(+), 22 deletions(-) rename rust/clippy.toml => clippy.toml (55%)
docs/devel/rust.rst +7 -3
@@ -37,12 +37,16 @@ output directory (typically ``rust/target/``). A vanilla invocation of Cargo will complain that it cannot find the generated sources, which can be fixed in different ways: -* by using special shorthand targets in the QEMU build directory:: +* by using Makefile targets, provided by Meson, that run ``clippy`` or + ``rustdoc``: make clippy - make rustfmt make rustdoc +A target for ``rustfmt`` is also declared in ``rust/meson.build``: + + make rustfmt + * by invoking ``cargo`` through the Meson `development environment`__ feature::
@@ -50,7 +54,7 @@ which can be fixed in different ways: pyvenv/bin/meson devenv -w ../rust cargo fmt If you are going to use ``cargo`` repeatedly, ``pyvenv/bin/meson devenv`` - will enter a shell where commands like ``cargo clippy`` just work. + will enter a shell where commands like ``cargo fmt`` just work. __ https://mesonbuild.com/Commands.html#devenv
meson.build +1 -1
@@ -4404,7 +4404,7 @@ foreach target : target_dirs build_by_default: true, build_always_stale: true) rlib = static_library('rust_' + target.underscorify(), - rlib_rs, + structured_sources([], {'.': rlib_rs}), dependencies: target_rust.dependencies(), override_options: ['rust_std=2021', 'build.rust_std=2021'], rust_abi: 'c')
clippy.toml renamed from rust/clippy.toml +1 -1
@@ -1,3 +1,3 @@ -doc-valid-idents = ["PrimeCell", ".."] +doc-valid-idents = ["IrDA", "PrimeCell", ".."] allow-mixed-uninlined-format-args = false msrv = "1.77.0"
rust/Cargo.toml +0 -1
@@ -63,7 +63,6 @@ ignored_unit_patterns = "deny" implicit_clone = "deny" macro_use_imports = "deny" missing_safety_doc = "deny" -multiple_crate_versions = "deny" mut_mut = "deny" needless_bitwise_bool = "deny" needless_pass_by_ref_mut = "deny"
rust/meson.build +0 -12
@@ -24,21 +24,9 @@ subdir('hw') cargo = find_program('cargo', required: false) if cargo.found() - run_target('clippy', - command: [config_host['MESON'], 'devenv', - '--workdir', '@CURRENT_SOURCE_DIR@', - cargo, 'clippy', '--tests'], - depends: bindings_rs) - run_target('rustfmt', command: [config_host['MESON'], 'devenv', '--workdir', '@CURRENT_SOURCE_DIR@', cargo, 'fmt'], depends: bindings_rs) - - run_target('rustdoc', - command: [config_host['MESON'], 'devenv', - '--workdir', '@CURRENT_SOURCE_DIR@', - cargo, 'doc', '--no-deps', '--document-private-items'], - depends: bindings_rs) endif
scripts/rust/rustc_args.py +1 -4
@@ -104,10 +104,7 @@ def generate_lint_flags(cargo_toml: CargoTOML, strict_lints: bool) -> Iterable[s else: raise Exception(f"invalid level {level} for {prefix}{lint}") - # This may change if QEMU ever invokes clippy-driver or rustdoc by - # hand. For now, check the syntax but do not add non-rustc lints to - # the command line. - if k == "rust" and not (strict_lints and lint in STRICT_LINTS): + if not (strict_lints and lint in STRICT_LINTS): lint_list.append(LintFlag(flags=[flag, prefix + lint], priority=priority)) if strict_lints:
Signature · 1 line
2.49.0
[PULL 11/16] meson: use config_base_arch for target libraries
In reply to Paolo BonziniFrom: Pierrick Bouvier <[email protected]>
Fixed commit introduced common dependencies for target libraries. Alas, it wrongly reused the 'target' variable, which was previously set from another loop.
Thus, some dependencies were missing depending on order of target list, as found here [1].
The fix is to use the correct config_base_arch instead. Kudos to Thomas Huth who had this right, before I reimplement it, and introduce this bug.
[1] https://lore.kernel.org/qemu-devel/[email protected]/
--- meson.build | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
meson.build +3 -4
@@ -4135,13 +4135,12 @@ common_all = static_library('common', target_common_arch_libs = {} target_common_system_arch_libs = {} foreach target_base_arch, config_base_arch : config_base_arch_mak - config_target = config_target_mak[target] target_inc = [include_directories('target' / target_base_arch)] inc = [common_user_inc + target_inc] - target_common = common_ss.apply(config_target, strict: false) - target_system = system_ss.apply(config_target, strict: false) - target_user = user_ss.apply(config_target, strict: false) + target_common = common_ss.apply(config_base_arch, strict: false) + target_system = system_ss.apply(config_base_arch, strict: false) + target_user = user_ss.apply(config_base_arch, strict: false) common_deps = [] system_deps = [] user_deps = []
Signature · 1 line
2.49.0
[PULL 06/16] rust: cell: remove support for running doctests with "cargo test --doc"
In reply to Paolo BonziniThis is not needed anymore now that tests link with libqemuutil.
--- rust/qemu-api/src/cell.rs | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-)
rust/qemu-api/src/cell.rs +9 -13
@@ -225,27 +225,23 @@/// An internal function that is used by doctests. pub fn bql_start_test () { -if cfg! (MESON ) { -// SAFETY: integration tests are run with --test-threads=1, while -// unit tests and doctests are not multithreaded and do not have -// any BQL-protected data. Just set bql_locked to true. -unsafe { - bindings::rust_bql_mock_lock (); - } +// SAFETY: integration tests are run with --test-threads=1, while +// unit tests and doctests are not multithreaded and do not have +// any BQL-protected data. Just set bql_locked to true. +unsafe { + bindings::rust_bql_mock_lock (); } }pub fn bql_locked () ->bool {// SAFETY: the function does nothing but return a thread-local bool - !cfg! (MESON ) ||unsafe { bindings::bql_locked () } +unsafe { bindings::bql_locked () } }fn bql_block_unlock (increase:bool ) { -if cfg! (MESON ) { -// SAFETY: this only adjusts a counter -unsafe { - bindings::bql_block_unlock (increase); - } +// SAFETY: this only adjusts a counter +unsafe { + bindings::bql_block_unlock (increase); } }
Signature · 1 line
2.49.0
[PULL 13/16] i386/tdvf: Fix build on 32-bit host
In reply to Paolo BonziniFrom: Cédric Le Goater <[email protected]>
Use PRI formats where required.
--- hw/i386/tdvf.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
hw/i386/tdvf.c +3 -3
@@ -101,16 +101,16 @@ static int tdvf_parse_and_check_section_entry(const TdvfSectionEntry *src,/* sanity check */ if (entry->size < entry->data_len) { -error_report ("Broken metadata RawDataSize 0x%x MemoryDataSize 0x%lx" , +error_report ("Broken metadata RawDataSize 0x%x MemoryDataSize 0x%" PRIx64, entry->data_len, entry->size);return -1 ; }if (!QEMU_IS_ALIGNED (entry->address,TDVF_ALIGNMENT )) { -error_report ("MemoryAddress 0x%lx not page aligned" , entry->address); +error_report ("MemoryAddress 0x%" PRIx64" not page aligned" , entry->address);return -1 ; }if (!QEMU_IS_ALIGNED (entry->size,TDVF_ALIGNMENT )) { -error_report ("MemoryDataSize 0x%lx not page aligned" , entry->size); +error_report ("MemoryDataSize 0x%" PRIx64" not page aligned" , entry->size);return -1 ; }
Signature · 1 line
2.49.0
[PULL 05/16] rust: add qemu-api doctests to "meson test"
In reply to Paolo BonziniDoctests are weird. They are essentially integration tests, but they're "ran" by executing rustdoc --test, which takes a compiler-ish command line. This is supported by Meson 1.8.0.
Because they run the linker and need all the .o files, run them in the build jobs rather than the test jobs.
--- docs/devel/rust.rst | 2 ++ .gitlab-ci.d/buildtest-template.yml | 3 ++- .gitlab-ci.d/buildtest.yml | 11 +++-------- rust/qemu-api/meson.build | 9 +++++++++ 4 files changed, 16 insertions(+), 9 deletions(-)
docs/devel/rust.rst +2 -0
@@ -66,6 +66,8 @@ be run via ``meson test`` or ``make``:: make check-rust +Note that doctests require all ``.o`` files from the build to be available. + Supported tools '''''''''''''''
.gitlab-ci.d/buildtest-template.yml +2 -1
@@ -76,7 +76,8 @@ fi - section_end buildenv - section_start test "Running tests" - - $MAKE NINJA=":" $MAKE_CHECK_ARGS + # doctests need all the compilation artifacts + - $MAKE NINJA=":" MTESTARGS="--no-suite doc" $MAKE_CHECK_ARGS - section_end test .native_test_job_template:
.gitlab-ci.d/buildtest.yml +3 -8
@@ -41,7 +41,7 @@ build-system-ubuntu: IMAGE: ubuntu2204 CONFIGURE_ARGS: --enable-docs --enable-rust TARGETS: alpha-softmmu microblazeel-softmmu mips64el-softmmu - MAKE_CHECK_ARGS: check-build + MAKE_CHECK_ARGS: check-build check-doc check-system-ubuntu: extends: .native_test_job_template
@@ -115,7 +115,7 @@ build-system-fedora: CONFIGURE_ARGS: --disable-gcrypt --enable-nettle --enable-docs --enable-crypto-afalg --enable-rust TARGETS: microblaze-softmmu mips-softmmu xtensa-softmmu m68k-softmmu riscv32-softmmu ppc-softmmu sparc64-softmmu - MAKE_CHECK_ARGS: check-build + MAKE_CHECK_ARGS: check-build check-doc build-system-fedora-rust-nightly: extends:
@@ -127,12 +127,7 @@ build-system-fedora-rust-nightly: IMAGE: fedora-rust-nightly CONFIGURE_ARGS: --disable-docs --enable-rust --enable-strict-rust-lints TARGETS: aarch64-softmmu - MAKE_CHECK_ARGS: check-build - after_script: - - source scripts/ci/gitlab-ci-section - - section_start test "Running Rust doctests" - - cd build - - pyvenv/bin/meson devenv -w ../rust ${CARGO-cargo} test --doc -p qemu_api + MAKE_CHECK_ARGS: check-build check-doc allow_failure: true
rust/qemu-api/meson.build +9 -0
@@ -45,6 +45,15 @@ rust.test('rust-qemu-api-tests', _qemu_api_rs, qemu_api = declare_dependency(link_with: [_qemu_api_rs], dependencies: [qemu_api_macros, qom, hwcore, chardev, migration]) +# Doctests are essentially integration tests, so they need the same dependencies. +# Note that running them requires the object files for C code, so place them +# in a separate suite that is run by the "build" CI jobs rather than "check". +rust.doctest('rust-qemu-api-doctests', + _qemu_api_rs, + protocol: 'rust', + dependencies: qemu_api, + suite: ['doc', 'rust']) + test('rust-qemu-api-integration', executable( 'rust-qemu-api-integration',
Signature · 1 line
2.49.0
[PULL 02/16] meson: update to version 1.8.1
In reply to Paolo BonziniThis adds several improvements to Rust support, including native clippy and rustdoc targets, the "objects" keyword, and running doctests.
Require it only when Rust support is requested, to avoid putting a strict requirement on all build platforms for the sake of an experimental feature.
--- configure | 8 ++++++++ python/scripts/vendor.py | 4 ++-- python/wheels/meson-1.5.0-py3-none-any.whl | Bin 959846 -> 0 bytes python/wheels/meson-1.8.1-py3-none-any.whl | Bin 0 -> 1013001 bytes pythondeps.toml | 2 +- tests/lcitool/mappings.yml | 6 +++++- 6 files changed, 16 insertions(+), 4 deletions(-) delete mode 100644 python/wheels/meson-1.5.0-py3-none-any.whl create mode 100644 python/wheels/meson-1.8.1-py3-none-any.whl
configure +8 -0
@@ -1178,6 +1178,14 @@ fi ########################################## # detect rust triple +meson_version=$($meson --version) +if test "$rust" != disabled && ! version_ge "$meson_version" 1.8.1; then + if test "$rust" = enabled; then + error_exit "Rust support needs Meson 1.8.1 or newer" + fi + echo "Rust needs Meson 1.8.1, disabling" 2>&1 + rust=disabled +fi if test "$rust" != disabled && has "$rustc" && $rustc -vV > "${TMPDIR1}/${TMPB}.out"; then rust_host_triple=$(sed -n 's/^host: //p' "${TMPDIR1}/${TMPB}.out") else
python/scripts/vendor.py +2 -2
@@ -41,8 +41,8 @@ def main() -> int: parser.parse_args() packages = { - "meson==1.5.0": - "52b34f4903b882df52ad0d533146d4b992c018ea77399f825579737672ae7b20", + "meson==1.8.1": + "374bbf71247e629475fc10b0bd2ef66fc418c2d8f4890572f74de0f97d0d42da", } vendor_dir = Path(__file__, "..", "..", "wheels").resolve()
python/wheels/meson-1.5.0-py3-none-any.whl deleted binary +0 -0
python/wheels/meson-1.8.1-py3-none-any.whl new file binary +0 -0
pythondeps.toml +1 -1
@@ -19,7 +19,7 @@ [meson] # The install key should match the version in python/wheels/ -meson = { accepted = ">=1.5.0", installed = "1.5.0", canary = "meson" } +meson = { accepted = ">=1.5.0", installed = "1.8.1", canary = "meson" } pycotap = { accepted = ">=1.1.0", installed = "1.3.1" } [docs]
tests/lcitool/mappings.yml +5 -1
@@ -8,6 +8,10 @@ mappings: meson: OpenSUSELeap15: + # Use Meson from PyPI wherever Rust is enabled + Debian: + Fedora: + Ubuntu: python3: OpenSUSELeap15: python311-base
@@ -72,7 +76,7 @@ mappings: pypi_mappings: # Request more recent version meson: - default: meson==1.5.0 + default: meson==1.8.1 # Drop packages that need devel headers python3-numpy:
Signature · 1 line
2.49.0
[PULL 14/16] rust: add "bits", a custom bitflags implementation
In reply to Paolo BonziniOne common thing that device emulation does is manipulate bitmasks, for example to check whether two bitmaps have common bits. One example in the pl011 crate is the checks for pending interrupts, where an interrupt cause corresponds to at least one interrupt source from a fixed set.
Unfortunately, this is one case where Rust *can* provide some kind of abstraction but it does so with a rather Perl-ish There Is More Way To Do It. It is not something where a crate like "bilge" helps, because it only covers the packing of bits in a structure; operations like "are all bits of Y set in X" almost never make sense for bit-packed structs; you need something else, there are several crates that do it and of course we're going to roll our own.
In particular I examined three:
- bitmask (https://docs.rs/bitmask/0.5.0/bitmask/) does not support const at all. This is a showstopper because one of the ugly things in the current pl011 code is the ugliness of code that defines interrupt masks at compile time:
pub const E: Self = Self(Self::OE.0 | Self::BE.0 | Self::PE.0 | Self::FE.0);
or even worse:
const IRQMASK: [u32; 6] = [
Interrupt::E.0 | Interrupt::MS.0 | Interrupt::RT.0 | Interrupt::TX.0 | Interrupt::RX.0,
...
}You would have to use roughly the same code---"bitmask" only helps with defining the struct.
- bitmask_enum (https://docs.rs/bitmask-enum/2.2.5/bitmask_enum/) does not have a good separation of "valid" and "invalid" bits, so for example "!x" will invert all 16 bits if you choose u16 as the representation -- even if you only defined 10 bits. This makes it easier to introduce subtle bugs in comparisons.
- bitflags (https://docs.rs/bitflags/2.6.0/bitflags/) is generally the most used such crate and is the one that I took most inspiration from with respect to the syntax. It's a pretty sophisticated implementation, with a lot of bells and whistles such as an implementation of "Iter" that returns the bits one at a time.
The main thing that all of them lack, however, is a way to simplify the ugly definitions like the above. "bitflags" includes const methods that perform AND/OR/XOR of masks (these are necessary because Rust operator overloading does not support const yet, and therefore overloaded operators cannot be used in the definition of a "static" variable), but they become even more verbose and unmanageable, like
Interrupt::E.union(Interrupt::MS).union(Interrupt::RT).union(Interrupt::TX).union(Interrupt::RX)
This was the main reason to create "bits", which allows something like
bits!(Interrupt: E | MS | RT | TX | RX)
and expands it 1) add "Interrupt::" in front of all identifiers 2) convert operators to the wordy const functions like "union". It supports boolean operators "&", "|", "^", "!" and parentheses, with a relatively simple recursive descent parser that's implemented in qemu_api_macros.
Since I don't remember exactly how the macro was developed, I cannot exclude that it contains code from "bitflags". Therefore, I am conservatively leaving in the MIT and Apache 2.0 licenses from bitflags. In fact, I think there would be a benefit in being able to push code back to "bitflags" anyway whenever applicable, so that the two libraries do not diverge too much, so that's another reason to use this.
--- rust/Cargo.lock | 7 + rust/Cargo.toml | 1 + rust/bits/Cargo.toml | 19 ++ rust/bits/meson.build | 16 ++ rust/bits/src/lib.rs | 443 +++++++++++++++++++++++++++++++ rust/meson.build | 1 + rust/qemu-api-macros/src/bits.rs | 229 ++++++++++++++++ rust/qemu-api-macros/src/lib.rs | 12 + 8 files changed, 728 insertions(+) create mode 100644 rust/bits/Cargo.toml create mode 100644 rust/bits/meson.build create mode 100644 rust/bits/src/lib.rs create mode 100644 rust/qemu-api-macros/src/bits.rs
rust/Cargo.lock +7 -0
@@ -31,6 +31,13 @@ dependencies = [ "syn", ] +[[package]] +name = "bits" +version = "0.1.0" +dependencies = [ + "qemu_api_macros", +] + [[package]] name = "either" version = "1.12.0"
rust/Cargo.toml +1 -0
@@ -1,6 +1,7 @@ [workspace] resolver = "2" members = [ + "bits", "qemu-api-macros", "qemu-api", "hw/char/pl011",
rust/bits/Cargo.toml new file +19 -0
@@ -0,0 +1,19 @@ +[package] +name = "bits" +version = "0.1.0" +authors = ["Paolo Bonzini <[email protected]>"] +description = "const-friendly bit flags" +resolver = "2" +publish = false + +edition.workspace = true +homepage.workspace = true +license.workspace = true +repository.workspace = true +rust-version.workspace = true + +[dependencies] +qemu_api_macros = { path = "../qemu-api-macros" } + +[lints] +workspace = true
rust/bits/meson.build new file +16 -0
@@ -0,0 +1,16 @@ +_bits_rs = static_library( + 'bits', + 'src/lib.rs', + override_options: ['rust_std=2021', 'build.rust_std=2021'], + rust_abi: 'rust', + dependencies: [qemu_api_macros], +) + +bits_rs = declare_dependency(link_with: _bits_rs) + +rust.test('rust-bits-tests', _bits_rs, + suite: ['unit', 'rust']) + +rust.doctest('rust-bits-doctests', _bits_rs, + dependencies: bits_rs, + suite: ['doc', 'rust'])
rust/bits/src/lib.rs new file +443 -0
443 lines not on this page · raw message
rust/meson.build +1 -0
@@ -17,6 +17,7 @@ proc_macro2_rs_native = dependency('proc-macro2-1-rs', native: true) qemuutil_rs = qemuutil.partial_dependency(link_args: true, links: true) subdir('qemu-api-macros') +subdir('bits') subdir('qemu-api') subdir('hw')
rust/qemu-api-macros/src/bits.rs new file +229 -0
229 lines not on this page · raw message
rust/qemu-api-macros/src/lib.rs +12 -0
@@ -12,6 +12,9 @@mod utils;use utils::MacroError ; +mod bits; +use bits::BitsConstInternal ; +fn get_fields <'a>( input: &'aDeriveInput , msg: &str,
@@ -219,3 +222,12 @@ pub fn derive_tryinto(input: TokenStream) -> TokenStream {TokenStream ::from (expanded) } + +#[proc_macro] +pub fn bits_const_internal (ts:TokenStream ) ->TokenStream { +let ts = proc_macro2::TokenStream ::from (ts); +let mut it = ts.into_iter (); + +let expanded =BitsConstInternal ::parse (&mut it).unwrap_or_else (Into ::into); +TokenStream ::from (expanded) +}
Signature · 1 line
2.49.0
[PULL 09/16] target/i386: Add a new CPU feature word for CPUID.7.1.ECX
In reply to Paolo BonziniFrom: "Xin Li (Intel)" <[email protected]>
The immediate form of MSR access instructions will use this new CPU feature word.
--- target/i386/cpu.h | 1 + target/i386/cpu.c | 23 ++++++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-)
target/i386/cpu.h +1 -0
@@ -668,6 +668,7 @@ typedef enum FeatureWord {FEAT_SGX_12_1_EAX ,/* CPUID[EAX=0x12,ECX=1].EAX (SGX ATTRIBUTES[31:0]) */ FEAT_XSAVE_XSS_LO ,/* CPUID[EAX=0xd,ECX=1].ECX */ FEAT_XSAVE_XSS_HI ,/* CPUID[EAX=0xd,ECX=1].EDX */ +FEAT_7_1_ECX ,/* CPUID[EAX=7,ECX=1].ECX */ FEAT_7_1_EDX ,/* CPUID[EAX=7,ECX=1].EDX */ FEAT_7_2_EDX ,/* CPUID[EAX=7,ECX=2].EDX */ FEAT_24_0_EBX, /* CPUID[EAX=0x24,ECX=0].EBX */
target/i386/cpu.c +22 -1
@@ -900,6 +900,7 @@ void x86_cpu_vendor_words2str(char *dst, uint32_t vendor1,#define TCG_7_1_EAX_FEATURES (CPUID_7_1_EAX_FZRM | CPUID_7_1_EAX_FSRS | \ CPUID_7_1_EAX_FSRC | CPUID_7_1_EAX_CMPCCXADD) +#define TCG_7_1_ECX_FEATURES 0#define TCG_7_1_EDX_FEATURES 0#define TCG_7_2_EDX_FEATURES 0#define TCG_APM_FEATURES 0
@@ -1150,6 +1151,25 @@ FeatureWordInfo feature_word_info[FEATURE_WORDS] = { }, .tcg_features = TCG_7_1_EAX_FEATURES, }, + [FEAT_7_1_ECX] = { + .type = CPUID_FEATURE_WORD, + .feat_names = { +NULL ,NULL ,NULL ,NULL , +NULL ,NULL ,NULL ,NULL , +NULL ,NULL ,NULL ,NULL , +NULL ,NULL ,NULL ,NULL , +NULL ,NULL ,NULL ,NULL , +NULL ,NULL ,NULL ,NULL , +NULL ,NULL ,NULL ,NULL , + NULL, NULL, NULL, NULL, + }, + .cpuid = { + .eax =7 , + .needs_ecx = true, .ecx = 1, + .reg = R_ECX, + }, + .tcg_features = TCG_7_1_ECX_FEATURES, + }, [FEAT_7_1_EDX] = { .type =CPUID_FEATURE_WORD , .feat_names = {
@@ -7442,9 +7462,9 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, *edx = env->features[FEAT_7_0_EDX ];/* Feature flags */ }else if (count ==1 ) { *eax = env->features[FEAT_7_1_EAX ]; + *ecx = env->features[FEAT_7_1_ECX ]; *edx = env->features[FEAT_7_1_EDX ]; *ebx =0 ; - *ecx =0 ; }else if (count ==2 ) { *edx = env->features[FEAT_7_2_EDX ]; *eax =0 ;
@@ -8349,6 +8369,7 @@ void x86_cpu_expand_features(X86CPU *cpu, Error **errp)x86_cpu_adjust_feat_level (cpu,FEAT_6_EAX );x86_cpu_adjust_feat_level (cpu,FEAT_7_0_ECX );x86_cpu_adjust_feat_level (cpu,FEAT_7_1_EAX ); +x86_cpu_adjust_feat_level (cpu,FEAT_7_1_ECX );x86_cpu_adjust_feat_level (cpu,FEAT_7_1_EDX );x86_cpu_adjust_feat_level (cpu,FEAT_7_2_EDX );x86_cpu_adjust_feat_level (cpu,FEAT_8000_0001_EDX );
Signature · 1 line
2.49.0
[PULL 16/16] rust: qemu-api-macros: add from_bits and into_bits to #[derive(TryInto)]
In reply to Paolo BonziniThese const functions make it possible to use enums easily together with the bitfield-struct crate.
--- rust/qemu-api-macros/src/lib.rs | 48 ++++++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 10 deletions(-)
rust/qemu-api-macros/src/lib.rs +38 -10
@@ -193,23 +193,51 @@ fn get_variants(input: &DeriveInput) -> Result<&Punctuated<Variant, Comma>, Macr }#[rustfmt::skip::macros(quote)] -fn derive_tryinto_or_error (input:DeriveInput ) ->Result <proc_macro2::TokenStream ,MacroError > { -let repr =get_repr_uN (&input,"#[derive(TryInto)]" )?; - -let name = &input.ident; -let variants =get_variants (&input)?; +fn derive_tryinto_body ( + name: &Ident , + variants: &Punctuated <Variant ,Comma >, + repr: &Path , +) ->Result <proc_macro2::TokenStream ,MacroError > {let discriminants:Vec <&Ident > = variants.iter ().map (|f| &f.ident).collect ();Ok (quote! { + #(const #discriminants: #repr = #name::#discriminantsas #repr ;)*; +match value { + #(#discriminants =>Ok (#name::#discriminants),)* + _ =>Err (value), + } + }) +} + +#[rustfmt::skip::macros(quote)] +fn derive_tryinto_or_error (input:DeriveInput ) ->Result <proc_macro2::TokenStream ,MacroError > { +let repr =get_repr_uN (&input,"#[derive(TryInto)]" )?; +let name = &input.ident; +let body =derive_tryinto_body (name,get_variants (&input)?, &repr)?; +let errmsg =format! ("invalid value for {name}" ); + +Ok (quote! { +impl #name { +#[allow(dead_code)] +pub const fn into_bits (self) -> #repr { + selfas #repr + } + +#[allow(dead_code)] +pub const fn from_bits (value: #repr ) ->Self { +match ({ + #body + }) { +Ok (x) => x, +Err (_) =>panic! (#errmsg) + } + } + }impl core::convert::TryFrom <#repr >for #name {type Error = #repr ;fn try_from (value: #repr ) ->Result <Self ,Self ::Error > { - #(const #discriminants: #repr = #name::#discriminantsas #repr ;)*; -match value { - #(#discriminants =>Ok (Self ::#discriminants),)* - _ =>Err (value), - } + #body } } })
Signature · 1 line
2.49.0
[PULL 10/16] target/i386: Add the immediate form MSR access instruction support
In reply to Paolo BonziniFrom: "Xin Li (Intel)" <[email protected]>
The immediate form of MSR access instructions are primarily motivated by performance, not code size: by having the MSR number in an immediate, it is available *much* earlier in the pipeline, which allows the hardware much more leeway about how a particular MSR is handled.
--- target/i386/cpu.h | 4 ++++ target/i386/cpu.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-)
target/i386/cpu.h +4 -0
@@ -1001,6 +1001,9 @@ uint64_t x86_cpu_get_supported_feature_word(X86CPU *cpu, FeatureWord w);/* Linear Address Masking */ #define CPUID_7_1_EAX_LAM (1U << 26) +/* The immediate form of MSR access instructions */ +#define CPUID_7_1_ECX_MSR_IMM (1U << 5) +/* Support for VPDPB[SU,UU,SS]D[,S] */ #define CPUID_7_1_EDX_AVX_VNNI_INT8 (1U << 4)/* AVX NE CONVERT Instructions */
@@ -1024,6 +1027,7 @@ uint64_t x86_cpu_get_supported_feature_word(X86CPU *cpu, FeatureWord w);#define CPUID_7_2_EDX_DDPD_U (1U << 3)/* Indicate bit 10 of the IA32_SPEC_CTRL MSR is supported */ #define CPUID_7_2_EDX_BHI_CTRL (1U << 4) +/* Do not exhibit MXCSR Configuration Dependent Timing (MCDT) behavior */ #define CPUID_7_2_EDX_MCDT_NO (1U << 5)
target/i386/cpu.c +1 -1
@@ -1155,7 +1155,7 @@ FeatureWordInfo feature_word_info[FEATURE_WORDS] = { .type = CPUID_FEATURE_WORD, .feat_names = {NULL ,NULL ,NULL ,NULL , -NULL ,NULL ,NULL ,NULL , +NULL ,"msr-imm" ,NULL ,NULL ,NULL ,NULL ,NULL ,NULL ,NULL ,NULL ,NULL ,NULL , NULL, NULL, NULL, NULL,
Signature · 1 line
2.49.0
[PULL 08/16] target/i386: Remove FRED dependency on WRMSRNS
In reply to Paolo BonziniFrom: "Xin Li (Intel)" <[email protected]>
WRMSRNS doesn't become a required feature for FERD, and Linux has removed the dependency, as such remove it from Qemu.
--- target/i386/cpu.c | 4 ---- 1 file changed, 4 deletions(-)
target/i386/cpu.c +0 -4
@@ -1803,10 +1803,6 @@ static FeatureDep feature_dependencies[] = { .from = { FEAT_7_1_EAX, CPUID_7_1_EAX_LKGS }, .to = { FEAT_7_1_EAX, CPUID_7_1_EAX_FRED }, }, - { - .from = { FEAT_7_1_EAX, CPUID_7_1_EAX_WRMSRNS }, - .to = { FEAT_7_1_EAX, CPUID_7_1_EAX_FRED }, - }, { .from = { FEAT_7_0_EBX, CPUID_7_0_EBX_SGX }, .to = { FEAT_7_0_ECX, CPUID_7_0_ECX_SGX_LC },
Signature · 1 line
2.49.0
[PULL 12/16] i386/tdx: Fix build on 32-bit host
In reply to Paolo BonziniFrom: Cédric Le Goater <[email protected]>
Use PRI formats where required and fix pointer cast.
--- target/i386/kvm/tdx.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)
target/i386/kvm/tdx.c +13 -13
@@ -284,7 +284,7 @@ static void tdx_post_init_vcpus(void) hob =tdx_get_hob_entry (tdx_guest);CPU_FOREACH (cpu) { -tdx_vcpu_ioctl (cpu,KVM_TDX_INIT_VCPU ,0 , (void *)hob->address, +tdx_vcpu_ioctl (cpu,KVM_TDX_INIT_VCPU ,0 , (void *)(uintptr_t )hob->address, &error_fatal); } }
@@ -339,7 +339,7 @@ static void tdx_finalize_vm(Notifier *notifier, void *unused)uint32_t flags; region = (struct kvm_tdx_init_mem_region ) { - .source_addr = (uint64_t )entry->mem_ptr, + .source_addr = (uintptr_t )entry->mem_ptr, .gpa = entry->address, .nr_pages = entry->size >>12 , };
@@ -893,16 +893,16 @@ static int tdx_check_features(X86ConfidentialGuest *cg, CPUState *cs)static int tdx_validate_attributes (TdxGuest *tdx,Error **errp) {if ((tdx->attributes & ~tdx_caps->supported_attrs)) { -error_setg (errp,"Invalid attributes 0x%lx for TDX VM " -"(KVM supported: 0x%llx)" , tdx->attributes, - tdx_caps->supported_attrs); +error_setg (errp,"Invalid attributes 0x%" PRIx64" for TDX VM " +"(KVM supported: 0x%" PRIx64")" , tdx->attributes, + (uint64_t )tdx_caps->supported_attrs);return -1 ; }if (tdx->attributes & ~TDX_SUPPORTED_TD_ATTRS ) {error_setg (errp,"Some QEMU unsupported TD attribute bits being " -"requested: 0x%lx (QEMU supported: 0x%llx)" , - tdx->attributes,TDX_SUPPORTED_TD_ATTRS ); +"requested: 0x%" PRIx64" (QEMU supported: 0x%" PRIx64")" , + tdx->attributes, (uint64_t )TDX_SUPPORTED_TD_ATTRS );return -1 ; }
@@ -931,8 +931,8 @@ static int setup_td_xfam(X86CPU *x86cpu, Error **errp) env->features[FEAT_XSAVE_XSS_HI ];if (xfam & ~tdx_caps->supported_xfam) { -error_setg (errp,"Invalid XFAM 0x%lx for TDX VM (supported: 0x%llx))" , - xfam, tdx_caps->supported_xfam); +error_setg (errp,"Invalid XFAM 0x%" PRIx64" for TDX VM (supported: 0x%" PRIx64"))" , + xfam, (uint64_t )tdx_caps->supported_xfam);return -1 ; }
@@ -999,14 +999,14 @@ int tdx_pre_create_vcpu(CPUState *cpu, Error **errp)if (env->tsc_khz && (env->tsc_khz <TDX_MIN_TSC_FREQUENCY_KHZ || env->tsc_khz >TDX_MAX_TSC_FREQUENCY_KHZ )) { -error_setg (errp,"Invalid TSC %ld KHz, must specify cpu_frequency " +error_setg (errp,"Invalid TSC %" PRId64" KHz, must specify cpu_frequency " "between [%d, %d] kHz" , env->tsc_khz,TDX_MIN_TSC_FREQUENCY_KHZ ,TDX_MAX_TSC_FREQUENCY_KHZ );return -EINVAL ; }if (env->tsc_khz % (25 *1000 )) { -error_setg (errp,"Invalid TSC %ld KHz, it must be multiple of 25MHz" , +error_setg (errp,"Invalid TSC %" PRId64" KHz, it must be multiple of 25MHz" , env->tsc_khz);return -EINVAL ; }
@@ -1014,7 +1014,7 @@ int tdx_pre_create_vcpu(CPUState *cpu, Error **errp)/* it's safe even env->tsc_khz is 0. KVM uses host's tsc_khz in this case */ r =kvm_vm_ioctl (kvm_state,KVM_SET_TSC_KHZ , env->tsc_khz);if (r <0 ) { -error_setg_errno (errp, -r,"Unable to set TSC frequency to %ld kHz" , +error_setg_errno (errp, -r,"Unable to set TSC frequency to %" PRId64" kHz" , env->tsc_khz);return r; }
@@ -1139,7 +1139,7 @@ int tdx_handle_report_fatal_error(X86CPU *cpu, struct kvm_run *run)uint64_t gpa =-1ull ;if (error_code &0xffff ) { -error_report ("TDX: REPORT_FATAL_ERROR: invalid error code: 0x%lx" , +error_report ("TDX: REPORT_FATAL_ERROR: invalid error code: 0x%" PRIx64, error_code);return -1 ; }
Signature · 1 line
2.49.0
[PULL 03/16] rust: use "objects" for Rust executables as well
In reply to Paolo Bonzinilibqemuutil is not meant be linked as a whole; if modules are enabled, doing so results in undefined symbols (corresponding to QMP commands) in rust/qemu-api/rust-qemu-api-integration.
Support for "objects" in Rust executables is available in Meson 1.8.0; use it to switching to the same dependencies that C targets use: link_with for libqemuutil, and objects for everything else.
--- docs/devel/rust.rst | 2 -- rust/meson.build | 2 ++ rust/qemu-api/meson.build | 27 +++++---------------------- 3 files changed, 7 insertions(+), 24 deletions(-)
docs/devel/rust.rst +0 -2
@@ -66,8 +66,6 @@ be run via ``meson test`` or ``make``:: make check-rust -Building Rust code with ``--enable-modules`` is not supported yet. - Supported tools '''''''''''''''
rust/meson.build +2 -0
@@ -14,6 +14,8 @@ quote_rs_native = dependency('quote-1-rs', native: true) syn_rs_native = dependency('syn-2-rs', native: true) proc_macro2_rs_native = dependency('proc-macro2-1-rs', native: true) +qemuutil_rs = qemuutil.partial_dependency(link_args: true, links: true) + subdir('qemu-api-macros') subdir('qemu-api')
rust/qemu-api/meson.build +5 -22
@@ -35,32 +35,15 @@ _qemu_api_rs = static_library( override_options: ['rust_std=2021', 'build.rust_std=2021'], rust_abi: 'rust', rust_args: _qemu_api_cfg, - dependencies: [libc_rs, qemu_api_macros], + dependencies: [libc_rs, qemu_api_macros, qemuutil_rs, + qom, hwcore, chardev, migration], ) rust.test('rust-qemu-api-tests', _qemu_api_rs, suite: ['unit', 'rust']) -qemu_api = declare_dependency(link_with: _qemu_api_rs) - -# Rust executables do not support objects, so add an intermediate step. -rust_qemu_api_objs = static_library( - 'rust_qemu_api_objs', - objects: [libqom.extract_all_objects(recursive: false), - libhwcore.extract_all_objects(recursive: false), - libchardev.extract_all_objects(recursive: false), - libcrypto.extract_all_objects(recursive: false), - libauthz.extract_all_objects(recursive: false), - libio.extract_all_objects(recursive: false), - libmigration.extract_all_objects(recursive: false)]) -rust_qemu_api_deps = declare_dependency( - dependencies: [ - qom_ss.dependencies(), - chardev_ss.dependencies(), - crypto_ss.dependencies(), - authz_ss.dependencies(), - io_ss.dependencies()], - link_whole: [rust_qemu_api_objs, libqemuutil]) +qemu_api = declare_dependency(link_with: [_qemu_api_rs], + dependencies: [qemu_api_macros, qom, hwcore, chardev, migration]) test('rust-qemu-api-integration', executable(
@@ -69,7 +52,7 @@ test('rust-qemu-api-integration', override_options: ['rust_std=2021', 'build.rust_std=2021'], rust_args: ['--test'], install: false, - dependencies: [qemu_api, qemu_api_macros, rust_qemu_api_deps]), + dependencies: [qemu_api]), args: [ '--test', '--test-threads', '1', '--format', 'pretty',
Signature · 1 line
2.49.0
[PULL 01/16] rust: bindings: allow ptr_offset_with_cast
In reply to Paolo BonziniThis is produced by recent versions of bindgen:
warning: use of offset with a usize casted to an isize
--> /builds/bonzini/qemu/rust/target/debug/build/qemu_api-35cb647f4db404b8/out/bindings.inc.rs:39:21
| 39 | let byte = *(core::ptr::addr_of!((*this).storage) as *const u8).offset(byte_index as isize); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(core::ptr::addr_of!((*this).storage) as *const u8).add(byte_index)` |
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ptr_offset_with_cast
= note: #[warn(clippy::ptr_offset_with_cast)] on by default
warning: use of offset with a usize casted to an isize
--> /builds/bonzini/qemu/rust/target/debug/build/qemu_api-35cb647f4db404b8/out/bindings.inc.rs:68:13
| 68 | (core::ptr::addr_of_mut!((*this).storage) as *mut u8).offset(byte_index as isize); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(core::ptr::addr_of_mut!((*this).storage) as *mut u8).add(byte_index)` |
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ptr_offset_with_cast
This seems to be new in bindgen 0.71.0, possibly related to bindgen commit 33006185b7878 ("Add raw_ref_macros feature", 2024-11-22).
--- rust/qemu-api/src/bindings.rs | 1 + 1 file changed, 1 insertion(+)
rust/qemu-api/src/bindings.rs +1 -0
@@ -11,6 +11,7 @@ clippy::restriction, clippy::style, clippy::missing_const_for_fn, + clippy::ptr_offset_with_cast, clippy::useless_transmute, clippy::missing_safety_doc )]
Signature · 1 line
2.49.0
[PULL 15/16] rust: pl011: use the bits macro
In reply to Paolo BonziniThis avoids the repeated ".0" when using the Interrupt struct.
--- rust/Cargo.lock | 1 + rust/hw/char/pl011/Cargo.toml | 1 + rust/hw/char/pl011/meson.build | 1 + rust/hw/char/pl011/src/device.rs | 51 ++++++++++++++--------------- rust/hw/char/pl011/src/registers.rs | 39 ++++++++++++---------- 5 files changed, 49 insertions(+), 44 deletions(-)
rust/Cargo.lock +1 -0
@@ -73,6 +73,7 @@ version = "0.1.0" dependencies = [ "bilge", "bilge-impl", + "bits", "qemu_api", "qemu_api_macros", ]
rust/hw/char/pl011/Cargo.toml +1 -0
@@ -18,6 +18,7 @@ crate-type = ["staticlib"] [dependencies] bilge = { version = "0.2.0" } bilge-impl = { version = "0.2.0" } +bits = { path = "../../../bits" } qemu_api = { path = "../../../qemu-api" } qemu_api_macros = { path = "../../../qemu-api-macros" }
rust/hw/char/pl011/meson.build +1 -0
@@ -6,6 +6,7 @@ _libpl011_rs = static_library( dependencies: [ bilge_rs, bilge_impl_rs, + bits_rs, qemu_api, qemu_api_macros, ],
rust/hw/char/pl011/src/device.rs +25 -26
124 lines not on this page · raw message
rust/hw/char/pl011/src/registers.rs +21 -18
@@ -9,7 +9,8 @@// https://developer.arm.com/documentation/ddi0183/latest/ use bilge::prelude::*; -use qemu_api::impl_vmstate_bitsized; +use bits::bits; +use qemu_api::{impl_vmstate_bitsized, impl_vmstate_forward};/// Offset of each register from the base memory address of the device. #[doc(alias = "offset" )]
@@ -326,22 +327,24 @@ fn default() -> Self { } } -/// Interrupt status bits in UARTRIS, UARTMIS, UARTIMSC -pub struct Interrupt (pub u32 ); +bits! { +/// Interrupt status bits in UARTRIS, UARTMIS, UARTIMSC +#[derive( Default )] +pub struct Interrupt (u32 ) { +OE =1 <<10 , +BE =1 <<9 , +PE =1 <<8 , +FE =1 <<7 , +RT =1 <<6 , +TX =1 <<5 , +RX =1 <<4 , +DSR =1 <<3 , +DCD =1 <<2 , +CTS =1 <<1 , +RI =1 <<0 , -impl Interrupt { -pub const OE :Self =Self (1 <<10 ); -pub const BE :Self =Self (1 <<9 ); -pub const PE :Self =Self (1 <<8 ); -pub const FE :Self =Self (1 <<7 ); -pub const RT :Self =Self (1 <<6 ); -pub const TX :Self =Self (1 <<5 ); -pub const RX :Self =Self (1 <<4 ); -pub const DSR :Self =Self (1 <<3 ); -pub const DCD :Self =Self (1 <<2 ); -pub const CTS :Self =Self (1 <<1 ); -pub const RI :Self =Self (1 <<0 ); - -pub const E :Self =Self (Self ::OE .0 |Self ::BE .0 |Self ::PE .0 |Self ::FE .0 ); -pub const MS :Self =Self (Self ::RI .0 |Self ::DSR .0 |Self ::DCD .0 |Self ::CTS .0 ); +E =bits! (Self as u32 :OE |BE |PE |FE ), +MS =bits! (Self as u32 :RI |DSR |DCD |CTS ), + } } +impl_vmstate_forward! (Interrupt );
Signature · 1 line
2.49.0
[PULL 04/16] build, dockerfiles: add support for detecting rustdoc
In reply to Paolo Bonzinirustdoc is effectively a custom version of rustc, and it is necessary to specify it in order to run doctests from Meson. Add the relevant configure option and environment variables.
--- configure | 8 ++++++++ meson.build | 2 ++ tests/docker/dockerfiles/fedora-rust-nightly.docker | 2 ++ tests/docker/dockerfiles/ubuntu2204.docker | 1 + tests/lcitool/refresh | 3 +++ 5 files changed, 16 insertions(+)
configure +8 -0
@@ -209,6 +209,8 @@ for opt do ;; --rustc=*) RUSTC="$optarg" ;; + --rustdoc=*) RUSTDOC="$optarg" + ;; --cpu=*) cpu="$optarg" ;; --extra-cflags=*)
@@ -323,6 +325,7 @@ pkg_config="${PKG_CONFIG-${cross_prefix}pkg-config}" sdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}" rustc="${RUSTC-rustc}" +rustdoc="${RUSTDOC-rustdoc}" check_define() { cat > $TMPC <<EOF
@@ -660,6 +663,8 @@ for opt do ;; --rustc=*) ;; + --rustdoc=*) + ;; --make=*) ;; --install=*)
@@ -890,6 +895,7 @@ Advanced options (experts only): --cxx=CXX use C++ compiler CXX [$cxx] --objcc=OBJCC use Objective-C compiler OBJCC [$objcc] --rustc=RUSTC use Rust compiler RUSTC [$rustc] + --rustdoc=RUSTDOC use rustdoc binary RUSTDOC [$rustdoc] --extra-cflags=CFLAGS append extra C compiler flags CFLAGS --extra-cxxflags=CXXFLAGS append extra C++ compiler flags CXXFLAGS --extra-objcflags=OBJCFLAGS append extra Objective C compiler flags OBJCFLAGS
@@ -1901,8 +1907,10 @@ if test "$skip_meson" = no; then if test "$rust" != disabled; then if test "$rust_host_triple" != "$rust_target_triple"; then echo "rust = [$(meson_quote $rustc --target "$rust_target_triple")]" >> $cross + echo "rustdoc = [$(meson_quote $rustdoc --target "$rust_target_triple")]" >> $cross else echo "rust = [$(meson_quote $rustc)]" >> $cross + echo "rustdoc = [$(meson_quote $rustdoc)]" >> $cross fi fi echo "ar = [$(meson_quote $ar)]" >> $cross
meson.build +2 -0
@@ -106,6 +106,7 @@ if have_rust endif if have_rust + rustdoc = find_program('rustdoc', required: get_option('rust')) bindgen = find_program('bindgen', required: get_option('rust')) if not bindgen.found() or bindgen.version().version_compare('<0.60.0') if get_option('rust').enabled()
@@ -4757,6 +4758,7 @@ if have_rust summary_info += {'Rust target': config_host['RUST_TARGET_TRIPLE']} summary_info += {'rustc': ' '.join(rustc.cmd_array())} summary_info += {'rustc version': rustc.version()} + summary_info += {'rustdoc': rustdoc} summary_info += {'bindgen': bindgen.full_path()} summary_info += {'bindgen version': bindgen.version()} endif
tests/docker/dockerfiles/fedora-rust-nightly.docker +2 -0
@@ -156,6 +156,7 @@ ENV PYTHON "/usr/bin/python3" RUN dnf install -y wget ENV RUSTUP_HOME=/usr/local/rustup CARGO_HOME=/usr/local/cargo ENV RUSTC=/usr/local/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/rustc +ENV RUSTDOC=/usr/local/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/rustdoc ENV CARGO=/usr/local/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/cargo RUN set -eux && \ rustArch='x86_64-unknown-linux-gnu' && \
@@ -170,6 +171,7 @@ RUN set -eux && \ /usr/local/cargo/bin/rustup run nightly cargo --version && \ /usr/local/cargo/bin/rustup run nightly rustc --version && \ test "$CARGO" = "$(/usr/local/cargo/bin/rustup +nightly which cargo)" && \ + test "$RUSTDOC" = "$(/usr/local/cargo/bin/rustup +nightly which rustdoc)" && \ test "$RUSTC" = "$(/usr/local/cargo/bin/rustup +nightly which rustc)" ENV PATH=$CARGO_HOME/bin:$PATH RUN /usr/local/cargo/bin/rustup run nightly cargo install bindgen-cli
tests/docker/dockerfiles/ubuntu2204.docker +1 -0
@@ -151,6 +151,7 @@ ENV MAKE "/usr/bin/make" ENV NINJA "/usr/bin/ninja" ENV PYTHON "/usr/bin/python3" ENV RUSTC=/usr/bin/rustc-1.77 +ENV RUSTDOC=/usr/bin/rustdoc-1.77 ENV CARGO_HOME=/usr/local/cargo ENV PATH=$CARGO_HOME/bin:$PATH RUN DEBIAN_FRONTEND=noninteractive eatmydata \
tests/lcitool/refresh +3 -0
@@ -121,6 +121,7 @@ fedora_rustup_nightly_extras = [ "RUN dnf install -y wget\n", "ENV RUSTUP_HOME=/usr/local/rustup CARGO_HOME=/usr/local/cargo\n", "ENV RUSTC=/usr/local/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/rustc\n", + "ENV RUSTDOC=/usr/local/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/rustdoc\n", "ENV CARGO=/usr/local/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/cargo\n", "RUN set -eux && \\\n", " rustArch='x86_64-unknown-linux-gnu' && \\\n",
@@ -135,6 +136,7 @@ fedora_rustup_nightly_extras = [ " /usr/local/cargo/bin/rustup run nightly cargo --version && \\\n", " /usr/local/cargo/bin/rustup run nightly rustc --version && \\\n", ' test "$CARGO" = "$(/usr/local/cargo/bin/rustup +nightly which cargo)" && \\\n', + ' test "$RUSTDOC" = "$(/usr/local/cargo/bin/rustup +nightly which rustdoc)" && \\\n', ' test "$RUSTC" = "$(/usr/local/cargo/bin/rustup +nightly which rustc)"\n', 'ENV PATH=$CARGO_HOME/bin:$PATH\n', 'RUN /usr/local/cargo/bin/rustup run nightly cargo install bindgen-cli\n',
@@ -143,6 +145,7 @@ fedora_rustup_nightly_extras = [ ubuntu2204_rust_extras = [ "ENV RUSTC=/usr/bin/rustc-1.77\n", + "ENV RUSTDOC=/usr/bin/rustdoc-1.77\n", "ENV CARGO_HOME=/usr/local/cargo\n", 'ENV PATH=$CARGO_HOME/bin:$PATH\n', "RUN DEBIAN_FRONTEND=noninteractive eatmydata \\\n",
Signature · 1 line
2.49.0
Stefan Hajnoczi
AppliedApplied, thanks.
Please update the changelog at https://wiki.qemu.org/ChangeLog/10.1 for any user-visible changes.